fsevents 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fsevents might be problematic. Click here for more details.
- package/Readme.md +12 -13
- package/node_modules/ansi/package.json +1 -2
- package/node_modules/are-we-there-yet/package.json +1 -2
- package/node_modules/asn1/.travis.yml +4 -0
- package/node_modules/asn1/lib/ber/reader.js +27 -33
- package/node_modules/asn1/lib/ber/writer.js +10 -11
- package/node_modules/asn1/package.json +21 -19
- package/node_modules/asn1/tst/ber/reader.test.js +36 -0
- package/node_modules/asn1/tst/ber/writer.test.js +74 -0
- package/node_modules/assert-plus/package.json +1 -0
- package/node_modules/{ctype → bl/node_modules/readable-stream/node_modules/core-util-is}/LICENSE +1 -6
- package/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/lib/util.js +11 -11
- package/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/package.json +17 -12
- package/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/test.js +68 -0
- package/node_modules/boom/package.json +1 -1
- package/node_modules/commander/package.json +1 -1
- package/node_modules/core-util-is/LICENSE +19 -0
- package/node_modules/core-util-is/lib/util.js +11 -11
- package/node_modules/core-util-is/package.json +17 -12
- package/node_modules/core-util-is/test.js +68 -0
- package/node_modules/dashdash/README.md +508 -0
- package/node_modules/dashdash/lib/dashdash.js +813 -0
- package/node_modules/dashdash/package.json +87 -0
- package/node_modules/deep-extend/LICENSE +1 -1
- package/node_modules/deep-extend/README.md +89 -52
- package/node_modules/deep-extend/index.js +1 -90
- package/node_modules/deep-extend/lib/deep-extend.js +144 -0
- package/node_modules/deep-extend/package.json +47 -16
- package/node_modules/deep-extend/test/index.spec.js +168 -5
- package/node_modules/delegates/package.json +1 -2
- package/node_modules/ecc-jsbn/.npmignore +15 -0
- package/node_modules/ecc-jsbn/LICENSE +21 -0
- package/node_modules/ecc-jsbn/README.md +8 -0
- package/node_modules/ecc-jsbn/index.js +57 -0
- package/node_modules/ecc-jsbn/lib/LICENSE-jsbn +40 -0
- package/node_modules/ecc-jsbn/lib/ec.js +561 -0
- package/node_modules/ecc-jsbn/lib/sec.js +170 -0
- package/node_modules/ecc-jsbn/package.json +63 -0
- package/node_modules/ecc-jsbn/test.js +14 -0
- package/node_modules/extsprintf/.gitmodules +6 -0
- package/node_modules/{path-is-absolute/license → extsprintf/LICENSE} +2 -4
- package/node_modules/extsprintf/Makefile +23 -0
- package/node_modules/extsprintf/Makefile.deps +39 -0
- package/node_modules/extsprintf/Makefile.targ +285 -0
- package/node_modules/extsprintf/README.md +39 -0
- package/node_modules/extsprintf/examples/simple.js +2 -0
- package/node_modules/{ctype/tools/jsl.conf → extsprintf/jsl.node.conf} +71 -63
- package/node_modules/extsprintf/lib/extsprintf.js +166 -0
- package/node_modules/extsprintf/package.json +48 -0
- package/node_modules/fstream/package.json +1 -2
- package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/package.json +4 -22
- package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/package.json +3 -21
- package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/package.json +4 -23
- package/node_modules/fstream-ignore/node_modules/minimatch/package.json +4 -24
- package/node_modules/fstream-ignore/package.json +1 -2
- package/node_modules/gauge/package.json +1 -2
- package/node_modules/har-validator/package.json +15 -15
- package/node_modules/has-unicode/package.json +1 -2
- package/node_modules/hawk/dist/client.js +340 -0
- package/node_modules/hawk/lib/browser.js +14 -20
- package/node_modules/hawk/package.json +10 -10
- package/node_modules/hawk/test/browser.js +134 -101
- package/node_modules/hawk/test/index.js +61 -61
- package/node_modules/hawk/test/server.js +72 -84
- package/node_modules/hawk/test/uri.js +52 -63
- package/node_modules/http-signature/CHANGES.md +39 -0
- package/node_modules/http-signature/http_signing.md +16 -17
- package/node_modules/http-signature/lib/index.js +6 -4
- package/node_modules/http-signature/lib/parser.js +43 -29
- package/node_modules/http-signature/lib/signer.js +290 -74
- package/node_modules/http-signature/lib/utils.js +112 -0
- package/node_modules/http-signature/lib/verify.js +47 -15
- package/node_modules/http-signature/package.json +20 -14
- package/node_modules/is-my-json-valid/index.js +16 -14
- package/node_modules/is-my-json-valid/package.json +16 -12
- package/node_modules/is-typedarray/LICENSE.md +18 -0
- package/node_modules/is-typedarray/README.md +16 -0
- package/node_modules/is-typedarray/index.js +41 -0
- package/node_modules/is-typedarray/package.json +63 -0
- package/node_modules/is-typedarray/test.js +34 -0
- package/node_modules/jodid25519/.npmignore +11 -0
- package/node_modules/jodid25519/.travis.yml +7 -0
- package/node_modules/jodid25519/AUTHORS.md +3 -0
- package/node_modules/jodid25519/LICENSE +23 -0
- package/node_modules/jodid25519/README.md +51 -0
- package/node_modules/jodid25519/almond.0 +42 -0
- package/node_modules/jodid25519/almond.1 +13 -0
- package/node_modules/jodid25519/index.js +35 -0
- package/node_modules/jodid25519/jsdoc.json +19 -0
- package/node_modules/jodid25519/lib/core.js +481 -0
- package/node_modules/jodid25519/lib/curve255.js +221 -0
- package/node_modules/jodid25519/lib/dh.js +111 -0
- package/node_modules/jodid25519/lib/eddsa.js +573 -0
- package/node_modules/jodid25519/lib/utils.js +198 -0
- package/node_modules/jodid25519/package.json +77 -0
- package/node_modules/jsbn/.npmignore +2 -0
- package/node_modules/jsbn/LICENSE +40 -0
- package/node_modules/jsbn/README.md +175 -0
- package/node_modules/jsbn/example.html +12 -0
- package/node_modules/jsbn/example.js +3 -0
- package/node_modules/jsbn/index.js +1358 -0
- package/node_modules/jsbn/package.json +60 -0
- package/node_modules/json-schema/README.md +5 -0
- package/node_modules/json-schema/draft-00/hyper-schema +68 -0
- package/node_modules/json-schema/draft-00/json-ref +26 -0
- package/node_modules/json-schema/draft-00/links +33 -0
- package/node_modules/json-schema/draft-00/schema +155 -0
- package/node_modules/json-schema/draft-01/hyper-schema +68 -0
- package/node_modules/json-schema/draft-01/json-ref +26 -0
- package/node_modules/json-schema/draft-01/links +33 -0
- package/node_modules/json-schema/draft-01/schema +155 -0
- package/node_modules/json-schema/draft-02/hyper-schema +68 -0
- package/node_modules/json-schema/draft-02/json-ref +26 -0
- package/node_modules/json-schema/draft-02/links +35 -0
- package/node_modules/json-schema/draft-02/schema +166 -0
- package/node_modules/json-schema/draft-03/examples/address +20 -0
- package/node_modules/json-schema/draft-03/examples/calendar +53 -0
- package/node_modules/json-schema/draft-03/examples/card +105 -0
- package/node_modules/json-schema/draft-03/examples/geo +8 -0
- package/node_modules/json-schema/draft-03/examples/interfaces +23 -0
- package/node_modules/json-schema/draft-03/hyper-schema +60 -0
- package/node_modules/json-schema/draft-03/json-ref +26 -0
- package/node_modules/json-schema/draft-03/links +35 -0
- package/node_modules/json-schema/draft-03/schema +174 -0
- package/node_modules/json-schema/draft-04/hyper-schema +60 -0
- package/node_modules/json-schema/draft-04/links +41 -0
- package/node_modules/json-schema/draft-04/schema +189 -0
- package/node_modules/json-schema/draft-zyp-json-schema-03.xml +1120 -0
- package/node_modules/json-schema/draft-zyp-json-schema-04.xml +1072 -0
- package/node_modules/json-schema/lib/links.js +52 -0
- package/node_modules/json-schema/lib/validate.js +260 -0
- package/node_modules/json-schema/package.json +67 -0
- package/node_modules/json-schema/test/tests.js +95 -0
- package/node_modules/jsprim/CHANGES.md +30 -0
- package/node_modules/jsprim/LICENSE +19 -0
- package/node_modules/jsprim/README.md +228 -0
- package/node_modules/jsprim/lib/jsprim.js +478 -0
- package/node_modules/jsprim/package.json +54 -0
- package/node_modules/lodash._basetostring/package.json +1 -2
- package/node_modules/lodash._createpadding/package.json +1 -2
- package/node_modules/lodash.pad/package.json +1 -2
- package/node_modules/lodash.padleft/package.json +1 -2
- package/node_modules/lodash.padright/package.json +1 -2
- package/node_modules/lodash.repeat/package.json +1 -2
- package/node_modules/node-pre-gyp/CHANGELOG.md +8 -0
- package/node_modules/node-pre-gyp/README.md +570 -0
- package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +4 -0
- package/node_modules/node-pre-gyp/node_modules/nopt/lib/nopt.js +2 -1
- package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/package.json +30 -37
- package/node_modules/node-pre-gyp/node_modules/nopt/package.json +37 -57
- package/node_modules/node-pre-gyp/node_modules/nopt/test/basic.js +22 -0
- package/node_modules/node-pre-gyp/package.json +17 -17
- package/node_modules/node-uuid/.npmignore +2 -0
- package/node_modules/node-uuid/README.md +12 -1
- package/node_modules/node-uuid/bower.json +1 -1
- package/node_modules/node-uuid/component.json +11 -4
- package/node_modules/node-uuid/package.json +25 -12
- package/node_modules/node-uuid/test/test.js +3 -0
- package/node_modules/node-uuid/uuid.js +70 -45
- package/node_modules/npmlog/.travis.yml +14 -0
- package/node_modules/npmlog/log.js +3 -0
- package/node_modules/npmlog/package.json +23 -20
- package/node_modules/npmlog/test/basic.js +8 -1
- package/node_modules/once/package.json +2 -3
- package/node_modules/pinkie/index.js +23 -7
- package/node_modules/pinkie/package.json +22 -15
- package/node_modules/pinkie/readme.md +17 -9
- package/node_modules/pinkie-promise/package.json +16 -14
- package/node_modules/pinkie-promise/readme.md +5 -3
- package/node_modules/rc/README.md +1 -1
- package/node_modules/rc/index.js +1 -1
- package/node_modules/rc/node_modules/minimist/package.json +1 -1
- package/node_modules/rc/package.json +12 -12
- package/node_modules/request/.eslintrc +1 -1
- package/node_modules/request/.travis.yml +4 -4
- package/node_modules/request/CHANGELOG.md +25 -0
- package/node_modules/request/README.md +12 -13
- package/node_modules/request/lib/har.js +84 -75
- package/node_modules/request/lib/redirect.js +2 -3
- package/node_modules/request/lib/tunnel.js +13 -18
- package/node_modules/request/package.json +17 -16
- package/node_modules/request/request.js +16 -59
- package/node_modules/rimraf/README.md +7 -2
- package/node_modules/{wrappy → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/package.json +5 -25
- package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/package.json +5 -25
- package/node_modules/rimraf/node_modules/glob/node_modules/inherits/LICENSE +16 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/inherits/README.md +42 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits.js +1 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/inherits/inherits_browser.js +23 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/inherits/package.json +58 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/inherits/test.js +25 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore +3 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md +122 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js +8 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +191 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore +2 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml +3 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/LICENSE.md +21 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile +6 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md +80 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js +5 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js +38 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +79 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js +56 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml +4 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE +18 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown +62 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js +6 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js +13 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +90 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js +39 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +81 -0
- package/node_modules/rimraf/node_modules/{minimatch → glob/node_modules/minimatch}/package.json +3 -21
- package/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/README.md +36 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/package.json +58 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js +51 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js +33 -0
- package/node_modules/rimraf/node_modules/glob/node_modules/once/package.json +70 -0
- package/node_modules/{path-is-absolute → rimraf/node_modules/glob/node_modules/path-is-absolute}/package.json +4 -22
- package/node_modules/rimraf/node_modules/glob/package.json +2 -20
- package/node_modules/rimraf/package.json +10 -10
- package/node_modules/semver/README.md +25 -1
- package/node_modules/semver/package.json +10 -10
- package/node_modules/semver/range.bnf +16 -0
- package/node_modules/semver/semver.js +0 -12
- package/node_modules/sshpk/.npmignore +8 -0
- package/node_modules/sshpk/.travis.yml +11 -0
- package/node_modules/sshpk/LICENSE +18 -0
- package/node_modules/sshpk/README.md +436 -0
- package/node_modules/sshpk/bin/sshpk-conv +183 -0
- package/node_modules/sshpk/lib/algs.js +168 -0
- package/node_modules/sshpk/lib/dhe.js +312 -0
- package/node_modules/sshpk/lib/ed-compat.js +94 -0
- package/node_modules/sshpk/lib/errors.js +58 -0
- package/node_modules/sshpk/lib/fingerprint.js +140 -0
- package/node_modules/sshpk/lib/formats/auto.js +73 -0
- package/node_modules/sshpk/lib/formats/pem.js +152 -0
- package/node_modules/sshpk/lib/formats/pkcs1.js +320 -0
- package/node_modules/sshpk/lib/formats/pkcs8.js +510 -0
- package/node_modules/sshpk/lib/formats/rfc4253.js +145 -0
- package/node_modules/sshpk/lib/formats/ssh-private.js +138 -0
- package/node_modules/sshpk/lib/formats/ssh.js +114 -0
- package/node_modules/sshpk/lib/index.js +25 -0
- package/node_modules/sshpk/lib/key.js +260 -0
- package/node_modules/sshpk/lib/private-key.js +224 -0
- package/node_modules/sshpk/lib/signature.js +237 -0
- package/node_modules/sshpk/lib/ssh-buffer.js +123 -0
- package/node_modules/sshpk/lib/utils.js +207 -0
- package/node_modules/sshpk/node_modules/assert-plus/AUTHORS +6 -0
- package/node_modules/sshpk/node_modules/assert-plus/CHANGES.md +8 -0
- package/node_modules/sshpk/node_modules/assert-plus/README.md +155 -0
- package/node_modules/sshpk/node_modules/assert-plus/assert.js +206 -0
- package/node_modules/sshpk/node_modules/assert-plus/package.json +88 -0
- package/node_modules/sshpk/package.json +92 -0
- package/node_modules/strip-json-comments/cli.js +2 -2
- package/node_modules/strip-json-comments/package.json +13 -12
- package/node_modules/strip-json-comments/readme.md +11 -5
- package/node_modules/strip-json-comments/strip-json-comments.js +16 -7
- package/node_modules/tar/package.json +1 -2
- package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/LICENSE +19 -0
- package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/lib/util.js +11 -11
- package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/package.json +17 -12
- package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/test.js +68 -0
- package/node_modules/tar-pack/node_modules/readable-stream/node_modules/inherits/package.json +1 -1
- package/node_modules/tar-pack/node_modules/rimraf/package.json +1 -2
- package/node_modules/tar-pack/package.json +1 -2
- package/node_modules/tough-cookie/lib/cookie.js +1 -1
- package/node_modules/tough-cookie/package.json +7 -7
- package/node_modules/tweetnacl/.npmignore +4 -0
- package/node_modules/tweetnacl/CHANGELOG.md +128 -0
- package/node_modules/tweetnacl/README.md +463 -0
- package/node_modules/tweetnacl/nacl-fast.js +2418 -0
- package/node_modules/tweetnacl/nacl-fast.min.js +2 -0
- package/node_modules/tweetnacl/nacl.js +1205 -0
- package/node_modules/tweetnacl/nacl.min.js +1 -0
- package/node_modules/tweetnacl/package.json +101 -0
- package/node_modules/uid-number/package.json +2 -3
- package/node_modules/verror/.gitmodules +0 -0
- package/node_modules/verror/LICENSE +19 -0
- package/node_modules/verror/Makefile +35 -0
- package/node_modules/verror/Makefile.targ +285 -0
- package/node_modules/verror/README.md +120 -0
- package/node_modules/verror/examples/levels-verror.js +36 -0
- package/node_modules/verror/examples/levels-werror.js +34 -0
- package/node_modules/verror/examples/varargs.js +6 -0
- package/node_modules/verror/examples/verror.js +13 -0
- package/node_modules/verror/examples/werror.js +14 -0
- package/node_modules/verror/jsl.node.conf +139 -0
- package/node_modules/verror/lib/verror.js +157 -0
- package/node_modules/verror/package.json +51 -0
- package/node_modules/verror/tests/tst.inherit.js +100 -0
- package/node_modules/verror/tests/tst.verror.js +156 -0
- package/node_modules/verror/tests/tst.werror.js +179 -0
- package/package.json +3 -3
- package/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/util.js +0 -106
- package/node_modules/core-util-is/util.js +0 -106
- package/node_modules/ctype/.npmignore +0 -1
- package/node_modules/ctype/CHANGELOG +0 -78
- package/node_modules/ctype/README +0 -82
- package/node_modules/ctype/README.old +0 -298
- package/node_modules/ctype/ctf.js +0 -245
- package/node_modules/ctype/ctio.js +0 -1485
- package/node_modules/ctype/ctype.js +0 -944
- package/node_modules/ctype/man/man3ctype/ctio.3ctype +0 -241
- package/node_modules/ctype/package.json +0 -51
- package/node_modules/ctype/tools/jsstyle +0 -839
- package/node_modules/http-signature/lib/util.js +0 -306
- package/node_modules/inflight/node_modules/once/package.json +0 -86
- package/node_modules/inflight/node_modules/once/test/once.js +0 -23
- package/node_modules/rimraf/node_modules/glob/LICENSE +0 -15
- package/node_modules/rimraf/node_modules/minimatch/LICENSE +0 -15
- package/node_modules/rimraf/node_modules/once/LICENSE +0 -15
- package/node_modules/rimraf/node_modules/once/README.md +0 -51
- package/node_modules/rimraf/node_modules/once/once.js +0 -21
- package/node_modules/rimraf/node_modules/once/package.json +0 -84
- package/node_modules/rimraf/node_modules/once/test/once.js +0 -23
- package/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/util.js +0 -106
- package/node_modules/wrappy/LICENSE +0 -15
- /package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/.npmignore +0 -0
- /package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/README.md +0 -0
- /package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/example.js +0 -0
- /package/node_modules/{brace-expansion → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion}/index.js +0 -0
- /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/.npmignore +0 -0
- /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/.travis.yml +0 -0
- /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/LICENSE.md +0 -0
- /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/Makefile +0 -0
- /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/README.md +0 -0
- /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/example.js +0 -0
- /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/index.js +0 -0
- /package/node_modules/{balanced-match → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match}/test/balanced.js +0 -0
- /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/.travis.yml +0 -0
- /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/LICENSE +0 -0
- /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/README.markdown +0 -0
- /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/example/map.js +0 -0
- /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/index.js +0 -0
- /package/node_modules/{concat-map → fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map}/test/map.js +0 -0
- /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/.npmignore +0 -0
- /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/.travis.yml +0 -0
- /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/CONTRIBUTING.md +0 -0
- /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/LICENSE +0 -0
- /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/README.md +0 -0
- /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/abbrev.js +0 -0
- /package/node_modules/{abbrev → node-pre-gyp/node_modules/nopt/node_modules/abbrev}/test.js +0 -0
- /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/.eslintrc +0 -0
- /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/LICENSE +0 -0
- /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/README.md +0 -0
- /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/inflight.js +0 -0
- /package/node_modules/{fstream-ignore/node_modules/minimatch → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/LICENSE +0 -0
- /package/node_modules/{wrappy → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/README.md +0 -0
- /package/node_modules/{wrappy → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/test/basic.js +0 -0
- /package/node_modules/{wrappy → rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy}/wrappy.js +0 -0
- /package/node_modules/{inflight → rimraf/node_modules/glob/node_modules/inflight}/test.js +0 -0
- /package/node_modules/rimraf/node_modules/{minimatch → glob/node_modules/minimatch}/README.md +0 -0
- /package/node_modules/rimraf/node_modules/{minimatch → glob/node_modules/minimatch}/minimatch.js +0 -0
- /package/node_modules/{inflight → rimraf/node_modules/glob}/node_modules/once/README.md +0 -0
- /package/node_modules/{inflight/node_modules/once → rimraf/node_modules/glob/node_modules/once/node_modules/wrappy}/LICENSE +0 -0
- /package/node_modules/{inflight → rimraf/node_modules/glob}/node_modules/once/once.js +0 -0
- /package/node_modules/{path-is-absolute → rimraf/node_modules/glob/node_modules/path-is-absolute}/index.js +0 -0
- /package/node_modules/{path-is-absolute → rimraf/node_modules/glob/node_modules/path-is-absolute}/readme.md +0 -0
- /package/node_modules/{deep-extend → verror}/.npmignore +0 -0
@@ -0,0 +1,228 @@
|
|
1
|
+
# jsprim: utilities for primitive JavaScript types
|
2
|
+
|
3
|
+
This module provides miscellaneous facilities for working with strings,
|
4
|
+
numbers, dates, and objects and arrays of these basic types.
|
5
|
+
|
6
|
+
|
7
|
+
### deepCopy(obj)
|
8
|
+
|
9
|
+
Creates a deep copy of a primitive type, object, or array of primitive types.
|
10
|
+
|
11
|
+
|
12
|
+
### deepEqual(obj1, obj2)
|
13
|
+
|
14
|
+
Returns whether two objects are equal.
|
15
|
+
|
16
|
+
|
17
|
+
### isEmpty(obj)
|
18
|
+
|
19
|
+
Returns true if the given object has no properties and false otherwise. This
|
20
|
+
is O(1) (unlike `Object.keys(obj).length === 0`, which is O(N)).
|
21
|
+
|
22
|
+
|
23
|
+
### forEachKey(obj, callback)
|
24
|
+
|
25
|
+
Like Array.forEach, but iterates properties of an object rather than elements
|
26
|
+
of an array. Equivalent to:
|
27
|
+
|
28
|
+
for (var key in obj)
|
29
|
+
callback(key, obj[key]);
|
30
|
+
|
31
|
+
|
32
|
+
### flattenObject(obj, depth)
|
33
|
+
|
34
|
+
Flattens an object up to a given level of nesting, returning an array of arrays
|
35
|
+
of length "depth + 1", where the first "depth" elements correspond to flattened
|
36
|
+
columns and the last element contains the remaining object . For example:
|
37
|
+
|
38
|
+
flattenObject({
|
39
|
+
'I': {
|
40
|
+
'A': {
|
41
|
+
'i': {
|
42
|
+
'datum1': [ 1, 2 ],
|
43
|
+
'datum2': [ 3, 4 ]
|
44
|
+
},
|
45
|
+
'ii': {
|
46
|
+
'datum1': [ 3, 4 ]
|
47
|
+
}
|
48
|
+
},
|
49
|
+
'B': {
|
50
|
+
'i': {
|
51
|
+
'datum1': [ 5, 6 ]
|
52
|
+
},
|
53
|
+
'ii': {
|
54
|
+
'datum1': [ 7, 8 ],
|
55
|
+
'datum2': [ 3, 4 ],
|
56
|
+
},
|
57
|
+
'iii': {
|
58
|
+
}
|
59
|
+
}
|
60
|
+
},
|
61
|
+
'II': {
|
62
|
+
'A': {
|
63
|
+
'i': {
|
64
|
+
'datum1': [ 1, 2 ],
|
65
|
+
'datum2': [ 3, 4 ]
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}, 3)
|
70
|
+
|
71
|
+
becomes:
|
72
|
+
|
73
|
+
[
|
74
|
+
[ 'I', 'A', 'i', { 'datum1': [ 1, 2 ], 'datum2': [ 3, 4 ] } ],
|
75
|
+
[ 'I', 'A', 'ii', { 'datum1': [ 3, 4 ] } ],
|
76
|
+
[ 'I', 'B', 'i', { 'datum1': [ 5, 6 ] } ],
|
77
|
+
[ 'I', 'B', 'ii', { 'datum1': [ 7, 8 ], 'datum2': [ 3, 4 ] } ],
|
78
|
+
[ 'I', 'B', 'iii', {} ],
|
79
|
+
[ 'II', 'A', 'i', { 'datum1': [ 1, 2 ], 'datum2': [ 3, 4 ] } ]
|
80
|
+
]
|
81
|
+
|
82
|
+
This function is strict: "depth" must be a non-negative integer and "obj" must
|
83
|
+
be a non-null object with at least "depth" levels of nesting under all keys.
|
84
|
+
|
85
|
+
|
86
|
+
### flattenIter(obj, depth, func)
|
87
|
+
|
88
|
+
This is similar to `flattenObject` except that instead of returning an array,
|
89
|
+
this function invokes `func(entry)` for each `entry` in the array that
|
90
|
+
`flattenObject` would return. `flattenIter(obj, depth, func)` is logically
|
91
|
+
equivalent to `flattenObject(obj, depth).forEach(func)`. Importantly, this
|
92
|
+
version never constructs the full array. Its memory usage is O(depth) rather
|
93
|
+
than O(n) (where `n` is the number of flattened elements).
|
94
|
+
|
95
|
+
There's another difference between `flattenObject` and `flattenIter` that's
|
96
|
+
related to the special case where `depth === 0`. In this case, `flattenObject`
|
97
|
+
omits the array wrapping `obj` (which is regrettable).
|
98
|
+
|
99
|
+
|
100
|
+
### pluck(obj, key)
|
101
|
+
|
102
|
+
Fetch nested property "key" from object "obj", traversing objects as needed.
|
103
|
+
For example, `pluck(obj, "foo.bar.baz")` is roughly equivalent to
|
104
|
+
`obj.foo.bar.baz`, except that:
|
105
|
+
|
106
|
+
1. If traversal fails, the resulting value is undefined, and no error is
|
107
|
+
thrown. For example, `pluck({}, "foo.bar")` is just undefined.
|
108
|
+
2. If "obj" has property "key" directly (without traversing), the
|
109
|
+
corresponding property is returned. For example,
|
110
|
+
`pluck({ 'foo.bar': 1 }, 'foo.bar')` is 1, not undefined. This is also
|
111
|
+
true recursively, so `pluck({ 'a': { 'foo.bar': 1 } }, 'a.foo.bar')` is
|
112
|
+
also 1, not undefined.
|
113
|
+
|
114
|
+
|
115
|
+
### randElt(array)
|
116
|
+
|
117
|
+
Returns an element from "array" selected uniformly at random. If "array" is
|
118
|
+
empty, throws an Error.
|
119
|
+
|
120
|
+
|
121
|
+
### startsWith(str, prefix)
|
122
|
+
|
123
|
+
Returns true if the given string starts with the given prefix and false
|
124
|
+
otherwise.
|
125
|
+
|
126
|
+
|
127
|
+
### endsWith(str, suffix)
|
128
|
+
|
129
|
+
Returns true if the given string ends with the given suffix and false
|
130
|
+
otherwise.
|
131
|
+
|
132
|
+
|
133
|
+
### iso8601(date)
|
134
|
+
|
135
|
+
Converts a Date object to an ISO8601 date string of the form
|
136
|
+
"YYYY-MM-DDTHH:MM:SS.sssZ". This format is not customizable.
|
137
|
+
|
138
|
+
|
139
|
+
### parseDateTime(str)
|
140
|
+
|
141
|
+
Parses a date expressed as a string, as either a number of milliseconds since
|
142
|
+
the epoch or any string format that Date accepts, giving preference to the
|
143
|
+
former where these two sets overlap (e.g., strings containing small numbers).
|
144
|
+
|
145
|
+
|
146
|
+
### hrtimeDiff(timeA, timeB)
|
147
|
+
|
148
|
+
Given two hrtime readings (as from Node's `process.hrtime()`), where timeA is
|
149
|
+
later than timeB, compute the difference and return that as an hrtime. It is
|
150
|
+
illegal to invoke this for a pair of times where timeB is newer than timeA.
|
151
|
+
|
152
|
+
### hrtimeAdd(timeA, timeB)
|
153
|
+
|
154
|
+
Add two hrtime intervals (as from Node's `process.hrtime()`), returning a new
|
155
|
+
hrtime interval array. This function does not modify either input argument.
|
156
|
+
|
157
|
+
|
158
|
+
### hrtimeAccum(timeA, timeB)
|
159
|
+
|
160
|
+
Add two hrtime intervals (as from Node's `process.hrtime()`), storing the
|
161
|
+
result in `timeA`. This function overwrites (and returns) the first argument
|
162
|
+
passed in.
|
163
|
+
|
164
|
+
|
165
|
+
### hrtimeNanosec(timeA), hrtimeMicrosec(timeA), hrtimeMillisec(timeA)
|
166
|
+
|
167
|
+
This suite of functions converts a hrtime interval (as from Node's
|
168
|
+
`process.hrtime()`) into a scalar number of nanoseconds, microseconds or
|
169
|
+
milliseconds. Results are truncated, as with `Math.floor()`.
|
170
|
+
|
171
|
+
|
172
|
+
### validateJsonObject(schema, object)
|
173
|
+
|
174
|
+
Uses JSON validation (via JSV) to validate the given object against the given
|
175
|
+
schema. On success, returns null. On failure, *returns* (does not throw) a
|
176
|
+
useful Error object.
|
177
|
+
|
178
|
+
|
179
|
+
### extraProperties(object, allowed)
|
180
|
+
|
181
|
+
Check an object for unexpected properties. Accepts the object to check, and an
|
182
|
+
array of allowed property name strings. If extra properties are detected, an
|
183
|
+
array of extra property names is returned. If no properties other than those
|
184
|
+
in the allowed list are present on the object, the returned array will be of
|
185
|
+
zero length.
|
186
|
+
|
187
|
+
### mergeObjects(provided, overrides, defaults)
|
188
|
+
|
189
|
+
Merge properties from objects "provided", "overrides", and "defaults". The
|
190
|
+
intended use case is for functions that accept named arguments in an "args"
|
191
|
+
object, but want to provide some default values and override other values. In
|
192
|
+
that case, "provided" is what the caller specified, "overrides" are what the
|
193
|
+
function wants to override, and "defaults" contains default values.
|
194
|
+
|
195
|
+
The function starts with the values in "defaults", overrides them with the
|
196
|
+
values in "provided", and then overrides those with the values in "overrides".
|
197
|
+
For convenience, any of these objects may be falsey, in which case they will be
|
198
|
+
ignored. The input objects are never modified, but properties in the returned
|
199
|
+
object are not deep-copied.
|
200
|
+
|
201
|
+
For example:
|
202
|
+
|
203
|
+
mergeObjects(undefined, { 'objectMode': true }, { 'highWaterMark': 0 })
|
204
|
+
|
205
|
+
returns:
|
206
|
+
|
207
|
+
{ 'objectMode': true, 'highWaterMark': 0 }
|
208
|
+
|
209
|
+
For another example:
|
210
|
+
|
211
|
+
mergeObjects(
|
212
|
+
{ 'highWaterMark': 16, 'objectMode': 7 }, /* from caller */
|
213
|
+
{ 'objectMode': true }, /* overrides */
|
214
|
+
{ 'highWaterMark': 0 }); /* default */
|
215
|
+
|
216
|
+
returns:
|
217
|
+
|
218
|
+
{ 'objectMode': true, 'highWaterMark': 16 }
|
219
|
+
|
220
|
+
|
221
|
+
# Contributing
|
222
|
+
|
223
|
+
Code should be "make check" clean. This target assumes that
|
224
|
+
[jsl](http://github.com/davepacheco/javascriptlint) and
|
225
|
+
[jsstyle](http://github.com/davepacheco/jsstyle) are on your path.
|
226
|
+
|
227
|
+
New tests should generally accompany new functions and bug fixes. The tests
|
228
|
+
should pass cleanly (run tests/basic.js).
|
@@ -0,0 +1,478 @@
|
|
1
|
+
/*
|
2
|
+
* lib/jsprim.js: utilities for primitive JavaScript types
|
3
|
+
*/
|
4
|
+
|
5
|
+
var mod_assert = require('assert');
|
6
|
+
var mod_util = require('util');
|
7
|
+
|
8
|
+
var mod_extsprintf = require('extsprintf');
|
9
|
+
var mod_verror = require('verror');
|
10
|
+
var mod_jsonschema = require('json-schema');
|
11
|
+
|
12
|
+
/*
|
13
|
+
* Public interface
|
14
|
+
*/
|
15
|
+
exports.deepCopy = deepCopy;
|
16
|
+
exports.deepEqual = deepEqual;
|
17
|
+
exports.isEmpty = isEmpty;
|
18
|
+
exports.forEachKey = forEachKey;
|
19
|
+
exports.pluck = pluck;
|
20
|
+
exports.flattenObject = flattenObject;
|
21
|
+
exports.flattenIter = flattenIter;
|
22
|
+
exports.validateJsonObject = validateJsonObjectJS;
|
23
|
+
exports.validateJsonObjectJS = validateJsonObjectJS;
|
24
|
+
exports.randElt = randElt;
|
25
|
+
exports.extraProperties = extraProperties;
|
26
|
+
exports.mergeObjects = mergeObjects;
|
27
|
+
|
28
|
+
exports.startsWith = startsWith;
|
29
|
+
exports.endsWith = endsWith;
|
30
|
+
|
31
|
+
exports.iso8601 = iso8601;
|
32
|
+
exports.rfc1123 = rfc1123;
|
33
|
+
exports.parseDateTime = parseDateTime;
|
34
|
+
|
35
|
+
exports.hrtimediff = hrtimeDiff;
|
36
|
+
exports.hrtimeDiff = hrtimeDiff;
|
37
|
+
exports.hrtimeAccum = hrtimeAccum;
|
38
|
+
exports.hrtimeAdd = hrtimeAdd;
|
39
|
+
exports.hrtimeNanosec = hrtimeNanosec;
|
40
|
+
exports.hrtimeMicrosec = hrtimeMicrosec;
|
41
|
+
exports.hrtimeMillisec = hrtimeMillisec;
|
42
|
+
|
43
|
+
|
44
|
+
/*
|
45
|
+
* Deep copy an acyclic *basic* Javascript object. This only handles basic
|
46
|
+
* scalars (strings, numbers, booleans) and arbitrarily deep arrays and objects
|
47
|
+
* containing these. This does *not* handle instances of other classes.
|
48
|
+
*/
|
49
|
+
function deepCopy(obj)
|
50
|
+
{
|
51
|
+
var ret, key;
|
52
|
+
var marker = '__deepCopy';
|
53
|
+
|
54
|
+
if (obj && obj[marker])
|
55
|
+
throw (new Error('attempted deep copy of cyclic object'));
|
56
|
+
|
57
|
+
if (obj && obj.constructor == Object) {
|
58
|
+
ret = {};
|
59
|
+
obj[marker] = true;
|
60
|
+
|
61
|
+
for (key in obj) {
|
62
|
+
if (key == marker)
|
63
|
+
continue;
|
64
|
+
|
65
|
+
ret[key] = deepCopy(obj[key]);
|
66
|
+
}
|
67
|
+
|
68
|
+
delete (obj[marker]);
|
69
|
+
return (ret);
|
70
|
+
}
|
71
|
+
|
72
|
+
if (obj && obj.constructor == Array) {
|
73
|
+
ret = [];
|
74
|
+
obj[marker] = true;
|
75
|
+
|
76
|
+
for (key = 0; key < obj.length; key++)
|
77
|
+
ret.push(deepCopy(obj[key]));
|
78
|
+
|
79
|
+
delete (obj[marker]);
|
80
|
+
return (ret);
|
81
|
+
}
|
82
|
+
|
83
|
+
/*
|
84
|
+
* It must be a primitive type -- just return it.
|
85
|
+
*/
|
86
|
+
return (obj);
|
87
|
+
}
|
88
|
+
|
89
|
+
function deepEqual(obj1, obj2)
|
90
|
+
{
|
91
|
+
if (typeof (obj1) != typeof (obj2))
|
92
|
+
return (false);
|
93
|
+
|
94
|
+
if (obj1 === null || obj2 === null || typeof (obj1) != 'object')
|
95
|
+
return (obj1 === obj2);
|
96
|
+
|
97
|
+
if (obj1.constructor != obj2.constructor)
|
98
|
+
return (false);
|
99
|
+
|
100
|
+
var k;
|
101
|
+
for (k in obj1) {
|
102
|
+
if (!obj2.hasOwnProperty(k))
|
103
|
+
return (false);
|
104
|
+
|
105
|
+
if (!deepEqual(obj1[k], obj2[k]))
|
106
|
+
return (false);
|
107
|
+
}
|
108
|
+
|
109
|
+
for (k in obj2) {
|
110
|
+
if (!obj1.hasOwnProperty(k))
|
111
|
+
return (false);
|
112
|
+
}
|
113
|
+
|
114
|
+
return (true);
|
115
|
+
}
|
116
|
+
|
117
|
+
function isEmpty(obj)
|
118
|
+
{
|
119
|
+
var key;
|
120
|
+
for (key in obj)
|
121
|
+
return (false);
|
122
|
+
return (true);
|
123
|
+
}
|
124
|
+
|
125
|
+
function forEachKey(obj, callback)
|
126
|
+
{
|
127
|
+
for (var key in obj)
|
128
|
+
callback(key, obj[key]);
|
129
|
+
}
|
130
|
+
|
131
|
+
function pluck(obj, key)
|
132
|
+
{
|
133
|
+
mod_assert.equal(typeof (key), 'string');
|
134
|
+
return (pluckv(obj, key));
|
135
|
+
}
|
136
|
+
|
137
|
+
function pluckv(obj, key)
|
138
|
+
{
|
139
|
+
if (obj === null || typeof (obj) !== 'object')
|
140
|
+
return (undefined);
|
141
|
+
|
142
|
+
if (obj.hasOwnProperty(key))
|
143
|
+
return (obj[key]);
|
144
|
+
|
145
|
+
var i = key.indexOf('.');
|
146
|
+
if (i == -1)
|
147
|
+
return (undefined);
|
148
|
+
|
149
|
+
var key1 = key.substr(0, i);
|
150
|
+
if (!obj.hasOwnProperty(key1))
|
151
|
+
return (undefined);
|
152
|
+
|
153
|
+
return (pluckv(obj[key1], key.substr(i + 1)));
|
154
|
+
}
|
155
|
+
|
156
|
+
/*
|
157
|
+
* Invoke callback(row) for each entry in the array that would be returned by
|
158
|
+
* flattenObject(data, depth). This is just like flattenObject(data,
|
159
|
+
* depth).forEach(callback), except that the intermediate array is never
|
160
|
+
* created.
|
161
|
+
*/
|
162
|
+
function flattenIter(data, depth, callback)
|
163
|
+
{
|
164
|
+
doFlattenIter(data, depth, [], callback);
|
165
|
+
}
|
166
|
+
|
167
|
+
function doFlattenIter(data, depth, accum, callback)
|
168
|
+
{
|
169
|
+
var each;
|
170
|
+
var key;
|
171
|
+
|
172
|
+
if (depth === 0) {
|
173
|
+
each = accum.slice(0);
|
174
|
+
each.push(data);
|
175
|
+
callback(each);
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
|
179
|
+
mod_assert.ok(data !== null);
|
180
|
+
mod_assert.equal(typeof (data), 'object');
|
181
|
+
mod_assert.equal(typeof (depth), 'number');
|
182
|
+
mod_assert.ok(depth >= 0);
|
183
|
+
|
184
|
+
for (key in data) {
|
185
|
+
each = accum.slice(0);
|
186
|
+
each.push(key);
|
187
|
+
doFlattenIter(data[key], depth - 1, each, callback);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
function flattenObject(data, depth)
|
192
|
+
{
|
193
|
+
if (depth === 0)
|
194
|
+
return ([ data ]);
|
195
|
+
|
196
|
+
mod_assert.ok(data !== null);
|
197
|
+
mod_assert.equal(typeof (data), 'object');
|
198
|
+
mod_assert.equal(typeof (depth), 'number');
|
199
|
+
mod_assert.ok(depth >= 0);
|
200
|
+
|
201
|
+
var rv = [];
|
202
|
+
var key;
|
203
|
+
|
204
|
+
for (key in data) {
|
205
|
+
flattenObject(data[key], depth - 1).forEach(function (p) {
|
206
|
+
rv.push([ key ].concat(p));
|
207
|
+
});
|
208
|
+
}
|
209
|
+
|
210
|
+
return (rv);
|
211
|
+
}
|
212
|
+
|
213
|
+
function startsWith(str, prefix)
|
214
|
+
{
|
215
|
+
return (str.substr(0, prefix.length) == prefix);
|
216
|
+
}
|
217
|
+
|
218
|
+
function endsWith(str, suffix)
|
219
|
+
{
|
220
|
+
return (str.substr(
|
221
|
+
str.length - suffix.length, suffix.length) == suffix);
|
222
|
+
}
|
223
|
+
|
224
|
+
function iso8601(d)
|
225
|
+
{
|
226
|
+
if (typeof (d) == 'number')
|
227
|
+
d = new Date(d);
|
228
|
+
mod_assert.ok(d.constructor === Date);
|
229
|
+
return (mod_extsprintf.sprintf('%4d-%02d-%02dT%02d:%02d:%02d.%03dZ',
|
230
|
+
d.getUTCFullYear(), d.getUTCMonth() + 1, d.getUTCDate(),
|
231
|
+
d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(),
|
232
|
+
d.getUTCMilliseconds()));
|
233
|
+
}
|
234
|
+
|
235
|
+
var RFC1123_MONTHS = [
|
236
|
+
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
237
|
+
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
238
|
+
var RFC1123_DAYS = [
|
239
|
+
'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
240
|
+
|
241
|
+
function rfc1123(date) {
|
242
|
+
return (mod_extsprintf.sprintf('%s, %02d %s %04d %02d:%02d:%02d GMT',
|
243
|
+
RFC1123_DAYS[date.getUTCDay()], date.getUTCDate(),
|
244
|
+
RFC1123_MONTHS[date.getUTCMonth()], date.getUTCFullYear(),
|
245
|
+
date.getUTCHours(), date.getUTCMinutes(),
|
246
|
+
date.getUTCSeconds()));
|
247
|
+
}
|
248
|
+
|
249
|
+
/*
|
250
|
+
* Parses a date expressed as a string, as either a number of milliseconds since
|
251
|
+
* the epoch or any string format that Date accepts, giving preference to the
|
252
|
+
* former where these two sets overlap (e.g., small numbers).
|
253
|
+
*/
|
254
|
+
function parseDateTime(str)
|
255
|
+
{
|
256
|
+
/*
|
257
|
+
* This is irritatingly implicit, but significantly more concise than
|
258
|
+
* alternatives. The "+str" will convert a string containing only a
|
259
|
+
* number directly to a Number, or NaN for other strings. Thus, if the
|
260
|
+
* conversion succeeds, we use it (this is the milliseconds-since-epoch
|
261
|
+
* case). Otherwise, we pass the string directly to the Date
|
262
|
+
* constructor to parse.
|
263
|
+
*/
|
264
|
+
var numeric = +str;
|
265
|
+
if (!isNaN(numeric)) {
|
266
|
+
return (new Date(numeric));
|
267
|
+
} else {
|
268
|
+
return (new Date(str));
|
269
|
+
}
|
270
|
+
}
|
271
|
+
|
272
|
+
function validateJsonObjectJS(schema, input)
|
273
|
+
{
|
274
|
+
var report = mod_jsonschema.validate(input, schema);
|
275
|
+
|
276
|
+
if (report.errors.length === 0)
|
277
|
+
return (null);
|
278
|
+
|
279
|
+
/* Currently, we only do anything useful with the first error. */
|
280
|
+
var error = report.errors[0];
|
281
|
+
|
282
|
+
/* The failed property is given by a URI with an irrelevant prefix. */
|
283
|
+
var propname = error['property'];
|
284
|
+
var reason = error['message'].toLowerCase();
|
285
|
+
var i, j;
|
286
|
+
|
287
|
+
/*
|
288
|
+
* There's at least one case where the property error message is
|
289
|
+
* confusing at best. We work around this here.
|
290
|
+
*/
|
291
|
+
if ((i = reason.indexOf('the property ')) != -1 &&
|
292
|
+
(j = reason.indexOf(' is not defined in the schema and the ' +
|
293
|
+
'schema does not allow additional properties')) != -1) {
|
294
|
+
i += 'the property '.length;
|
295
|
+
if (propname === '')
|
296
|
+
propname = reason.substr(i, j - i);
|
297
|
+
else
|
298
|
+
propname = propname + '.' + reason.substr(i, j - i);
|
299
|
+
|
300
|
+
reason = 'unsupported property';
|
301
|
+
}
|
302
|
+
|
303
|
+
var rv = new mod_verror.VError('property "%s": %s', propname, reason);
|
304
|
+
rv.jsv_details = error;
|
305
|
+
return (rv);
|
306
|
+
}
|
307
|
+
|
308
|
+
function randElt(arr)
|
309
|
+
{
|
310
|
+
mod_assert.ok(Array.isArray(arr) && arr.length > 0,
|
311
|
+
'randElt argument must be a non-empty array');
|
312
|
+
|
313
|
+
return (arr[Math.floor(Math.random() * arr.length)]);
|
314
|
+
}
|
315
|
+
|
316
|
+
function assertHrtime(a)
|
317
|
+
{
|
318
|
+
mod_assert.ok(a[0] >= 0 && a[1] >= 0,
|
319
|
+
'negative numbers not allowed in hrtimes');
|
320
|
+
mod_assert.ok(a[1] < 1e9, 'nanoseconds column overflow');
|
321
|
+
}
|
322
|
+
|
323
|
+
/*
|
324
|
+
* Compute the time elapsed between hrtime readings A and B, where A is later
|
325
|
+
* than B. hrtime readings come from Node's process.hrtime(). There is no
|
326
|
+
* defined way to represent negative deltas, so it's illegal to diff B from A
|
327
|
+
* where the time denoted by B is later than the time denoted by A. If this
|
328
|
+
* becomes valuable, we can define a representation and extend the
|
329
|
+
* implementation to support it.
|
330
|
+
*/
|
331
|
+
function hrtimeDiff(a, b)
|
332
|
+
{
|
333
|
+
assertHrtime(a);
|
334
|
+
assertHrtime(b);
|
335
|
+
mod_assert.ok(a[0] > b[0] || (a[0] == b[0] && a[1] >= b[1]),
|
336
|
+
'negative differences not allowed');
|
337
|
+
|
338
|
+
var rv = [ a[0] - b[0], 0 ];
|
339
|
+
|
340
|
+
if (a[1] >= b[1]) {
|
341
|
+
rv[1] = a[1] - b[1];
|
342
|
+
} else {
|
343
|
+
rv[0]--;
|
344
|
+
rv[1] = 1e9 - (b[1] - a[1]);
|
345
|
+
}
|
346
|
+
|
347
|
+
return (rv);
|
348
|
+
}
|
349
|
+
|
350
|
+
/*
|
351
|
+
* Convert a hrtime reading from the array format returned by Node's
|
352
|
+
* process.hrtime() into a scalar number of nanoseconds.
|
353
|
+
*/
|
354
|
+
function hrtimeNanosec(a)
|
355
|
+
{
|
356
|
+
assertHrtime(a);
|
357
|
+
|
358
|
+
return (Math.floor(a[0] * 1e9 + a[1]));
|
359
|
+
}
|
360
|
+
|
361
|
+
/*
|
362
|
+
* Convert a hrtime reading from the array format returned by Node's
|
363
|
+
* process.hrtime() into a scalar number of microseconds.
|
364
|
+
*/
|
365
|
+
function hrtimeMicrosec(a)
|
366
|
+
{
|
367
|
+
assertHrtime(a);
|
368
|
+
|
369
|
+
return (Math.floor(a[0] * 1e6 + a[1] / 1e3));
|
370
|
+
}
|
371
|
+
|
372
|
+
/*
|
373
|
+
* Convert a hrtime reading from the array format returned by Node's
|
374
|
+
* process.hrtime() into a scalar number of milliseconds.
|
375
|
+
*/
|
376
|
+
function hrtimeMillisec(a)
|
377
|
+
{
|
378
|
+
assertHrtime(a);
|
379
|
+
|
380
|
+
return (Math.floor(a[0] * 1e3 + a[1] / 1e6));
|
381
|
+
}
|
382
|
+
|
383
|
+
/*
|
384
|
+
* Add two hrtime readings A and B, overwriting A with the result of the
|
385
|
+
* addition. This function is useful for accumulating several hrtime intervals
|
386
|
+
* into a counter. Returns A.
|
387
|
+
*/
|
388
|
+
function hrtimeAccum(a, b)
|
389
|
+
{
|
390
|
+
assertHrtime(a);
|
391
|
+
assertHrtime(b);
|
392
|
+
|
393
|
+
/*
|
394
|
+
* Accumulate the nanosecond component.
|
395
|
+
*/
|
396
|
+
a[1] += b[1];
|
397
|
+
if (a[1] >= 1e9) {
|
398
|
+
/*
|
399
|
+
* The nanosecond component overflowed, so carry to the seconds
|
400
|
+
* field.
|
401
|
+
*/
|
402
|
+
a[0]++;
|
403
|
+
a[1] -= 1e9;
|
404
|
+
}
|
405
|
+
|
406
|
+
/*
|
407
|
+
* Accumulate the seconds component.
|
408
|
+
*/
|
409
|
+
a[0] += b[0];
|
410
|
+
|
411
|
+
return (a);
|
412
|
+
}
|
413
|
+
|
414
|
+
/*
|
415
|
+
* Add two hrtime readings A and B, returning the result as a new hrtime array.
|
416
|
+
* Does not modify either input argument.
|
417
|
+
*/
|
418
|
+
function hrtimeAdd(a, b)
|
419
|
+
{
|
420
|
+
assertHrtime(a);
|
421
|
+
|
422
|
+
var rv = [ a[0], a[1] ];
|
423
|
+
|
424
|
+
return (hrtimeAccum(rv, b));
|
425
|
+
}
|
426
|
+
|
427
|
+
|
428
|
+
/*
|
429
|
+
* Check an object for unexpected properties. Accepts the object to check, and
|
430
|
+
* an array of allowed property names (strings). Returns an array of key names
|
431
|
+
* that were found on the object, but did not appear in the list of allowed
|
432
|
+
* properties. If no properties were found, the returned array will be of
|
433
|
+
* zero length.
|
434
|
+
*/
|
435
|
+
function extraProperties(obj, allowed)
|
436
|
+
{
|
437
|
+
mod_assert.ok(typeof (obj) === 'object' && obj !== null,
|
438
|
+
'obj argument must be a non-null object');
|
439
|
+
mod_assert.ok(Array.isArray(allowed),
|
440
|
+
'allowed argument must be an array of strings');
|
441
|
+
for (var i = 0; i < allowed.length; i++) {
|
442
|
+
mod_assert.ok(typeof (allowed[i]) === 'string',
|
443
|
+
'allowed argument must be an array of strings');
|
444
|
+
}
|
445
|
+
|
446
|
+
return (Object.keys(obj).filter(function (key) {
|
447
|
+
return (allowed.indexOf(key) === -1);
|
448
|
+
}));
|
449
|
+
}
|
450
|
+
|
451
|
+
/*
|
452
|
+
* Given three sets of properties "provided" (may be undefined), "overrides"
|
453
|
+
* (required), and "defaults" (may be undefined), construct an object containing
|
454
|
+
* the union of these sets with "overrides" overriding "provided", and
|
455
|
+
* "provided" overriding "defaults". None of the input objects are modified.
|
456
|
+
*/
|
457
|
+
function mergeObjects(provided, overrides, defaults)
|
458
|
+
{
|
459
|
+
var rv, k;
|
460
|
+
|
461
|
+
rv = {};
|
462
|
+
if (defaults) {
|
463
|
+
for (k in defaults)
|
464
|
+
rv[k] = defaults[k];
|
465
|
+
}
|
466
|
+
|
467
|
+
if (provided) {
|
468
|
+
for (k in provided)
|
469
|
+
rv[k] = provided[k];
|
470
|
+
}
|
471
|
+
|
472
|
+
if (overrides) {
|
473
|
+
for (k in overrides)
|
474
|
+
rv[k] = overrides[k];
|
475
|
+
}
|
476
|
+
|
477
|
+
return (rv);
|
478
|
+
}
|