mirror of
https://gitee.com/dcloud/uni-preset-vue
synced 2026-04-22 00:00:04 +08:00
add node_modules
This commit is contained in:
+1
@@ -0,0 +1 @@
|
||||
../atob/bin/atob.js
|
||||
+1
@@ -0,0 +1 @@
|
||||
../mkdirp/bin/cmd.js
|
||||
+1
@@ -0,0 +1 @@
|
||||
../rimraf/bin.js
|
||||
+1
@@ -0,0 +1 @@
|
||||
../seek-bzip/bin/seek-bunzip
|
||||
+1
@@ -0,0 +1 @@
|
||||
../seek-bzip/bin/seek-bzip-table
|
||||
+264
@@ -0,0 +1,264 @@
|
||||
{
|
||||
"systemParams": "darwin-x64-64",
|
||||
"modulesFolders": [
|
||||
"node_modules"
|
||||
],
|
||||
"flags": [],
|
||||
"linkedModules": [],
|
||||
"topLevelPatterns": [
|
||||
"download-git-repo@^1.1.0",
|
||||
"globby@^8.0.1",
|
||||
"ora@^3.0.0",
|
||||
"rimraf@^2.6.2",
|
||||
"user-home@^2.0.0"
|
||||
],
|
||||
"lockfileEntries": {
|
||||
"@mrmlnc/readdir-enhanced@^2.2.1": "http://registry.npm.taobao.org/@mrmlnc/readdir-enhanced/download/@mrmlnc/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde",
|
||||
"@nodelib/fs.stat@^1.1.2": "http://registry.npm.taobao.org/@nodelib/fs.stat/download/@nodelib/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b",
|
||||
"ansi-regex@^3.0.0": "http://registry.npm.taobao.org/ansi-regex/download/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998",
|
||||
"ansi-styles@^3.2.1": "http://registry.npm.taobao.org/ansi-styles/download/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d",
|
||||
"arr-diff@^4.0.0": "http://registry.npm.taobao.org/arr-diff/download/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520",
|
||||
"arr-flatten@^1.1.0": "http://registry.npm.taobao.org/arr-flatten/download/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1",
|
||||
"arr-union@^3.1.0": "http://registry.npm.taobao.org/arr-union/download/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4",
|
||||
"array-union@^1.0.1": "http://registry.npm.taobao.org/array-union/download/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39",
|
||||
"array-uniq@^1.0.1": "http://registry.npm.taobao.org/array-uniq/download/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6",
|
||||
"array-unique@^0.3.2": "http://registry.npm.taobao.org/array-unique/download/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428",
|
||||
"arrify@^1.0.1": "http://registry.npm.taobao.org/arrify/download/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d",
|
||||
"assign-symbols@^1.0.0": "http://registry.npm.taobao.org/assign-symbols/download/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367",
|
||||
"atob@^2.1.1": "http://registry.npm.taobao.org/atob/download/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9",
|
||||
"balanced-match@^1.0.0": "http://registry.npm.taobao.org/balanced-match/download/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767",
|
||||
"base64-js@0.0.8": "http://registry.npm.taobao.org/base64-js/download/base64-js-0.0.8.tgz#1101e9544f4a76b1bc3b26d452ca96d7a35e7978",
|
||||
"base@^0.11.1": "http://registry.npm.taobao.org/base/download/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f",
|
||||
"bl@^1.0.0": "http://registry.npm.taobao.org/bl/download/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c",
|
||||
"brace-expansion@^1.1.7": "http://registry.npm.taobao.org/brace-expansion/download/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd",
|
||||
"braces@^2.3.1": "http://registry.npm.taobao.org/braces/download/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729",
|
||||
"buffer-alloc-unsafe@^1.1.0": "http://registry.npm.taobao.org/buffer-alloc-unsafe/download/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0",
|
||||
"buffer-alloc@^1.2.0": "http://registry.npm.taobao.org/buffer-alloc/download/buffer-alloc-1.2.0.tgz#890dd90d923a873e08e10e5fd51a57e5b7cce0ec",
|
||||
"buffer-crc32@~0.2.3": "http://registry.npm.taobao.org/buffer-crc32/download/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242",
|
||||
"buffer-fill@^1.0.0": "http://registry.npm.taobao.org/buffer-fill/download/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c",
|
||||
"buffer@^3.0.1": "http://registry.npm.taobao.org/buffer/download/buffer-3.6.0.tgz#a72c936f77b96bf52f5f7e7b467180628551defb",
|
||||
"cache-base@^1.0.1": "http://registry.npm.taobao.org/cache-base/download/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2",
|
||||
"call-me-maybe@^1.0.1": "http://registry.npm.taobao.org/call-me-maybe/download/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b",
|
||||
"capture-stack-trace@^1.0.0": "http://registry.npm.taobao.org/capture-stack-trace/download/capture-stack-trace-1.0.1.tgz#a6c0bbe1f38f3aa0b92238ecb6ff42c344d4135d",
|
||||
"caw@^2.0.0": "http://registry.npm.taobao.org/caw/download/caw-2.0.1.tgz#6c3ca071fc194720883c2dc5da9b074bfc7e9e95",
|
||||
"chalk@^2.0.1": "http://registry.npm.taobao.org/chalk/download/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e",
|
||||
"chalk@^2.3.1": "http://registry.npm.taobao.org/chalk/download/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e",
|
||||
"class-utils@^0.3.5": "http://registry.npm.taobao.org/class-utils/download/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463",
|
||||
"cli-cursor@^2.1.0": "http://registry.npm.taobao.org/cli-cursor/download/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5",
|
||||
"cli-spinners@^1.1.0": "http://registry.npm.taobao.org/cli-spinners/download/cli-spinners-1.3.1.tgz#002c1990912d0d59580c93bd36c056de99e4259a",
|
||||
"clone@^1.0.2": "http://registry.npm.taobao.org/clone/download/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e",
|
||||
"collection-visit@^1.0.0": "http://registry.npm.taobao.org/collection-visit/download/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0",
|
||||
"color-convert@^1.9.0": "http://registry.npm.taobao.org/color-convert/download/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8",
|
||||
"color-name@1.1.3": "http://registry.npm.taobao.org/color-name/download/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25",
|
||||
"commander@~2.8.1": "http://registry.npm.taobao.org/commander/download/commander-2.8.1.tgz#06be367febfda0c330aa1e2a072d3dc9762425d4",
|
||||
"component-emitter@^1.2.1": "http://registry.npm.taobao.org/component-emitter/download/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6",
|
||||
"concat-map@0.0.1": "http://registry.npm.taobao.org/concat-map/download/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b",
|
||||
"config-chain@^1.1.11": "http://registry.npm.taobao.org/config-chain/download/config-chain-1.1.12.tgz#0fde8d091200eb5e808caf25fe618c02f48e4efa",
|
||||
"copy-descriptor@^0.1.0": "http://registry.npm.taobao.org/copy-descriptor/download/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d",
|
||||
"core-util-is@~1.0.0": "http://registry.npm.taobao.org/core-util-is/download/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7",
|
||||
"create-error-class@^3.0.0": "http://registry.npm.taobao.org/create-error-class/download/create-error-class-3.0.2.tgz#06be7abef947a3f14a30fd610671d401bca8b7b6",
|
||||
"debug@^2.2.0": "http://registry.npm.taobao.org/debug/download/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f",
|
||||
"debug@^2.3.3": "http://registry.npm.taobao.org/debug/download/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f",
|
||||
"decode-uri-component@^0.2.0": "http://registry.npm.taobao.org/decode-uri-component/download/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545",
|
||||
"decompress-tar@^4.0.0": "http://registry.npm.taobao.org/decompress-tar/download/decompress-tar-4.1.1.tgz#718cbd3fcb16209716e70a26b84e7ba4592e5af1",
|
||||
"decompress-tar@^4.1.0": "http://registry.npm.taobao.org/decompress-tar/download/decompress-tar-4.1.1.tgz#718cbd3fcb16209716e70a26b84e7ba4592e5af1",
|
||||
"decompress-tar@^4.1.1": "http://registry.npm.taobao.org/decompress-tar/download/decompress-tar-4.1.1.tgz#718cbd3fcb16209716e70a26b84e7ba4592e5af1",
|
||||
"decompress-tarbz2@^4.0.0": "http://registry.npm.taobao.org/decompress-tarbz2/download/decompress-tarbz2-4.1.1.tgz#3082a5b880ea4043816349f378b56c516be1a39b",
|
||||
"decompress-targz@^4.0.0": "http://registry.npm.taobao.org/decompress-targz/download/decompress-targz-4.1.1.tgz#c09bc35c4d11f3de09f2d2da53e9de23e7ce1eee",
|
||||
"decompress-unzip@^4.0.1": "http://registry.npm.taobao.org/decompress-unzip/download/decompress-unzip-4.0.1.tgz#deaaccdfd14aeaf85578f733ae8210f9b4848f69",
|
||||
"decompress@^4.0.0": "http://registry.npm.taobao.org/decompress/download/decompress-4.2.0.tgz#7aedd85427e5a92dacfe55674a7c505e96d01f9d",
|
||||
"defaults@^1.0.3": "http://registry.npm.taobao.org/defaults/download/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d",
|
||||
"define-property@^0.2.5": "http://registry.npm.taobao.org/define-property/download/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116",
|
||||
"define-property@^1.0.0": "http://registry.npm.taobao.org/define-property/download/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6",
|
||||
"define-property@^2.0.2": "http://registry.npm.taobao.org/define-property/download/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d",
|
||||
"dir-glob@^2.0.0": "http://registry.npm.taobao.org/dir-glob/download/dir-glob-2.0.0.tgz#0b205d2b6aef98238ca286598a8204d29d0a0034",
|
||||
"download-git-repo@^1.1.0": "http://registry.npm.taobao.org/download-git-repo/download/download-git-repo-1.1.0.tgz#7dc88a82ced064b1372a0002f8a3aebf10eb1d3c",
|
||||
"download@^5.0.3": "http://registry.npm.taobao.org/download/download/download-5.0.3.tgz#63537f977f99266a30eb8a2a2fbd1f20b8000f7a",
|
||||
"duplexer3@^0.1.4": "http://registry.npm.taobao.org/duplexer3/download/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2",
|
||||
"end-of-stream@^1.0.0": "http://registry.npm.taobao.org/end-of-stream/download/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43",
|
||||
"escape-string-regexp@^1.0.2": "http://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4",
|
||||
"escape-string-regexp@^1.0.5": "http://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4",
|
||||
"expand-brackets@^2.1.4": "http://registry.npm.taobao.org/expand-brackets/download/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622",
|
||||
"extend-shallow@^2.0.1": "http://registry.npm.taobao.org/extend-shallow/download/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f",
|
||||
"extend-shallow@^3.0.0": "http://registry.npm.taobao.org/extend-shallow/download/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8",
|
||||
"extend-shallow@^3.0.2": "http://registry.npm.taobao.org/extend-shallow/download/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8",
|
||||
"extglob@^2.0.4": "http://registry.npm.taobao.org/extglob/download/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543",
|
||||
"fast-glob@^2.0.2": "http://registry.npm.taobao.org/fast-glob/download/fast-glob-2.2.4.tgz#e54f4b66d378040e0e4d6a68ec36bbc5b04363c0",
|
||||
"fd-slicer@~1.1.0": "http://registry.npm.taobao.org/fd-slicer/download/fd-slicer-1.1.0.tgz#25c7c89cb1f9077f8891bbe61d8f390eae256f1e",
|
||||
"file-type@^3.8.0": "http://registry.npm.taobao.org/file-type/download/file-type-3.9.0.tgz#257a078384d1db8087bc449d107d52a52672b9e9",
|
||||
"file-type@^5.2.0": "http://registry.npm.taobao.org/file-type/download/file-type-5.2.0.tgz#2ddbea7c73ffe36368dfae49dc338c058c2b8ad6",
|
||||
"file-type@^6.1.0": "http://registry.npm.taobao.org/file-type/download/file-type-6.2.0.tgz#e50cd75d356ffed4e306dc4f5bcf52a79903a919",
|
||||
"filename-reserved-regex@^2.0.0": "http://registry.npm.taobao.org/filename-reserved-regex/download/filename-reserved-regex-2.0.0.tgz#abf73dfab735d045440abfea2d91f389ebbfa229",
|
||||
"filenamify@^2.0.0": "http://registry.npm.taobao.org/filenamify/download/filenamify-2.1.0.tgz#88faf495fb1b47abfd612300002a16228c677ee9",
|
||||
"fill-range@^4.0.0": "http://registry.npm.taobao.org/fill-range/download/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7",
|
||||
"for-in@^1.0.2": "http://registry.npm.taobao.org/for-in/download/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80",
|
||||
"fragment-cache@^0.2.1": "http://registry.npm.taobao.org/fragment-cache/download/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19",
|
||||
"fs-constants@^1.0.0": "http://registry.npm.taobao.org/fs-constants/download/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad",
|
||||
"fs.realpath@^1.0.0": "http://registry.npm.taobao.org/fs.realpath/download/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f",
|
||||
"get-proxy@^2.0.0": "http://registry.npm.taobao.org/get-proxy/download/get-proxy-2.1.0.tgz#349f2b4d91d44c4d4d4e9cba2ad90143fac5ef93",
|
||||
"get-stream@^2.2.0": "http://registry.npm.taobao.org/get-stream/download/get-stream-2.3.1.tgz#5f38f93f346009666ee0150a054167f91bdd95de",
|
||||
"get-stream@^3.0.0": "http://registry.npm.taobao.org/get-stream/download/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14",
|
||||
"get-value@^2.0.3": "http://registry.npm.taobao.org/get-value/download/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28",
|
||||
"get-value@^2.0.6": "http://registry.npm.taobao.org/get-value/download/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28",
|
||||
"git-clone@^0.1.0": "http://registry.npm.taobao.org/git-clone/download/git-clone-0.1.0.tgz#0d76163778093aef7f1c30238f2a9ef3f07a2eb9",
|
||||
"glob-parent@^3.1.0": "http://registry.npm.taobao.org/glob-parent/download/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae",
|
||||
"glob-to-regexp@^0.3.0": "http://registry.npm.taobao.org/glob-to-regexp/download/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab",
|
||||
"glob@^7.0.5": "http://registry.npm.taobao.org/glob/download/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1",
|
||||
"glob@^7.1.2": "http://registry.npm.taobao.org/glob/download/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1",
|
||||
"globby@^8.0.1": "http://registry.npm.taobao.org/globby/download/globby-8.0.1.tgz#b5ad48b8aa80b35b814fc1281ecc851f1d2b5b50",
|
||||
"got@^6.3.0": "http://registry.npm.taobao.org/got/download/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0",
|
||||
"graceful-fs@^4.1.10": "http://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00",
|
||||
"graceful-readlink@>= 1.0.0": "http://registry.npm.taobao.org/graceful-readlink/download/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725",
|
||||
"has-flag@^3.0.0": "http://registry.npm.taobao.org/has-flag/download/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd",
|
||||
"has-symbol-support-x@^1.4.1": "http://registry.npm.taobao.org/has-symbol-support-x/download/has-symbol-support-x-1.4.2.tgz#1409f98bc00247da45da67cee0a36f282ff26455",
|
||||
"has-to-string-tag-x@^1.2.0": "http://registry.npm.taobao.org/has-to-string-tag-x/download/has-to-string-tag-x-1.4.1.tgz#a045ab383d7b4b2012a00148ab0aa5f290044d4d",
|
||||
"has-value@^0.3.1": "http://registry.npm.taobao.org/has-value/download/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f",
|
||||
"has-value@^1.0.0": "http://registry.npm.taobao.org/has-value/download/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177",
|
||||
"has-values@^0.1.4": "http://registry.npm.taobao.org/has-values/download/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771",
|
||||
"has-values@^1.0.0": "http://registry.npm.taobao.org/has-values/download/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f",
|
||||
"ieee754@^1.1.4": "http://registry.npm.taobao.org/ieee754/download/ieee754-1.1.12.tgz#50bf24e5b9c8bb98af4964c941cdb0918da7b60b",
|
||||
"ignore@^3.3.5": "http://registry.npm.taobao.org/ignore/download/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043",
|
||||
"inflight@^1.0.4": "http://registry.npm.taobao.org/inflight/download/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9",
|
||||
"inherits@2": "http://registry.npm.taobao.org/inherits/download/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de",
|
||||
"inherits@~2.0.3": "http://registry.npm.taobao.org/inherits/download/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de",
|
||||
"ini@^1.3.4": "http://registry.npm.taobao.org/ini/download/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927",
|
||||
"is-accessor-descriptor@^0.1.6": "http://registry.npm.taobao.org/is-accessor-descriptor/download/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6",
|
||||
"is-accessor-descriptor@^1.0.0": "http://registry.npm.taobao.org/is-accessor-descriptor/download/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656",
|
||||
"is-buffer@^1.1.5": "http://registry.npm.taobao.org/is-buffer/download/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be",
|
||||
"is-data-descriptor@^0.1.4": "http://registry.npm.taobao.org/is-data-descriptor/download/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56",
|
||||
"is-data-descriptor@^1.0.0": "http://registry.npm.taobao.org/is-data-descriptor/download/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7",
|
||||
"is-descriptor@^0.1.0": "http://registry.npm.taobao.org/is-descriptor/download/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca",
|
||||
"is-descriptor@^1.0.0": "http://registry.npm.taobao.org/is-descriptor/download/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec",
|
||||
"is-descriptor@^1.0.2": "http://registry.npm.taobao.org/is-descriptor/download/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec",
|
||||
"is-extendable@^0.1.0": "http://registry.npm.taobao.org/is-extendable/download/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89",
|
||||
"is-extendable@^0.1.1": "http://registry.npm.taobao.org/is-extendable/download/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89",
|
||||
"is-extendable@^1.0.1": "http://registry.npm.taobao.org/is-extendable/download/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4",
|
||||
"is-extglob@^2.1.0": "http://registry.npm.taobao.org/is-extglob/download/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2",
|
||||
"is-extglob@^2.1.1": "http://registry.npm.taobao.org/is-extglob/download/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2",
|
||||
"is-glob@^3.1.0": "http://registry.npm.taobao.org/is-glob/download/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a",
|
||||
"is-glob@^4.0.0": "http://registry.npm.taobao.org/is-glob/download/is-glob-4.0.0.tgz#9521c76845cc2610a85203ddf080a958c2ffabc0",
|
||||
"is-natural-number@^4.0.1": "http://registry.npm.taobao.org/is-natural-number/download/is-natural-number-4.0.1.tgz#ab9d76e1db4ced51e35de0c72ebecf09f734cde8",
|
||||
"is-number@^3.0.0": "http://registry.npm.taobao.org/is-number/download/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195",
|
||||
"is-object@^1.0.1": "http://registry.npm.taobao.org/is-object/download/is-object-1.0.1.tgz#8952688c5ec2ffd6b03ecc85e769e02903083470",
|
||||
"is-plain-object@^2.0.1": "http://registry.npm.taobao.org/is-plain-object/download/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677",
|
||||
"is-plain-object@^2.0.3": "http://registry.npm.taobao.org/is-plain-object/download/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677",
|
||||
"is-plain-object@^2.0.4": "http://registry.npm.taobao.org/is-plain-object/download/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677",
|
||||
"is-redirect@^1.0.0": "http://registry.npm.taobao.org/is-redirect/download/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24",
|
||||
"is-retry-allowed@^1.0.0": "http://registry.npm.taobao.org/is-retry-allowed/download/is-retry-allowed-1.1.0.tgz#11a060568b67339444033d0125a61a20d564fb34",
|
||||
"is-stream@^1.0.0": "http://registry.npm.taobao.org/is-stream/download/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44",
|
||||
"is-stream@^1.1.0": "http://registry.npm.taobao.org/is-stream/download/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44",
|
||||
"is-windows@^1.0.2": "http://registry.npm.taobao.org/is-windows/download/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d",
|
||||
"isarray@1.0.0": "http://registry.npm.taobao.org/isarray/download/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11",
|
||||
"isarray@^1.0.0": "http://registry.npm.taobao.org/isarray/download/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11",
|
||||
"isarray@~1.0.0": "http://registry.npm.taobao.org/isarray/download/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11",
|
||||
"isobject@^2.0.0": "http://registry.npm.taobao.org/isobject/download/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89",
|
||||
"isobject@^3.0.0": "http://registry.npm.taobao.org/isobject/download/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df",
|
||||
"isobject@^3.0.1": "http://registry.npm.taobao.org/isobject/download/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df",
|
||||
"isurl@^1.0.0-alpha5": "http://registry.npm.taobao.org/isurl/download/isurl-1.0.0.tgz#b27f4f49f3cdaa3ea44a0a5b7f3462e6edc39d67",
|
||||
"kind-of@^3.0.2": "http://registry.npm.taobao.org/kind-of/download/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64",
|
||||
"kind-of@^3.0.3": "http://registry.npm.taobao.org/kind-of/download/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64",
|
||||
"kind-of@^3.2.0": "http://registry.npm.taobao.org/kind-of/download/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64",
|
||||
"kind-of@^4.0.0": "http://registry.npm.taobao.org/kind-of/download/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57",
|
||||
"kind-of@^5.0.0": "http://registry.npm.taobao.org/kind-of/download/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d",
|
||||
"kind-of@^6.0.0": "http://registry.npm.taobao.org/kind-of/download/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051",
|
||||
"kind-of@^6.0.2": "http://registry.npm.taobao.org/kind-of/download/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051",
|
||||
"log-symbols@^2.2.0": "http://registry.npm.taobao.org/log-symbols/download/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a",
|
||||
"lowercase-keys@^1.0.0": "http://registry.npm.taobao.org/lowercase-keys/download/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f",
|
||||
"make-dir@^1.0.0": "http://registry.npm.taobao.org/make-dir/download/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c",
|
||||
"map-cache@^0.2.2": "http://registry.npm.taobao.org/map-cache/download/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf",
|
||||
"map-visit@^1.0.0": "http://registry.npm.taobao.org/map-visit/download/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f",
|
||||
"merge2@^1.2.3": "http://registry.npm.taobao.org/merge2/download/merge2-1.2.3.tgz#7ee99dbd69bb6481689253f018488a1b902b0ed5",
|
||||
"micromatch@^3.1.10": "http://registry.npm.taobao.org/micromatch/download/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23",
|
||||
"mimic-fn@^1.0.0": "http://registry.npm.taobao.org/mimic-fn/download/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022",
|
||||
"minimatch@^3.0.4": "http://registry.npm.taobao.org/minimatch/download/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083",
|
||||
"minimist@0.0.8": "http://registry.npm.taobao.org/minimist/download/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d",
|
||||
"mixin-deep@^1.2.0": "http://registry.npm.taobao.org/mixin-deep/download/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe",
|
||||
"mkdirp@^0.5.1": "http://registry.npm.taobao.org/mkdirp/download/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903",
|
||||
"ms@2.0.0": "http://registry.npm.taobao.org/ms/download/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8",
|
||||
"nanomatch@^1.2.9": "http://registry.npm.taobao.org/nanomatch/download/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119",
|
||||
"npm-conf@^1.1.0": "http://registry.npm.taobao.org/npm-conf/download/npm-conf-1.1.3.tgz#256cc47bd0e218c259c4e9550bf413bc2192aff9",
|
||||
"object-assign@^4.0.1": "http://registry.npm.taobao.org/object-assign/download/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863",
|
||||
"object-copy@^0.1.0": "http://registry.npm.taobao.org/object-copy/download/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c",
|
||||
"object-visit@^1.0.0": "http://registry.npm.taobao.org/object-visit/download/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb",
|
||||
"object.pick@^1.3.0": "http://registry.npm.taobao.org/object.pick/download/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747",
|
||||
"once@^1.3.0": "http://registry.npm.taobao.org/once/download/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1",
|
||||
"once@^1.4.0": "http://registry.npm.taobao.org/once/download/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1",
|
||||
"onetime@^2.0.0": "http://registry.npm.taobao.org/onetime/download/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4",
|
||||
"ora@^3.0.0": "http://registry.npm.taobao.org/ora/download/ora-3.0.0.tgz#8179e3525b9aafd99242d63cc206fd64732741d0",
|
||||
"os-homedir@^1.0.0": "http://registry.npm.taobao.org/os-homedir/download/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3",
|
||||
"pascalcase@^0.1.1": "http://registry.npm.taobao.org/pascalcase/download/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14",
|
||||
"path-dirname@^1.0.0": "http://registry.npm.taobao.org/path-dirname/download/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0",
|
||||
"path-is-absolute@^1.0.0": "http://registry.npm.taobao.org/path-is-absolute/download/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f",
|
||||
"path-type@^3.0.0": "http://registry.npm.taobao.org/path-type/download/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f",
|
||||
"pend@~1.2.0": "http://registry.npm.taobao.org/pend/download/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50",
|
||||
"pify@^2.3.0": "http://registry.npm.taobao.org/pify/download/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c",
|
||||
"pify@^3.0.0": "http://registry.npm.taobao.org/pify/download/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176",
|
||||
"pinkie-promise@^2.0.0": "http://registry.npm.taobao.org/pinkie-promise/download/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa",
|
||||
"pinkie@^2.0.0": "http://registry.npm.taobao.org/pinkie/download/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870",
|
||||
"posix-character-classes@^0.1.0": "http://registry.npm.taobao.org/posix-character-classes/download/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab",
|
||||
"prepend-http@^1.0.1": "http://registry.npm.taobao.org/prepend-http/download/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc",
|
||||
"process-nextick-args@~2.0.0": "http://registry.npm.taobao.org/process-nextick-args/download/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa",
|
||||
"proto-list@~1.2.1": "http://registry.npm.taobao.org/proto-list/download/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849",
|
||||
"readable-stream@^2.3.0": "http://registry.npm.taobao.org/readable-stream/download/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf",
|
||||
"readable-stream@^2.3.5": "http://registry.npm.taobao.org/readable-stream/download/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf",
|
||||
"regex-not@^1.0.0": "http://registry.npm.taobao.org/regex-not/download/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c",
|
||||
"regex-not@^1.0.2": "http://registry.npm.taobao.org/regex-not/download/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c",
|
||||
"repeat-element@^1.1.2": "http://registry.npm.taobao.org/repeat-element/download/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce",
|
||||
"repeat-string@^1.6.1": "http://registry.npm.taobao.org/repeat-string/download/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637",
|
||||
"resolve-url@^0.2.1": "http://registry.npm.taobao.org/resolve-url/download/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a",
|
||||
"restore-cursor@^2.0.0": "http://registry.npm.taobao.org/restore-cursor/download/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf",
|
||||
"ret@~0.1.10": "http://registry.npm.taobao.org/ret/download/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc",
|
||||
"rimraf@^2.6.1": "http://registry.npm.taobao.org/rimraf/download/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36",
|
||||
"rimraf@^2.6.2": "http://registry.npm.taobao.org/rimraf/download/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36",
|
||||
"safe-buffer@^5.0.1": "http://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d",
|
||||
"safe-buffer@^5.1.1": "http://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d",
|
||||
"safe-buffer@~5.1.0": "http://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d",
|
||||
"safe-buffer@~5.1.1": "http://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d",
|
||||
"safe-regex@^1.1.0": "http://registry.npm.taobao.org/safe-regex/download/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e",
|
||||
"seek-bzip@^1.0.5": "http://registry.npm.taobao.org/seek-bzip/download/seek-bzip-1.0.5.tgz#cfe917cb3d274bcffac792758af53173eb1fabdc",
|
||||
"set-value@^0.4.3": "http://registry.npm.taobao.org/set-value/download/set-value-0.4.3.tgz#7db08f9d3d22dc7f78e53af3c3bf4666ecdfccf1",
|
||||
"set-value@^2.0.0": "http://registry.npm.taobao.org/set-value/download/set-value-2.0.0.tgz#71ae4a88f0feefbbf52d1ea604f3fb315ebb6274",
|
||||
"signal-exit@^3.0.2": "http://registry.npm.taobao.org/signal-exit/download/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d",
|
||||
"slash@^1.0.0": "http://registry.npm.taobao.org/slash/download/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55",
|
||||
"snapdragon-node@^2.0.1": "http://registry.npm.taobao.org/snapdragon-node/download/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b",
|
||||
"snapdragon-util@^3.0.1": "http://registry.npm.taobao.org/snapdragon-util/download/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2",
|
||||
"snapdragon@^0.8.1": "http://registry.npm.taobao.org/snapdragon/download/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d",
|
||||
"source-map-resolve@^0.5.0": "http://registry.npm.taobao.org/source-map-resolve/download/source-map-resolve-0.5.2.tgz#72e2cc34095543e43b2c62b2c4c10d4a9054f259",
|
||||
"source-map-url@^0.4.0": "http://registry.npm.taobao.org/source-map-url/download/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3",
|
||||
"source-map@^0.5.6": "http://registry.npm.taobao.org/source-map/download/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc",
|
||||
"split-string@^3.0.1": "http://registry.npm.taobao.org/split-string/download/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2",
|
||||
"split-string@^3.0.2": "http://registry.npm.taobao.org/split-string/download/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2",
|
||||
"static-extend@^0.1.1": "http://registry.npm.taobao.org/static-extend/download/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6",
|
||||
"string_decoder@~1.1.1": "http://registry.npm.taobao.org/string_decoder/download/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8",
|
||||
"strip-ansi@^4.0.0": "http://registry.npm.taobao.org/strip-ansi/download/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f",
|
||||
"strip-dirs@^2.0.0": "http://registry.npm.taobao.org/strip-dirs/download/strip-dirs-2.1.0.tgz#4987736264fc344cf20f6c34aca9d13d1d4ed6c5",
|
||||
"strip-outer@^1.0.0": "http://registry.npm.taobao.org/strip-outer/download/strip-outer-1.0.1.tgz#b2fd2abf6604b9d1e6013057195df836b8a9d631",
|
||||
"supports-color@^5.3.0": "http://registry.npm.taobao.org/supports-color/download/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f",
|
||||
"tar-stream@^1.5.2": "http://registry.npm.taobao.org/tar-stream/download/tar-stream-1.6.2.tgz#8ea55dab37972253d9a9af90fdcd559ae435c555",
|
||||
"through@^2.3.6": "http://registry.npm.taobao.org/through/download/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5",
|
||||
"timed-out@^4.0.0": "http://registry.npm.taobao.org/timed-out/download/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f",
|
||||
"to-buffer@^1.1.1": "http://registry.npm.taobao.org/to-buffer/download/to-buffer-1.1.1.tgz#493bd48f62d7c43fcded313a03dcadb2e1213a80",
|
||||
"to-object-path@^0.3.0": "http://registry.npm.taobao.org/to-object-path/download/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af",
|
||||
"to-regex-range@^2.1.0": "http://registry.npm.taobao.org/to-regex-range/download/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38",
|
||||
"to-regex@^3.0.1": "http://registry.npm.taobao.org/to-regex/download/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce",
|
||||
"to-regex@^3.0.2": "http://registry.npm.taobao.org/to-regex/download/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce",
|
||||
"trim-repeated@^1.0.0": "http://registry.npm.taobao.org/trim-repeated/download/trim-repeated-1.0.0.tgz#e3646a2ea4e891312bf7eace6cfb05380bc01c21",
|
||||
"tunnel-agent@^0.6.0": "http://registry.npm.taobao.org/tunnel-agent/download/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd",
|
||||
"unbzip2-stream@^1.0.9": "http://registry.npm.taobao.org/unbzip2-stream/download/unbzip2-stream-1.3.1.tgz#7854da51622a7e63624221196357803b552966a1",
|
||||
"union-value@^1.0.0": "http://registry.npm.taobao.org/union-value/download/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4",
|
||||
"unset-value@^1.0.0": "http://registry.npm.taobao.org/unset-value/download/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559",
|
||||
"unzip-response@^2.0.1": "http://registry.npm.taobao.org/unzip-response/download/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97",
|
||||
"urix@^0.1.0": "http://registry.npm.taobao.org/urix/download/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72",
|
||||
"url-parse-lax@^1.0.0": "http://registry.npm.taobao.org/url-parse-lax/download/url-parse-lax-1.0.0.tgz#7af8f303645e9bd79a272e7a14ac68bc0609da73",
|
||||
"url-to-options@^1.0.1": "http://registry.npm.taobao.org/url-to-options/download/url-to-options-1.0.1.tgz#1505a03a289a48cbd7a434efbaeec5055f5633a9",
|
||||
"use@^3.1.0": "http://registry.npm.taobao.org/use/download/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f",
|
||||
"user-home@^2.0.0": "http://registry.npm.taobao.org/user-home/download/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f",
|
||||
"util-deprecate@~1.0.1": "http://registry.npm.taobao.org/util-deprecate/download/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf",
|
||||
"wcwidth@^1.0.1": "http://registry.npm.taobao.org/wcwidth/download/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8",
|
||||
"wrappy@1": "http://registry.npm.taobao.org/wrappy/download/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f",
|
||||
"xtend@^4.0.0": "http://registry.npm.taobao.org/xtend/download/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af",
|
||||
"yauzl@^2.4.2": "http://registry.npm.taobao.org/yauzl/download/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9"
|
||||
},
|
||||
"files": [],
|
||||
"artifacts": {}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
# Change Log
|
||||
All notable changes will be documented in this file.
|
||||
`readdir-enhanced` adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [v2.2.0](https://github.com/BigstickCarpet/readdir-enhanced/tree/v2.2.0) (2018-01-09)
|
||||
|
||||
- Refactored the codebase to use ES6 syntax (Node v4.x compatible)
|
||||
|
||||
- You can now provide [your own implementation](https://github.com/BigstickCarpet/readdir-enhanced#custom-fs-methods) for the [filesystem module](https://nodejs.org/api/fs.html) that's used by `readdir-enhanced`. Just set the `fs` option to your implementation. Thanks to [@mrmlnc](https://github.com/mrmlnc) for the idea and [the PR](https://github.com/BigstickCarpet/readdir-enhanced/pull/10)!
|
||||
|
||||
- [Better error handling](https://github.com/BigstickCarpet/readdir-enhanced/commit/0d330b68524bafbdeae11566a3e8af1bc3f184bf), especially around user-specified logic, such as `options.deep`, `options.filter`, and `options.fs`
|
||||
|
||||
[Full Changelog](https://github.com/BigstickCarpet/readdir-enhanced/compare/v2.1.0...v2.2.0)
|
||||
|
||||
|
||||
## [v2.1.0](https://github.com/BigstickCarpet/readdir-enhanced/tree/v2.1.0) (2017-12-01)
|
||||
|
||||
- The `fs.Stats` objects now include a `depth` property, which indicates the number of subdirectories beneath the base path. Thanks to [@mrmlnc](https://github.com/mrmlnc) for [the PR](https://github.com/BigstickCarpet/readdir-enhanced/pull/8)!
|
||||
|
||||
[Full Changelog](https://github.com/BigstickCarpet/readdir-enhanced/compare/v2.0.0...v2.1.0)
|
||||
|
||||
|
||||
## [v2.0.0](https://github.com/BigstickCarpet/readdir-enhanced/tree/v2.0.0) (2017-11-15)
|
||||
|
||||
- Dropped support for Node v0.x, which is no longer actively maintained. Please upgrade to Node 4 or newer.
|
||||
|
||||
[Full Changelog](https://github.com/BigstickCarpet/readdir-enhanced/compare/v1.5.0...v2.0.0)
|
||||
|
||||
|
||||
## [v1.5.0](https://github.com/BigstickCarpet/readdir-enhanced/tree/v1.5.0) (2017-04-10)
|
||||
|
||||
The [`deep` option](README.md#deep) can now be set to a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp), a [glob pattern](https://github.com/isaacs/node-glob#glob-primer), or a function, which allows you to customize which subdirectories get crawled. Of course, you can also still still set the `deep` option to `true` to crawl _all_ subdirectories, or a number if you just want to limit the recursion depth.
|
||||
|
||||
[Full Changelog](https://github.com/BigstickCarpet/readdir-enhanced/compare/v1.4.0...v1.5.0)
|
||||
|
||||
|
||||
## [v1.4.0](https://github.com/BigstickCarpet/readdir-enhanced/tree/v1.4.0) (2016-08-26)
|
||||
|
||||
The [`filter` option](README.md#filter) can now be set to a regular expression or a glob pattern string, which simplifies filtering based on file names. Of course, you can still set the `filter` option to a function if you need to perform more advanced filtering based on the [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) of each file.
|
||||
|
||||
[Full Changelog](https://github.com/BigstickCarpet/readdir-enhanced/compare/v1.3.4...v1.4.0)
|
||||
|
||||
|
||||
## [v1.3.4](https://github.com/BigstickCarpet/readdir-enhanced/tree/v1.3.4) (2016-08-26)
|
||||
|
||||
As of this release, `readdir-enhanced` is fully tested on all major Node versions (0.x, 4.x, 5.x, 6.x) on [linux](https://travis-ci.org/BigstickCarpet/readdir-enhanced) and [Windows](https://ci.appveyor.com/project/BigstickCarpet/readdir-enhanced/branch/master), with [nearly 100% code coverage](https://coveralls.io/github/BigstickCarpet/readdir-enhanced?branch=master). I do all of my local development and testing on MacOS, so that's covered too.
|
||||
|
||||
[Full Changelog](https://github.com/BigstickCarpet/readdir-enhanced/compare/v1.0.1...v1.3.4)
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 James Messinger
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
.
|
||||
+347
@@ -0,0 +1,347 @@
|
||||
Enhanced `fs.readdir()`
|
||||
=======================
|
||||
|
||||
> :warning: This is «fork» for original `readdir-enhanced` package but with some monkey fixes.
|
||||
|
||||
[](https://travis-ci.org/BigstickCarpet/readdir-enhanced)
|
||||
[](https://ci.appveyor.com/project/BigstickCarpet/readdir-enhanced/branch/master)
|
||||
|
||||
[](https://coveralls.io/github/BigstickCarpet/readdir-enhanced?branch=master)
|
||||
[](https://www.codacy.com/public/jamesmessinger/readdir-enhanced)
|
||||
[](http://inch-ci.org/github/BigstickCarpet/readdir-enhanced)
|
||||
[](https://david-dm.org/BigstickCarpet/readdir-enhanced)
|
||||
|
||||
[](https://www.npmjs.com/package/readdir-enhanced)
|
||||
[](LICENSE)
|
||||
|
||||
`readdir-enhanced` is a [backward-compatible](#backward-compatible) drop-in replacement for [`fs.readdir()`](https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback) and [`fs.readdirSync()`](https://nodejs.org/api/fs.html#fs_fs_readdirsync_path_options) with tons of extra features ([filtering](#filter), [recursion](#deep), [absolute paths](#basepath), [stats](#stats), and more) as well as additional APIs for Promises, Streams, and EventEmitters.
|
||||
|
||||
|
||||
Pick Your API
|
||||
-----------------
|
||||
`readdir-enhanced` has multiple APIs, so you can pick whichever one you prefer. There are three main APIs:
|
||||
|
||||
- **Synchronous API**<br>
|
||||
aliases: `readdir.sync`, `readdir.readdirSync`<br>
|
||||
Blocks the thread until all directory contents are read, and then returns all the results.
|
||||
|
||||
- **Async API**<br>
|
||||
aliases: `readdir`, `readdir.async`, `readdir.readdirAsync`<br>
|
||||
Reads the starting directory contents asynchronously and buffers all the results until all contents have been read. Supports callback or Promise syntax (see example below).
|
||||
|
||||
- **Streaming API**<br>
|
||||
aliases: `readdir.stream`, `readdir.readdirStream`<br>
|
||||
The streaming API reads the starting directory asynchronously and returns the results in real-time as they are read. The results can be [piped](https://nodejs.org/api/stream.html#stream_readable_pipe_destination_options) to other Node.js streams, or you can listen for specific events via the [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) interface. (see example below)
|
||||
|
||||
```javascript
|
||||
var readdir = require('readdir-enhanced');
|
||||
var through2 = require('through2');
|
||||
|
||||
// Synchronous API
|
||||
var files = readdir.sync('my/directory');
|
||||
|
||||
// Callback API
|
||||
readdir.async('my/directory', function(err, files) { ... });
|
||||
|
||||
// Promises API
|
||||
readdir.async('my/directory')
|
||||
.then(function(files) { ... })
|
||||
.catch(function(err) { ... });
|
||||
|
||||
// EventEmitter API
|
||||
readdir.stream('my/directory')
|
||||
.on('data', function(path) { ... })
|
||||
.on('file', function(path) { ... })
|
||||
.on('directory', function(path) { ... })
|
||||
.on('symlink', function(path) { ... })
|
||||
.on('error', function(err) { ... });
|
||||
|
||||
// Streaming API
|
||||
var stream = readdir.stream('my/directory')
|
||||
.pipe(through2.obj(function(data, enc, next) {
|
||||
console.log(data);
|
||||
this.push(data);
|
||||
next();
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
<a id="options"></a>
|
||||
Enhanced Features
|
||||
-----------------
|
||||
`readdir-enhanced` adds several features to the built-in `fs.readdir()` function. All of the enhanced features are opt-in, which makes `readdir-enhanced` [fully backward compatible by default](#backward-compatible). You can enable any of the features by passing-in an `options` argument as the second parameter.
|
||||
|
||||
|
||||
<a id="deep"></a>
|
||||
### Recursion
|
||||
By default, `readdir-enhanced` will only return the top-level contents of the starting directory. But you can set the `deep` option to recursively traverse the subdirectories and return their contents as well.
|
||||
|
||||
#### Crawl ALL subdirectories
|
||||
|
||||
The `deep` option can be set to `true` to traverse the entire directory structure.
|
||||
|
||||
```javascript
|
||||
var readdir = require('readdir-enhanced');
|
||||
|
||||
readdir('my/directory', {deep: true}, function(err, files) {
|
||||
console.log(files);
|
||||
// => subdir1
|
||||
// => subdir1/file.txt
|
||||
// => subdir1/subdir2
|
||||
// => subdir1/subdir2/file.txt
|
||||
// => subdir1/subdir2/subdir3
|
||||
// => subdir1/subdir2/subdir3/file.txt
|
||||
});
|
||||
```
|
||||
|
||||
#### Crawl to a specific depth
|
||||
The `deep` option can be set to a number to only traverse that many levels deep. For example, calling `readdir('my/directory', {deep: 2})` will return `subdir1/file.txt` and `subdir1/subdir2/file.txt`, but it _won't_ return `subdir1/subdir2/subdir3/file.txt`.
|
||||
|
||||
```javascript
|
||||
var readdir = require('readdir-enhanced');
|
||||
|
||||
readdir('my/directory', {deep: 2}, function(err, files) {
|
||||
console.log(files);
|
||||
// => subdir1
|
||||
// => subdir1/file.txt
|
||||
// => subdir1/subdir2
|
||||
// => subdir1/subdir2/file.txt
|
||||
// => subdir1/subdir2/subdir3
|
||||
});
|
||||
```
|
||||
|
||||
#### Crawl subdirectories by name
|
||||
For simple use-cases, you can use a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) or a [glob pattern](https://github.com/isaacs/node-glob#glob-primer) to crawl only the directories whose path matches the pattern. The path is relative to the starting directory by default, but you can customize this via [`options.basePath`](#basepath).
|
||||
|
||||
> **NOTE:** Glob patterns [_always_ use forward-slashes](https://github.com/isaacs/node-glob#windows), even on Windows. This _does not_ apply to regular expressions though. Regular expressions should use the appropraite path separator for the environment. Or, you can match both types of separators using `[\\/]`.
|
||||
|
||||
```javascript
|
||||
var readdir = require('readdir-enhanced');
|
||||
|
||||
// Only crawl the "lib" and "bin" subdirectories
|
||||
// (notice that the "node_modules" subdirectory does NOT get crawled)
|
||||
readdir('my/directory', {deep: /lib|bin/}, function(err, files) {
|
||||
console.log(files);
|
||||
// => bin
|
||||
// => bin/cli.js
|
||||
// => lib
|
||||
// => lib/index.js
|
||||
// => node_modules
|
||||
// => package.json
|
||||
});
|
||||
```
|
||||
|
||||
#### Custom recursion logic
|
||||
For more advanced recursion, you can set the `deep` option to a function that accepts an [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object and returns a truthy value if the starting directory should be crawled.
|
||||
|
||||
> **NOTE:** The [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object that's passed to the function has additional `path` and `depth` properties. The `path` is relative to the starting directory by default, but you can customize this via [`options.basePath`](#basepath). The `depth` is the number of subdirectories beneath the base path (see [`options.deep`](#deep)).
|
||||
|
||||
```javascript
|
||||
var readdir = require('readdir-enhanced');
|
||||
|
||||
// Crawl all subdirectories, except "node_modules"
|
||||
function ignoreNodeModules (stats) {
|
||||
return stats.path.indexOf('node_modules') === -1;
|
||||
}
|
||||
|
||||
readdir('my/directory', {deep: ignoreNodeModules}, function(err, files) {
|
||||
console.log(files);
|
||||
// => bin
|
||||
// => bin/cli.js
|
||||
// => lib
|
||||
// => lib/index.js
|
||||
// => node_modules
|
||||
// => package.json
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
<a id="filter"></a>
|
||||
### Filtering
|
||||
The `filter` option lets you limit the results based on any criteria you want.
|
||||
|
||||
#### Filter by name
|
||||
For simple use-cases, you can use a [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) or a [glob pattern](https://github.com/isaacs/node-glob#glob-primer) to filter items by their path. The path is relative to the starting directory by default, but you can customize this via [`options.basePath`](#basepath).
|
||||
|
||||
> **NOTE:** Glob patterns [_always_ use forward-slashes](https://github.com/isaacs/node-glob#windows), even on Windows. This _does not_ apply to regular expressions though. Regular expressions should use the appropraite path separator for the environment. Or, you can match both types of separators using `[\\/]`.
|
||||
|
||||
```javascript
|
||||
var readdir = require('readdir-enhanced');
|
||||
|
||||
// Find all .txt files
|
||||
readdir('my/directory', {filter: '*.txt'});
|
||||
|
||||
// Find all package.json files
|
||||
readdir('my/directory', {filter: '**/package.json', deep: true});
|
||||
|
||||
// Find everything with at least one number in the name
|
||||
readdir('my/directory', {filter: /\d+/});
|
||||
```
|
||||
|
||||
#### Custom filtering logic
|
||||
For more advanced filtering, you can specify a filter function that accepts an [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object and returns a truthy value if the item should be included in the results.
|
||||
|
||||
> **NOTE:** The [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object that's passed to the filter function has additional `path` and `depth` properties. The `path` is relative to the starting directory by default, but you can customize this via [`options.basePath`](#basepath). The `depth` is the number of subdirectories beneath the base path (see [`options.deep`](#deep)).
|
||||
|
||||
```javascript
|
||||
var readdir = require('readdir-enhanced');
|
||||
|
||||
// Only return file names containing an underscore
|
||||
function myFilter(stats) {
|
||||
return stats.isFile() && stats.path.indexOf('_') >= 0;
|
||||
}
|
||||
|
||||
readdir('my/directory', {filter: myFilter}, function(err, files) {
|
||||
console.log(files);
|
||||
// => __myFile.txt
|
||||
// => my_other_file.txt
|
||||
// => img_1.jpg
|
||||
// => node_modules
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
<a id="basepath"></a>
|
||||
### Base Path
|
||||
By default all `readdir-enhanced` functions return paths that are relative to the starting directory. But you can use the `basePath` option to customize this. The `basePath` will be prepended to all of the returned paths. One common use-case for this is to set `basePath` to the absolute path of the starting directory, so that all of the returned paths will be absolute.
|
||||
|
||||
```javascript
|
||||
var readdir = require('readdir-enhanced');
|
||||
var path = require('path');
|
||||
|
||||
// Get absolute paths
|
||||
var absPath = path.resolve('my/dir');
|
||||
readdir('my/directory', {basePath: absPath}, function(err, files) {
|
||||
console.log(files);
|
||||
// => /absolute/path/to/my/directory/file1.txt
|
||||
// => /absolute/path/to/my/directory/file2.txt
|
||||
// => /absolute/path/to/my/directory/subdir
|
||||
});
|
||||
|
||||
// Get paths relative to the working directory
|
||||
readdir('my/directory', {basePath: 'my/directory'}, function(err, files) {
|
||||
console.log(files);
|
||||
// => my/directory/file1.txt
|
||||
// => my/directory/file2.txt
|
||||
// => my/directory/subdir
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
<a id="sep"></a>
|
||||
### Path Separator
|
||||
By default, `readdir-enhanced` uses the correct path separator for your OS (`\` on Windows, `/` on Linux & MacOS). But you can set the `sep` option to any separator character(s) that you want to use instead. This is usually used to ensure consistent path separators across different OSes.
|
||||
|
||||
```javascript
|
||||
var readdir = require('readdir-enhanced');
|
||||
|
||||
// Always use Windows path separators
|
||||
readdir('my/directory', {sep: '\\', deep: true}, function(err, files) {
|
||||
console.log(files);
|
||||
// => subdir1
|
||||
// => subdir1\file.txt
|
||||
// => subdir1\subdir2
|
||||
// => subdir1\subdir2\file.txt
|
||||
// => subdir1\subdir2\subdir3
|
||||
// => subdir1\subdir2\subdir3\file.txt
|
||||
});
|
||||
```
|
||||
|
||||
<a id="fs"></a>
|
||||
### Custom FS methods
|
||||
By default, `readdir-enhanced` uses the default [Node.js FileSystem module](https://nodejs.org/api/fs.html) for methods like `fs.stat`, `fs.readdir` and `fs.lstat`. But in some situations, you can want to use your own FS methods (FTP, SSH, remote drive and etc). So you can provide your own implementation of FS methods by setting `options.fs` or specific methods, such as `options.fs.stat`.
|
||||
|
||||
```javascript
|
||||
var readdir = require('readdir-enhanced');
|
||||
|
||||
function myCustomReaddirMethod(dir, callback) {
|
||||
callback(null, ['__myFile.txt']);
|
||||
}
|
||||
|
||||
var options = {
|
||||
fs: {
|
||||
readdir: myCustomReaddirMethod
|
||||
}
|
||||
};
|
||||
|
||||
readdir('my/directory', options, function(err, files) {
|
||||
console.log(files);
|
||||
// => __myFile.txt
|
||||
});
|
||||
```
|
||||
|
||||
<a id="stats"></a>
|
||||
Get `fs.Stats` objects instead of strings
|
||||
------------------------
|
||||
All of the `readdir-enhanced` functions listed above return an array of strings (paths). But in some situations, the path isn't enough information. So, `readdir-enhanced` provides alternative versions of each function, which return an array of [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) objects instead of strings. The `fs.Stats` object contains all sorts of useful information, such as the size, the creation date/time, and helper methods such as `isFile()`, `isDirectory()`, `isSymbolicLink()`, etc.
|
||||
|
||||
> **NOTE:** The [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) objects that are returned also have additional `path` and `depth` properties. The `path` is relative to the starting directory by default, but you can customize this via [`options.basePath`](#basepath). The `depth` is the number of subdirectories beneath the base path (see [`options.deep`](#deep)).
|
||||
|
||||
To get `fs.Stats` objects instead of strings, just add the word "Stat" to the function name. As with the normal functions, each one is aliased (e.g. `readdir.async.stat` is the same as `readdir.readdirAsyncStat`), so you can use whichever naming style you prefer.
|
||||
|
||||
```javascript
|
||||
var readdir = require('readdir-enhanced');
|
||||
|
||||
// Synchronous API
|
||||
var stats = readdir.sync.stat('my/directory');
|
||||
var stats = readdir.readdirSyncStat('my/directory');
|
||||
|
||||
// Async API
|
||||
readdir.async.stat('my/directory', function(err, stats) { ... });
|
||||
readdir.readdirAsyncStat('my/directory', function(err, stats) { ... });
|
||||
|
||||
// Streaming API
|
||||
readdir.stream.stat('my/directory')
|
||||
.on('data', function(stat) { ... })
|
||||
.on('file', function(stat) { ... })
|
||||
.on('directory', function(stat) { ... })
|
||||
.on('symlink', function(stat) { ... });
|
||||
|
||||
readdir.readdirStreamStat('my/directory')
|
||||
.on('data', function(stat) { ... })
|
||||
.on('file', function(stat) { ... })
|
||||
.on('directory', function(stat) { ... })
|
||||
.on('symlink', function(stat) { ... });
|
||||
|
||||
```
|
||||
|
||||
<a id="backward-compatible"></a>
|
||||
Backward Compatible
|
||||
--------------------
|
||||
`readdir-enhanced` is fully backward-compatible with Node.js' built-in `fs.readdir()` and `fs.readdirSync()` functions, so you can use it as a drop-in replacement in existing projects without affecting existing functionality, while still being able to use the enhanced features as needed.
|
||||
|
||||
```javascript
|
||||
var readdir = require('readdir-enhanced');
|
||||
var readdirSync = readdir.sync;
|
||||
|
||||
// Use it just like Node's built-in fs.readdir function
|
||||
readdir('my/directory', function(err, files) { ... });
|
||||
|
||||
// Use it just like Node's built-in fs.readdirSync function
|
||||
var files = readdirSync('my/directory');
|
||||
```
|
||||
|
||||
|
||||
|
||||
Contributing
|
||||
--------------------------
|
||||
I welcome any contributions, enhancements, and bug-fixes. [File an issue](https://github.com/BigstickCarpet/readdir-enhanced/issues) on GitHub and [submit a pull request](https://github.com/BigstickCarpet/readdir-enhanced/pulls).
|
||||
|
||||
#### Building
|
||||
To build the project locally on your computer:
|
||||
|
||||
1. __Clone this repo__<br>
|
||||
`git clone https://github.com/bigstickcarpet/readdir-enhanced.git`
|
||||
|
||||
2. __Install dependencies__<br>
|
||||
`npm install`
|
||||
|
||||
3. __Run the tests__<br>
|
||||
`npm test`
|
||||
|
||||
|
||||
|
||||
License
|
||||
--------------------------
|
||||
`readdir-enhanced` is 100% free and open-source, under the [MIT license](LICENSE). Use it however you want.
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = asyncForEach;
|
||||
|
||||
/**
|
||||
* Simultaneously processes all items in the given array.
|
||||
*
|
||||
* @param {array} array - The array to iterate over
|
||||
* @param {function} iterator - The function to call for each item in the array
|
||||
* @param {function} done - The function to call when all iterators have completed
|
||||
*/
|
||||
function asyncForEach (array, iterator, done) {
|
||||
if (array.length === 0) {
|
||||
// NOTE: Normally a bad idea to mix sync and async, but it's safe here because
|
||||
// of the way that this method is currently used by DirectoryReader.
|
||||
done();
|
||||
return;
|
||||
}
|
||||
|
||||
// Simultaneously process all items in the array.
|
||||
let pending = array.length;
|
||||
array.forEach(item => {
|
||||
iterator(item, () => {
|
||||
if (--pending === 0) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = readdirAsync;
|
||||
|
||||
const maybe = require('call-me-maybe');
|
||||
const DirectoryReader = require('../directory-reader');
|
||||
|
||||
let asyncFacade = {
|
||||
fs: require('fs'),
|
||||
forEach: require('./for-each'),
|
||||
async: true
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the buffered output from an asynchronous {@link DirectoryReader},
|
||||
* via an error-first callback or a {@link Promise}.
|
||||
*
|
||||
* @param {string} dir
|
||||
* @param {object} [options]
|
||||
* @param {function} [callback]
|
||||
* @param {object} internalOptions
|
||||
*/
|
||||
function readdirAsync (dir, options, callback, internalOptions) {
|
||||
if (typeof options === 'function') {
|
||||
callback = options;
|
||||
options = undefined;
|
||||
}
|
||||
|
||||
return maybe(callback, new Promise(((resolve, reject) => {
|
||||
let results = [];
|
||||
|
||||
internalOptions.facade = asyncFacade;
|
||||
|
||||
let reader = new DirectoryReader(dir, options, internalOptions);
|
||||
let stream = reader.stream;
|
||||
|
||||
stream.on('error', err => {
|
||||
reject(err);
|
||||
stream.pause();
|
||||
});
|
||||
stream.on('data', result => {
|
||||
results.push(result);
|
||||
});
|
||||
stream.on('end', () => {
|
||||
resolve(results);
|
||||
});
|
||||
})));
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
|
||||
let call = module.exports = {
|
||||
safe: safeCall,
|
||||
once: callOnce,
|
||||
};
|
||||
|
||||
/**
|
||||
* Calls a function with the given arguments, and ensures that the error-first callback is _always_
|
||||
* invoked exactly once, even if the function throws an error.
|
||||
*
|
||||
* @param {function} fn - The function to invoke
|
||||
* @param {...*} args - The arguments to pass to the function. The final argument must be a callback function.
|
||||
*/
|
||||
function safeCall (fn, args) {
|
||||
// Get the function arguments as an array
|
||||
args = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
// Replace the callback function with a wrapper that ensures it will only be called once
|
||||
let callback = call.once(args.pop());
|
||||
args.push(callback);
|
||||
|
||||
try {
|
||||
fn.apply(null, args);
|
||||
}
|
||||
catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a wrapper function that ensures the given callback function is only called once.
|
||||
* Subsequent calls are ignored, unless the first argument is an Error, in which case the
|
||||
* error is thrown.
|
||||
*
|
||||
* @param {function} fn - The function that should only be called once
|
||||
* @returns {function}
|
||||
*/
|
||||
function callOnce (fn) {
|
||||
let fulfilled = false;
|
||||
|
||||
return function onceWrapper (err) {
|
||||
if (!fulfilled) {
|
||||
fulfilled = true;
|
||||
return fn.apply(this, arguments);
|
||||
}
|
||||
else if (err) {
|
||||
// The callback has already been called, but now an error has occurred
|
||||
// (most likely inside the callback function). So re-throw the error,
|
||||
// so it gets handled further up the call stack
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
}
|
||||
+380
@@ -0,0 +1,380 @@
|
||||
'use strict';
|
||||
|
||||
const Readable = require('stream').Readable;
|
||||
const EventEmitter = require('events').EventEmitter;
|
||||
const path = require('path');
|
||||
const normalizeOptions = require('./normalize-options');
|
||||
const stat = require('./stat');
|
||||
const call = require('./call');
|
||||
|
||||
/**
|
||||
* Asynchronously reads the contents of a directory and streams the results
|
||||
* via a {@link stream.Readable}.
|
||||
*/
|
||||
class DirectoryReader {
|
||||
/**
|
||||
* @param {string} dir - The absolute or relative directory path to read
|
||||
* @param {object} [options] - User-specified options, if any (see {@link normalizeOptions})
|
||||
* @param {object} internalOptions - Internal options that aren't part of the public API
|
||||
* @class
|
||||
*/
|
||||
constructor (dir, options, internalOptions) {
|
||||
this.options = options = normalizeOptions(options, internalOptions);
|
||||
|
||||
// Indicates whether we should keep reading
|
||||
// This is set false if stream.Readable.push() returns false.
|
||||
this.shouldRead = true;
|
||||
|
||||
// The directories to read
|
||||
// (initialized with the top-level directory)
|
||||
this.queue = [{
|
||||
path: dir,
|
||||
basePath: options.basePath,
|
||||
posixBasePath: options.posixBasePath,
|
||||
depth: 0
|
||||
}];
|
||||
|
||||
// The number of directories that are currently being processed
|
||||
this.pending = 0;
|
||||
|
||||
// The data that has been read, but not yet emitted
|
||||
this.buffer = [];
|
||||
|
||||
this.stream = new Readable({ objectMode: true });
|
||||
this.stream._read = () => {
|
||||
// Start (or resume) reading
|
||||
this.shouldRead = true;
|
||||
|
||||
// If we have data in the buffer, then send the next chunk
|
||||
if (this.buffer.length > 0) {
|
||||
this.pushFromBuffer();
|
||||
}
|
||||
|
||||
// If we have directories queued, then start processing the next one
|
||||
if (this.queue.length > 0) {
|
||||
if (this.options.facade.sync) {
|
||||
while (this.queue.length > 0) {
|
||||
this.readNextDirectory();
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.readNextDirectory();
|
||||
}
|
||||
}
|
||||
|
||||
this.checkForEOF();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the next directory in the queue
|
||||
*/
|
||||
readNextDirectory () {
|
||||
let facade = this.options.facade;
|
||||
let dir = this.queue.shift();
|
||||
this.pending++;
|
||||
|
||||
// Read the directory listing
|
||||
call.safe(facade.fs.readdir, dir.path, (err, items) => {
|
||||
if (err) {
|
||||
// fs.readdir threw an error
|
||||
this.emit('error', err);
|
||||
return this.finishedReadingDirectory();
|
||||
}
|
||||
|
||||
try {
|
||||
// Process each item in the directory (simultaneously, if async)
|
||||
facade.forEach(
|
||||
items,
|
||||
this.processItem.bind(this, dir),
|
||||
this.finishedReadingDirectory.bind(this, dir)
|
||||
);
|
||||
}
|
||||
catch (err2) {
|
||||
// facade.forEach threw an error
|
||||
// (probably because fs.readdir returned an invalid result)
|
||||
this.emit('error', err2);
|
||||
this.finishedReadingDirectory();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called after all items in a directory have been processed.
|
||||
*
|
||||
* NOTE: This does not necessarily mean that the reader is finished, since there may still
|
||||
* be other directories queued or pending.
|
||||
*/
|
||||
finishedReadingDirectory () {
|
||||
this.pending--;
|
||||
|
||||
if (this.shouldRead) {
|
||||
// If we have directories queued, then start processing the next one
|
||||
if (this.queue.length > 0 && this.options.facade.async) {
|
||||
this.readNextDirectory();
|
||||
}
|
||||
|
||||
this.checkForEOF();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the reader has finished processing all items in all directories.
|
||||
* If so, then the "end" event is fired (via {@Readable#push})
|
||||
*/
|
||||
checkForEOF () {
|
||||
if (this.buffer.length === 0 && // The stuff we've already read
|
||||
this.pending === 0 && // The stuff we're currently reading
|
||||
this.queue.length === 0) { // The stuff we haven't read yet
|
||||
// There's no more stuff!
|
||||
this.stream.push(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a single item in a directory.
|
||||
*
|
||||
* If the item is a directory, and `option.deep` is enabled, then the item will be added
|
||||
* to the directory queue.
|
||||
*
|
||||
* If the item meets the filter criteria, then it will be emitted to the reader's stream.
|
||||
*
|
||||
* @param {object} dir - A directory object from the queue
|
||||
* @param {string} item - The name of the item (name only, no path)
|
||||
* @param {function} done - A callback function that is called after the item has been processed
|
||||
*/
|
||||
processItem (dir, item, done) {
|
||||
let stream = this.stream;
|
||||
let options = this.options;
|
||||
|
||||
let itemPath = dir.basePath + item;
|
||||
let posixPath = dir.posixBasePath + item;
|
||||
let fullPath = path.join(dir.path, item);
|
||||
|
||||
// If `options.deep` is a number, and we've already recursed to the max depth,
|
||||
// then there's no need to check fs.Stats to know if it's a directory.
|
||||
// If `options.deep` is a function, then we'll need fs.Stats
|
||||
let maxDepthReached = dir.depth >= options.recurseDepth;
|
||||
|
||||
// Do we need to call `fs.stat`?
|
||||
let needStats =
|
||||
!maxDepthReached || // we need the fs.Stats to know if it's a directory
|
||||
options.stats || // the user wants fs.Stats objects returned
|
||||
options.recurseFn || // we need fs.Stats for the recurse function
|
||||
options.filterFn || // we need fs.Stats for the filter function
|
||||
EventEmitter.listenerCount(stream, 'file') || // we need the fs.Stats to know if it's a file
|
||||
EventEmitter.listenerCount(stream, 'directory') || // we need the fs.Stats to know if it's a directory
|
||||
EventEmitter.listenerCount(stream, 'symlink'); // we need the fs.Stats to know if it's a symlink
|
||||
|
||||
// If we don't need stats, then exit early
|
||||
if (!needStats) {
|
||||
if (this.filter(itemPath, posixPath)) {
|
||||
this.pushOrBuffer({ data: itemPath });
|
||||
}
|
||||
return done();
|
||||
}
|
||||
|
||||
// Get the fs.Stats object for this path
|
||||
stat(options.facade.fs, fullPath, (err, stats) => {
|
||||
if (err) {
|
||||
// fs.stat threw an error
|
||||
this.emit('error', err);
|
||||
return done();
|
||||
}
|
||||
|
||||
try {
|
||||
// Add the item's path to the fs.Stats object
|
||||
// The base of this path, and its separators are determined by the options
|
||||
// (i.e. options.basePath and options.sep)
|
||||
stats.path = itemPath;
|
||||
|
||||
// Add depth of the path to the fs.Stats object for use this in the filter function
|
||||
stats.depth = dir.depth;
|
||||
|
||||
if (this.shouldRecurse(stats, posixPath, maxDepthReached)) {
|
||||
// Add this subdirectory to the queue
|
||||
this.queue.push({
|
||||
path: fullPath,
|
||||
basePath: itemPath + options.sep,
|
||||
posixBasePath: posixPath + '/',
|
||||
depth: dir.depth + 1,
|
||||
});
|
||||
}
|
||||
|
||||
// Determine whether this item matches the filter criteria
|
||||
if (this.filter(stats, posixPath)) {
|
||||
this.pushOrBuffer({
|
||||
data: options.stats ? stats : itemPath,
|
||||
file: stats.isFile(),
|
||||
directory: stats.isDirectory(),
|
||||
symlink: stats.isSymbolicLink(),
|
||||
});
|
||||
}
|
||||
|
||||
done();
|
||||
}
|
||||
catch (err2) {
|
||||
// An error occurred while processing the item
|
||||
// (probably during a user-specified function, such as options.deep, options.filter, etc.)
|
||||
this.emit('error', err2);
|
||||
done();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Pushes the given chunk of data to the stream, or adds it to the buffer,
|
||||
* depending on the state of the stream.
|
||||
*
|
||||
* @param {object} chunk
|
||||
*/
|
||||
pushOrBuffer (chunk) {
|
||||
// Add the chunk to the buffer
|
||||
this.buffer.push(chunk);
|
||||
|
||||
// If we're still reading, then immediately emit the next chunk in the buffer
|
||||
// (which may or may not be the chunk that we just added)
|
||||
if (this.shouldRead) {
|
||||
this.pushFromBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Immediately pushes the next chunk in the buffer to the reader's stream.
|
||||
* The "data" event will always be fired (via {@link Readable#push}).
|
||||
* In addition, the "file", "directory", and/or "symlink" events may be fired,
|
||||
* depending on the type of properties of the chunk.
|
||||
*/
|
||||
pushFromBuffer () {
|
||||
let stream = this.stream;
|
||||
let chunk = this.buffer.shift();
|
||||
|
||||
// Stream the data
|
||||
try {
|
||||
this.shouldRead = stream.push(chunk.data);
|
||||
}
|
||||
catch (err) {
|
||||
this.emit('error', err);
|
||||
}
|
||||
|
||||
// Also emit specific events, based on the type of chunk
|
||||
chunk.file && this.emit('file', chunk.data);
|
||||
chunk.symlink && this.emit('symlink', chunk.data);
|
||||
chunk.directory && this.emit('directory', chunk.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the given directory meets the user-specified recursion criteria.
|
||||
* If the user didn't specify recursion criteria, then this function will default to true.
|
||||
*
|
||||
* @param {fs.Stats} stats - The directory's {@link fs.Stats} object
|
||||
* @param {string} posixPath - The item's POSIX path (used for glob matching)
|
||||
* @param {boolean} maxDepthReached - Whether we've already crawled the user-specified depth
|
||||
* @returns {boolean}
|
||||
*/
|
||||
shouldRecurse (stats, posixPath, maxDepthReached) {
|
||||
let options = this.options;
|
||||
|
||||
if (maxDepthReached) {
|
||||
// We've already crawled to the maximum depth. So no more recursion.
|
||||
return false;
|
||||
}
|
||||
else if (!stats.isDirectory()) {
|
||||
// It's not a directory. So don't try to crawl it.
|
||||
return false;
|
||||
}
|
||||
else if (options.recurseGlob) {
|
||||
// Glob patterns are always tested against the POSIX path, even on Windows
|
||||
// https://github.com/isaacs/node-glob#windows
|
||||
return options.recurseGlob.test(posixPath);
|
||||
}
|
||||
else if (options.recurseRegExp) {
|
||||
// Regular expressions are tested against the normal path
|
||||
// (based on the OS or options.sep)
|
||||
return options.recurseRegExp.test(stats.path);
|
||||
}
|
||||
else if (options.recurseFn) {
|
||||
try {
|
||||
// Run the user-specified recursion criteria
|
||||
return options.recurseFn.call(null, stats);
|
||||
}
|
||||
catch (err) {
|
||||
// An error occurred in the user's code.
|
||||
// In Sync and Async modes, this will return an error.
|
||||
// In Streaming mode, we emit an "error" event, but continue processing
|
||||
this.emit('error', err);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No recursion function was specified, and we're within the maximum depth.
|
||||
// So crawl this directory.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the given item meets the user-specified filter criteria.
|
||||
* If the user didn't specify a filter, then this function will always return true.
|
||||
*
|
||||
* @param {string|fs.Stats} value - Either the item's path, or the item's {@link fs.Stats} object
|
||||
* @param {string} posixPath - The item's POSIX path (used for glob matching)
|
||||
* @returns {boolean}
|
||||
*/
|
||||
filter (value, posixPath) {
|
||||
let options = this.options;
|
||||
|
||||
if (options.filterGlob) {
|
||||
// Glob patterns are always tested against the POSIX path, even on Windows
|
||||
// https://github.com/isaacs/node-glob#windows
|
||||
return options.filterGlob.test(posixPath);
|
||||
}
|
||||
else if (options.filterRegExp) {
|
||||
// Regular expressions are tested against the normal path
|
||||
// (based on the OS or options.sep)
|
||||
return options.filterRegExp.test(value.path || value);
|
||||
}
|
||||
else if (options.filterFn) {
|
||||
try {
|
||||
// Run the user-specified filter function
|
||||
return options.filterFn.call(null, value);
|
||||
}
|
||||
catch (err) {
|
||||
// An error occurred in the user's code.
|
||||
// In Sync and Async modes, this will return an error.
|
||||
// In Streaming mode, we emit an "error" event, but continue processing
|
||||
this.emit('error', err);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No filter was specified, so match everything
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits an event. If one of the event listeners throws an error,
|
||||
* then an "error" event is emitted.
|
||||
*
|
||||
* @param {string} eventName
|
||||
* @param {*} data
|
||||
*/
|
||||
emit (eventName, data) {
|
||||
let stream = this.stream;
|
||||
|
||||
try {
|
||||
stream.emit(eventName, data);
|
||||
}
|
||||
catch (err) {
|
||||
if (eventName === 'error') {
|
||||
// Don't recursively emit "error" events.
|
||||
// If the first one fails, then just throw
|
||||
throw err;
|
||||
}
|
||||
else {
|
||||
stream.emit('error', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DirectoryReader;
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
'use strict';
|
||||
|
||||
const readdirSync = require('./sync');
|
||||
const readdirAsync = require('./async');
|
||||
const readdirStream = require('./stream');
|
||||
|
||||
module.exports = exports = readdirAsyncPath;
|
||||
exports.readdir = exports.readdirAsync = exports.async = readdirAsyncPath;
|
||||
exports.readdirAsyncStat = exports.async.stat = readdirAsyncStat;
|
||||
exports.readdirStream = exports.stream = readdirStreamPath;
|
||||
exports.readdirStreamStat = exports.stream.stat = readdirStreamStat;
|
||||
exports.readdirSync = exports.sync = readdirSyncPath;
|
||||
exports.readdirSyncStat = exports.sync.stat = readdirSyncStat;
|
||||
|
||||
/**
|
||||
* Synchronous readdir that returns an array of string paths.
|
||||
*
|
||||
* @param {string} dir
|
||||
* @param {object} [options]
|
||||
* @returns {string[]}
|
||||
*/
|
||||
function readdirSyncPath (dir, options) {
|
||||
return readdirSync(dir, options, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronous readdir that returns results as an array of {@link fs.Stats} objects
|
||||
*
|
||||
* @param {string} dir
|
||||
* @param {object} [options]
|
||||
* @returns {fs.Stats[]}
|
||||
*/
|
||||
function readdirSyncStat (dir, options) {
|
||||
return readdirSync(dir, options, { stats: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Aynchronous readdir (accepts an error-first callback or returns a {@link Promise}).
|
||||
* Results are an array of path strings.
|
||||
*
|
||||
* @param {string} dir
|
||||
* @param {object} [options]
|
||||
* @param {function} [callback]
|
||||
* @returns {Promise<string[]>}
|
||||
*/
|
||||
function readdirAsyncPath (dir, options, callback) {
|
||||
return readdirAsync(dir, options, callback, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Aynchronous readdir (accepts an error-first callback or returns a {@link Promise}).
|
||||
* Results are an array of {@link fs.Stats} objects.
|
||||
*
|
||||
* @param {string} dir
|
||||
* @param {object} [options]
|
||||
* @param {function} [callback]
|
||||
* @returns {Promise<fs.Stats[]>}
|
||||
*/
|
||||
function readdirAsyncStat (dir, options, callback) {
|
||||
return readdirAsync(dir, options, callback, { stats: true });
|
||||
}
|
||||
|
||||
/**
|
||||
* Aynchronous readdir that returns a {@link stream.Readable} (which is also an {@link EventEmitter}).
|
||||
* All stream data events ("data", "file", "directory", "symlink") are passed a path string.
|
||||
*
|
||||
* @param {string} dir
|
||||
* @param {object} [options]
|
||||
* @returns {stream.Readable}
|
||||
*/
|
||||
function readdirStreamPath (dir, options) {
|
||||
return readdirStream(dir, options, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Aynchronous readdir that returns a {@link stream.Readable} (which is also an {@link EventEmitter})
|
||||
* All stream data events ("data", "file", "directory", "symlink") are passed an {@link fs.Stats} object.
|
||||
*
|
||||
* @param {string} dir
|
||||
* @param {object} [options]
|
||||
* @returns {stream.Readable}
|
||||
*/
|
||||
function readdirStreamStat (dir, options) {
|
||||
return readdirStream(dir, options, { stats: true });
|
||||
}
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const globToRegExp = require('glob-to-regexp');
|
||||
|
||||
module.exports = normalizeOptions;
|
||||
|
||||
let isWindows = /^win/.test(process.platform);
|
||||
|
||||
/**
|
||||
* @typedef {Object} FSFacade
|
||||
* @property {fs.readdir} readdir
|
||||
* @property {fs.stat} stat
|
||||
* @property {fs.lstat} lstat
|
||||
*/
|
||||
|
||||
/**
|
||||
* Validates and normalizes the options argument
|
||||
*
|
||||
* @param {object} [options] - User-specified options, if any
|
||||
* @param {object} internalOptions - Internal options that aren't part of the public API
|
||||
*
|
||||
* @param {number|boolean|function} [options.deep]
|
||||
* The number of directories to recursively traverse. Any falsy value or negative number will
|
||||
* default to zero, so only the top-level contents will be returned. Set to `true` or `Infinity`
|
||||
* to traverse all subdirectories. Or provide a function that accepts a {@link fs.Stats} object
|
||||
* and returns a truthy value if the directory's contents should be crawled.
|
||||
*
|
||||
* @param {function|string|RegExp} [options.filter]
|
||||
* A function that accepts a {@link fs.Stats} object and returns a truthy value if the data should
|
||||
* be returned. Or a RegExp or glob string pattern, to filter by file name.
|
||||
*
|
||||
* @param {string} [options.sep]
|
||||
* The path separator to use. By default, the OS-specific separator will be used, but this can be
|
||||
* set to a specific value to ensure consistency across platforms.
|
||||
*
|
||||
* @param {string} [options.basePath]
|
||||
* The base path to prepend to each result. If empty, then all results will be relative to `dir`.
|
||||
*
|
||||
* @param {FSFacade} [options.fs]
|
||||
* Synchronous or asynchronous facades for Node.js File System module
|
||||
*
|
||||
* @param {object} [internalOptions.facade]
|
||||
* Synchronous or asynchronous facades for various methods, including for the Node.js File System module
|
||||
*
|
||||
* @param {boolean} [internalOptions.emit]
|
||||
* Indicates whether the reader should emit "file", "directory", and "symlink" events
|
||||
*
|
||||
* @param {boolean} [internalOptions.stats]
|
||||
* Indicates whether the reader should emit {@link fs.Stats} objects instead of path strings
|
||||
*
|
||||
* @returns {object}
|
||||
*/
|
||||
function normalizeOptions (options, internalOptions) {
|
||||
if (options === null || options === undefined) {
|
||||
options = {};
|
||||
}
|
||||
else if (typeof options !== 'object') {
|
||||
throw new TypeError('options must be an object');
|
||||
}
|
||||
|
||||
let recurseDepth, recurseFn, recurseRegExp, recurseGlob, deep = options.deep;
|
||||
if (deep === null || deep === undefined) {
|
||||
recurseDepth = 0;
|
||||
}
|
||||
else if (typeof deep === 'boolean') {
|
||||
recurseDepth = deep ? Infinity : 0;
|
||||
}
|
||||
else if (typeof deep === 'number') {
|
||||
if (deep < 0 || isNaN(deep)) {
|
||||
throw new Error('options.deep must be a positive number');
|
||||
}
|
||||
else if (Math.floor(deep) !== deep) {
|
||||
throw new Error('options.deep must be an integer');
|
||||
}
|
||||
else {
|
||||
recurseDepth = deep;
|
||||
}
|
||||
}
|
||||
else if (typeof deep === 'function') {
|
||||
recurseDepth = Infinity;
|
||||
recurseFn = deep;
|
||||
}
|
||||
else if (deep instanceof RegExp) {
|
||||
recurseDepth = Infinity;
|
||||
recurseRegExp = deep;
|
||||
}
|
||||
else if (typeof deep === 'string' && deep.length > 0) {
|
||||
recurseDepth = Infinity;
|
||||
recurseGlob = globToRegExp(deep, { extended: true, globstar: true });
|
||||
}
|
||||
else {
|
||||
throw new TypeError('options.deep must be a boolean, number, function, regular expression, or glob pattern');
|
||||
}
|
||||
|
||||
let filterFn, filterRegExp, filterGlob, filter = options.filter;
|
||||
if (filter !== null && filter !== undefined) {
|
||||
if (typeof filter === 'function') {
|
||||
filterFn = filter;
|
||||
}
|
||||
else if (filter instanceof RegExp) {
|
||||
filterRegExp = filter;
|
||||
}
|
||||
else if (typeof filter === 'string' && filter.length > 0) {
|
||||
filterGlob = globToRegExp(filter, { extended: true, globstar: true });
|
||||
}
|
||||
else {
|
||||
throw new TypeError('options.filter must be a function, regular expression, or glob pattern');
|
||||
}
|
||||
}
|
||||
|
||||
let sep = options.sep;
|
||||
if (sep === null || sep === undefined) {
|
||||
sep = path.sep;
|
||||
}
|
||||
else if (typeof sep !== 'string') {
|
||||
throw new TypeError('options.sep must be a string');
|
||||
}
|
||||
|
||||
let basePath = options.basePath;
|
||||
if (basePath === null || basePath === undefined) {
|
||||
basePath = '';
|
||||
}
|
||||
else if (typeof basePath === 'string') {
|
||||
// Append a path separator to the basePath, if necessary
|
||||
if (basePath && basePath.substr(-1) !== sep) {
|
||||
basePath += sep;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new TypeError('options.basePath must be a string');
|
||||
}
|
||||
|
||||
// Convert the basePath to POSIX (forward slashes)
|
||||
// so that glob pattern matching works consistently, even on Windows
|
||||
let posixBasePath = basePath;
|
||||
if (posixBasePath && sep !== '/') {
|
||||
posixBasePath = posixBasePath.replace(new RegExp('\\' + sep, 'g'), '/');
|
||||
|
||||
/* istanbul ignore if */
|
||||
if (isWindows) {
|
||||
// Convert Windows root paths (C:\) and UNCs (\\) to POSIX root paths
|
||||
posixBasePath = posixBasePath.replace(/^([a-zA-Z]\:\/|\/\/)/, '/');
|
||||
}
|
||||
}
|
||||
|
||||
// Determine which facade methods to use
|
||||
let facade;
|
||||
if (options.fs === null || options.fs === undefined) {
|
||||
// The user didn't provide their own facades, so use our internal ones
|
||||
facade = internalOptions.facade;
|
||||
}
|
||||
else if (typeof options.fs === 'object') {
|
||||
// Merge the internal facade methods with the user-provided `fs` facades
|
||||
facade = Object.assign({}, internalOptions.facade);
|
||||
facade.fs = Object.assign({}, internalOptions.facade.fs, options.fs);
|
||||
}
|
||||
else {
|
||||
throw new TypeError('options.fs must be an object');
|
||||
}
|
||||
|
||||
return {
|
||||
recurseDepth,
|
||||
recurseFn,
|
||||
recurseRegExp,
|
||||
recurseGlob,
|
||||
filterFn,
|
||||
filterRegExp,
|
||||
filterGlob,
|
||||
sep,
|
||||
basePath,
|
||||
posixBasePath,
|
||||
facade,
|
||||
emit: !!internalOptions.emit,
|
||||
stats: !!internalOptions.stats,
|
||||
};
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
'use strict';
|
||||
|
||||
const call = require('./call');
|
||||
|
||||
module.exports = stat;
|
||||
|
||||
/**
|
||||
* Retrieves the {@link fs.Stats} for the given path. If the path is a symbolic link,
|
||||
* then the Stats of the symlink's target are returned instead. If the symlink is broken,
|
||||
* then the Stats of the symlink itself are returned.
|
||||
*
|
||||
* @param {object} fs - Synchronous or Asynchronouse facade for the "fs" module
|
||||
* @param {string} path - The path to return stats for
|
||||
* @param {function} callback
|
||||
*/
|
||||
function stat (fs, path, callback) {
|
||||
let isSymLink = false;
|
||||
|
||||
call.safe(fs.lstat, path, (err, lstats) => {
|
||||
if (err) {
|
||||
// fs.lstat threw an eror
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
try {
|
||||
isSymLink = lstats.isSymbolicLink();
|
||||
}
|
||||
catch (err2) {
|
||||
// lstats.isSymbolicLink() threw an error
|
||||
// (probably because fs.lstat returned an invalid result)
|
||||
return callback(err2);
|
||||
}
|
||||
|
||||
if (isSymLink) {
|
||||
// Try to resolve the symlink
|
||||
symlinkStat(fs, path, lstats, callback);
|
||||
}
|
||||
else {
|
||||
// It's not a symlink, so return the stats as-is
|
||||
callback(null, lstats);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the {@link fs.Stats} for the target of the given symlink.
|
||||
* If the symlink is broken, then the Stats of the symlink itself are returned.
|
||||
*
|
||||
* @param {object} fs - Synchronous or Asynchronouse facade for the "fs" module
|
||||
* @param {string} path - The path of the symlink to return stats for
|
||||
* @param {object} lstats - The stats of the symlink
|
||||
* @param {function} callback
|
||||
*/
|
||||
function symlinkStat (fs, path, lstats, callback) {
|
||||
call.safe(fs.stat, path, (err, stats) => {
|
||||
if (err) {
|
||||
// The symlink is broken, so return the stats for the link itself
|
||||
return callback(null, lstats);
|
||||
}
|
||||
|
||||
try {
|
||||
// Return the stats for the resolved symlink target,
|
||||
// and override the `isSymbolicLink` method to indicate that it's a symlink
|
||||
stats.isSymbolicLink = () => true;
|
||||
}
|
||||
catch (err2) {
|
||||
// Setting stats.isSymbolicLink threw an error
|
||||
// (probably because fs.stat returned an invalid result)
|
||||
return callback(err2);
|
||||
}
|
||||
|
||||
callback(null, stats);
|
||||
});
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = readdirStream;
|
||||
|
||||
const DirectoryReader = require('../directory-reader');
|
||||
|
||||
let streamFacade = {
|
||||
fs: require('fs'),
|
||||
forEach: require('../async/for-each'),
|
||||
async: true
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the {@link stream.Readable} of an asynchronous {@link DirectoryReader}.
|
||||
*
|
||||
* @param {string} dir
|
||||
* @param {object} [options]
|
||||
* @param {object} internalOptions
|
||||
*/
|
||||
function readdirStream (dir, options, internalOptions) {
|
||||
internalOptions.facade = streamFacade;
|
||||
|
||||
let reader = new DirectoryReader(dir, options, internalOptions);
|
||||
return reader.stream;
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = syncForEach;
|
||||
|
||||
/**
|
||||
* A facade that allows {@link Array.forEach} to be called as though it were asynchronous.
|
||||
*
|
||||
* @param {array} array - The array to iterate over
|
||||
* @param {function} iterator - The function to call for each item in the array
|
||||
* @param {function} done - The function to call when all iterators have completed
|
||||
*/
|
||||
function syncForEach (array, iterator, done) {
|
||||
array.forEach(item => {
|
||||
iterator(item, () => {
|
||||
// Note: No error-handling here because this is currently only ever called
|
||||
// by DirectoryReader, which never passes an `error` parameter to the callback.
|
||||
// Instead, DirectoryReader emits an "error" event if an error occurs.
|
||||
});
|
||||
});
|
||||
|
||||
done();
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const call = require('../call');
|
||||
|
||||
/**
|
||||
* A facade around {@link fs.readdirSync} that allows it to be called
|
||||
* the same way as {@link fs.readdir}.
|
||||
*
|
||||
* @param {string} dir
|
||||
* @param {function} callback
|
||||
*/
|
||||
exports.readdir = function (dir, callback) {
|
||||
// Make sure the callback is only called once
|
||||
callback = call.once(callback);
|
||||
|
||||
try {
|
||||
let items = fs.readdirSync(dir);
|
||||
callback(null, items);
|
||||
}
|
||||
catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A facade around {@link fs.statSync} that allows it to be called
|
||||
* the same way as {@link fs.stat}.
|
||||
*
|
||||
* @param {string} path
|
||||
* @param {function} callback
|
||||
*/
|
||||
exports.stat = function (path, callback) {
|
||||
// Make sure the callback is only called once
|
||||
callback = call.once(callback);
|
||||
|
||||
try {
|
||||
let stats = fs.statSync(path);
|
||||
callback(null, stats);
|
||||
}
|
||||
catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A facade around {@link fs.lstatSync} that allows it to be called
|
||||
* the same way as {@link fs.lstat}.
|
||||
*
|
||||
* @param {string} path
|
||||
* @param {function} callback
|
||||
*/
|
||||
exports.lstat = function (path, callback) {
|
||||
// Make sure the callback is only called once
|
||||
callback = call.once(callback);
|
||||
|
||||
try {
|
||||
let stats = fs.lstatSync(path);
|
||||
callback(null, stats);
|
||||
}
|
||||
catch (err) {
|
||||
callback(err);
|
||||
}
|
||||
};
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = readdirSync;
|
||||
|
||||
const DirectoryReader = require('../directory-reader');
|
||||
|
||||
let syncFacade = {
|
||||
fs: require('./fs'),
|
||||
forEach: require('./for-each'),
|
||||
sync: true
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the buffered output from a synchronous {@link DirectoryReader}.
|
||||
*
|
||||
* @param {string} dir
|
||||
* @param {object} [options]
|
||||
* @param {object} internalOptions
|
||||
*/
|
||||
function readdirSync (dir, options, internalOptions) {
|
||||
internalOptions.facade = syncFacade;
|
||||
|
||||
let reader = new DirectoryReader(dir, options, internalOptions);
|
||||
let stream = reader.stream;
|
||||
|
||||
let results = [];
|
||||
let data = stream.read();
|
||||
while (data !== null) {
|
||||
results.push(data);
|
||||
data = stream.read();
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "@mrmlnc/readdir-enhanced",
|
||||
"version": "2.2.1",
|
||||
"description": "fs.readdir with sync, async, and streaming APIs + filtering, recursion, absolute paths, etc.",
|
||||
"keywords": [
|
||||
"fs",
|
||||
"readdir",
|
||||
"stream",
|
||||
"event",
|
||||
"recursive",
|
||||
"deep",
|
||||
"filter",
|
||||
"absolute"
|
||||
],
|
||||
"author": {
|
||||
"name": "James Messinger",
|
||||
"url": "http://bigstickcarpet.com"
|
||||
},
|
||||
"homepage": "https://github.com/bigstickcarpet/readdir-enhanced",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bigstickcarpet/readdir-enhanced.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"typings": "types.d.ts",
|
||||
"files": [
|
||||
"lib",
|
||||
"types.d.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint lib test --fix",
|
||||
"test": "mocha && npm run lint",
|
||||
"cover": "istanbul cover _mocha",
|
||||
"upgrade": "npm-check -u",
|
||||
"bump": "bump --prompt --tag --push --all",
|
||||
"release": "npm run upgrade && npm test && npm run bump && npm publish"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.1.2",
|
||||
"codacy-coverage": "^2.0.3",
|
||||
"coveralls": "^3.0.0",
|
||||
"del": "^3.0.0",
|
||||
"eslint": "^4.15.0",
|
||||
"eslint-config-modular": "^4.1.1",
|
||||
"istanbul": "^0.4.5",
|
||||
"mkdirp": "^0.5.1",
|
||||
"mocha": "^4.1.0",
|
||||
"npm-check": "^5.5.2",
|
||||
"through2": "^2.0.3",
|
||||
"version-bump-prompt": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"call-me-maybe": "^1.0.1",
|
||||
"glob-to-regexp": "^0.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import fs = require('fs');
|
||||
|
||||
declare namespace re {
|
||||
interface Entry extends fs.Stats {
|
||||
path: string;
|
||||
depth: number;
|
||||
}
|
||||
|
||||
type FilterFunction = (stat: Entry) => boolean;
|
||||
type Callback<T> = (err: NodeJS.ErrnoException, result: T) => void;
|
||||
type CallbackString = Callback<string[]>;
|
||||
type CallbackEntry = Callback<Entry[]>;
|
||||
|
||||
interface FileSystem {
|
||||
readdir?: (path: string, callback: Callback<string[]>) => void;
|
||||
lstat?: (path: string, callback: Callback<fs.Stats>) => void;
|
||||
stat?: (path: string, callback: Callback<fs.Stats>) => void;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
filter?: string | RegExp | FilterFunction;
|
||||
deep?: boolean | number | RegExp | FilterFunction;
|
||||
sep?: string;
|
||||
basePath?: string;
|
||||
fs?: FileSystem;
|
||||
}
|
||||
|
||||
function stat(root: string, options?: Options): Promise<Entry[]>;
|
||||
function stat(root: string, callback: CallbackEntry): void;
|
||||
function stat(root: string, options: Options, callback: CallbackEntry): void;
|
||||
|
||||
function async(root: string, options?: Options): Promise<string[]>;
|
||||
function async(root: string, callback: CallbackString): void;
|
||||
function async(root: string, options: Options, callback: CallbackString): void;
|
||||
|
||||
function readdirAsyncStat(root: string, options?: Options): Promise<Entry[]>;
|
||||
function readdirAsyncStat(root: string, callback: CallbackEntry): void;
|
||||
function readdirAsyncStat(root: string, options: Options, callback: CallbackEntry): void;
|
||||
|
||||
namespace async {
|
||||
function stat(root: string, options?: Options): Promise<Entry[]>;
|
||||
function stat(root: string, callback: CallbackEntry): void;
|
||||
function stat(root: string, options: Options, callback: CallbackEntry): void;
|
||||
}
|
||||
|
||||
function stream(root: string, options?: Options): NodeJS.ReadableStream;
|
||||
function readdirStreamStat(root: string, options?: Options): NodeJS.ReadableStream;
|
||||
|
||||
namespace stream {
|
||||
function stat(root: string, options?: Options): NodeJS.ReadableStream;
|
||||
}
|
||||
|
||||
function sync(root: string, options?: Options): string[];
|
||||
function readdirSyncStat(root: string, options?: Options): Entry[];
|
||||
|
||||
namespace sync {
|
||||
function stat(root: string, options?: Options): Entry[];
|
||||
}
|
||||
}
|
||||
|
||||
declare function re(root: string, options?: re.Options): Promise<string[]>;
|
||||
declare function re(root: string, callback: re.CallbackString): void;
|
||||
declare function re(root: string, options: re.Options, callback: re.CallbackString): void;
|
||||
|
||||
export = re;
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
# @nodelib/fs.stat
|
||||
|
||||
> Get the status of a file with some features.
|
||||
|
||||
## :bulb: Highlights
|
||||
|
||||
Wrapper over standard methods ([`fs.lstat`](https://nodejs.org/dist/latest/docs/api/fs.html#fs_fs_lstat_path_callback), [`fs.stat`](https://nodejs.org/dist/latest/docs/api/fs.html#fs_fs_stat_path_callback)) with some features.
|
||||
|
||||
* :beginner: Normally follows symlinks.
|
||||
* :gear: Can safely work with broken symlinks (returns information about symlink instead of generating an error).
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install @nodelib/fs.stat
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const fsStat = require('@nodelib/fs.stat');
|
||||
|
||||
fsStat.stat('path').then((stat) => {
|
||||
console.log(stat); // => fs.Stats
|
||||
});
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### fsStat.stat(path, [options])
|
||||
|
||||
Returns a [`Promise<fs.Stats>`](https://nodejs.org/dist/latest/docs/api/fs.html#fs_class_fs_stats) for provided path.
|
||||
|
||||
### fsStat.statSync(path, [options])
|
||||
|
||||
Returns a [`fs.Stats`](https://nodejs.org/dist/latest/docs/api/fs.html#fs_class_fs_stats) for provided path.
|
||||
|
||||
### fsStat.statCallback(path, [options], callback)
|
||||
|
||||
Returns a [`fs.Stats`](https://nodejs.org/dist/latest/docs/api/fs.html#fs_class_fs_stats) for provided path with standard callback-style.
|
||||
|
||||
#### path
|
||||
|
||||
* Type: `string | Buffer | URL`
|
||||
|
||||
The `path` argument for [`fs.lstat`](https://nodejs.org/dist/latest/docs/api/fs.html#fs_fs_lstat_path_callback) or [`fs.stat`](https://nodejs.org/dist/latest/docs/api/fs.html#fs_fs_stat_path_callback) method.
|
||||
|
||||
#### options
|
||||
|
||||
* Type: `Object`
|
||||
|
||||
See [options](#options-1) section for more detailed information.
|
||||
|
||||
## Options
|
||||
|
||||
### throwErrorOnBrokenSymlinks
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `true`
|
||||
|
||||
Throw an error or return information about symlink, when symlink is broken. When `false`, methods will be return lstat call for broken symlinks.
|
||||
|
||||
### followSymlinks
|
||||
|
||||
* Type: `boolean`
|
||||
* Default: `true`
|
||||
|
||||
By default, the methods of this package follows symlinks. If you do not want it, set this option to `false` or use the standard method [`fs.lstat`](https://nodejs.org/dist/latest/docs/api/fs.html#fs_fs_lstat_path_callback).
|
||||
|
||||
### fs
|
||||
|
||||
* Type: `FileSystemAdapter`
|
||||
* Default: `built-in FS methods`
|
||||
|
||||
By default, the built-in Node.js module (`fs`) is used to work with the file system. You can replace each method with your own.
|
||||
|
||||
```ts
|
||||
interface FileSystemAdapter {
|
||||
lstat?: typeof fs.lstat;
|
||||
stat?: typeof fs.stat;
|
||||
lstatSync?: typeof fs.lstatSync;
|
||||
statSync?: typeof fs.statSync;
|
||||
}
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
See the [Releases section of our GitHub project](https://github.com/nodelib/nodelib/releases) for changelogs for each release version.
|
||||
|
||||
## License
|
||||
|
||||
This software is released under the terms of the MIT license.
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/// <reference types="node" />
|
||||
import * as fs from 'fs';
|
||||
export interface FileSystemAdapter {
|
||||
lstat: typeof fs.lstat;
|
||||
stat: typeof fs.stat;
|
||||
lstatSync: typeof fs.lstatSync;
|
||||
statSync: typeof fs.statSync;
|
||||
}
|
||||
export declare const FILE_SYSTEM_ADAPTER: FileSystemAdapter;
|
||||
export declare function getFileSystemAdapter(fsMethods?: Partial<FileSystemAdapter>): FileSystemAdapter;
|
||||
//# sourceMappingURL=fs.d.ts.map
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = require("fs");
|
||||
exports.FILE_SYSTEM_ADAPTER = {
|
||||
lstat: fs.lstat,
|
||||
stat: fs.stat,
|
||||
lstatSync: fs.lstatSync,
|
||||
statSync: fs.statSync
|
||||
};
|
||||
function getFileSystemAdapter(fsMethods) {
|
||||
if (!fsMethods) {
|
||||
return exports.FILE_SYSTEM_ADAPTER;
|
||||
}
|
||||
return Object.assign({}, exports.FILE_SYSTEM_ADAPTER, fsMethods);
|
||||
}
|
||||
exports.getFileSystemAdapter = getFileSystemAdapter;
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/// <reference types="node" />
|
||||
import * as fs from 'fs';
|
||||
import { FileSystemAdapter } from './adapters/fs';
|
||||
import { Options } from './managers/options';
|
||||
import { AsyncCallback } from './providers/stat';
|
||||
/**
|
||||
* Asynchronous API.
|
||||
*/
|
||||
export declare function stat(path: fs.PathLike, opts?: Options): Promise<fs.Stats>;
|
||||
/**
|
||||
* Callback API.
|
||||
*/
|
||||
export declare function statCallback(path: fs.PathLike, callback: AsyncCallback): void;
|
||||
export declare function statCallback(path: fs.PathLike, opts: Options, callback: AsyncCallback): void;
|
||||
/**
|
||||
* Synchronous API.
|
||||
*/
|
||||
export declare function statSync(path: fs.PathLike, opts?: Options): fs.Stats;
|
||||
export declare type Options = Options;
|
||||
export declare type StatAsyncCallback = AsyncCallback;
|
||||
export declare type FileSystemAdapter = FileSystemAdapter;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const optionsManager = require("./managers/options");
|
||||
const statProvider = require("./providers/stat");
|
||||
/**
|
||||
* Asynchronous API.
|
||||
*/
|
||||
function stat(path, opts) {
|
||||
return new Promise((resolve, reject) => {
|
||||
statProvider.async(path, optionsManager.prepare(opts), (err, stats) => err ? reject(err) : resolve(stats));
|
||||
});
|
||||
}
|
||||
exports.stat = stat;
|
||||
function statCallback(path, optsOrCallback, callback) {
|
||||
if (typeof optsOrCallback === 'function') {
|
||||
callback = optsOrCallback; /* tslint:disable-line: no-parameter-reassignment */
|
||||
optsOrCallback = undefined; /* tslint:disable-line: no-parameter-reassignment */
|
||||
}
|
||||
if (typeof callback === 'undefined') {
|
||||
throw new TypeError('The "callback" argument must be of type Function.');
|
||||
}
|
||||
statProvider.async(path, optionsManager.prepare(optsOrCallback), callback);
|
||||
}
|
||||
exports.statCallback = statCallback;
|
||||
/**
|
||||
* Synchronous API.
|
||||
*/
|
||||
function statSync(path, opts) {
|
||||
return statProvider.sync(path, optionsManager.prepare(opts));
|
||||
}
|
||||
exports.statSync = statSync;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { FileSystemAdapter } from '../adapters/fs';
|
||||
export interface Options {
|
||||
fs?: Partial<FileSystemAdapter>;
|
||||
throwErrorOnBrokenSymlinks?: boolean;
|
||||
followSymlinks?: boolean;
|
||||
}
|
||||
export declare type StrictOptions = {
|
||||
fs: FileSystemAdapter;
|
||||
} & Required<Options>;
|
||||
export declare function prepare(opts?: Options): StrictOptions;
|
||||
//# sourceMappingURL=options.d.ts.map
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fsAdapter = require("../adapters/fs");
|
||||
function prepare(opts) {
|
||||
const options = Object.assign({
|
||||
fs: fsAdapter.getFileSystemAdapter(opts ? opts.fs : undefined),
|
||||
throwErrorOnBrokenSymlinks: true,
|
||||
followSymlinks: true
|
||||
}, opts);
|
||||
return options;
|
||||
}
|
||||
exports.prepare = prepare;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/// <reference types="node" />
|
||||
import * as fs from 'fs';
|
||||
import { StrictOptions } from '../managers/options';
|
||||
export declare function sync(path: fs.PathLike, options: StrictOptions): fs.Stats;
|
||||
export declare type AsyncCallback = (err: NodeJS.ErrnoException | null, stats?: fs.Stats) => void;
|
||||
export declare function async(path: fs.PathLike, options: StrictOptions, callback: AsyncCallback): void;
|
||||
/**
|
||||
* Returns `true` for followed symlink.
|
||||
*/
|
||||
export declare function isFollowedSymlink(stat: fs.Stats, options: StrictOptions): boolean;
|
||||
//# sourceMappingURL=stat.d.ts.map
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function sync(path, options) {
|
||||
const lstat = options.fs.lstatSync(path);
|
||||
if (!isFollowedSymlink(lstat, options)) {
|
||||
return lstat;
|
||||
}
|
||||
try {
|
||||
const stat = options.fs.statSync(path);
|
||||
stat.isSymbolicLink = () => true;
|
||||
return stat;
|
||||
}
|
||||
catch (err) {
|
||||
if (!options.throwErrorOnBrokenSymlinks) {
|
||||
return lstat;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
exports.sync = sync;
|
||||
function async(path, options, callback) {
|
||||
options.fs.lstat(path, (err0, lstat) => {
|
||||
if (err0) {
|
||||
return callback(err0, undefined);
|
||||
}
|
||||
if (!isFollowedSymlink(lstat, options)) {
|
||||
return callback(null, lstat);
|
||||
}
|
||||
options.fs.stat(path, (err1, stat) => {
|
||||
if (err1) {
|
||||
return options.throwErrorOnBrokenSymlinks ? callback(err1) : callback(null, lstat);
|
||||
}
|
||||
stat.isSymbolicLink = () => true;
|
||||
callback(null, stat);
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.async = async;
|
||||
/**
|
||||
* Returns `true` for followed symlink.
|
||||
*/
|
||||
function isFollowedSymlink(stat, options) {
|
||||
return stat.isSymbolicLink() && options.followSymlinks;
|
||||
}
|
||||
exports.isFollowedSymlink = isFollowedSymlink;
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "@nodelib/fs.stat",
|
||||
"version": "1.1.3",
|
||||
"description": "Get the status of a file with some features",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.stat",
|
||||
"keywords": [
|
||||
"NodeLib",
|
||||
"fs",
|
||||
"FileSystem",
|
||||
"file system",
|
||||
"stat"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
},
|
||||
"main": "out/index.js",
|
||||
"typings": "out/index.d.ts",
|
||||
"scripts": {
|
||||
"clean": "rimraf out",
|
||||
"lint": "tslint \"src/**/*.ts\" -p . -t stylish",
|
||||
"compile": "tsc -b .",
|
||||
"compile:watch": "tsc -p . --watch --sourceMap",
|
||||
"test": "mocha \"out/**/*.spec.js\" -s 0",
|
||||
"build": "npm run clean && npm run lint && npm run compile && npm test",
|
||||
"watch": "npm run clean && npm run compile:watch"
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = () => {
|
||||
const pattern = [
|
||||
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)',
|
||||
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))'
|
||||
].join('|');
|
||||
|
||||
return new RegExp(pattern, 'g');
|
||||
};
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "ansi-regex",
|
||||
"version": "3.0.0",
|
||||
"description": "Regular expression for matching ANSI escape codes",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/ansi-regex",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava",
|
||||
"view-supported": "node fixtures/view-codes.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"styles",
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"tty",
|
||||
"escape",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"command-line",
|
||||
"text",
|
||||
"regex",
|
||||
"regexp",
|
||||
"re",
|
||||
"match",
|
||||
"test",
|
||||
"find",
|
||||
"pattern"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
# ansi-regex [](https://travis-ci.org/chalk/ansi-regex)
|
||||
|
||||
> Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install ansi-regex
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const ansiRegex = require('ansi-regex');
|
||||
|
||||
ansiRegex().test('\u001B[4mcake\u001B[0m');
|
||||
//=> true
|
||||
|
||||
ansiRegex().test('cake');
|
||||
//=> false
|
||||
|
||||
'\u001B[4mcake\u001B[0m'.match(ansiRegex());
|
||||
//=> ['\u001B[4m', '\u001B[0m']
|
||||
```
|
||||
|
||||
|
||||
## FAQ
|
||||
|
||||
### Why do you test for codes not in the ECMA 48 standard?
|
||||
|
||||
Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. We test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them.
|
||||
|
||||
On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out.
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
'use strict';
|
||||
const colorConvert = require('color-convert');
|
||||
|
||||
const wrapAnsi16 = (fn, offset) => function () {
|
||||
const code = fn.apply(colorConvert, arguments);
|
||||
return `\u001B[${code + offset}m`;
|
||||
};
|
||||
|
||||
const wrapAnsi256 = (fn, offset) => function () {
|
||||
const code = fn.apply(colorConvert, arguments);
|
||||
return `\u001B[${38 + offset};5;${code}m`;
|
||||
};
|
||||
|
||||
const wrapAnsi16m = (fn, offset) => function () {
|
||||
const rgb = fn.apply(colorConvert, arguments);
|
||||
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
||||
};
|
||||
|
||||
function assembleStyles() {
|
||||
const codes = new Map();
|
||||
const styles = {
|
||||
modifier: {
|
||||
reset: [0, 0],
|
||||
// 21 isn't widely supported and 22 does the same thing
|
||||
bold: [1, 22],
|
||||
dim: [2, 22],
|
||||
italic: [3, 23],
|
||||
underline: [4, 24],
|
||||
inverse: [7, 27],
|
||||
hidden: [8, 28],
|
||||
strikethrough: [9, 29]
|
||||
},
|
||||
color: {
|
||||
black: [30, 39],
|
||||
red: [31, 39],
|
||||
green: [32, 39],
|
||||
yellow: [33, 39],
|
||||
blue: [34, 39],
|
||||
magenta: [35, 39],
|
||||
cyan: [36, 39],
|
||||
white: [37, 39],
|
||||
gray: [90, 39],
|
||||
|
||||
// Bright color
|
||||
redBright: [91, 39],
|
||||
greenBright: [92, 39],
|
||||
yellowBright: [93, 39],
|
||||
blueBright: [94, 39],
|
||||
magentaBright: [95, 39],
|
||||
cyanBright: [96, 39],
|
||||
whiteBright: [97, 39]
|
||||
},
|
||||
bgColor: {
|
||||
bgBlack: [40, 49],
|
||||
bgRed: [41, 49],
|
||||
bgGreen: [42, 49],
|
||||
bgYellow: [43, 49],
|
||||
bgBlue: [44, 49],
|
||||
bgMagenta: [45, 49],
|
||||
bgCyan: [46, 49],
|
||||
bgWhite: [47, 49],
|
||||
|
||||
// Bright color
|
||||
bgBlackBright: [100, 49],
|
||||
bgRedBright: [101, 49],
|
||||
bgGreenBright: [102, 49],
|
||||
bgYellowBright: [103, 49],
|
||||
bgBlueBright: [104, 49],
|
||||
bgMagentaBright: [105, 49],
|
||||
bgCyanBright: [106, 49],
|
||||
bgWhiteBright: [107, 49]
|
||||
}
|
||||
};
|
||||
|
||||
// Fix humans
|
||||
styles.color.grey = styles.color.gray;
|
||||
|
||||
for (const groupName of Object.keys(styles)) {
|
||||
const group = styles[groupName];
|
||||
|
||||
for (const styleName of Object.keys(group)) {
|
||||
const style = group[styleName];
|
||||
|
||||
styles[styleName] = {
|
||||
open: `\u001B[${style[0]}m`,
|
||||
close: `\u001B[${style[1]}m`
|
||||
};
|
||||
|
||||
group[styleName] = styles[styleName];
|
||||
|
||||
codes.set(style[0], style[1]);
|
||||
}
|
||||
|
||||
Object.defineProperty(styles, groupName, {
|
||||
value: group,
|
||||
enumerable: false
|
||||
});
|
||||
|
||||
Object.defineProperty(styles, 'codes', {
|
||||
value: codes,
|
||||
enumerable: false
|
||||
});
|
||||
}
|
||||
|
||||
const ansi2ansi = n => n;
|
||||
const rgb2rgb = (r, g, b) => [r, g, b];
|
||||
|
||||
styles.color.close = '\u001B[39m';
|
||||
styles.bgColor.close = '\u001B[49m';
|
||||
|
||||
styles.color.ansi = {
|
||||
ansi: wrapAnsi16(ansi2ansi, 0)
|
||||
};
|
||||
styles.color.ansi256 = {
|
||||
ansi256: wrapAnsi256(ansi2ansi, 0)
|
||||
};
|
||||
styles.color.ansi16m = {
|
||||
rgb: wrapAnsi16m(rgb2rgb, 0)
|
||||
};
|
||||
|
||||
styles.bgColor.ansi = {
|
||||
ansi: wrapAnsi16(ansi2ansi, 10)
|
||||
};
|
||||
styles.bgColor.ansi256 = {
|
||||
ansi256: wrapAnsi256(ansi2ansi, 10)
|
||||
};
|
||||
styles.bgColor.ansi16m = {
|
||||
rgb: wrapAnsi16m(rgb2rgb, 10)
|
||||
};
|
||||
|
||||
for (let key of Object.keys(colorConvert)) {
|
||||
if (typeof colorConvert[key] !== 'object') {
|
||||
continue;
|
||||
}
|
||||
|
||||
const suite = colorConvert[key];
|
||||
|
||||
if (key === 'ansi16') {
|
||||
key = 'ansi';
|
||||
}
|
||||
|
||||
if ('ansi16' in suite) {
|
||||
styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
|
||||
styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
|
||||
}
|
||||
|
||||
if ('ansi256' in suite) {
|
||||
styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
|
||||
styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
|
||||
}
|
||||
|
||||
if ('rgb' in suite) {
|
||||
styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
|
||||
styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
|
||||
}
|
||||
}
|
||||
|
||||
return styles;
|
||||
}
|
||||
|
||||
// Make the export immutable
|
||||
Object.defineProperty(module, 'exports', {
|
||||
enumerable: true,
|
||||
get: assembleStyles
|
||||
});
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"name": "ansi-styles",
|
||||
"version": "3.2.1",
|
||||
"description": "ANSI escape codes for styling strings in the terminal",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/ansi-styles",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava",
|
||||
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"styles",
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"tty",
|
||||
"escape",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"dependencies": {
|
||||
"color-convert": "^1.9.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"babel-polyfill": "^6.23.0",
|
||||
"svg-term-cli": "^2.1.1",
|
||||
"xo": "*"
|
||||
},
|
||||
"ava": {
|
||||
"require": "babel-polyfill"
|
||||
}
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
# ansi-styles [](https://travis-ci.org/chalk/ansi-styles)
|
||||
|
||||
> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
|
||||
|
||||
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
|
||||
|
||||
<img src="https://cdn.rawgit.com/chalk/ansi-styles/8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install ansi-styles
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const style = require('ansi-styles');
|
||||
|
||||
console.log(`${style.green.open}Hello world!${style.green.close}`);
|
||||
|
||||
|
||||
// Color conversion between 16/256/truecolor
|
||||
// NOTE: If conversion goes to 16 colors or 256 colors, the original color
|
||||
// may be degraded to fit that color palette. This means terminals
|
||||
// that do not support 16 million colors will best-match the
|
||||
// original color.
|
||||
console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
|
||||
console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
|
||||
console.log(style.color.ansi16m.hex('#ABCDEF') + 'Hello world!' + style.color.close);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
Each style has an `open` and `close` property.
|
||||
|
||||
|
||||
## Styles
|
||||
|
||||
### Modifiers
|
||||
|
||||
- `reset`
|
||||
- `bold`
|
||||
- `dim`
|
||||
- `italic` *(Not widely supported)*
|
||||
- `underline`
|
||||
- `inverse`
|
||||
- `hidden`
|
||||
- `strikethrough` *(Not widely supported)*
|
||||
|
||||
### Colors
|
||||
|
||||
- `black`
|
||||
- `red`
|
||||
- `green`
|
||||
- `yellow`
|
||||
- `blue`
|
||||
- `magenta`
|
||||
- `cyan`
|
||||
- `white`
|
||||
- `gray` ("bright black")
|
||||
- `redBright`
|
||||
- `greenBright`
|
||||
- `yellowBright`
|
||||
- `blueBright`
|
||||
- `magentaBright`
|
||||
- `cyanBright`
|
||||
- `whiteBright`
|
||||
|
||||
### Background colors
|
||||
|
||||
- `bgBlack`
|
||||
- `bgRed`
|
||||
- `bgGreen`
|
||||
- `bgYellow`
|
||||
- `bgBlue`
|
||||
- `bgMagenta`
|
||||
- `bgCyan`
|
||||
- `bgWhite`
|
||||
- `bgBlackBright`
|
||||
- `bgRedBright`
|
||||
- `bgGreenBright`
|
||||
- `bgYellowBright`
|
||||
- `bgBlueBright`
|
||||
- `bgMagentaBright`
|
||||
- `bgCyanBright`
|
||||
- `bgWhiteBright`
|
||||
|
||||
|
||||
## Advanced usage
|
||||
|
||||
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
|
||||
|
||||
- `style.modifier`
|
||||
- `style.color`
|
||||
- `style.bgColor`
|
||||
|
||||
###### Example
|
||||
|
||||
```js
|
||||
console.log(style.color.green.open);
|
||||
```
|
||||
|
||||
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
|
||||
|
||||
###### Example
|
||||
|
||||
```js
|
||||
console.log(style.codes.get(36));
|
||||
//=> 39
|
||||
```
|
||||
|
||||
|
||||
## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
|
||||
|
||||
`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
|
||||
|
||||
To use these, call the associated conversion function with the intended output, for example:
|
||||
|
||||
```js
|
||||
style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
|
||||
style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
|
||||
|
||||
style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
|
||||
style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
|
||||
|
||||
style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
|
||||
style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017, Jon Schlinkert
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
# arr-diff [](https://www.npmjs.com/package/arr-diff) [](https://npmjs.org/package/arr-diff) [](https://travis-ci.org/jonschlinkert/arr-diff)
|
||||
|
||||
> Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save arr-diff
|
||||
```
|
||||
|
||||
Install with [yarn](https://yarnpkg.com):
|
||||
|
||||
```sh
|
||||
$ yarn add arr-diff
|
||||
```
|
||||
|
||||
Install with [bower](https://bower.io/)
|
||||
|
||||
```sh
|
||||
$ bower install arr-diff --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Returns the difference between the first array and additional arrays.
|
||||
|
||||
```js
|
||||
var diff = require('arr-diff');
|
||||
|
||||
var a = ['a', 'b', 'c', 'd'];
|
||||
var b = ['b', 'c'];
|
||||
|
||||
console.log(diff(a, b))
|
||||
//=> ['a', 'd']
|
||||
```
|
||||
|
||||
## Benchmarks
|
||||
|
||||
This library versus [array-differ](https://github.com/sindresorhus/array-differ), on April 14, 2017:
|
||||
|
||||
```
|
||||
Benchmarking: (4 of 4)
|
||||
· long-dupes
|
||||
· long
|
||||
· med
|
||||
· short
|
||||
|
||||
# benchmark/fixtures/long-dupes.js (100804 bytes)
|
||||
arr-diff-3.0.0 x 822 ops/sec ±0.67% (86 runs sampled)
|
||||
arr-diff-4.0.0 x 2,141 ops/sec ±0.42% (89 runs sampled)
|
||||
array-differ x 708 ops/sec ±0.70% (89 runs sampled)
|
||||
|
||||
fastest is arr-diff-4.0.0
|
||||
|
||||
# benchmark/fixtures/long.js (94529 bytes)
|
||||
arr-diff-3.0.0 x 882 ops/sec ±0.60% (87 runs sampled)
|
||||
arr-diff-4.0.0 x 2,329 ops/sec ±0.97% (83 runs sampled)
|
||||
array-differ x 769 ops/sec ±0.61% (90 runs sampled)
|
||||
|
||||
fastest is arr-diff-4.0.0
|
||||
|
||||
# benchmark/fixtures/med.js (708 bytes)
|
||||
arr-diff-3.0.0 x 856,150 ops/sec ±0.42% (89 runs sampled)
|
||||
arr-diff-4.0.0 x 4,665,249 ops/sec ±1.06% (89 runs sampled)
|
||||
array-differ x 653,888 ops/sec ±1.02% (86 runs sampled)
|
||||
|
||||
fastest is arr-diff-4.0.0
|
||||
|
||||
# benchmark/fixtures/short.js (60 bytes)
|
||||
arr-diff-3.0.0 x 3,078,467 ops/sec ±0.77% (93 runs sampled)
|
||||
arr-diff-4.0.0 x 9,213,296 ops/sec ±0.65% (89 runs sampled)
|
||||
array-differ x 1,337,051 ops/sec ±0.91% (92 runs sampled)
|
||||
|
||||
fastest is arr-diff-4.0.0
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [arr-flatten](https://www.npmjs.com/package/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | [homepage](https://github.com/jonschlinkert/arr-flatten "Recursively flatten an array or arrays. This is the fastest implementation of array flatten.")
|
||||
* [array-filter](https://www.npmjs.com/package/array-filter): Array#filter for older browsers. | [homepage](https://github.com/juliangruber/array-filter "Array#filter for older browsers.")
|
||||
* [array-intersection](https://www.npmjs.com/package/array-intersection): Return an array with the unique values present in _all_ given arrays using strict equality… [more](https://github.com/jonschlinkert/array-intersection) | [homepage](https://github.com/jonschlinkert/array-intersection "Return an array with the unique values present in _all_ given arrays using strict equality for comparisons.")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 33 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 2 | [paulmillr](https://github.com/paulmillr) |
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 14, 2017._
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*!
|
||||
* arr-diff <https://github.com/jonschlinkert/arr-diff>
|
||||
*
|
||||
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function diff(arr/*, arrays*/) {
|
||||
var len = arguments.length;
|
||||
var idx = 0;
|
||||
while (++idx < len) {
|
||||
arr = diffArray(arr, arguments[idx]);
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
function diffArray(one, two) {
|
||||
if (!Array.isArray(two)) {
|
||||
return one.slice();
|
||||
}
|
||||
|
||||
var tlen = two.length
|
||||
var olen = one.length;
|
||||
var idx = -1;
|
||||
var arr = [];
|
||||
|
||||
while (++idx < olen) {
|
||||
var ele = one[idx];
|
||||
|
||||
var hasEle = false;
|
||||
for (var i = 0; i < tlen; i++) {
|
||||
var val = two[i];
|
||||
|
||||
if (ele === val) {
|
||||
hasEle = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasEle === false) {
|
||||
arr.push(ele);
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"name": "arr-diff",
|
||||
"description": "Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons.",
|
||||
"version": "4.0.0",
|
||||
"homepage": "https://github.com/jonschlinkert/arr-diff",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)",
|
||||
"Paul Miller <paul+gh@paulmillr.com> (paulmillr.com)"
|
||||
],
|
||||
"repository": "jonschlinkert/arr-diff",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/arr-diff/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"ansi-bold": "^0.1.1",
|
||||
"arr-flatten": "^1.0.1",
|
||||
"array-differ": "^1.0.0",
|
||||
"benchmarked": "^0.2.4",
|
||||
"gulp-format-md": "^0.1.9",
|
||||
"minimist": "^1.2.0",
|
||||
"mocha": "^2.4.5"
|
||||
},
|
||||
"keywords": [
|
||||
"arr",
|
||||
"array",
|
||||
"array differ",
|
||||
"array-differ",
|
||||
"diff",
|
||||
"differ",
|
||||
"difference"
|
||||
],
|
||||
"verb": {
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"related": {
|
||||
"list": [
|
||||
"arr-flatten",
|
||||
"array-filter",
|
||||
"array-intersection"
|
||||
]
|
||||
},
|
||||
"reflinks": [
|
||||
"array-differ",
|
||||
"verb"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
# arr-flatten [](https://www.npmjs.com/package/arr-flatten) [](https://npmjs.org/package/arr-flatten) [](https://npmjs.org/package/arr-flatten) [](https://travis-ci.org/jonschlinkert/arr-flatten) [](https://ci.appveyor.com/project/jonschlinkert/arr-flatten)
|
||||
|
||||
> Recursively flatten an array or arrays.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save arr-flatten
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
Install with [bower](https://bower.io/)
|
||||
|
||||
```sh
|
||||
$ bower install arr-flatten --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var flatten = require('arr-flatten');
|
||||
|
||||
flatten(['a', ['b', ['c']], 'd', ['e']]);
|
||||
//=> ['a', 'b', 'c', 'd', 'e']
|
||||
```
|
||||
|
||||
## Why another flatten utility?
|
||||
|
||||
I wanted the fastest implementation I could find, with implementation choices that should work for 95% of use cases, but no cruft to cover the other 5%.
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [arr-filter](https://www.npmjs.com/package/arr-filter): Faster alternative to javascript's native filter method. | [homepage](https://github.com/jonschlinkert/arr-filter "Faster alternative to javascript's native filter method.")
|
||||
* [arr-union](https://www.npmjs.com/package/arr-union): Combines a list of arrays, returning a single array with unique values, using strict equality… [more](https://github.com/jonschlinkert/arr-union) | [homepage](https://github.com/jonschlinkert/arr-union "Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.")
|
||||
* [array-each](https://www.npmjs.com/package/array-each): Loop over each item in an array and call the given function on every element. | [homepage](https://github.com/jonschlinkert/array-each "Loop over each item in an array and call the given function on every element.")
|
||||
* [array-unique](https://www.npmjs.com/package/array-unique): Remove duplicate values from an array. Fastest ES5 implementation. | [homepage](https://github.com/jonschlinkert/array-unique "Remove duplicate values from an array. Fastest ES5 implementation.")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 20 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 1 | [lukeed](https://github.com/lukeed) |
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 05, 2017._
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/*!
|
||||
* arr-flatten <https://github.com/jonschlinkert/arr-flatten>
|
||||
*
|
||||
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function (arr) {
|
||||
return flat(arr, []);
|
||||
};
|
||||
|
||||
function flat(arr, res) {
|
||||
var i = 0, cur;
|
||||
var len = arr.length;
|
||||
for (; i < len; i++) {
|
||||
cur = arr[i];
|
||||
Array.isArray(cur) ? flat(cur, res) : res.push(cur);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"name": "arr-flatten",
|
||||
"description": "Recursively flatten an array or arrays.",
|
||||
"version": "1.1.0",
|
||||
"homepage": "https://github.com/jonschlinkert/arr-flatten",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"contributors": [
|
||||
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||
"Luke Edwards (https://lukeed.com)"
|
||||
],
|
||||
"repository": "jonschlinkert/arr-flatten",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/arr-flatten/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ansi-bold": "^0.1.1",
|
||||
"array-flatten": "^2.1.1",
|
||||
"array-slice": "^1.0.0",
|
||||
"benchmarked": "^1.0.0",
|
||||
"compute-flatten": "^1.0.0",
|
||||
"flatit": "^1.1.1",
|
||||
"flatten": "^1.0.2",
|
||||
"flatten-array": "^1.0.0",
|
||||
"glob": "^7.1.1",
|
||||
"gulp-format-md": "^0.1.12",
|
||||
"just-flatten-it": "^1.1.23",
|
||||
"lodash.flattendeep": "^4.4.0",
|
||||
"m_flattened": "^1.0.1",
|
||||
"mocha": "^3.2.0",
|
||||
"utils-flatten": "^1.0.0",
|
||||
"write": "^0.3.3"
|
||||
},
|
||||
"keywords": [
|
||||
"arr",
|
||||
"array",
|
||||
"elements",
|
||||
"flat",
|
||||
"flatten",
|
||||
"nested",
|
||||
"recurse",
|
||||
"recursive",
|
||||
"recursively"
|
||||
],
|
||||
"verb": {
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"related": {
|
||||
"list": [
|
||||
"arr-filter",
|
||||
"arr-union",
|
||||
"array-each",
|
||||
"array-unique"
|
||||
]
|
||||
},
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2016, Jon Schlinkert.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
# arr-union [](https://www.npmjs.com/package/arr-union) [](https://travis-ci.org/jonschlinkert/arr-union)
|
||||
|
||||
> Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm i arr-union --save
|
||||
```
|
||||
|
||||
## Benchmarks
|
||||
|
||||
This library is **10-20 times faster** and more performant than [array-union](https://github.com/sindresorhus/array-union).
|
||||
|
||||
See the [benchmarks](./benchmark).
|
||||
|
||||
```sh
|
||||
#1: five-arrays
|
||||
array-union x 511,121 ops/sec ±0.80% (96 runs sampled)
|
||||
arr-union x 5,716,039 ops/sec ±0.86% (93 runs sampled)
|
||||
|
||||
#2: ten-arrays
|
||||
array-union x 245,196 ops/sec ±0.69% (94 runs sampled)
|
||||
arr-union x 1,850,786 ops/sec ±0.84% (97 runs sampled)
|
||||
|
||||
#3: two-arrays
|
||||
array-union x 563,869 ops/sec ±0.97% (94 runs sampled)
|
||||
arr-union x 9,602,852 ops/sec ±0.87% (92 runs sampled)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var union = require('arr-union');
|
||||
|
||||
union(['a'], ['b', 'c'], ['d', 'e', 'f']);
|
||||
//=> ['a', 'b', 'c', 'd', 'e', 'f']
|
||||
```
|
||||
|
||||
Returns only unique elements:
|
||||
|
||||
```js
|
||||
union(['a', 'a'], ['b', 'c']);
|
||||
//=> ['a', 'b', 'c']
|
||||
```
|
||||
|
||||
## Related projects
|
||||
|
||||
* [arr-diff](https://www.npmjs.com/package/arr-diff): Returns an array with only the unique values from the first array, by excluding all… [more](https://www.npmjs.com/package/arr-diff) | [homepage](https://github.com/jonschlinkert/arr-diff)
|
||||
* [arr-filter](https://www.npmjs.com/package/arr-filter): Faster alternative to javascript's native filter method. | [homepage](https://github.com/jonschlinkert/arr-filter)
|
||||
* [arr-flatten](https://www.npmjs.com/package/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | [homepage](https://github.com/jonschlinkert/arr-flatten)
|
||||
* [arr-map](https://www.npmjs.com/package/arr-map): Faster, node.js focused alternative to JavaScript's native array map. | [homepage](https://github.com/jonschlinkert/arr-map)
|
||||
* [arr-pluck](https://www.npmjs.com/package/arr-pluck): Retrieves the value of a specified property from all elements in the collection. | [homepage](https://github.com/jonschlinkert/arr-pluck)
|
||||
* [arr-reduce](https://www.npmjs.com/package/arr-reduce): Fast array reduce that also loops over sparse elements. | [homepage](https://github.com/jonschlinkert/arr-reduce)
|
||||
* [array-unique](https://www.npmjs.com/package/array-unique): Return an array free of duplicate values. Fastest ES5 implementation. | [homepage](https://github.com/jonschlinkert/array-unique)
|
||||
|
||||
## Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/arr-union/issues/new).
|
||||
|
||||
## Building docs
|
||||
|
||||
Generate readme and API documentation with [verb](https://github.com/verbose/verb):
|
||||
|
||||
```sh
|
||||
$ npm i verb && npm run docs
|
||||
```
|
||||
|
||||
Or, if [verb](https://github.com/verbose/verb) is installed globally:
|
||||
|
||||
```sh
|
||||
$ verb
|
||||
```
|
||||
|
||||
## Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ npm i -d && npm test
|
||||
```
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2016 [Jon Schlinkert](https://github.com/jonschlinkert)
|
||||
Released under the [MIT license](https://github.com/jonschlinkert/arr-union/blob/master/LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on February 23, 2016._
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function union(init) {
|
||||
if (!Array.isArray(init)) {
|
||||
throw new TypeError('arr-union expects the first argument to be an array.');
|
||||
}
|
||||
|
||||
var len = arguments.length;
|
||||
var i = 0;
|
||||
|
||||
while (++i < len) {
|
||||
var arg = arguments[i];
|
||||
if (!arg) continue;
|
||||
|
||||
if (!Array.isArray(arg)) {
|
||||
arg = [arg];
|
||||
}
|
||||
|
||||
for (var j = 0; j < arg.length; j++) {
|
||||
var ele = arg[j];
|
||||
|
||||
if (init.indexOf(ele) >= 0) {
|
||||
continue;
|
||||
}
|
||||
init.push(ele);
|
||||
}
|
||||
}
|
||||
return init;
|
||||
};
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"name": "arr-union",
|
||||
"description": "Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.",
|
||||
"version": "3.1.0",
|
||||
"homepage": "https://github.com/jonschlinkert/arr-union",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/arr-union",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/arr-union/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ansi-bold": "^0.1.1",
|
||||
"array-union": "^1.0.1",
|
||||
"array-unique": "^0.2.1",
|
||||
"benchmarked": "^0.1.4",
|
||||
"gulp-format-md": "^0.1.7",
|
||||
"minimist": "^1.1.1",
|
||||
"mocha": "*",
|
||||
"should": "*"
|
||||
},
|
||||
"keywords": [
|
||||
"add",
|
||||
"append",
|
||||
"array",
|
||||
"arrays",
|
||||
"combine",
|
||||
"concat",
|
||||
"extend",
|
||||
"union",
|
||||
"uniq",
|
||||
"unique",
|
||||
"util",
|
||||
"utility",
|
||||
"utils"
|
||||
],
|
||||
"verb": {
|
||||
"run": true,
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"related": {
|
||||
"list": [
|
||||
"arr-diff",
|
||||
"arr-flatten",
|
||||
"arr-filter",
|
||||
"arr-map",
|
||||
"arr-pluck",
|
||||
"arr-reduce",
|
||||
"array-unique"
|
||||
]
|
||||
},
|
||||
"reflinks": [
|
||||
"verb",
|
||||
"array-union"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
var arrayUniq = require('array-uniq');
|
||||
|
||||
module.exports = function () {
|
||||
return arrayUniq([].concat.apply([], arguments));
|
||||
};
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "array-union",
|
||||
"version": "1.0.2",
|
||||
"description": "Create an array of unique values, in order, from the input arrays",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/array-union",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"array",
|
||||
"arr",
|
||||
"set",
|
||||
"uniq",
|
||||
"unique",
|
||||
"duplicate",
|
||||
"remove",
|
||||
"union",
|
||||
"combine",
|
||||
"merge"
|
||||
],
|
||||
"dependencies": {
|
||||
"array-uniq": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
# array-union [](https://travis-ci.org/sindresorhus/array-union)
|
||||
|
||||
> Create an array of unique values, in order, from the input arrays
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save array-union
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const arrayUnion = require('array-union');
|
||||
|
||||
arrayUnion([1, 1, 2, 3], [2, 3]);
|
||||
//=> [1, 2, 3]
|
||||
|
||||
arrayUnion(['foo', 'foo', 'bar'], ['foo']);
|
||||
//=> ['foo', 'bar']
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
// there's 3 implementations written in increasing order of efficiency
|
||||
|
||||
// 1 - no Set type is defined
|
||||
function uniqNoSet(arr) {
|
||||
var ret = [];
|
||||
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
if (ret.indexOf(arr[i]) === -1) {
|
||||
ret.push(arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 2 - a simple Set type is defined
|
||||
function uniqSet(arr) {
|
||||
var seen = new Set();
|
||||
return arr.filter(function (el) {
|
||||
if (!seen.has(el)) {
|
||||
seen.add(el);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// 3 - a standard Set type is defined and it has a forEach method
|
||||
function uniqSetWithForEach(arr) {
|
||||
var ret = [];
|
||||
|
||||
(new Set(arr)).forEach(function (el) {
|
||||
ret.push(el);
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// V8 currently has a broken implementation
|
||||
// https://github.com/joyent/node/issues/8449
|
||||
function doesForEachActuallyWork() {
|
||||
var ret = false;
|
||||
|
||||
(new Set([true])).forEach(function (el) {
|
||||
ret = el;
|
||||
});
|
||||
|
||||
return ret === true;
|
||||
}
|
||||
|
||||
if ('Set' in global) {
|
||||
if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) {
|
||||
module.exports = uniqSetWithForEach;
|
||||
} else {
|
||||
module.exports = uniqSet;
|
||||
}
|
||||
} else {
|
||||
module.exports = uniqNoSet;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "array-uniq",
|
||||
"version": "1.0.3",
|
||||
"description": "Create an array without duplicates",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/array-uniq",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"array",
|
||||
"arr",
|
||||
"set",
|
||||
"uniq",
|
||||
"unique",
|
||||
"es6",
|
||||
"duplicate",
|
||||
"remove"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"es6-set": "^0.1.0",
|
||||
"require-uncached": "^1.0.2",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
# array-uniq [](https://travis-ci.org/sindresorhus/array-uniq)
|
||||
|
||||
> Create an array without duplicates
|
||||
|
||||
It's already pretty fast, but will be much faster when [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) becomes available in V8 (especially with large arrays).
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save array-uniq
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const arrayUniq = require('array-uniq');
|
||||
|
||||
arrayUniq([1, 1, 2, 3, 3]);
|
||||
//=> [1, 2, 3]
|
||||
|
||||
arrayUniq(['foo', 'foo', 'bar', 'foo']);
|
||||
//=> ['foo', 'bar']
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2016, Jon Schlinkert
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
# array-unique [](https://www.npmjs.com/package/array-unique) [](https://npmjs.org/package/array-unique) [](https://travis-ci.org/jonschlinkert/array-unique)
|
||||
|
||||
Remove duplicate values from an array. Fastest ES5 implementation.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save array-unique
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var unique = require('array-unique');
|
||||
|
||||
var arr = ['a', 'b', 'c', 'c'];
|
||||
console.log(unique(arr)) //=> ['a', 'b', 'c']
|
||||
console.log(arr) //=> ['a', 'b', 'c']
|
||||
|
||||
/* The above modifies the input array. To prevent that at a slight performance cost: */
|
||||
var unique = require("array-unique").immutable;
|
||||
|
||||
var arr = ['a', 'b', 'c', 'c'];
|
||||
console.log(unique(arr)) //=> ['a', 'b', 'c']
|
||||
console.log(arr) //=> ['a', 'b', 'c', 'c']
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [arr-diff](https://www.npmjs.com/package/arr-diff): Returns an array with only the unique values from the first array, by excluding all… [more](https://github.com/jonschlinkert/arr-diff) | [homepage](https://github.com/jonschlinkert/arr-diff "Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons.")
|
||||
* [arr-flatten](https://www.npmjs.com/package/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten. | [homepage](https://github.com/jonschlinkert/arr-flatten "Recursively flatten an array or arrays. This is the fastest implementation of array flatten.")
|
||||
* [arr-map](https://www.npmjs.com/package/arr-map): Faster, node.js focused alternative to JavaScript's native array map. | [homepage](https://github.com/jonschlinkert/arr-map "Faster, node.js focused alternative to JavaScript's native array map.")
|
||||
* [arr-pluck](https://www.npmjs.com/package/arr-pluck): Retrieves the value of a specified property from all elements in the collection. | [homepage](https://github.com/jonschlinkert/arr-pluck "Retrieves the value of a specified property from all elements in the collection.")
|
||||
* [arr-reduce](https://www.npmjs.com/package/arr-reduce): Fast array reduce that also loops over sparse elements. | [homepage](https://github.com/jonschlinkert/arr-reduce "Fast array reduce that also loops over sparse elements.")
|
||||
* [arr-union](https://www.npmjs.com/package/arr-union): Combines a list of arrays, returning a single array with unique values, using strict equality… [more](https://github.com/jonschlinkert/arr-union) | [homepage](https://github.com/jonschlinkert/arr-union "Combines a list of arrays, returning a single array with unique values, using strict equality for comparisons.")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
|
||||
|
||||
To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
|
||||
|
||||
```sh
|
||||
$ npm install -g verb verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ npm install -d && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT license](https://github.com/jonschlinkert/array-unique/blob/master/LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.28, on July 31, 2016._
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*!
|
||||
* array-unique <https://github.com/jonschlinkert/array-unique>
|
||||
*
|
||||
* Copyright (c) 2014-2015, Jon Schlinkert.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function unique(arr) {
|
||||
if (!Array.isArray(arr)) {
|
||||
throw new TypeError('array-unique expects an array.');
|
||||
}
|
||||
|
||||
var len = arr.length;
|
||||
var i = -1;
|
||||
|
||||
while (i++ < len) {
|
||||
var j = i + 1;
|
||||
|
||||
for (; j < arr.length; ++j) {
|
||||
if (arr[i] === arr[j]) {
|
||||
arr.splice(j--, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
module.exports.immutable = function uniqueImmutable(arr) {
|
||||
if (!Array.isArray(arr)) {
|
||||
throw new TypeError('array-unique expects an array.');
|
||||
}
|
||||
|
||||
var arrLen = arr.length;
|
||||
var newArr = new Array(arrLen);
|
||||
|
||||
for (var i = 0; i < arrLen; i++) {
|
||||
newArr[i] = arr[i];
|
||||
}
|
||||
|
||||
return module.exports(newArr);
|
||||
};
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"name": "array-unique",
|
||||
"description": "Remove duplicate values from an array. Fastest ES5 implementation.",
|
||||
"version": "0.3.2",
|
||||
"homepage": "https://github.com/jonschlinkert/array-unique",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/array-unique",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/array-unique/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"array-uniq": "^1.0.2",
|
||||
"benchmarked": "^0.1.3",
|
||||
"gulp-format-md": "^0.1.9",
|
||||
"mocha": "^2.5.3",
|
||||
"should": "^10.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"array",
|
||||
"unique"
|
||||
],
|
||||
"verb": {
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"related": {
|
||||
"list": [
|
||||
"arr-diff",
|
||||
"arr-union",
|
||||
"arr-flatten",
|
||||
"arr-reduce",
|
||||
"arr-map",
|
||||
"arr-pluck"
|
||||
]
|
||||
},
|
||||
"reflinks": [
|
||||
"verb",
|
||||
"verb-generate-readme"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
module.exports = function (val) {
|
||||
if (val === null || val === undefined) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Array.isArray(val) ? val : [val];
|
||||
};
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "arrify",
|
||||
"version": "1.0.1",
|
||||
"description": "Convert a value to an array",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/arrify",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"array",
|
||||
"arr",
|
||||
"arrify",
|
||||
"arrayify",
|
||||
"convert",
|
||||
"value"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
# arrify [](https://travis-ci.org/sindresorhus/arrify)
|
||||
|
||||
> Convert a value to an array
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save arrify
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const arrify = require('arrify');
|
||||
|
||||
arrify('unicorn');
|
||||
//=> ['unicorn']
|
||||
|
||||
arrify(['unicorn']);
|
||||
//=> ['unicorn']
|
||||
|
||||
arrify(null);
|
||||
//=> []
|
||||
|
||||
arrify(undefined);
|
||||
//=> []
|
||||
```
|
||||
|
||||
*Supplying `null` or `undefined` results in an empty array.*
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015, Jon Schlinkert.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
# assign-symbols [](http://badge.fury.io/js/assign-symbols)
|
||||
|
||||
> Assign the enumerable es6 Symbol properties from an object (or objects) to the first object passed on the arguments. Can be used as a supplement to other extend, assign or merge methods as a polyfill for the Symbols part of the es6 Object.assign method.
|
||||
|
||||
From the [Mozilla Developer docs for Symbol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol):
|
||||
|
||||
> A symbol is a unique and immutable data type and may be used as an identifier for object properties. The symbol object is an implicit object wrapper for the symbol primitive data type.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/)
|
||||
|
||||
```sh
|
||||
$ npm i assign-symbols --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var assignSymbols = require('assign-symbols');
|
||||
var obj = {};
|
||||
|
||||
var one = {};
|
||||
var symbolOne = Symbol('aaa');
|
||||
one[symbolOne] = 'bbb';
|
||||
|
||||
var two = {};
|
||||
var symbolTwo = Symbol('ccc');
|
||||
two[symbolTwo] = 'ddd';
|
||||
|
||||
assignSymbols(obj, one, two);
|
||||
|
||||
console.log(obj[symbolOne]);
|
||||
//=> 'bbb'
|
||||
console.log(obj[symbolTwo]);
|
||||
//=> 'ddd'
|
||||
```
|
||||
|
||||
## Similar projects
|
||||
|
||||
* [assign-deep](https://www.npmjs.com/package/assign-deep): Deeply assign the enumerable properties of source objects to a destination object. | [homepage](https://github.com/jonschlinkert/assign-deep)
|
||||
* [clone-deep](https://www.npmjs.com/package/clone-deep): Recursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives. | [homepage](https://github.com/jonschlinkert/clone-deep)
|
||||
* [extend-shallow](https://www.npmjs.com/package/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util. | [homepage](https://github.com/jonschlinkert/extend-shallow)
|
||||
* [merge-deep](https://www.npmjs.com/package/merge-deep): Recursively merge values in a javascript object. | [homepage](https://github.com/jonschlinkert/merge-deep)
|
||||
* [mixin-deep](https://www.npmjs.com/package/mixin-deep): Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone. | [homepage](https://github.com/jonschlinkert/mixin-deep)
|
||||
|
||||
## Running tests
|
||||
|
||||
Install dev dependencies:
|
||||
|
||||
```sh
|
||||
$ npm i -d && npm test
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/assign-symbols/issues/new).
|
||||
|
||||
## Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
+ [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
|
||||
|
||||
## License
|
||||
|
||||
Copyright © 2015 Jon Schlinkert
|
||||
Released under the MIT license.
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 06, 2015._
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*!
|
||||
* assign-symbols <https://github.com/jonschlinkert/assign-symbols>
|
||||
*
|
||||
* Copyright (c) 2015, Jon Schlinkert.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = function(receiver, objects) {
|
||||
if (receiver === null || typeof receiver === 'undefined') {
|
||||
throw new TypeError('expected first argument to be an object.');
|
||||
}
|
||||
|
||||
if (typeof objects === 'undefined' || typeof Symbol === 'undefined') {
|
||||
return receiver;
|
||||
}
|
||||
|
||||
if (typeof Object.getOwnPropertySymbols !== 'function') {
|
||||
return receiver;
|
||||
}
|
||||
|
||||
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
||||
var target = Object(receiver);
|
||||
var len = arguments.length, i = 0;
|
||||
|
||||
while (++i < len) {
|
||||
var provider = Object(arguments[i]);
|
||||
var names = Object.getOwnPropertySymbols(provider);
|
||||
|
||||
for (var j = 0; j < names.length; j++) {
|
||||
var key = names[j];
|
||||
|
||||
if (isEnumerable.call(provider, key)) {
|
||||
target[key] = provider[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
};
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "assign-symbols",
|
||||
"description": "Assign the enumerable es6 Symbol properties from an object (or objects) to the first object passed on the arguments. Can be used as a supplement to other extend, assign or merge methods as a polyfill for the Symbols part of the es6 Object.assign method.",
|
||||
"version": "1.0.0",
|
||||
"homepage": "https://github.com/jonschlinkert/assign-symbols",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/assign-symbols",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/assign-symbols/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^3.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"assign",
|
||||
"symbols"
|
||||
],
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"assign-deep",
|
||||
"mixin-deep",
|
||||
"merge-deep",
|
||||
"extend-shallow",
|
||||
"clone-deep"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
At your option you may choose either of the following licenses:
|
||||
|
||||
* The MIT License (MIT)
|
||||
* The Apache License 2.0 (Apache-2.0)
|
||||
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 AJ ONeal
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2015 AJ ONeal
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
+319
@@ -0,0 +1,319 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
Attribution 3.0 Unported
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
|
||||
DAMAGES RESULTING FROM ITS USE.
|
||||
|
||||
License
|
||||
|
||||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
|
||||
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
|
||||
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
|
||||
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
||||
|
||||
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
|
||||
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
|
||||
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
|
||||
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
|
||||
CONDITIONS.
|
||||
|
||||
1. Definitions
|
||||
|
||||
a. "Adaptation" means a work based upon the Work, or upon the Work and
|
||||
other pre-existing works, such as a translation, adaptation,
|
||||
derivative work, arrangement of music or other alterations of a
|
||||
literary or artistic work, or phonogram or performance and includes
|
||||
cinematographic adaptations or any other form in which the Work may be
|
||||
recast, transformed, or adapted including in any form recognizably
|
||||
derived from the original, except that a work that constitutes a
|
||||
Collection will not be considered an Adaptation for the purpose of
|
||||
this License. For the avoidance of doubt, where the Work is a musical
|
||||
work, performance or phonogram, the synchronization of the Work in
|
||||
timed-relation with a moving image ("synching") will be considered an
|
||||
Adaptation for the purpose of this License.
|
||||
b. "Collection" means a collection of literary or artistic works, such as
|
||||
encyclopedias and anthologies, or performances, phonograms or
|
||||
broadcasts, or other works or subject matter other than works listed
|
||||
in Section 1(f) below, which, by reason of the selection and
|
||||
arrangement of their contents, constitute intellectual creations, in
|
||||
which the Work is included in its entirety in unmodified form along
|
||||
with one or more other contributions, each constituting separate and
|
||||
independent works in themselves, which together are assembled into a
|
||||
collective whole. A work that constitutes a Collection will not be
|
||||
considered an Adaptation (as defined above) for the purposes of this
|
||||
License.
|
||||
c. "Distribute" means to make available to the public the original and
|
||||
copies of the Work or Adaptation, as appropriate, through sale or
|
||||
other transfer of ownership.
|
||||
d. "Licensor" means the individual, individuals, entity or entities that
|
||||
offer(s) the Work under the terms of this License.
|
||||
e. "Original Author" means, in the case of a literary or artistic work,
|
||||
the individual, individuals, entity or entities who created the Work
|
||||
or if no individual or entity can be identified, the publisher; and in
|
||||
addition (i) in the case of a performance the actors, singers,
|
||||
musicians, dancers, and other persons who act, sing, deliver, declaim,
|
||||
play in, interpret or otherwise perform literary or artistic works or
|
||||
expressions of folklore; (ii) in the case of a phonogram the producer
|
||||
being the person or legal entity who first fixes the sounds of a
|
||||
performance or other sounds; and, (iii) in the case of broadcasts, the
|
||||
organization that transmits the broadcast.
|
||||
f. "Work" means the literary and/or artistic work offered under the terms
|
||||
of this License including without limitation any production in the
|
||||
literary, scientific and artistic domain, whatever may be the mode or
|
||||
form of its expression including digital form, such as a book,
|
||||
pamphlet and other writing; a lecture, address, sermon or other work
|
||||
of the same nature; a dramatic or dramatico-musical work; a
|
||||
choreographic work or entertainment in dumb show; a musical
|
||||
composition with or without words; a cinematographic work to which are
|
||||
assimilated works expressed by a process analogous to cinematography;
|
||||
a work of drawing, painting, architecture, sculpture, engraving or
|
||||
lithography; a photographic work to which are assimilated works
|
||||
expressed by a process analogous to photography; a work of applied
|
||||
art; an illustration, map, plan, sketch or three-dimensional work
|
||||
relative to geography, topography, architecture or science; a
|
||||
performance; a broadcast; a phonogram; a compilation of data to the
|
||||
extent it is protected as a copyrightable work; or a work performed by
|
||||
a variety or circus performer to the extent it is not otherwise
|
||||
considered a literary or artistic work.
|
||||
g. "You" means an individual or entity exercising rights under this
|
||||
License who has not previously violated the terms of this License with
|
||||
respect to the Work, or who has received express permission from the
|
||||
Licensor to exercise rights under this License despite a previous
|
||||
violation.
|
||||
h. "Publicly Perform" means to perform public recitations of the Work and
|
||||
to communicate to the public those public recitations, by any means or
|
||||
process, including by wire or wireless means or public digital
|
||||
performances; to make available to the public Works in such a way that
|
||||
members of the public may access these Works from a place and at a
|
||||
place individually chosen by them; to perform the Work to the public
|
||||
by any means or process and the communication to the public of the
|
||||
performances of the Work, including by public digital performance; to
|
||||
broadcast and rebroadcast the Work by any means including signs,
|
||||
sounds or images.
|
||||
i. "Reproduce" means to make copies of the Work by any means including
|
||||
without limitation by sound or visual recordings and the right of
|
||||
fixation and reproducing fixations of the Work, including storage of a
|
||||
protected performance or phonogram in digital form or other electronic
|
||||
medium.
|
||||
|
||||
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
|
||||
limit, or restrict any uses free from copyright or rights arising from
|
||||
limitations or exceptions that are provided for in connection with the
|
||||
copyright protection under copyright law or other applicable laws.
|
||||
|
||||
3. License Grant. Subject to the terms and conditions of this License,
|
||||
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
|
||||
perpetual (for the duration of the applicable copyright) license to
|
||||
exercise the rights in the Work as stated below:
|
||||
|
||||
a. to Reproduce the Work, to incorporate the Work into one or more
|
||||
Collections, and to Reproduce the Work as incorporated in the
|
||||
Collections;
|
||||
b. to create and Reproduce Adaptations provided that any such Adaptation,
|
||||
including any translation in any medium, takes reasonable steps to
|
||||
clearly label, demarcate or otherwise identify that changes were made
|
||||
to the original Work. For example, a translation could be marked "The
|
||||
original work was translated from English to Spanish," or a
|
||||
modification could indicate "The original work has been modified.";
|
||||
c. to Distribute and Publicly Perform the Work including as incorporated
|
||||
in Collections; and,
|
||||
d. to Distribute and Publicly Perform Adaptations.
|
||||
e. For the avoidance of doubt:
|
||||
|
||||
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme cannot be waived, the Licensor
|
||||
reserves the exclusive right to collect such royalties for any
|
||||
exercise by You of the rights granted under this License;
|
||||
ii. Waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme can be waived, the Licensor waives the
|
||||
exclusive right to collect such royalties for any exercise by You
|
||||
of the rights granted under this License; and,
|
||||
iii. Voluntary License Schemes. The Licensor waives the right to
|
||||
collect royalties, whether individually or, in the event that the
|
||||
Licensor is a member of a collecting society that administers
|
||||
voluntary licensing schemes, via that society, from any exercise
|
||||
by You of the rights granted under this License.
|
||||
|
||||
The above rights may be exercised in all media and formats whether now
|
||||
known or hereafter devised. The above rights include the right to make
|
||||
such modifications as are technically necessary to exercise the rights in
|
||||
other media and formats. Subject to Section 8(f), all rights not expressly
|
||||
granted by Licensor are hereby reserved.
|
||||
|
||||
4. Restrictions. The license granted in Section 3 above is expressly made
|
||||
subject to and limited by the following restrictions:
|
||||
|
||||
a. You may Distribute or Publicly Perform the Work only under the terms
|
||||
of this License. You must include a copy of, or the Uniform Resource
|
||||
Identifier (URI) for, this License with every copy of the Work You
|
||||
Distribute or Publicly Perform. You may not offer or impose any terms
|
||||
on the Work that restrict the terms of this License or the ability of
|
||||
the recipient of the Work to exercise the rights granted to that
|
||||
recipient under the terms of the License. You may not sublicense the
|
||||
Work. You must keep intact all notices that refer to this License and
|
||||
to the disclaimer of warranties with every copy of the Work You
|
||||
Distribute or Publicly Perform. When You Distribute or Publicly
|
||||
Perform the Work, You may not impose any effective technological
|
||||
measures on the Work that restrict the ability of a recipient of the
|
||||
Work from You to exercise the rights granted to that recipient under
|
||||
the terms of the License. This Section 4(a) applies to the Work as
|
||||
incorporated in a Collection, but this does not require the Collection
|
||||
apart from the Work itself to be made subject to the terms of this
|
||||
License. If You create a Collection, upon notice from any Licensor You
|
||||
must, to the extent practicable, remove from the Collection any credit
|
||||
as required by Section 4(b), as requested. If You create an
|
||||
Adaptation, upon notice from any Licensor You must, to the extent
|
||||
practicable, remove from the Adaptation any credit as required by
|
||||
Section 4(b), as requested.
|
||||
b. If You Distribute, or Publicly Perform the Work or any Adaptations or
|
||||
Collections, You must, unless a request has been made pursuant to
|
||||
Section 4(a), keep intact all copyright notices for the Work and
|
||||
provide, reasonable to the medium or means You are utilizing: (i) the
|
||||
name of the Original Author (or pseudonym, if applicable) if supplied,
|
||||
and/or if the Original Author and/or Licensor designate another party
|
||||
or parties (e.g., a sponsor institute, publishing entity, journal) for
|
||||
attribution ("Attribution Parties") in Licensor's copyright notice,
|
||||
terms of service or by other reasonable means, the name of such party
|
||||
or parties; (ii) the title of the Work if supplied; (iii) to the
|
||||
extent reasonably practicable, the URI, if any, that Licensor
|
||||
specifies to be associated with the Work, unless such URI does not
|
||||
refer to the copyright notice or licensing information for the Work;
|
||||
and (iv) , consistent with Section 3(b), in the case of an Adaptation,
|
||||
a credit identifying the use of the Work in the Adaptation (e.g.,
|
||||
"French translation of the Work by Original Author," or "Screenplay
|
||||
based on original Work by Original Author"). The credit required by
|
||||
this Section 4 (b) may be implemented in any reasonable manner;
|
||||
provided, however, that in the case of a Adaptation or Collection, at
|
||||
a minimum such credit will appear, if a credit for all contributing
|
||||
authors of the Adaptation or Collection appears, then as part of these
|
||||
credits and in a manner at least as prominent as the credits for the
|
||||
other contributing authors. For the avoidance of doubt, You may only
|
||||
use the credit required by this Section for the purpose of attribution
|
||||
in the manner set out above and, by exercising Your rights under this
|
||||
License, You may not implicitly or explicitly assert or imply any
|
||||
connection with, sponsorship or endorsement by the Original Author,
|
||||
Licensor and/or Attribution Parties, as appropriate, of You or Your
|
||||
use of the Work, without the separate, express prior written
|
||||
permission of the Original Author, Licensor and/or Attribution
|
||||
Parties.
|
||||
c. Except as otherwise agreed in writing by the Licensor or as may be
|
||||
otherwise permitted by applicable law, if You Reproduce, Distribute or
|
||||
Publicly Perform the Work either by itself or as part of any
|
||||
Adaptations or Collections, You must not distort, mutilate, modify or
|
||||
take other derogatory action in relation to the Work which would be
|
||||
prejudicial to the Original Author's honor or reputation. Licensor
|
||||
agrees that in those jurisdictions (e.g. Japan), in which any exercise
|
||||
of the right granted in Section 3(b) of this License (the right to
|
||||
make Adaptations) would be deemed to be a distortion, mutilation,
|
||||
modification or other derogatory action prejudicial to the Original
|
||||
Author's honor and reputation, the Licensor will waive or not assert,
|
||||
as appropriate, this Section, to the fullest extent permitted by the
|
||||
applicable national law, to enable You to reasonably exercise Your
|
||||
right under Section 3(b) of this License (right to make Adaptations)
|
||||
but not otherwise.
|
||||
|
||||
5. Representations, Warranties and Disclaimer
|
||||
|
||||
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
|
||||
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
|
||||
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
|
||||
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
|
||||
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
|
||||
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
|
||||
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
|
||||
|
||||
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
|
||||
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
|
||||
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
|
||||
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
|
||||
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
7. Termination
|
||||
|
||||
a. This License and the rights granted hereunder will terminate
|
||||
automatically upon any breach by You of the terms of this License.
|
||||
Individuals or entities who have received Adaptations or Collections
|
||||
from You under this License, however, will not have their licenses
|
||||
terminated provided such individuals or entities remain in full
|
||||
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
|
||||
survive any termination of this License.
|
||||
b. Subject to the above terms and conditions, the license granted here is
|
||||
perpetual (for the duration of the applicable copyright in the Work).
|
||||
Notwithstanding the above, Licensor reserves the right to release the
|
||||
Work under different license terms or to stop distributing the Work at
|
||||
any time; provided, however that any such election will not serve to
|
||||
withdraw this License (or any other license that has been, or is
|
||||
required to be, granted under the terms of this License), and this
|
||||
License will continue in full force and effect unless terminated as
|
||||
stated above.
|
||||
|
||||
8. Miscellaneous
|
||||
|
||||
a. Each time You Distribute or Publicly Perform the Work or a Collection,
|
||||
the Licensor offers to the recipient a license to the Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
|
||||
offers to the recipient a license to the original Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
c. If any provision of this License is invalid or unenforceable under
|
||||
applicable law, it shall not affect the validity or enforceability of
|
||||
the remainder of the terms of this License, and without further action
|
||||
by the parties to this agreement, such provision shall be reformed to
|
||||
the minimum extent necessary to make such provision valid and
|
||||
enforceable.
|
||||
d. No term or provision of this License shall be deemed waived and no
|
||||
breach consented to unless such waiver or consent shall be in writing
|
||||
and signed by the party to be charged with such waiver or consent.
|
||||
e. This License constitutes the entire agreement between the parties with
|
||||
respect to the Work licensed here. There are no understandings,
|
||||
agreements or representations with respect to the Work not specified
|
||||
here. Licensor shall not be bound by any additional provisions that
|
||||
may appear in any communication from You. This License may not be
|
||||
modified without the mutual written agreement of the Licensor and You.
|
||||
f. The rights granted under, and the subject matter referenced, in this
|
||||
License were drafted utilizing the terminology of the Berne Convention
|
||||
for the Protection of Literary and Artistic Works (as amended on
|
||||
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
|
||||
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
|
||||
and the Universal Copyright Convention (as revised on July 24, 1971).
|
||||
These rights and subject matter take effect in the relevant
|
||||
jurisdiction in which the License terms are sought to be enforced
|
||||
according to the corresponding provisions of the implementation of
|
||||
those treaty provisions in the applicable national law. If the
|
||||
standard suite of rights granted under applicable copyright law
|
||||
includes additional rights not granted under this License, such
|
||||
additional rights are deemed to be included in the License; this
|
||||
License is not intended to restrict the license of any rights under
|
||||
applicable law.
|
||||
|
||||
|
||||
Creative Commons Notice
|
||||
|
||||
Creative Commons is not a party to this License, and makes no warranty
|
||||
whatsoever in connection with the Work. Creative Commons will not be
|
||||
liable to You or any party on any legal theory for any damages
|
||||
whatsoever, including without limitation any general, special,
|
||||
incidental or consequential damages arising in connection to this
|
||||
license. Notwithstanding the foregoing two (2) sentences, if Creative
|
||||
Commons has expressly identified itself as the Licensor hereunder, it
|
||||
shall have all rights and obligations of Licensor.
|
||||
|
||||
Except for the limited purpose of indicating to the public that the
|
||||
Work is licensed under the CCPL, Creative Commons does not authorize
|
||||
the use by either party of the trademark "Creative Commons" or any
|
||||
related trademark or logo of Creative Commons without the prior
|
||||
written consent of Creative Commons. Any permitted use will be in
|
||||
compliance with Creative Commons' then-current trademark usage
|
||||
guidelines, as may be published on its website or otherwise made
|
||||
available upon request from time to time. For the avoidance of doubt,
|
||||
this trademark restriction does not form part of this License.
|
||||
|
||||
Creative Commons may be contacted at http://creativecommons.org/.
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
atob
|
||||
===
|
||||
|
||||
| **atob**
|
||||
| [btoa](https://git.coolaj86.com/coolaj86/btoa.js)
|
||||
| [unibabel.js](https://git.coolaj86.com/coolaj86/unibabel.js)
|
||||
| Sponsored by [ppl](https://ppl.family)
|
||||
|
||||
Uses `Buffer` to emulate the exact functionality of the browser's atob.
|
||||
|
||||
Note: Unicode may be handled incorrectly (like the browser).
|
||||
|
||||
It turns base64-encoded <strong>a</strong>scii data back **to** <strong>b</strong>inary.
|
||||
|
||||
```javascript
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var atob = require('atob');
|
||||
var b64 = "SGVsbG8sIFdvcmxkIQ==";
|
||||
var bin = atob(b64);
|
||||
|
||||
console.log(bin); // "Hello, World!"
|
||||
}());
|
||||
```
|
||||
|
||||
### Need Unicode and Binary Support in the Browser?
|
||||
|
||||
Check out [unibabel.js](https://git.coolaj86.com/coolaj86/unibabel.js)
|
||||
|
||||
Changelog
|
||||
=======
|
||||
|
||||
* v2.1.0 address a few issues and PRs, update URLs
|
||||
* v2.0.0 provide browser version for ios web workers
|
||||
* v1.2.0 provide (empty) browser version
|
||||
* v1.1.3 add MIT license
|
||||
* v1.1.2 node only
|
||||
|
||||
LICENSE
|
||||
=======
|
||||
|
||||
Code copyright 2012-2018 AJ ONeal
|
||||
|
||||
Dual-licensed MIT and Apache-2.0
|
||||
|
||||
Docs copyright 2012-2018 AJ ONeal
|
||||
|
||||
Docs released under [Creative Commons](https://git.coolaj86.com/coolaj86/atob.js/blob/master/LICENSE.DOCS).
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var atob = require('../node-atob');
|
||||
var str = process.argv[2];
|
||||
console.log(atob(str));
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "atob",
|
||||
"description": "atob for isomorphic environments",
|
||||
"main": "browser-atob.js",
|
||||
"authors": [
|
||||
"AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com)"
|
||||
],
|
||||
"license": "(MIT OR Apache-2.0)",
|
||||
"keywords": [
|
||||
"atob",
|
||||
"browser"
|
||||
],
|
||||
"homepage": "https://github.com/node-browser-compat/atob",
|
||||
"moduleType": [
|
||||
"globals"
|
||||
],
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
(function (w) {
|
||||
"use strict";
|
||||
|
||||
function findBest(atobNative) {
|
||||
// normal window
|
||||
if ('function' === typeof atobNative) { return atobNative; }
|
||||
|
||||
|
||||
// browserify (web worker)
|
||||
if ('function' === typeof Buffer) {
|
||||
return function atobBrowserify(a) {
|
||||
//!! Deliberately using an API that's deprecated in node.js because
|
||||
//!! this file is for browsers and we expect them to cope with it.
|
||||
//!! Discussion: github.com/node-browser-compat/atob/pull/9
|
||||
return new Buffer(a, 'base64').toString('binary');
|
||||
};
|
||||
}
|
||||
|
||||
// ios web worker with base64js
|
||||
if ('object' === typeof w.base64js) {
|
||||
// bufferToBinaryString
|
||||
// https://git.coolaj86.com/coolaj86/unibabel.js/blob/master/index.js#L50
|
||||
return function atobWebWorker_iOS(a) {
|
||||
var buf = w.base64js.b64ToByteArray(a);
|
||||
return Array.prototype.map.call(buf, function (ch) {
|
||||
return String.fromCharCode(ch);
|
||||
}).join('');
|
||||
};
|
||||
}
|
||||
|
||||
return function () {
|
||||
// ios web worker without base64js
|
||||
throw new Error("You're probably in an old browser or an iOS webworker." +
|
||||
" It might help to include beatgammit's base64-js.");
|
||||
};
|
||||
}
|
||||
|
||||
var atobBest = findBest(w.atob);
|
||||
w.atob = atobBest;
|
||||
|
||||
if ((typeof module === 'object') && module && module.exports) {
|
||||
module.exports = atobBest;
|
||||
}
|
||||
}(window));
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
function atob(str) {
|
||||
return Buffer.from(str, 'base64').toString('binary');
|
||||
}
|
||||
|
||||
module.exports = atob.atob = atob;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "atob",
|
||||
"homepage": "https://git.coolaj86.com/coolaj86/atob.js.git",
|
||||
"description": "atob for Node.JS and Linux / Mac / Windows CLI (it's a one-liner)",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://git.coolaj86.com/coolaj86/atob.js.git"
|
||||
},
|
||||
"keywords": [
|
||||
"atob",
|
||||
"browser"
|
||||
],
|
||||
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com)",
|
||||
"engines": {
|
||||
"node": ">= 4.5.0"
|
||||
},
|
||||
"main": "node-atob.js",
|
||||
"browser": "browser-atob.js",
|
||||
"bin": {
|
||||
"atob": "bin/atob.js"
|
||||
},
|
||||
"license": "(MIT OR Apache-2.0)",
|
||||
"version": "2.1.2"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var atob = require('.');
|
||||
var encoded = "SGVsbG8sIFdvcmxkIQ=="
|
||||
var unencoded = "Hello, World!";
|
||||
/*
|
||||
, encoded = "SGVsbG8sIBZM"
|
||||
, unencoded = "Hello, 世界"
|
||||
*/
|
||||
|
||||
if (unencoded !== atob(encoded)) {
|
||||
console.log('[FAIL]', unencoded, atob(encoded));
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('[PASS] all tests pass');
|
||||
}());
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
test
|
||||
.gitignore
|
||||
.travis.yml
|
||||
Makefile
|
||||
example.js
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
(MIT)
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
# balanced-match
|
||||
|
||||
Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`. Supports regular expressions as well!
|
||||
|
||||
[](http://travis-ci.org/juliangruber/balanced-match)
|
||||
[](https://www.npmjs.org/package/balanced-match)
|
||||
|
||||
[](https://ci.testling.com/juliangruber/balanced-match)
|
||||
|
||||
## Example
|
||||
|
||||
Get the first matching pair of braces:
|
||||
|
||||
```js
|
||||
var balanced = require('balanced-match');
|
||||
|
||||
console.log(balanced('{', '}', 'pre{in{nested}}post'));
|
||||
console.log(balanced('{', '}', 'pre{first}between{second}post'));
|
||||
console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post'));
|
||||
```
|
||||
|
||||
The matches are:
|
||||
|
||||
```bash
|
||||
$ node example.js
|
||||
{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
|
||||
{ start: 3,
|
||||
end: 9,
|
||||
pre: 'pre',
|
||||
body: 'first',
|
||||
post: 'between{second}post' }
|
||||
{ start: 3, end: 17, pre: 'pre', body: 'in{nest}', post: 'post' }
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### var m = balanced(a, b, str)
|
||||
|
||||
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
||||
object with those keys:
|
||||
|
||||
* **start** the index of the first match of `a`
|
||||
* **end** the index of the matching `b`
|
||||
* **pre** the preamble, `a` and `b` not included
|
||||
* **body** the match, `a` and `b` not included
|
||||
* **post** the postscript, `a` and `b` not included
|
||||
|
||||
If there's no match, `undefined` will be returned.
|
||||
|
||||
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']` and `{a}}` will match `['', 'a', '}']`.
|
||||
|
||||
### var r = balanced.range(a, b, str)
|
||||
|
||||
For the first non-nested matching pair of `a` and `b` in `str`, return an
|
||||
array with indexes: `[ <a index>, <b index> ]`.
|
||||
|
||||
If there's no match, `undefined` will be returned.
|
||||
|
||||
If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `[ 1, 3 ]` and `{a}}` will match `[0, 2]`.
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```bash
|
||||
npm install balanced-match
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(MIT)
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
module.exports = balanced;
|
||||
function balanced(a, b, str) {
|
||||
if (a instanceof RegExp) a = maybeMatch(a, str);
|
||||
if (b instanceof RegExp) b = maybeMatch(b, str);
|
||||
|
||||
var r = range(a, b, str);
|
||||
|
||||
return r && {
|
||||
start: r[0],
|
||||
end: r[1],
|
||||
pre: str.slice(0, r[0]),
|
||||
body: str.slice(r[0] + a.length, r[1]),
|
||||
post: str.slice(r[1] + b.length)
|
||||
};
|
||||
}
|
||||
|
||||
function maybeMatch(reg, str) {
|
||||
var m = str.match(reg);
|
||||
return m ? m[0] : null;
|
||||
}
|
||||
|
||||
balanced.range = range;
|
||||
function range(a, b, str) {
|
||||
var begs, beg, left, right, result;
|
||||
var ai = str.indexOf(a);
|
||||
var bi = str.indexOf(b, ai + 1);
|
||||
var i = ai;
|
||||
|
||||
if (ai >= 0 && bi > 0) {
|
||||
begs = [];
|
||||
left = str.length;
|
||||
|
||||
while (i >= 0 && !result) {
|
||||
if (i == ai) {
|
||||
begs.push(i);
|
||||
ai = str.indexOf(a, i + 1);
|
||||
} else if (begs.length == 1) {
|
||||
result = [ begs.pop(), bi ];
|
||||
} else {
|
||||
beg = begs.pop();
|
||||
if (beg < left) {
|
||||
left = beg;
|
||||
right = bi;
|
||||
}
|
||||
|
||||
bi = str.indexOf(b, i + 1);
|
||||
}
|
||||
|
||||
i = ai < bi && ai >= 0 ? ai : bi;
|
||||
}
|
||||
|
||||
if (begs.length) {
|
||||
result = [ left, right ];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "balanced-match",
|
||||
"description": "Match balanced character pairs, like \"{\" and \"}\"",
|
||||
"version": "1.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/juliangruber/balanced-match.git"
|
||||
},
|
||||
"homepage": "https://github.com/juliangruber/balanced-match",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "make test",
|
||||
"bench": "make bench"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"matcha": "^0.7.0",
|
||||
"tape": "^4.6.0"
|
||||
},
|
||||
"keywords": [
|
||||
"match",
|
||||
"regexp",
|
||||
"test",
|
||||
"balanced",
|
||||
"parse"
|
||||
],
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"firefox/20..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/25..latest",
|
||||
"chrome/canary",
|
||||
"opera/12..latest",
|
||||
"opera/next",
|
||||
"safari/5.1..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2..latest"
|
||||
]
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2017, Jon Schlinkert.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+491
@@ -0,0 +1,491 @@
|
||||
<p align="center">
|
||||
<a href="https://github.com/node-base/base">
|
||||
<img height="250" width="250" src="https://raw.githubusercontent.com/node-base/base/master/docs/logo.png">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
# base [](https://www.npmjs.com/package/base) [](https://npmjs.org/package/base) [](https://npmjs.org/package/base) [](https://travis-ci.org/node-base/base)
|
||||
|
||||
> base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting with a handful of common methods, like `set`, `get`, `del` and `use`.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save base
|
||||
```
|
||||
|
||||
## What is Base?
|
||||
|
||||
Base is a framework for rapidly creating high quality node.js applications, using plugins like building blocks.
|
||||
|
||||
### Guiding principles
|
||||
|
||||
The core team follows these principles to help guide API decisions:
|
||||
|
||||
* **Compact API surface**: The smaller the API surface, the easier the library will be to learn and use.
|
||||
* **Easy to extend**: Implementors can use any npm package, and write plugins in pure JavaScript. If you're building complex apps, Base simplifies inheritance.
|
||||
* **Easy to test**: No special setup should be required to unit test `Base` or base plugins
|
||||
|
||||
### Minimal API surface
|
||||
|
||||
[The API](#api) was designed to provide only the minimum necessary functionality for creating a useful application, with or without [plugins](#plugins).
|
||||
|
||||
**Base core**
|
||||
|
||||
Base itself ships with only a handful of [useful methods](#api), such as:
|
||||
|
||||
* `.set`: for setting values on the instance
|
||||
* `.get`: for getting values from the instance
|
||||
* `.has`: to check if a property exists on the instance
|
||||
* `.define`: for setting non-enumerable values on the instance
|
||||
* `.use`: for adding plugins
|
||||
|
||||
**Be generic**
|
||||
|
||||
When deciding on method to add or remove, we try to answer these questions:
|
||||
|
||||
1. Will all or most Base applications need this method?
|
||||
2. Will this method encourage practices or enforce conventions that are beneficial to implementors?
|
||||
3. Can or should this be done in a plugin instead?
|
||||
|
||||
### Composability
|
||||
|
||||
**Plugin system**
|
||||
|
||||
It couldn't be easier to extend Base with any features or custom functionality you can think of.
|
||||
|
||||
Base plugins are just functions that take an instance of `Base`:
|
||||
|
||||
```js
|
||||
var base = new Base();
|
||||
|
||||
function plugin(base) {
|
||||
// do plugin stuff, in pure JavaScript
|
||||
}
|
||||
// use the plugin
|
||||
base.use(plugin);
|
||||
```
|
||||
|
||||
**Inheritance**
|
||||
|
||||
Easily inherit Base using `.extend`:
|
||||
|
||||
```js
|
||||
var Base = require('base');
|
||||
|
||||
function MyApp() {
|
||||
Base.call(this);
|
||||
}
|
||||
Base.extend(MyApp);
|
||||
|
||||
var app = new MyApp();
|
||||
app.set('a', 'b');
|
||||
app.get('a');
|
||||
//=> 'b';
|
||||
```
|
||||
|
||||
**Inherit or instantiate with a namespace**
|
||||
|
||||
By default, the `.get`, `.set` and `.has` methods set and get values from the root of the `base` instance. You can customize this using the `.namespace` method exposed on the exported function. For example:
|
||||
|
||||
```js
|
||||
var Base = require('base');
|
||||
// get and set values on the `base.cache` object
|
||||
var base = Base.namespace('cache');
|
||||
|
||||
var app = base();
|
||||
app.set('foo', 'bar');
|
||||
console.log(app.cache.foo);
|
||||
//=> 'bar'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
**Usage**
|
||||
|
||||
```js
|
||||
var Base = require('base');
|
||||
var app = new Base();
|
||||
app.set('foo', 'bar');
|
||||
console.log(app.foo);
|
||||
//=> 'bar'
|
||||
```
|
||||
|
||||
### [Base](index.js#L44)
|
||||
|
||||
Create an instance of `Base` with the given `config` and `options`.
|
||||
|
||||
**Params**
|
||||
|
||||
* `config` **{Object}**: If supplied, this object is passed to [cache-base](https://github.com/jonschlinkert/cache-base) to merge onto the the instance upon instantiation.
|
||||
* `options` **{Object}**: If supplied, this object is used to initialize the `base.options` object.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
// initialize with `config` and `options`
|
||||
var app = new Base({isApp: true}, {abc: true});
|
||||
app.set('foo', 'bar');
|
||||
|
||||
// values defined with the given `config` object will be on the root of the instance
|
||||
console.log(app.baz); //=> undefined
|
||||
console.log(app.foo); //=> 'bar'
|
||||
// or use `.get`
|
||||
console.log(app.get('isApp')); //=> true
|
||||
console.log(app.get('foo')); //=> 'bar'
|
||||
|
||||
// values defined with the given `options` object will be on `app.options
|
||||
console.log(app.options.abc); //=> true
|
||||
```
|
||||
|
||||
### [.is](index.js#L107)
|
||||
|
||||
Set the given `name` on `app._name` and `app.is*` properties. Used for doing lookups in plugins.
|
||||
|
||||
**Params**
|
||||
|
||||
* `name` **{String}**
|
||||
* `returns` **{Boolean}**
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
app.is('foo');
|
||||
console.log(app._name);
|
||||
//=> 'foo'
|
||||
console.log(app.isFoo);
|
||||
//=> true
|
||||
app.is('bar');
|
||||
console.log(app.isFoo);
|
||||
//=> true
|
||||
console.log(app.isBar);
|
||||
//=> true
|
||||
console.log(app._name);
|
||||
//=> 'bar'
|
||||
```
|
||||
|
||||
### [.isRegistered](index.js#L145)
|
||||
|
||||
Returns true if a plugin has already been registered on an instance.
|
||||
|
||||
Plugin implementors are encouraged to use this first thing in a plugin
|
||||
to prevent the plugin from being called more than once on the same
|
||||
instance.
|
||||
|
||||
**Params**
|
||||
|
||||
* `name` **{String}**: The plugin name.
|
||||
* `register` **{Boolean}**: If the plugin if not already registered, to record it as being registered pass `true` as the second argument.
|
||||
* `returns` **{Boolean}**: Returns true if a plugin is already registered.
|
||||
|
||||
**Events**
|
||||
|
||||
* `emits`: `plugin` Emits the name of the plugin being registered. Useful for unit tests, to ensure plugins are only registered once.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
var base = new Base();
|
||||
base.use(function(app) {
|
||||
if (app.isRegistered('myPlugin')) return;
|
||||
// do stuff to `app`
|
||||
});
|
||||
|
||||
// to also record the plugin as being registered
|
||||
base.use(function(app) {
|
||||
if (app.isRegistered('myPlugin', true)) return;
|
||||
// do stuff to `app`
|
||||
});
|
||||
```
|
||||
|
||||
### [.use](index.js#L175)
|
||||
|
||||
Define a plugin function to be called immediately upon init. Plugins are chainable and expose the following arguments to the plugin function:
|
||||
|
||||
* `app`: the current instance of `Base`
|
||||
* `base`: the [first ancestor instance](#base) of `Base`
|
||||
|
||||
**Params**
|
||||
|
||||
* `fn` **{Function}**: plugin function to call
|
||||
* `returns` **{Object}**: Returns the item instance for chaining.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
var app = new Base()
|
||||
.use(foo)
|
||||
.use(bar)
|
||||
.use(baz)
|
||||
```
|
||||
|
||||
### [.define](index.js#L197)
|
||||
|
||||
The `.define` method is used for adding non-enumerable property on the instance. Dot-notation is **not supported** with `define`.
|
||||
|
||||
**Params**
|
||||
|
||||
* `key` **{String}**: The name of the property to define.
|
||||
* `value` **{any}**
|
||||
* `returns` **{Object}**: Returns the instance for chaining.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
// arbitrary `render` function using lodash `template`
|
||||
app.define('render', function(str, locals) {
|
||||
return _.template(str)(locals);
|
||||
});
|
||||
```
|
||||
|
||||
### [.mixin](index.js#L222)
|
||||
|
||||
Mix property `key` onto the Base prototype. If base is inherited using `Base.extend` this method will be overridden by a new `mixin` method that will only add properties to the prototype of the inheriting application.
|
||||
|
||||
**Params**
|
||||
|
||||
* `key` **{String}**
|
||||
* `val` **{Object|Array}**
|
||||
* `returns` **{Object}**: Returns the `base` instance for chaining.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
app.mixin('foo', function() {
|
||||
// do stuff
|
||||
});
|
||||
```
|
||||
|
||||
### [.base](index.js#L268)
|
||||
|
||||
Getter/setter used when creating nested instances of `Base`, for storing a reference to the first ancestor instance. This works by setting an instance of `Base` on the `parent` property of a "child" instance. The `base` property defaults to the current instance if no `parent` property is defined.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
// create an instance of `Base`, this is our first ("base") instance
|
||||
var first = new Base();
|
||||
first.foo = 'bar'; // arbitrary property, to make it easier to see what's happening later
|
||||
|
||||
// create another instance
|
||||
var second = new Base();
|
||||
// create a reference to the first instance (`first`)
|
||||
second.parent = first;
|
||||
|
||||
// create another instance
|
||||
var third = new Base();
|
||||
// create a reference to the previous instance (`second`)
|
||||
// repeat this pattern every time a "child" instance is created
|
||||
third.parent = second;
|
||||
|
||||
// we can always access the first instance using the `base` property
|
||||
console.log(first.base.foo);
|
||||
//=> 'bar'
|
||||
console.log(second.base.foo);
|
||||
//=> 'bar'
|
||||
console.log(third.base.foo);
|
||||
//=> 'bar'
|
||||
// and now you know how to get to third base ;)
|
||||
```
|
||||
|
||||
### [#use](index.js#L293)
|
||||
|
||||
Static method for adding global plugin functions that will be added to an instance when created.
|
||||
|
||||
**Params**
|
||||
|
||||
* `fn` **{Function}**: Plugin function to use on each instance.
|
||||
* `returns` **{Object}**: Returns the `Base` constructor for chaining
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
Base.use(function(app) {
|
||||
app.foo = 'bar';
|
||||
});
|
||||
var app = new Base();
|
||||
console.log(app.foo);
|
||||
//=> 'bar'
|
||||
```
|
||||
|
||||
### [#extend](index.js#L337)
|
||||
|
||||
Static method for inheriting the prototype and static methods of the `Base` class. This method greatly simplifies the process of creating inheritance-based applications. See [static-extend](https://github.com/jonschlinkert/static-extend) for more details.
|
||||
|
||||
**Params**
|
||||
|
||||
* `Ctor` **{Function}**: constructor to extend
|
||||
* `methods` **{Object}**: Optional prototype properties to mix in.
|
||||
* `returns` **{Object}**: Returns the `Base` constructor for chaining
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
var extend = cu.extend(Parent);
|
||||
Parent.extend(Child);
|
||||
|
||||
// optional methods
|
||||
Parent.extend(Child, {
|
||||
foo: function() {},
|
||||
bar: function() {}
|
||||
});
|
||||
```
|
||||
|
||||
### [#mixin](index.js#L379)
|
||||
|
||||
Used for adding methods to the `Base` prototype, and/or to the prototype of child instances. When a mixin function returns a function, the returned function is pushed onto the `.mixins` array, making it available to be used on inheriting classes whenever `Base.mixins()` is called (e.g. `Base.mixins(Child)`).
|
||||
|
||||
**Params**
|
||||
|
||||
* `fn` **{Function}**: Function to call
|
||||
* `returns` **{Object}**: Returns the `Base` constructor for chaining
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
Base.mixin(function(proto) {
|
||||
proto.foo = function(msg) {
|
||||
return 'foo ' + msg;
|
||||
};
|
||||
});
|
||||
```
|
||||
|
||||
### [#mixins](index.js#L401)
|
||||
|
||||
Static method for running global mixin functions against a child constructor. Mixins must be registered before calling this method.
|
||||
|
||||
**Params**
|
||||
|
||||
* `Child` **{Function}**: Constructor function of a child class
|
||||
* `returns` **{Object}**: Returns the `Base` constructor for chaining
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
Base.extend(Child);
|
||||
Base.mixins(Child);
|
||||
```
|
||||
|
||||
### [#inherit](index.js#L420)
|
||||
|
||||
Similar to `util.inherit`, but copies all static properties, prototype properties, and getters/setters from `Provider` to `Receiver`. See [class-utils](https://github.com/jonschlinkert/class-utils#inherit) for more details.
|
||||
|
||||
**Params**
|
||||
|
||||
* `Receiver` **{Function}**: Receiving (child) constructor
|
||||
* `Provider` **{Function}**: Providing (parent) constructor
|
||||
* `returns` **{Object}**: Returns the `Base` constructor for chaining
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
Base.inherit(Foo, Bar);
|
||||
```
|
||||
|
||||
## In the wild
|
||||
|
||||
The following node.js applications were built with `Base`:
|
||||
|
||||
* [assemble](https://github.com/assemble/assemble)
|
||||
* [verb](https://github.com/verbose/verb)
|
||||
* [generate](https://github.com/generate/generate)
|
||||
* [scaffold](https://github.com/jonschlinkert/scaffold)
|
||||
* [boilerplate](https://github.com/jonschlinkert/boilerplate)
|
||||
|
||||
## Test coverage
|
||||
|
||||
```
|
||||
Statements : 98.91% ( 91/92 )
|
||||
Branches : 92.86% ( 26/28 )
|
||||
Functions : 100% ( 17/17 )
|
||||
Lines : 98.9% ( 90/91 )
|
||||
```
|
||||
|
||||
## History
|
||||
|
||||
### v0.11.2
|
||||
|
||||
* fixes https://github.com/micromatch/micromatch/issues/99
|
||||
|
||||
### v0.11.0
|
||||
|
||||
**Breaking changes**
|
||||
|
||||
* Static `.use` and `.run` methods are now non-enumerable
|
||||
|
||||
### v0.9.0
|
||||
|
||||
**Breaking changes**
|
||||
|
||||
* `.is` no longer takes a function, a string must be passed
|
||||
* all remaining `.debug` code has been removed
|
||||
* `app._namespace` was removed (related to `debug`)
|
||||
* `.plugin`, `.use`, and `.define` no longer emit events
|
||||
* `.assertPlugin` was removed
|
||||
* `.lazy` was removed
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [base-cwd](https://www.npmjs.com/package/base-cwd): Base plugin that adds a getter/setter for the current working directory. | [homepage](https://github.com/node-base/base-cwd "Base plugin that adds a getter/setter for the current working directory.")
|
||||
* [base-data](https://www.npmjs.com/package/base-data): adds a `data` method to base-methods. | [homepage](https://github.com/node-base/base-data "adds a `data` method to base-methods.")
|
||||
* [base-fs](https://www.npmjs.com/package/base-fs): base-methods plugin that adds vinyl-fs methods to your 'base' application for working with the file… [more](https://github.com/node-base/base-fs) | [homepage](https://github.com/node-base/base-fs "base-methods plugin that adds vinyl-fs methods to your 'base' application for working with the file system, like src, dest, copy and symlink.")
|
||||
* [base-generators](https://www.npmjs.com/package/base-generators): Adds project-generator support to your `base` application. | [homepage](https://github.com/node-base/base-generators "Adds project-generator support to your `base` application.")
|
||||
* [base-option](https://www.npmjs.com/package/base-option): Adds a few options methods to base, like `option`, `enable` and `disable`. See the readme… [more](https://github.com/node-base/base-option) | [homepage](https://github.com/node-base/base-option "Adds a few options methods to base, like `option`, `enable` and `disable`. See the readme for the full API.")
|
||||
* [base-pipeline](https://www.npmjs.com/package/base-pipeline): base-methods plugin that adds pipeline and plugin methods for dynamically composing streaming plugin pipelines. | [homepage](https://github.com/node-base/base-pipeline "base-methods plugin that adds pipeline and plugin methods for dynamically composing streaming plugin pipelines.")
|
||||
* [base-pkg](https://www.npmjs.com/package/base-pkg): Plugin for adding a `pkg` method that exposes pkg-store to your base application. | [homepage](https://github.com/node-base/base-pkg "Plugin for adding a `pkg` method that exposes pkg-store to your base application.")
|
||||
* [base-plugins](https://www.npmjs.com/package/base-plugins): Adds 'smart plugin' support to your base application. | [homepage](https://github.com/node-base/base-plugins "Adds 'smart plugin' support to your base application.")
|
||||
* [base-questions](https://www.npmjs.com/package/base-questions): Plugin for base-methods that adds methods for prompting the user and storing the answers on… [more](https://github.com/node-base/base-questions) | [homepage](https://github.com/node-base/base-questions "Plugin for base-methods that adds methods for prompting the user and storing the answers on a project-by-project basis.")
|
||||
* [base-store](https://www.npmjs.com/package/base-store): Plugin for getting and persisting config values with your base-methods application. Adds a 'store' object… [more](https://github.com/node-base/base-store) | [homepage](https://github.com/node-base/base-store "Plugin for getting and persisting config values with your base-methods application. Adds a 'store' object that exposes all of the methods from the data-store library. Also now supports sub-stores!")
|
||||
* [base-task](https://www.npmjs.com/package/base-task): base plugin that provides a very thin wrapper around [https://github.com/doowb/composer](https://github.com/doowb/composer) for adding task methods to… [more](https://github.com/node-base/base-task) | [homepage](https://github.com/node-base/base-task "base plugin that provides a very thin wrapper around <https://github.com/doowb/composer> for adding task methods to your application.")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Contributors
|
||||
|
||||
| **Commits** | **Contributor** |
|
||||
| --- | --- |
|
||||
| 141 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||
| 30 | [doowb](https://github.com/doowb) |
|
||||
| 3 | [charlike](https://github.com/charlike) |
|
||||
| 1 | [criticalmash](https://github.com/criticalmash) |
|
||||
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on September 07, 2017._
|
||||
+435
@@ -0,0 +1,435 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var define = require('define-property');
|
||||
var CacheBase = require('cache-base');
|
||||
var Emitter = require('component-emitter');
|
||||
var isObject = require('isobject');
|
||||
var merge = require('mixin-deep');
|
||||
var pascal = require('pascalcase');
|
||||
var cu = require('class-utils');
|
||||
|
||||
/**
|
||||
* Optionally define a custom `cache` namespace to use.
|
||||
*/
|
||||
|
||||
function namespace(name) {
|
||||
var Cache = name ? CacheBase.namespace(name) : CacheBase;
|
||||
var fns = [];
|
||||
|
||||
/**
|
||||
* Create an instance of `Base` with the given `config` and `options`.
|
||||
*
|
||||
* ```js
|
||||
* // initialize with `config` and `options`
|
||||
* var app = new Base({isApp: true}, {abc: true});
|
||||
* app.set('foo', 'bar');
|
||||
*
|
||||
* // values defined with the given `config` object will be on the root of the instance
|
||||
* console.log(app.baz); //=> undefined
|
||||
* console.log(app.foo); //=> 'bar'
|
||||
* // or use `.get`
|
||||
* console.log(app.get('isApp')); //=> true
|
||||
* console.log(app.get('foo')); //=> 'bar'
|
||||
*
|
||||
* // values defined with the given `options` object will be on `app.options
|
||||
* console.log(app.options.abc); //=> true
|
||||
* ```
|
||||
*
|
||||
* @param {Object} `config` If supplied, this object is passed to [cache-base][] to merge onto the the instance upon instantiation.
|
||||
* @param {Object} `options` If supplied, this object is used to initialize the `base.options` object.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Base(config, options) {
|
||||
if (!(this instanceof Base)) {
|
||||
return new Base(config, options);
|
||||
}
|
||||
Cache.call(this, config);
|
||||
this.is('base');
|
||||
this.initBase(config, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit cache-base
|
||||
*/
|
||||
|
||||
util.inherits(Base, Cache);
|
||||
|
||||
/**
|
||||
* Add static emitter methods
|
||||
*/
|
||||
|
||||
Emitter(Base);
|
||||
|
||||
/**
|
||||
* Initialize `Base` defaults with the given `config` object
|
||||
*/
|
||||
|
||||
Base.prototype.initBase = function(config, options) {
|
||||
this.options = merge({}, this.options, options);
|
||||
this.cache = this.cache || {};
|
||||
this.define('registered', {});
|
||||
if (name) this[name] = {};
|
||||
|
||||
// make `app._callbacks` non-enumerable
|
||||
this.define('_callbacks', this._callbacks);
|
||||
if (isObject(config)) {
|
||||
this.visit('set', config);
|
||||
}
|
||||
Base.run(this, 'use', fns);
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the given `name` on `app._name` and `app.is*` properties. Used for doing
|
||||
* lookups in plugins.
|
||||
*
|
||||
* ```js
|
||||
* app.is('foo');
|
||||
* console.log(app._name);
|
||||
* //=> 'foo'
|
||||
* console.log(app.isFoo);
|
||||
* //=> true
|
||||
* app.is('bar');
|
||||
* console.log(app.isFoo);
|
||||
* //=> true
|
||||
* console.log(app.isBar);
|
||||
* //=> true
|
||||
* console.log(app._name);
|
||||
* //=> 'bar'
|
||||
* ```
|
||||
* @name .is
|
||||
* @param {String} `name`
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Base.prototype.is = function(name) {
|
||||
if (typeof name !== 'string') {
|
||||
throw new TypeError('expected name to be a string');
|
||||
}
|
||||
this.define('is' + pascal(name), true);
|
||||
this.define('_name', name);
|
||||
this.define('_appname', name);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if a plugin has already been registered on an instance.
|
||||
*
|
||||
* Plugin implementors are encouraged to use this first thing in a plugin
|
||||
* to prevent the plugin from being called more than once on the same
|
||||
* instance.
|
||||
*
|
||||
* ```js
|
||||
* var base = new Base();
|
||||
* base.use(function(app) {
|
||||
* if (app.isRegistered('myPlugin')) return;
|
||||
* // do stuff to `app`
|
||||
* });
|
||||
*
|
||||
* // to also record the plugin as being registered
|
||||
* base.use(function(app) {
|
||||
* if (app.isRegistered('myPlugin', true)) return;
|
||||
* // do stuff to `app`
|
||||
* });
|
||||
* ```
|
||||
* @name .isRegistered
|
||||
* @emits `plugin` Emits the name of the plugin being registered. Useful for unit tests, to ensure plugins are only registered once.
|
||||
* @param {String} `name` The plugin name.
|
||||
* @param {Boolean} `register` If the plugin if not already registered, to record it as being registered pass `true` as the second argument.
|
||||
* @return {Boolean} Returns true if a plugin is already registered.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Base.prototype.isRegistered = function(name, register) {
|
||||
if (this.registered.hasOwnProperty(name)) {
|
||||
return true;
|
||||
}
|
||||
if (register !== false) {
|
||||
this.registered[name] = true;
|
||||
this.emit('plugin', name);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Define a plugin function to be called immediately upon init. Plugins are chainable
|
||||
* and expose the following arguments to the plugin function:
|
||||
*
|
||||
* - `app`: the current instance of `Base`
|
||||
* - `base`: the [first ancestor instance](#base) of `Base`
|
||||
*
|
||||
* ```js
|
||||
* var app = new Base()
|
||||
* .use(foo)
|
||||
* .use(bar)
|
||||
* .use(baz)
|
||||
* ```
|
||||
* @name .use
|
||||
* @param {Function} `fn` plugin function to call
|
||||
* @return {Object} Returns the item instance for chaining.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Base.prototype.use = function(fn) {
|
||||
fn.call(this, this);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* The `.define` method is used for adding non-enumerable property on the instance.
|
||||
* Dot-notation is **not supported** with `define`.
|
||||
*
|
||||
* ```js
|
||||
* // arbitrary `render` function using lodash `template`
|
||||
* app.define('render', function(str, locals) {
|
||||
* return _.template(str)(locals);
|
||||
* });
|
||||
* ```
|
||||
* @name .define
|
||||
* @param {String} `key` The name of the property to define.
|
||||
* @param {any} `value`
|
||||
* @return {Object} Returns the instance for chaining.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Base.prototype.define = function(key, val) {
|
||||
if (isObject(key)) {
|
||||
return this.visit('define', key);
|
||||
}
|
||||
define(this, key, val);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Mix property `key` onto the Base prototype. If base is inherited using
|
||||
* `Base.extend` this method will be overridden by a new `mixin` method that will
|
||||
* only add properties to the prototype of the inheriting application.
|
||||
*
|
||||
* ```js
|
||||
* app.mixin('foo', function() {
|
||||
* // do stuff
|
||||
* });
|
||||
* ```
|
||||
* @name .mixin
|
||||
* @param {String} `key`
|
||||
* @param {Object|Array} `val`
|
||||
* @return {Object} Returns the `base` instance for chaining.
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Base.prototype.mixin = function(key, val) {
|
||||
Base.prototype[key] = val;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Non-enumberable mixin array, used by the static [Base.mixin]() method.
|
||||
*/
|
||||
|
||||
Base.prototype.mixins = Base.prototype.mixins || [];
|
||||
|
||||
/**
|
||||
* Getter/setter used when creating nested instances of `Base`, for storing a reference
|
||||
* to the first ancestor instance. This works by setting an instance of `Base` on the `parent`
|
||||
* property of a "child" instance. The `base` property defaults to the current instance if
|
||||
* no `parent` property is defined.
|
||||
*
|
||||
* ```js
|
||||
* // create an instance of `Base`, this is our first ("base") instance
|
||||
* var first = new Base();
|
||||
* first.foo = 'bar'; // arbitrary property, to make it easier to see what's happening later
|
||||
*
|
||||
* // create another instance
|
||||
* var second = new Base();
|
||||
* // create a reference to the first instance (`first`)
|
||||
* second.parent = first;
|
||||
*
|
||||
* // create another instance
|
||||
* var third = new Base();
|
||||
* // create a reference to the previous instance (`second`)
|
||||
* // repeat this pattern every time a "child" instance is created
|
||||
* third.parent = second;
|
||||
*
|
||||
* // we can always access the first instance using the `base` property
|
||||
* console.log(first.base.foo);
|
||||
* //=> 'bar'
|
||||
* console.log(second.base.foo);
|
||||
* //=> 'bar'
|
||||
* console.log(third.base.foo);
|
||||
* //=> 'bar'
|
||||
* // and now you know how to get to third base ;)
|
||||
* ```
|
||||
* @name .base
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Object.defineProperty(Base.prototype, 'base', {
|
||||
configurable: true,
|
||||
get: function() {
|
||||
return this.parent ? this.parent.base : this;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Static method for adding global plugin functions that will
|
||||
* be added to an instance when created.
|
||||
*
|
||||
* ```js
|
||||
* Base.use(function(app) {
|
||||
* app.foo = 'bar';
|
||||
* });
|
||||
* var app = new Base();
|
||||
* console.log(app.foo);
|
||||
* //=> 'bar'
|
||||
* ```
|
||||
* @name #use
|
||||
* @param {Function} `fn` Plugin function to use on each instance.
|
||||
* @return {Object} Returns the `Base` constructor for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
define(Base, 'use', function(fn) {
|
||||
fns.push(fn);
|
||||
return Base;
|
||||
});
|
||||
|
||||
/**
|
||||
* Run an array of functions by passing each function
|
||||
* to a method on the given object specified by the given property.
|
||||
*
|
||||
* @param {Object} `obj` Object containing method to use.
|
||||
* @param {String} `prop` Name of the method on the object to use.
|
||||
* @param {Array} `arr` Array of functions to pass to the method.
|
||||
*/
|
||||
|
||||
define(Base, 'run', function(obj, prop, arr) {
|
||||
var len = arr.length, i = 0;
|
||||
while (len--) {
|
||||
obj[prop](arr[i++]);
|
||||
}
|
||||
return Base;
|
||||
});
|
||||
|
||||
/**
|
||||
* Static method for inheriting the prototype and static methods of the `Base` class.
|
||||
* This method greatly simplifies the process of creating inheritance-based applications.
|
||||
* See [static-extend][] for more details.
|
||||
*
|
||||
* ```js
|
||||
* var extend = cu.extend(Parent);
|
||||
* Parent.extend(Child);
|
||||
*
|
||||
* // optional methods
|
||||
* Parent.extend(Child, {
|
||||
* foo: function() {},
|
||||
* bar: function() {}
|
||||
* });
|
||||
* ```
|
||||
* @name #extend
|
||||
* @param {Function} `Ctor` constructor to extend
|
||||
* @param {Object} `methods` Optional prototype properties to mix in.
|
||||
* @return {Object} Returns the `Base` constructor for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
define(Base, 'extend', cu.extend(Base, function(Ctor, Parent) {
|
||||
Ctor.prototype.mixins = Ctor.prototype.mixins || [];
|
||||
|
||||
define(Ctor, 'mixin', function(fn) {
|
||||
var mixin = fn(Ctor.prototype, Ctor);
|
||||
if (typeof mixin === 'function') {
|
||||
Ctor.prototype.mixins.push(mixin);
|
||||
}
|
||||
return Ctor;
|
||||
});
|
||||
|
||||
define(Ctor, 'mixins', function(Child) {
|
||||
Base.run(Child, 'mixin', Ctor.prototype.mixins);
|
||||
return Ctor;
|
||||
});
|
||||
|
||||
Ctor.prototype.mixin = function(key, value) {
|
||||
Ctor.prototype[key] = value;
|
||||
return this;
|
||||
};
|
||||
return Base;
|
||||
}));
|
||||
|
||||
/**
|
||||
* Used for adding methods to the `Base` prototype, and/or to the prototype of child instances.
|
||||
* When a mixin function returns a function, the returned function is pushed onto the `.mixins`
|
||||
* array, making it available to be used on inheriting classes whenever `Base.mixins()` is
|
||||
* called (e.g. `Base.mixins(Child)`).
|
||||
*
|
||||
* ```js
|
||||
* Base.mixin(function(proto) {
|
||||
* proto.foo = function(msg) {
|
||||
* return 'foo ' + msg;
|
||||
* };
|
||||
* });
|
||||
* ```
|
||||
* @name #mixin
|
||||
* @param {Function} `fn` Function to call
|
||||
* @return {Object} Returns the `Base` constructor for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
define(Base, 'mixin', function(fn) {
|
||||
var mixin = fn(Base.prototype, Base);
|
||||
if (typeof mixin === 'function') {
|
||||
Base.prototype.mixins.push(mixin);
|
||||
}
|
||||
return Base;
|
||||
});
|
||||
|
||||
/**
|
||||
* Static method for running global mixin functions against a child constructor.
|
||||
* Mixins must be registered before calling this method.
|
||||
*
|
||||
* ```js
|
||||
* Base.extend(Child);
|
||||
* Base.mixins(Child);
|
||||
* ```
|
||||
* @name #mixins
|
||||
* @param {Function} `Child` Constructor function of a child class
|
||||
* @return {Object} Returns the `Base` constructor for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
define(Base, 'mixins', function(Child) {
|
||||
Base.run(Child, 'mixin', Base.prototype.mixins);
|
||||
return Base;
|
||||
});
|
||||
|
||||
/**
|
||||
* Similar to `util.inherit`, but copies all static properties, prototype properties, and
|
||||
* getters/setters from `Provider` to `Receiver`. See [class-utils][]{#inherit} for more details.
|
||||
*
|
||||
* ```js
|
||||
* Base.inherit(Foo, Bar);
|
||||
* ```
|
||||
* @name #inherit
|
||||
* @param {Function} `Receiver` Receiving (child) constructor
|
||||
* @param {Function} `Provider` Providing (parent) constructor
|
||||
* @return {Object} Returns the `Base` constructor for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
define(Base, 'inherit', cu.inherit);
|
||||
define(Base, 'bubble', cu.bubble);
|
||||
return Base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose `Base` with default settings
|
||||
*/
|
||||
|
||||
module.exports = namespace();
|
||||
|
||||
/**
|
||||
* Allow users to define a namespace
|
||||
*/
|
||||
|
||||
module.exports.namespace = namespace;
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015, 2017, Jon Schlinkert
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
# define-property [](https://www.npmjs.com/package/define-property) [](https://npmjs.org/package/define-property) [](https://npmjs.org/package/define-property) [](https://travis-ci.org/jonschlinkert/define-property)
|
||||
|
||||
> Define a non-enumerable property on an object.
|
||||
|
||||
## Install
|
||||
|
||||
Install with [npm](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
$ npm install --save define-property
|
||||
```
|
||||
|
||||
Install with [yarn](https://yarnpkg.com):
|
||||
|
||||
```sh
|
||||
$ yarn add define-property
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
**Params**
|
||||
|
||||
* `obj`: The object on which to define the property.
|
||||
* `prop`: The name of the property to be defined or modified.
|
||||
* `descriptor`: The descriptor for the property being defined or modified.
|
||||
|
||||
```js
|
||||
var define = require('define-property');
|
||||
var obj = {};
|
||||
define(obj, 'foo', function(val) {
|
||||
return val.toUpperCase();
|
||||
});
|
||||
|
||||
console.log(obj);
|
||||
//=> {}
|
||||
|
||||
console.log(obj.foo('bar'));
|
||||
//=> 'BAR'
|
||||
```
|
||||
|
||||
**get/set**
|
||||
|
||||
```js
|
||||
define(obj, 'foo', {
|
||||
get: function() {},
|
||||
set: function() {}
|
||||
});
|
||||
```
|
||||
|
||||
## About
|
||||
|
||||
### Related projects
|
||||
|
||||
* [assign-deep](https://www.npmjs.com/package/assign-deep): Deeply assign the enumerable properties and/or es6 Symbol properies of source objects to the target… [more](https://github.com/jonschlinkert/assign-deep) | [homepage](https://github.com/jonschlinkert/assign-deep "Deeply assign the enumerable properties and/or es6 Symbol properies of source objects to the target (first) object.")
|
||||
* [extend-shallow](https://www.npmjs.com/package/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util. | [homepage](https://github.com/jonschlinkert/extend-shallow "Extend an object with the properties of additional objects. node.js/javascript util.")
|
||||
* [merge-deep](https://www.npmjs.com/package/merge-deep): Recursively merge values in a javascript object. | [homepage](https://github.com/jonschlinkert/merge-deep "Recursively merge values in a javascript object.")
|
||||
* [mixin-deep](https://www.npmjs.com/package/mixin-deep): Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone. | [homepage](https://github.com/jonschlinkert/mixin-deep "Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone.")
|
||||
|
||||
### Contributing
|
||||
|
||||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||
|
||||
### Building docs
|
||||
|
||||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||
|
||||
To generate the readme, run the following command:
|
||||
|
||||
```sh
|
||||
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||
```
|
||||
|
||||
### Running tests
|
||||
|
||||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||
|
||||
```sh
|
||||
$ npm install && npm test
|
||||
```
|
||||
|
||||
### Author
|
||||
|
||||
**Jon Schlinkert**
|
||||
|
||||
* [github/jonschlinkert](https://github.com/jonschlinkert)
|
||||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
|
||||
|
||||
### License
|
||||
|
||||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||
Released under the [MIT License](LICENSE).
|
||||
|
||||
***
|
||||
|
||||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.5.0, on April 20, 2017._
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*!
|
||||
* define-property <https://github.com/jonschlinkert/define-property>
|
||||
*
|
||||
* Copyright (c) 2015, 2017, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var isDescriptor = require('is-descriptor');
|
||||
|
||||
module.exports = function defineProperty(obj, prop, val) {
|
||||
if (typeof obj !== 'object' && typeof obj !== 'function') {
|
||||
throw new TypeError('expected an object or function.');
|
||||
}
|
||||
|
||||
if (typeof prop !== 'string') {
|
||||
throw new TypeError('expected `prop` to be a string.');
|
||||
}
|
||||
|
||||
if (isDescriptor(val) && ('set' in val || 'get' in val)) {
|
||||
return Object.defineProperty(obj, prop, val);
|
||||
}
|
||||
|
||||
return Object.defineProperty(obj, prop, {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
value: val
|
||||
});
|
||||
};
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"name": "define-property",
|
||||
"description": "Define a non-enumerable property on an object.",
|
||||
"version": "1.0.0",
|
||||
"homepage": "https://github.com/jonschlinkert/define-property",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"repository": "jonschlinkert/define-property",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jonschlinkert/define-property/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-descriptor": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp-format-md": "^0.1.12",
|
||||
"mocha": "^3.2.0"
|
||||
},
|
||||
"keywords": [
|
||||
"define",
|
||||
"define-property",
|
||||
"enumerable",
|
||||
"key",
|
||||
"non",
|
||||
"non-enumerable",
|
||||
"object",
|
||||
"prop",
|
||||
"property",
|
||||
"value"
|
||||
],
|
||||
"verb": {
|
||||
"related": {
|
||||
"list": [
|
||||
"extend-shallow",
|
||||
"merge-deep",
|
||||
"assign-deep",
|
||||
"mixin-deep"
|
||||
]
|
||||
},
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"name": "base",
|
||||
"description": "base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting with a handful of common methods, like `set`, `get`, `del` and `use`.",
|
||||
"version": "0.11.2",
|
||||
"homepage": "https://github.com/node-base/base",
|
||||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||
"maintainers": [
|
||||
"Brian Woodward (https://github.com/doowb)",
|
||||
"Jon Schlinkert (https://github.com/jonschlinkert)"
|
||||
],
|
||||
"contributors": [
|
||||
"Brian Woodward (https://twitter.com/doowb)",
|
||||
"John O'Donnell (https://github.com/criticalmash)",
|
||||
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||
"tunnckoCore (https://i.am.charlike.online)",
|
||||
"(https://github.com/wtgtybhertgeghgtwtg)"
|
||||
],
|
||||
"repository": "node-base/base",
|
||||
"bugs": {
|
||||
"url": "https://github.com/node-base/base/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"cache-base": "^1.0.1",
|
||||
"class-utils": "^0.3.5",
|
||||
"component-emitter": "^1.2.1",
|
||||
"define-property": "^1.0.0",
|
||||
"isobject": "^3.0.1",
|
||||
"mixin-deep": "^1.2.0",
|
||||
"pascalcase": "^0.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-eslint": "^4.0.0",
|
||||
"gulp-format-md": "^1.0.0",
|
||||
"gulp-istanbul": "^1.1.2",
|
||||
"gulp-mocha": "^3.0.1",
|
||||
"helper-coverage": "^0.1.3",
|
||||
"mocha": "^3.5.0",
|
||||
"should": "^13.0.1",
|
||||
"through2": "^2.0.3",
|
||||
"verb-generate-readme": "^0.6.0"
|
||||
},
|
||||
"keywords": [
|
||||
"base",
|
||||
"boilerplate",
|
||||
"cache",
|
||||
"del",
|
||||
"get",
|
||||
"inherit",
|
||||
"methods",
|
||||
"set",
|
||||
"starter",
|
||||
"unset",
|
||||
"visit"
|
||||
],
|
||||
"verb": {
|
||||
"run": true,
|
||||
"toc": false,
|
||||
"layout": "default",
|
||||
"tasks": [
|
||||
"readme"
|
||||
],
|
||||
"plugins": [
|
||||
"gulp-format-md"
|
||||
],
|
||||
"helpers": [
|
||||
"helper-coverage"
|
||||
],
|
||||
"related": {
|
||||
"description": "There are a number of different plugins available for extending base. Let us know if you create your own!",
|
||||
"hightlight": "generate",
|
||||
"list": [
|
||||
"base-cwd",
|
||||
"base-data",
|
||||
"base-fs",
|
||||
"base-generators",
|
||||
"base-option",
|
||||
"base-pipeline",
|
||||
"base-pkg",
|
||||
"base-plugins",
|
||||
"base-questions",
|
||||
"base-store",
|
||||
"base-task"
|
||||
]
|
||||
},
|
||||
"reflinks": [
|
||||
"assemble",
|
||||
"boilerplate",
|
||||
"cache-base",
|
||||
"class-utils",
|
||||
"generate",
|
||||
"scaffold",
|
||||
"static-extend",
|
||||
"verb"
|
||||
],
|
||||
"lint": {
|
||||
"reflinks": true
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
- "0.11"
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
base64-js
|
||||
=========
|
||||
|
||||
`base64-js` does basic base64 encoding/decoding in pure JS.
|
||||
|
||||
[](http://travis-ci.org/beatgammit/base64-js)
|
||||
|
||||
[](https://ci.testling.com/beatgammit/base64-js)
|
||||
|
||||
Many browsers already have base64 encoding/decoding functionality, but it is for text data, not all-purpose binary data.
|
||||
|
||||
Sometimes encoding/decoding binary data in the browser is useful, and that is what this module does.
|
||||
|
||||
## install
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
`npm install base64-js`
|
||||
|
||||
## methods
|
||||
|
||||
`var base64 = require('base64-js')`
|
||||
|
||||
`base64` has two exposed functions, `toByteArray` and `fromByteArray`, which both take a single argument.
|
||||
|
||||
* `toByteArray` - Takes a base64 string and returns a byte array
|
||||
* `fromByteArray` - Takes a byte array and returns a base64 string
|
||||
|
||||
## license
|
||||
|
||||
MIT
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
var random = require('crypto').pseudoRandomBytes
|
||||
|
||||
var b64 = require('../')
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var data = random(1e6).toString('base64')
|
||||
//fs.readFileSync(path.join(__dirname, 'example.b64'), 'ascii').split('\n').join('')
|
||||
var start = Date.now()
|
||||
var raw = b64.toByteArray(data)
|
||||
var middle = Date.now()
|
||||
var data = b64.fromByteArray(raw)
|
||||
var end = Date.now()
|
||||
|
||||
console.log('decode ms, decode ops/ms, encode ms, encode ops/ms')
|
||||
console.log(
|
||||
middle - start, data.length / (middle - start),
|
||||
end - middle, data.length / (end - middle))
|
||||
//console.log(data)
|
||||
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||
|
||||
;(function (exports) {
|
||||
'use strict';
|
||||
|
||||
var Arr = (typeof Uint8Array !== 'undefined')
|
||||
? Uint8Array
|
||||
: Array
|
||||
|
||||
var PLUS = '+'.charCodeAt(0)
|
||||
var SLASH = '/'.charCodeAt(0)
|
||||
var NUMBER = '0'.charCodeAt(0)
|
||||
var LOWER = 'a'.charCodeAt(0)
|
||||
var UPPER = 'A'.charCodeAt(0)
|
||||
var PLUS_URL_SAFE = '-'.charCodeAt(0)
|
||||
var SLASH_URL_SAFE = '_'.charCodeAt(0)
|
||||
|
||||
function decode (elt) {
|
||||
var code = elt.charCodeAt(0)
|
||||
if (code === PLUS ||
|
||||
code === PLUS_URL_SAFE)
|
||||
return 62 // '+'
|
||||
if (code === SLASH ||
|
||||
code === SLASH_URL_SAFE)
|
||||
return 63 // '/'
|
||||
if (code < NUMBER)
|
||||
return -1 //no match
|
||||
if (code < NUMBER + 10)
|
||||
return code - NUMBER + 26 + 26
|
||||
if (code < UPPER + 26)
|
||||
return code - UPPER
|
||||
if (code < LOWER + 26)
|
||||
return code - LOWER + 26
|
||||
}
|
||||
|
||||
function b64ToByteArray (b64) {
|
||||
var i, j, l, tmp, placeHolders, arr
|
||||
|
||||
if (b64.length % 4 > 0) {
|
||||
throw new Error('Invalid string. Length must be a multiple of 4')
|
||||
}
|
||||
|
||||
// the number of equal signs (place holders)
|
||||
// if there are two placeholders, than the two characters before it
|
||||
// represent one byte
|
||||
// if there is only one, then the three characters before it represent 2 bytes
|
||||
// this is just a cheap hack to not do indexOf twice
|
||||
var len = b64.length
|
||||
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
|
||||
|
||||
// base64 is 4/3 + up to two characters of the original data
|
||||
arr = new Arr(b64.length * 3 / 4 - placeHolders)
|
||||
|
||||
// if there are placeholders, only get up to the last complete 4 chars
|
||||
l = placeHolders > 0 ? b64.length - 4 : b64.length
|
||||
|
||||
var L = 0
|
||||
|
||||
function push (v) {
|
||||
arr[L++] = v
|
||||
}
|
||||
|
||||
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
||||
tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
|
||||
push((tmp & 0xFF0000) >> 16)
|
||||
push((tmp & 0xFF00) >> 8)
|
||||
push(tmp & 0xFF)
|
||||
}
|
||||
|
||||
if (placeHolders === 2) {
|
||||
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
|
||||
push(tmp & 0xFF)
|
||||
} else if (placeHolders === 1) {
|
||||
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
|
||||
push((tmp >> 8) & 0xFF)
|
||||
push(tmp & 0xFF)
|
||||
}
|
||||
|
||||
return arr
|
||||
}
|
||||
|
||||
function uint8ToBase64 (uint8) {
|
||||
var i,
|
||||
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
|
||||
output = "",
|
||||
temp, length
|
||||
|
||||
function encode (num) {
|
||||
return lookup.charAt(num)
|
||||
}
|
||||
|
||||
function tripletToBase64 (num) {
|
||||
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
|
||||
}
|
||||
|
||||
// go through the array every three bytes, we'll deal with trailing stuff later
|
||||
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
||||
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
|
||||
output += tripletToBase64(temp)
|
||||
}
|
||||
|
||||
// pad the end with zeros, but make sure to not forget the extra bytes
|
||||
switch (extraBytes) {
|
||||
case 1:
|
||||
temp = uint8[uint8.length - 1]
|
||||
output += encode(temp >> 2)
|
||||
output += encode((temp << 4) & 0x3F)
|
||||
output += '=='
|
||||
break
|
||||
case 2:
|
||||
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
|
||||
output += encode(temp >> 10)
|
||||
output += encode((temp >> 4) & 0x3F)
|
||||
output += encode((temp << 2) & 0x3F)
|
||||
output += '='
|
||||
break
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
exports.toByteArray = b64ToByteArray
|
||||
exports.fromByteArray = uint8ToBase64
|
||||
}(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"author": "T. Jameson Little <t.jameson.little@gmail.com>",
|
||||
"name": "base64-js",
|
||||
"description": "Base64 encoding/decoding in pure JS",
|
||||
"version": "0.0.8",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/beatgammit/base64-js.git"
|
||||
},
|
||||
"main": "lib/b64.js",
|
||||
"scripts": {
|
||||
"test": "tape test/*.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/6..latest",
|
||||
"chrome/4..latest",
|
||||
"firefox/3..latest",
|
||||
"safari/5.1..latest",
|
||||
"opera/11.0..latest",
|
||||
"iphone/6",
|
||||
"ipad/6"
|
||||
]
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"tape": "~2.3.2"
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user