Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

r2-utils-js

readium4.8kBSD-3-Clause1.0.42TypeScript support: included

Readium 2 'utils' for NodeJS (TypeScript)

readium, readium2, utils, EPUB, TypeScript, JavaScript, ES5, ES6, ECMAScript 2015, ECMAScript 6, ES7, ECMAScript 2016, ECMAScript 7, ES8, ECMAScript 2017, ECMAScript 8

readme

NodeJS / TypeScript Readium-2 "utils"

NodeJS implementation (written in TypeScript) of utilities for the Readium2 architecture ( https://github.com/readium/architecture/ ).

License

Build status

NPM David

Changelog

Prerequisites

1) https://nodejs.org NodeJS >= 8, NPM >= 5 (check with command line node --version and npm --version) 2) OPTIONAL: https://yarnpkg.com Yarn >= 1.0 (check with command line yarn --version)

GitHub repository

https://github.com/readium/r2-utils-js

There is no github.io site for this project (no gh-pages branch).

NPM package

https://www.npmjs.com/package/r2-utils-js

Command line install:

npm install r2-utils-js OR yarn add r2-utils-js

...or manually add in your package.json:

  "dependencies": {
    "r2-utils-js": "latest"
  }

The JavaScript code distributed in the NPM package is usable as-is (no transpilation required), as it is automatically-generated from the TypeScript source.

Several ECMAScript flavours are provided out-of-the-box: ES5, ES6-2015, ES7-2016, ES8-2017:

https://unpkg.com/r2-utils-js/dist/

(alternatively, GitHub mirror with semantic-versioning release tags: https://github.com/edrlab/r2-utils-js-dist/tree/develop/dist/ )

The JavaScript code is not bundled, and it uses require() statement for imports (NodeJS style).

More information about NodeJS compatibility:

http://node.green

Note that web-browser Javascript is currently not supported (only NodeJS runtimes).

The type definitions (aka "typings") are included as *.d.ts files in ./node_modules/r2-utils-js/dist/**, so this package can be used directly in a TypeScript project.

Example usage:

// currently no index file
// import { * } from "r2-utils-js";

// ES5 import (assuming node_modules/r2-utils-js/):
import { sortObject } from "r2-utils-js/dist/es5/src/_utils/JsonUtils";

// ... or alternatively using a convenient path alias in the TypeScript config (+ WebPack etc.):
import { sortObject } from "@r2-utils-js/JsonUtils";

Dependencies

https://david-dm.org/readium/r2-utils-js

A package-lock.json is provided (modern NPM replacement for npm-shrinkwrap.json).

A yarn.lock file is currently not provided at the root of the source tree.

Continuous Integration

TODO (unit tests?) https://travis-ci.org/readium/r2-utils-js

Badge: [![Travis](https://travis-ci.org/readium/r2-utils-js.svg?branch=develop)](https://travis-ci.org/readium/r2-utils-js)

Version(s), Git revision(s)

NPM package (latest published):

https://unpkg.com/r2-utils-js/dist/gitrev.json

Alternatively, GitHub mirror with semantic-versioning release tags:

https://raw.githack.com/edrlab/r2-utils-js-dist/develop/dist/gitrev.json

Developer quick start

Command line steps (NPM, but similar with YARN):

1) cd r2-utils-js 2) git status (please ensure there are no local changes, especially in package-lock.json and the dependency versions in package.json) 3) rm -rf node_modules (to start from a clean slate) 4) npm install, or alternatively npm ci (both commands initialize the node_modules tree of package dependencies, based on the strict package-lock.json definition) 5) npm run build:all (invoke the main build script: clean, lint, compile) 6) ls dist (that's the build output which gets published as NPM package)

Documentation

TODO

changelog

Next

Git diff:

Changes:

  • TODO

1.0.42

Build environment: NodeJS 22.12.0, NPM 11.0.0

Changes:

  • Fix fake zip deep directory scan (subfolder), for example concrete use case is DAISY 2.02 NCC.html non-zipped publication

Git revision info:

Git commit history:

Git diff:

1.0.41

Build environment: NodeJS 22.12.0, NPM 11.0.0

Changes:

  • NPM package updates
  • Flox/Nix updates (dev)

Git revision info:

Git commit history:

Git diff:

1.0.40

Build environment: NodeJS 22.11.0, NPM 11.0.0

Changes:

  • NPM package updates
  • Added UTF8 BOM removal util function
  • Support for Flox/Nix (dev)

Git revision info:

Git commit history:

Git diff:

1.0.39

Build environment: NodeJS 20.17.0, NPM 10.8.3

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.38

Build environment: NodeJS 20.10.0, NPM 10.2.5

Changes:

  • NPM (re)publish, previous package upload failed because of NPM breaking change (bug?): "files" array in package.json doesn't accept wildcard / glob pattern

Git revision info:

Git commit history:

Git diff:

1.0.37

Build environment: NodeJS 20.10.0, NPM 10.2.5

Changes:

  • NPM (re)publish, previous package upload was corrupted

Git revision info:

Git commit history:

Git diff:

1.0.36

Build environment: NodeJS 20.10.0, NPM 10.2.5

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.35

Build environment: NodeJS 18.16.0, NPM 9.8.0

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.34

Build environment: NodeJS 18.14.2, NPM 9.5.1

Changes:

  • NPM package updates
  • Fixed Windows filesystem backslash vs. forward slash handling (absolute path prefix in exploded / fake ZIP adapter)

Git revision info:

Git commit history:

Git diff:

1.0.33

Build environment: NodeJS 18.14.2, NPM 9.5.1

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.32

Build environment: NodeJS 18.12.1, NPM 9.1.1

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.31

Build environment: NodeJS 16.13.1, NPM 8.3.0

Changes:

  • NPM package updates
  • safeguard against callbacks that do not capture async / await thrown errors (exceptions do not automatically transit up the call chain) avoids UnhandledPromiseRejectionWarning

Git revision info:

Git commit history:

Git diff:

1.0.30

Build environment: NodeJS 16.13.1, NPM 8.3.0

Changes:

  • NPM package updates and migration from TSLINT to ESLINT

Git revision info:

Git commit history:

Git diff:

1.0.29

Build environment: NodeJS 16.13.0, NPM 8.1.4

Changes:

  • Removed console verbose output in filesystem folder zip emulation
  • Harmonised regular expressions for file extensions and HTTP URLs checks

Git revision info:

Git commit history:

Git diff:

1.0.28

Build environment: NodeJS 16.13.0, NPM 8.1.4

Changes:

  • Fix: regression bug when replacing filehound with plain NodeJS "fs" API to scan directory contents (ZIP directory emulated from filesystem)

Git revision info:

Git commit history:

Git diff:

1.0.27

Build environment: NodeJS 14.18.1, NPM 6.14.15

Changes:

  • NPM package updates
  • NodeJS v12 minimum requirement
  • Removed FileHound lib dependency in TypeScript code

Git revision info:

Git commit history:

Git diff:

1.0.26

Build environment: NodeJS 14.17.5, NPM 6.14.14

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.25

Build environment: NodeJS 14.16.1, NPM 6.14.13

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.24

Build environment: NodeJS 14.15.1, NPM 6.14.9

Changes:

  • NPM package updates
  • Fix: added missing Number converter in XML declarative parser (similar to TA-JSON)

Git revision info:

Git commit history:

Git diff:

1.0.23

Build environment: NodeJS 12.18.2, NPM 6.14.5

Changes:

  • NPM package updates
  • TypeScript const enum safeguard (isolated modules)

Git revision info:

Git commit history:

Git diff:

1.0.22

Build environment: NodeJS 12.18.1, NPM 6.14.5

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.21

Build environment: NodeJS 12.16.3, NPM 6.14.5

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.20

Build environment: NodeJS 12.16.1, NPM 6.14.4

Changes:

  • NPM package updates
  • Fixed CSON-2-JSON script

Git revision info:

Git commit history:

Git diff:

1.0.19

Build environment: NodeJS 12.16.1, NPM 6.14.4

Changes:

  • NPM package updates

Git revision info:

Git commit history:

Git diff:

1.0.18

Build environment: NodeJS 12.15.0, NPM 6.13.7

Changes:

  • NPM package updates
  • Buffer streaming error now forwarded into Promise rejection

Git revision info:

Git commit history:

Git diff:

1.0.17

Build environment: NodeJS 12.13.0, NPM 6.12.1

Changes:

  • ZIP injector: object close() was missing! (causing retained handle on filesystem ... thankfully only affected r2-testapp-js, but will soon be used in refactored LCP/LSD implementation of readium-desktop as well, see WIP pull request)

Git revision info:

Git commit history:

Git diff:

1.0.16

Build environment: NodeJS 12.13.0, NPM 6.12.0

Changes:

  • CLI utility to benchmark ZIP libs with CRC and directory entry streaming
  • YAUZL and YAZL TypeScript typings (no more "any")
  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.15

Build environment: NodeJS 10.16.3, NPM 6.12.0

Changes:

  • NPM updates (including NodeJS v12 for Electron v6)

Git revision info:

Git commit history:

Git diff:

1.0.14

Build environment: NodeJS 10.16.3, NPM 6.11.3

Changes:

  • Fixed bug in JSON tree walker (incorrect null / undefined check)
  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.13

Build environment: NodeJS 10.16.3, NPM 6.11.3

Changes:

  • NPM updates
  • TypeScript import sorter

Git revision info:

Git commit history:

Git diff:

1.0.12

Build environment: NodeJS 10.16.3, NPM 6.11.3

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.11

Build environment: NodeJS 10.16.0, NPM 6.10.2

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.10

Build environment: NodeJS 10.16.0, NPM 6.9.0

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.9

Build environment: NodeJS 10.15.3, NPM 6.9.0

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.8

Build environment: NodeJS 8.15.1, NPM 6.4.1

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.7

Build environment: NodeJS 8.15.1, NPM 6.4.1

Changes:

  • NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.6

Build environment: NodeJS 8.14.1, NPM 6.4.1

Changes:

  • NPM updates
  • Added sanity check in JSON traversal for edge-case of property val === null (which is typeof val === "object")

Git revision info:

Git commit history:

Git diff:

1.0.5

Build environment: NodeJS 8.14.1, NPM 6.4.1

Changes:

  • NPM updates
  • Fixed JSON traverse utility (correctly checks for null vs. undefined values)

Git revision info:

Git commit history:

Git diff:

1.0.4

Build environment: NodeJS 8.14.1, NPM 6.4.1

Changes:

  • Updated documentation (minor)
  • Fixed a NodeJS v8+ regression bug: readable-stream end event was not raised (which is why LCP decryption with basic-test profile was broken at Heroku and Now.sh streamer deployments)
  • NPM 6.5.* has regression bugs for global package installs, so revert back to NPM 6.4.1 (which is officially shipped with the NodeJS installer).

Git revision info:

Git commit history:

Git diff:

1.0.3

Build environment: NodeJS 8.14.0, NPM 6.5.0

Changes:

  • Minor NPM updates

Git revision info:

Git commit history:

Git diff:

1.0.2

Build environment: NodeJS 8.14.0, NPM 6.5.0

Changes:

  • Added support for exploded remote HTTP publications (fetcher / zip interface)

Git revision info:

Git commit history:

Git diff:

1.0.1

Build environment: NodeJS 8.14.0, NPM 6.5.0

Changes:

  • NPM updates (minor)
  • Replaced deprecated RawGit URLs
  • Fixed HTTP(s) URL detection (now regexp)
  • Workaround for bogus HTTP accept-ranges=bytes headers (e.g. https://raw.githubusercontent.com)

Git revision info:

Git commit history:

Git diff:

1.0.0

Build environment: NodeJS 8.14.0, NPM 6.5.0

Changes:

  • NPM updates (minor)
  • README info
  • VisualStudio code tweaks (developer workflow)
  • Semantic versioning bump 1.. (3-digit style now, "-alphaX" suffix caused issues with NPM tooling: updates, lockfile, etc.)

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.7

Build environment: NodeJS 8.12.0, NPM 6.4.1

Changes:

  • NPM updates (minor)
  • Git revision JSON info now includes NodeJS and NPM version (build environment)

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.6

Changes:

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.5

Changes:

  • Fixed TypeScript regression bug (3.0.3 -> 3.1.1) related to XML / HTML DOM typings
  • Removed TypeScript linter warning message (checks for no unused variables)
  • NPM updates related to the Node TypeScript typings
  • Dependency "ta-json" updates, and NPM integration GitHub semver reference

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.4

Changes:

  • removed rogue console.log()
  • NPM upates (minor, external dependencies)

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.3

Changes:

  • correct version in package-lock.json

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.2

Changes (NPM updates):

  • @types/node

Git revision info:

Git commit history:

Git diff:

1.0.0-alpha.1

Changes:

  • initial NPM publish

Git revision info:

Git commit history:

Git diff:

  • initial NPM publish