node-datachannel 0.5.0-dev → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CMakeLists.txt +1 -1
- package/examples/electron-demo/package-lock.json +164 -419
- package/examples/electron-demo/package.json +2 -2
- package/lib/index.d.ts +5 -0
- package/lib/index.js +33 -2
- package/package.json +1 -5
- package/polyfill/RTCDtlsTransport.js +30 -12
- package/polyfill/RTCIceCandidate.js +1 -1
- package/polyfill/RTCIceTransport.js +48 -21
- package/polyfill/RTCPeerConnection.js +46 -23
- package/polyfill/RTCSctpTransport.js +33 -14
- package/src/peer-connection-wrapper.cpp +50 -0
- package/src/peer-connection-wrapper.h +2 -0
- package/test/connectivity.js +1 -1
- package/test/polyfill-connectivity.js +2 -1
- package/test/test.js +2 -2
- package/examples/build/Dockerfile +0 -30
- package/examples/build/README.md +0 -24
- package/node_modules/base64-js/LICENSE +0 -21
- package/node_modules/base64-js/README.md +0 -34
- package/node_modules/base64-js/base64js.min.js +0 -1
- package/node_modules/base64-js/index.d.ts +0 -3
- package/node_modules/base64-js/index.js +0 -150
- package/node_modules/base64-js/package.json +0 -47
- package/node_modules/buffer/AUTHORS.md +0 -70
- package/node_modules/buffer/LICENSE +0 -21
- package/node_modules/buffer/README.md +0 -410
- package/node_modules/buffer/index.d.ts +0 -186
- package/node_modules/buffer/index.js +0 -1817
- package/node_modules/buffer/package.json +0 -96
- package/node_modules/chownr/LICENSE +0 -15
- package/node_modules/chownr/README.md +0 -3
- package/node_modules/chownr/chownr.js +0 -167
- package/node_modules/chownr/package.json +0 -29
- package/node_modules/decompress-response/index.d.ts +0 -22
- package/node_modules/decompress-response/index.js +0 -58
- package/node_modules/decompress-response/license +0 -9
- package/node_modules/decompress-response/package.json +0 -56
- package/node_modules/decompress-response/readme.md +0 -48
- package/node_modules/deep-extend/CHANGELOG.md +0 -46
- package/node_modules/deep-extend/LICENSE +0 -20
- package/node_modules/deep-extend/README.md +0 -91
- package/node_modules/deep-extend/index.js +0 -1
- package/node_modules/deep-extend/lib/deep-extend.js +0 -150
- package/node_modules/deep-extend/package.json +0 -62
- package/node_modules/detect-libc/LICENSE +0 -201
- package/node_modules/detect-libc/README.md +0 -163
- package/node_modules/detect-libc/index.d.ts +0 -14
- package/node_modules/detect-libc/lib/detect-libc.js +0 -279
- package/node_modules/detect-libc/lib/filesystem.js +0 -41
- package/node_modules/detect-libc/lib/process.js +0 -19
- package/node_modules/detect-libc/package.json +0 -40
- package/node_modules/end-of-stream/LICENSE +0 -21
- package/node_modules/end-of-stream/README.md +0 -54
- package/node_modules/end-of-stream/index.js +0 -94
- package/node_modules/end-of-stream/package.json +0 -37
- package/node_modules/expand-template/.travis.yml +0 -6
- package/node_modules/expand-template/LICENSE +0 -21
- package/node_modules/expand-template/README.md +0 -43
- package/node_modules/expand-template/index.js +0 -26
- package/node_modules/expand-template/package.json +0 -29
- package/node_modules/expand-template/test.js +0 -67
- package/node_modules/fs-constants/LICENSE +0 -21
- package/node_modules/fs-constants/README.md +0 -26
- package/node_modules/fs-constants/browser.js +0 -1
- package/node_modules/fs-constants/index.js +0 -1
- package/node_modules/fs-constants/package.json +0 -19
- package/node_modules/github-from-package/.travis.yml +0 -4
- package/node_modules/github-from-package/LICENSE +0 -18
- package/node_modules/github-from-package/example/package.json +0 -8
- package/node_modules/github-from-package/example/url.js +0 -3
- package/node_modules/github-from-package/index.js +0 -17
- package/node_modules/github-from-package/package.json +0 -30
- package/node_modules/github-from-package/readme.markdown +0 -53
- package/node_modules/github-from-package/test/a.json +0 -8
- package/node_modules/github-from-package/test/b.json +0 -5
- package/node_modules/github-from-package/test/c.json +0 -5
- package/node_modules/github-from-package/test/d.json +0 -7
- package/node_modules/github-from-package/test/e.json +0 -5
- package/node_modules/github-from-package/test/url.js +0 -19
- package/node_modules/ieee754/LICENSE +0 -11
- package/node_modules/ieee754/README.md +0 -51
- package/node_modules/ieee754/index.d.ts +0 -10
- package/node_modules/ieee754/index.js +0 -85
- package/node_modules/ieee754/package.json +0 -52
- package/node_modules/inherits/LICENSE +0 -16
- package/node_modules/inherits/README.md +0 -42
- package/node_modules/inherits/inherits.js +0 -9
- package/node_modules/inherits/inherits_browser.js +0 -27
- package/node_modules/inherits/package.json +0 -29
- package/node_modules/ini/LICENSE +0 -15
- package/node_modules/ini/README.md +0 -102
- package/node_modules/ini/ini.js +0 -206
- package/node_modules/ini/package.json +0 -33
- package/node_modules/mimic-response/index.d.ts +0 -17
- package/node_modules/mimic-response/index.js +0 -77
- package/node_modules/mimic-response/license +0 -9
- package/node_modules/mimic-response/package.json +0 -42
- package/node_modules/mimic-response/readme.md +0 -78
- package/node_modules/minimist/.eslintrc +0 -29
- package/node_modules/minimist/.github/FUNDING.yml +0 -12
- package/node_modules/minimist/.nycrc +0 -14
- package/node_modules/minimist/CHANGELOG.md +0 -298
- package/node_modules/minimist/LICENSE +0 -18
- package/node_modules/minimist/README.md +0 -121
- package/node_modules/minimist/example/parse.js +0 -4
- package/node_modules/minimist/index.js +0 -263
- package/node_modules/minimist/package.json +0 -75
- package/node_modules/minimist/test/all_bool.js +0 -34
- package/node_modules/minimist/test/bool.js +0 -177
- package/node_modules/minimist/test/dash.js +0 -43
- package/node_modules/minimist/test/default_bool.js +0 -37
- package/node_modules/minimist/test/dotted.js +0 -24
- package/node_modules/minimist/test/kv_short.js +0 -32
- package/node_modules/minimist/test/long.js +0 -33
- package/node_modules/minimist/test/num.js +0 -38
- package/node_modules/minimist/test/parse.js +0 -209
- package/node_modules/minimist/test/parse_modified.js +0 -11
- package/node_modules/minimist/test/proto.js +0 -64
- package/node_modules/minimist/test/short.js +0 -69
- package/node_modules/minimist/test/stop_early.js +0 -17
- package/node_modules/minimist/test/unknown.js +0 -104
- package/node_modules/minimist/test/whitespace.js +0 -10
- package/node_modules/mkdirp-classic/LICENSE +0 -21
- package/node_modules/mkdirp-classic/README.md +0 -18
- package/node_modules/mkdirp-classic/index.js +0 -98
- package/node_modules/mkdirp-classic/package.json +0 -18
- package/node_modules/napi-build-utils/LICENSE +0 -21
- package/node_modules/napi-build-utils/README.md +0 -48
- package/node_modules/napi-build-utils/index.js +0 -213
- package/node_modules/napi-build-utils/index.md +0 -81
- package/node_modules/napi-build-utils/package.json +0 -41
- package/node_modules/node-abi/LICENSE +0 -21
- package/node_modules/node-abi/README.md +0 -52
- package/node_modules/node-abi/abi_registry.json +0 -276
- package/node_modules/node-abi/index.js +0 -179
- package/node_modules/node-abi/package.json +0 -41
- package/node_modules/once/LICENSE +0 -15
- package/node_modules/once/README.md +0 -79
- package/node_modules/once/once.js +0 -42
- package/node_modules/once/package.json +0 -33
- package/node_modules/prebuild-install/CHANGELOG.md +0 -116
- package/node_modules/prebuild-install/CONTRIBUTING.md +0 -6
- package/node_modules/prebuild-install/LICENSE +0 -21
- package/node_modules/prebuild-install/README.md +0 -163
- package/node_modules/prebuild-install/asset.js +0 -44
- package/node_modules/prebuild-install/bin.js +0 -78
- package/node_modules/prebuild-install/download.js +0 -142
- package/node_modules/prebuild-install/error.js +0 -14
- package/node_modules/prebuild-install/help.txt +0 -16
- package/node_modules/prebuild-install/index.js +0 -1
- package/node_modules/prebuild-install/log.js +0 -33
- package/node_modules/prebuild-install/package.json +0 -67
- package/node_modules/prebuild-install/proxy.js +0 -35
- package/node_modules/prebuild-install/rc.js +0 -64
- package/node_modules/prebuild-install/util.js +0 -143
- package/node_modules/pump/.travis.yml +0 -5
- package/node_modules/pump/LICENSE +0 -21
- package/node_modules/pump/README.md +0 -65
- package/node_modules/pump/index.js +0 -82
- package/node_modules/pump/package.json +0 -24
- package/node_modules/pump/test-browser.js +0 -66
- package/node_modules/pump/test-node.js +0 -53
- package/node_modules/rc/LICENSE.APACHE2 +0 -15
- package/node_modules/rc/LICENSE.BSD +0 -26
- package/node_modules/rc/LICENSE.MIT +0 -24
- package/node_modules/rc/README.md +0 -227
- package/node_modules/rc/browser.js +0 -7
- package/node_modules/rc/cli.js +0 -4
- package/node_modules/rc/index.js +0 -53
- package/node_modules/rc/lib/utils.js +0 -104
- package/node_modules/rc/node_modules/strip-json-comments/index.js +0 -70
- package/node_modules/rc/node_modules/strip-json-comments/license +0 -21
- package/node_modules/rc/node_modules/strip-json-comments/package.json +0 -42
- package/node_modules/rc/node_modules/strip-json-comments/readme.md +0 -64
- package/node_modules/rc/package.json +0 -29
- package/node_modules/rc/test/ini.js +0 -16
- package/node_modules/rc/test/nested-env-vars.js +0 -50
- package/node_modules/rc/test/test.js +0 -59
- package/node_modules/safe-buffer/LICENSE +0 -21
- package/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/safe-buffer/index.js +0 -65
- package/node_modules/safe-buffer/package.json +0 -51
- package/node_modules/semver/LICENSE +0 -15
- package/node_modules/semver/README.md +0 -637
- package/node_modules/semver/bin/semver.js +0 -197
- package/node_modules/semver/classes/comparator.js +0 -141
- package/node_modules/semver/classes/index.js +0 -5
- package/node_modules/semver/classes/range.js +0 -539
- package/node_modules/semver/classes/semver.js +0 -302
- package/node_modules/semver/functions/clean.js +0 -6
- package/node_modules/semver/functions/cmp.js +0 -52
- package/node_modules/semver/functions/coerce.js +0 -52
- package/node_modules/semver/functions/compare-build.js +0 -7
- package/node_modules/semver/functions/compare-loose.js +0 -3
- package/node_modules/semver/functions/compare.js +0 -5
- package/node_modules/semver/functions/diff.js +0 -65
- package/node_modules/semver/functions/eq.js +0 -3
- package/node_modules/semver/functions/gt.js +0 -3
- package/node_modules/semver/functions/gte.js +0 -3
- package/node_modules/semver/functions/inc.js +0 -19
- package/node_modules/semver/functions/lt.js +0 -3
- package/node_modules/semver/functions/lte.js +0 -3
- package/node_modules/semver/functions/major.js +0 -3
- package/node_modules/semver/functions/minor.js +0 -3
- package/node_modules/semver/functions/neq.js +0 -3
- package/node_modules/semver/functions/parse.js +0 -16
- package/node_modules/semver/functions/patch.js +0 -3
- package/node_modules/semver/functions/prerelease.js +0 -6
- package/node_modules/semver/functions/rcompare.js +0 -3
- package/node_modules/semver/functions/rsort.js +0 -3
- package/node_modules/semver/functions/satisfies.js +0 -10
- package/node_modules/semver/functions/sort.js +0 -3
- package/node_modules/semver/functions/valid.js +0 -6
- package/node_modules/semver/index.js +0 -89
- package/node_modules/semver/internal/constants.js +0 -35
- package/node_modules/semver/internal/debug.js +0 -9
- package/node_modules/semver/internal/identifiers.js +0 -23
- package/node_modules/semver/internal/parse-options.js +0 -15
- package/node_modules/semver/internal/re.js +0 -212
- package/node_modules/semver/node_modules/lru-cache/LICENSE +0 -15
- package/node_modules/semver/node_modules/lru-cache/README.md +0 -166
- package/node_modules/semver/node_modules/lru-cache/index.js +0 -334
- package/node_modules/semver/node_modules/lru-cache/package.json +0 -34
- package/node_modules/semver/node_modules/yallist/LICENSE +0 -15
- package/node_modules/semver/node_modules/yallist/README.md +0 -204
- package/node_modules/semver/node_modules/yallist/iterator.js +0 -8
- package/node_modules/semver/node_modules/yallist/package.json +0 -29
- package/node_modules/semver/node_modules/yallist/yallist.js +0 -426
- package/node_modules/semver/package.json +0 -87
- package/node_modules/semver/preload.js +0 -2
- package/node_modules/semver/range.bnf +0 -16
- package/node_modules/semver/ranges/gtr.js +0 -4
- package/node_modules/semver/ranges/intersects.js +0 -7
- package/node_modules/semver/ranges/ltr.js +0 -4
- package/node_modules/semver/ranges/max-satisfying.js +0 -25
- package/node_modules/semver/ranges/min-satisfying.js +0 -24
- package/node_modules/semver/ranges/min-version.js +0 -61
- package/node_modules/semver/ranges/outside.js +0 -80
- package/node_modules/semver/ranges/simplify.js +0 -47
- package/node_modules/semver/ranges/subset.js +0 -247
- package/node_modules/semver/ranges/to-comparators.js +0 -8
- package/node_modules/semver/ranges/valid.js +0 -11
- package/node_modules/simple-concat/.travis.yml +0 -3
- package/node_modules/simple-concat/LICENSE +0 -20
- package/node_modules/simple-concat/README.md +0 -44
- package/node_modules/simple-concat/index.js +0 -15
- package/node_modules/simple-concat/package.json +0 -47
- package/node_modules/simple-concat/test/basic.js +0 -41
- package/node_modules/simple-get/.github/dependabot.yml +0 -15
- package/node_modules/simple-get/.github/workflows/ci.yml +0 -23
- package/node_modules/simple-get/LICENSE +0 -20
- package/node_modules/simple-get/README.md +0 -333
- package/node_modules/simple-get/index.js +0 -108
- package/node_modules/simple-get/package.json +0 -67
- package/node_modules/tar-fs/.travis.yml +0 -6
- package/node_modules/tar-fs/LICENSE +0 -21
- package/node_modules/tar-fs/README.md +0 -165
- package/node_modules/tar-fs/index.js +0 -351
- package/node_modules/tar-fs/node_modules/bl/.travis.yml +0 -17
- package/node_modules/tar-fs/node_modules/bl/BufferList.js +0 -396
- package/node_modules/tar-fs/node_modules/bl/LICENSE.md +0 -13
- package/node_modules/tar-fs/node_modules/bl/README.md +0 -247
- package/node_modules/tar-fs/node_modules/bl/bl.js +0 -84
- package/node_modules/tar-fs/node_modules/bl/package.json +0 -37
- package/node_modules/tar-fs/node_modules/bl/test/convert.js +0 -21
- package/node_modules/tar-fs/node_modules/bl/test/indexOf.js +0 -492
- package/node_modules/tar-fs/node_modules/bl/test/isBufferList.js +0 -32
- package/node_modules/tar-fs/node_modules/bl/test/test.js +0 -869
- package/node_modules/tar-fs/node_modules/readable-stream/CONTRIBUTING.md +0 -38
- package/node_modules/tar-fs/node_modules/readable-stream/GOVERNANCE.md +0 -136
- package/node_modules/tar-fs/node_modules/readable-stream/LICENSE +0 -47
- package/node_modules/tar-fs/node_modules/readable-stream/README.md +0 -106
- package/node_modules/tar-fs/node_modules/readable-stream/errors-browser.js +0 -127
- package/node_modules/tar-fs/node_modules/readable-stream/errors.js +0 -116
- package/node_modules/tar-fs/node_modules/readable-stream/experimentalWarning.js +0 -17
- package/node_modules/tar-fs/node_modules/readable-stream/lib/_stream_duplex.js +0 -126
- package/node_modules/tar-fs/node_modules/readable-stream/lib/_stream_passthrough.js +0 -37
- package/node_modules/tar-fs/node_modules/readable-stream/lib/_stream_readable.js +0 -1027
- package/node_modules/tar-fs/node_modules/readable-stream/lib/_stream_transform.js +0 -190
- package/node_modules/tar-fs/node_modules/readable-stream/lib/_stream_writable.js +0 -641
- package/node_modules/tar-fs/node_modules/readable-stream/lib/internal/streams/async_iterator.js +0 -180
- package/node_modules/tar-fs/node_modules/readable-stream/lib/internal/streams/buffer_list.js +0 -183
- package/node_modules/tar-fs/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -96
- package/node_modules/tar-fs/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +0 -86
- package/node_modules/tar-fs/node_modules/readable-stream/lib/internal/streams/from-browser.js +0 -3
- package/node_modules/tar-fs/node_modules/readable-stream/lib/internal/streams/from.js +0 -52
- package/node_modules/tar-fs/node_modules/readable-stream/lib/internal/streams/pipeline.js +0 -86
- package/node_modules/tar-fs/node_modules/readable-stream/lib/internal/streams/state.js +0 -22
- package/node_modules/tar-fs/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- package/node_modules/tar-fs/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- package/node_modules/tar-fs/node_modules/readable-stream/package.json +0 -68
- package/node_modules/tar-fs/node_modules/readable-stream/readable-browser.js +0 -9
- package/node_modules/tar-fs/node_modules/readable-stream/readable.js +0 -16
- package/node_modules/tar-fs/node_modules/string_decoder/LICENSE +0 -48
- package/node_modules/tar-fs/node_modules/string_decoder/README.md +0 -47
- package/node_modules/tar-fs/node_modules/string_decoder/lib/string_decoder.js +0 -296
- package/node_modules/tar-fs/node_modules/string_decoder/package.json +0 -34
- package/node_modules/tar-fs/node_modules/tar-stream/LICENSE +0 -21
- package/node_modules/tar-fs/node_modules/tar-stream/README.md +0 -168
- package/node_modules/tar-fs/node_modules/tar-stream/extract.js +0 -257
- package/node_modules/tar-fs/node_modules/tar-stream/headers.js +0 -295
- package/node_modules/tar-fs/node_modules/tar-stream/index.js +0 -2
- package/node_modules/tar-fs/node_modules/tar-stream/pack.js +0 -255
- package/node_modules/tar-fs/node_modules/tar-stream/package.json +0 -58
- package/node_modules/tar-fs/node_modules/tar-stream/sandbox.js +0 -11
- package/node_modules/tar-fs/package.json +0 -41
- package/node_modules/tar-fs/test/fixtures/a/hello.txt +0 -1
- package/node_modules/tar-fs/test/fixtures/b/a/test.txt +0 -1
- package/node_modules/tar-fs/test/fixtures/d/file1 +0 -0
- package/node_modules/tar-fs/test/fixtures/d/file2 +0 -0
- package/node_modules/tar-fs/test/fixtures/d/sub-dir/file5 +0 -0
- package/node_modules/tar-fs/test/fixtures/d/sub-files/file3 +0 -0
- package/node_modules/tar-fs/test/fixtures/d/sub-files/file4 +0 -0
- package/node_modules/tar-fs/test/fixtures/e/directory/.ignore +0 -0
- package/node_modules/tar-fs/test/fixtures/e/file +0 -0
- package/node_modules/tar-fs/test/fixtures/invalid.tar +0 -0
- package/node_modules/tar-fs/test/index.js +0 -346
- package/node_modules/tunnel-agent/LICENSE +0 -55
- package/node_modules/tunnel-agent/README.md +0 -4
- package/node_modules/tunnel-agent/index.js +0 -244
- package/node_modules/tunnel-agent/package.json +0 -22
- package/node_modules/util-deprecate/History.md +0 -16
- package/node_modules/util-deprecate/LICENSE +0 -24
- package/node_modules/util-deprecate/README.md +0 -53
- package/node_modules/util-deprecate/browser.js +0 -67
- package/node_modules/util-deprecate/node.js +0 -6
- package/node_modules/util-deprecate/package.json +0 -27
- package/node_modules/wrappy/LICENSE +0 -15
- package/node_modules/wrappy/README.md +0 -36
- package/node_modules/wrappy/package.json +0 -29
- package/node_modules/wrappy/wrappy.js +0 -33
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
The MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2011 Dominic Tarr
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge,
|
|
6
|
-
to any person obtaining a copy of this software and
|
|
7
|
-
associated documentation files (the "Software"), to
|
|
8
|
-
deal in the Software without restriction, including
|
|
9
|
-
without limitation the rights to use, copy, modify,
|
|
10
|
-
merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom
|
|
12
|
-
the Software is furnished to do so,
|
|
13
|
-
subject to the following conditions:
|
|
14
|
-
|
|
15
|
-
The above copyright notice and this permission notice
|
|
16
|
-
shall be included in all copies or substantial portions of the Software.
|
|
17
|
-
|
|
18
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
20
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
21
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
|
22
|
-
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
24
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
# rc
|
|
2
|
-
|
|
3
|
-
The non-configurable configuration loader for lazy people.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
The only option is to pass rc the name of your app, and your default configuration.
|
|
8
|
-
|
|
9
|
-
```javascript
|
|
10
|
-
var conf = require('rc')(appname, {
|
|
11
|
-
//defaults go here.
|
|
12
|
-
port: 2468,
|
|
13
|
-
|
|
14
|
-
//defaults which are objects will be merged, not replaced
|
|
15
|
-
views: {
|
|
16
|
-
engine: 'jade'
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
`rc` will return your configuration options merged with the defaults you specify.
|
|
22
|
-
If you pass in a predefined defaults object, it will be mutated:
|
|
23
|
-
|
|
24
|
-
```javascript
|
|
25
|
-
var conf = {};
|
|
26
|
-
require('rc')(appname, conf);
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
If `rc` finds any config files for your app, the returned config object will have
|
|
30
|
-
a `configs` array containing their paths:
|
|
31
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
var appCfg = require('rc')(appname, conf);
|
|
34
|
-
appCfg.configs[0] // /etc/appnamerc
|
|
35
|
-
appCfg.configs[1] // /home/dominictarr/.config/appname
|
|
36
|
-
appCfg.config // same as appCfg.configs[appCfg.configs.length - 1]
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Standards
|
|
40
|
-
|
|
41
|
-
Given your application name (`appname`), rc will look in all the obvious places for configuration.
|
|
42
|
-
|
|
43
|
-
* command line arguments, parsed by minimist _(e.g. `--foo baz`, also nested: `--foo.bar=baz`)_
|
|
44
|
-
* environment variables prefixed with `${appname}_`
|
|
45
|
-
* or use "\_\_" to indicate nested properties <br/> _(e.g. `appname_foo__bar__baz` => `foo.bar.baz`)_
|
|
46
|
-
* if you passed an option `--config file` then from that file
|
|
47
|
-
* a local `.${appname}rc` or the first found looking in `./ ../ ../../ ../../../` etc.
|
|
48
|
-
* `$HOME/.${appname}rc`
|
|
49
|
-
* `$HOME/.${appname}/config`
|
|
50
|
-
* `$HOME/.config/${appname}`
|
|
51
|
-
* `$HOME/.config/${appname}/config`
|
|
52
|
-
* `/etc/${appname}rc`
|
|
53
|
-
* `/etc/${appname}/config`
|
|
54
|
-
* the defaults object you passed in.
|
|
55
|
-
|
|
56
|
-
All configuration sources that were found will be flattened into one object,
|
|
57
|
-
so that sources **earlier** in this list override later ones.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
## Configuration File Formats
|
|
61
|
-
|
|
62
|
-
Configuration files (e.g. `.appnamerc`) may be in either [json](http://json.org/example) or [ini](http://en.wikipedia.org/wiki/INI_file) format. **No** file extension (`.json` or `.ini`) should be used. The example configurations below are equivalent:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
#### Formatted as `ini`
|
|
66
|
-
|
|
67
|
-
```
|
|
68
|
-
; You can include comments in `ini` format if you want.
|
|
69
|
-
|
|
70
|
-
dependsOn=0.10.0
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
; `rc` has built-in support for ini sections, see?
|
|
74
|
-
|
|
75
|
-
[commands]
|
|
76
|
-
www = ./commands/www
|
|
77
|
-
console = ./commands/repl
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
; You can even do nested sections
|
|
81
|
-
|
|
82
|
-
[generators.options]
|
|
83
|
-
engine = ejs
|
|
84
|
-
|
|
85
|
-
[generators.modules]
|
|
86
|
-
new = generate-new
|
|
87
|
-
engine = generate-backend
|
|
88
|
-
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
#### Formatted as `json`
|
|
92
|
-
|
|
93
|
-
```javascript
|
|
94
|
-
{
|
|
95
|
-
// You can even comment your JSON, if you want
|
|
96
|
-
"dependsOn": "0.10.0",
|
|
97
|
-
"commands": {
|
|
98
|
-
"www": "./commands/www",
|
|
99
|
-
"console": "./commands/repl"
|
|
100
|
-
},
|
|
101
|
-
"generators": {
|
|
102
|
-
"options": {
|
|
103
|
-
"engine": "ejs"
|
|
104
|
-
},
|
|
105
|
-
"modules": {
|
|
106
|
-
"new": "generate-new",
|
|
107
|
-
"backend": "generate-backend"
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Comments are stripped from JSON config via [strip-json-comments](https://github.com/sindresorhus/strip-json-comments).
|
|
114
|
-
|
|
115
|
-
> Since ini, and env variables do not have a standard for types, your application needs be prepared for strings.
|
|
116
|
-
|
|
117
|
-
To ensure that string representations of booleans and numbers are always converted into their proper types (especially useful if you intend to do strict `===` comparisons), consider using a module such as [parse-strings-in-object](https://github.com/anselanza/parse-strings-in-object) to wrap the config object returned from rc.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
## Simple example demonstrating precedence
|
|
121
|
-
Assume you have an application like this (notice the hard-coded defaults passed to rc):
|
|
122
|
-
```
|
|
123
|
-
const conf = require('rc')('myapp', {
|
|
124
|
-
port: 12345,
|
|
125
|
-
mode: 'test'
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
console.log(JSON.stringify(conf, null, 2));
|
|
129
|
-
```
|
|
130
|
-
You also have a file `config.json`, with these contents:
|
|
131
|
-
```
|
|
132
|
-
{
|
|
133
|
-
"port": 9000,
|
|
134
|
-
"foo": "from config json",
|
|
135
|
-
"something": "else"
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
And a file `.myapprc` in the same folder, with these contents:
|
|
139
|
-
```
|
|
140
|
-
{
|
|
141
|
-
"port": "3001",
|
|
142
|
-
"foo": "bar"
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
Here is the expected output from various commands:
|
|
146
|
-
|
|
147
|
-
`node .`
|
|
148
|
-
```
|
|
149
|
-
{
|
|
150
|
-
"port": "3001",
|
|
151
|
-
"mode": "test",
|
|
152
|
-
"foo": "bar",
|
|
153
|
-
"_": [],
|
|
154
|
-
"configs": [
|
|
155
|
-
"/Users/stephen/repos/conftest/.myapprc"
|
|
156
|
-
],
|
|
157
|
-
"config": "/Users/stephen/repos/conftest/.myapprc"
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
*Default `mode` from hard-coded object is retained, but port is overridden by `.myapprc` file (automatically found based on appname match), and `foo` is added.*
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
`node . --foo baz`
|
|
164
|
-
```
|
|
165
|
-
{
|
|
166
|
-
"port": "3001",
|
|
167
|
-
"mode": "test",
|
|
168
|
-
"foo": "baz",
|
|
169
|
-
"_": [],
|
|
170
|
-
"configs": [
|
|
171
|
-
"/Users/stephen/repos/conftest/.myapprc"
|
|
172
|
-
],
|
|
173
|
-
"config": "/Users/stephen/repos/conftest/.myapprc"
|
|
174
|
-
}
|
|
175
|
-
```
|
|
176
|
-
*Same result as above but `foo` is overridden because command-line arguments take precedence over `.myapprc` file.*
|
|
177
|
-
|
|
178
|
-
`node . --foo barbar --config config.json`
|
|
179
|
-
```
|
|
180
|
-
{
|
|
181
|
-
"port": 9000,
|
|
182
|
-
"mode": "test",
|
|
183
|
-
"foo": "barbar",
|
|
184
|
-
"something": "else",
|
|
185
|
-
"_": [],
|
|
186
|
-
"config": "config.json",
|
|
187
|
-
"configs": [
|
|
188
|
-
"/Users/stephen/repos/conftest/.myapprc",
|
|
189
|
-
"config.json"
|
|
190
|
-
]
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
*Now the `port` comes from the `config.json` file specified (overriding the value from `.myapprc`), and `foo` value is overriden by command-line despite also being specified in the `config.json` file.*
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
## Advanced Usage
|
|
198
|
-
|
|
199
|
-
#### Pass in your own `argv`
|
|
200
|
-
|
|
201
|
-
You may pass in your own `argv` as the third argument to `rc`. This is in case you want to [use your own command-line opts parser](https://github.com/dominictarr/rc/pull/12).
|
|
202
|
-
|
|
203
|
-
```javascript
|
|
204
|
-
require('rc')(appname, defaults, customArgvParser);
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
## Pass in your own parser
|
|
208
|
-
|
|
209
|
-
If you have a special need to use a non-standard parser,
|
|
210
|
-
you can do so by passing in the parser as the 4th argument.
|
|
211
|
-
(leave the 3rd as null to get the default args parser)
|
|
212
|
-
|
|
213
|
-
```javascript
|
|
214
|
-
require('rc')(appname, defaults, null, parser);
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
This may also be used to force a more strict format,
|
|
218
|
-
such as strict, valid JSON only.
|
|
219
|
-
|
|
220
|
-
## Note on Performance
|
|
221
|
-
|
|
222
|
-
`rc` is running `fs.statSync`-- so make sure you don't use it in a hot code path (e.g. a request handler)
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
## License
|
|
226
|
-
|
|
227
|
-
Multi-licensed under the two-clause BSD License, MIT License, or Apache License, version 2.0
|
package/node_modules/rc/cli.js
DELETED
package/node_modules/rc/index.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
var cc = require('./lib/utils')
|
|
2
|
-
var join = require('path').join
|
|
3
|
-
var deepExtend = require('deep-extend')
|
|
4
|
-
var etc = '/etc'
|
|
5
|
-
var win = process.platform === "win32"
|
|
6
|
-
var home = win
|
|
7
|
-
? process.env.USERPROFILE
|
|
8
|
-
: process.env.HOME
|
|
9
|
-
|
|
10
|
-
module.exports = function (name, defaults, argv, parse) {
|
|
11
|
-
if('string' !== typeof name)
|
|
12
|
-
throw new Error('rc(name): name *must* be string')
|
|
13
|
-
if(!argv)
|
|
14
|
-
argv = require('minimist')(process.argv.slice(2))
|
|
15
|
-
defaults = (
|
|
16
|
-
'string' === typeof defaults
|
|
17
|
-
? cc.json(defaults) : defaults
|
|
18
|
-
) || {}
|
|
19
|
-
|
|
20
|
-
parse = parse || cc.parse
|
|
21
|
-
|
|
22
|
-
var env = cc.env(name + '_')
|
|
23
|
-
|
|
24
|
-
var configs = [defaults]
|
|
25
|
-
var configFiles = []
|
|
26
|
-
function addConfigFile (file) {
|
|
27
|
-
if (configFiles.indexOf(file) >= 0) return
|
|
28
|
-
var fileConfig = cc.file(file)
|
|
29
|
-
if (fileConfig) {
|
|
30
|
-
configs.push(parse(fileConfig))
|
|
31
|
-
configFiles.push(file)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// which files do we look at?
|
|
36
|
-
if (!win)
|
|
37
|
-
[join(etc, name, 'config'),
|
|
38
|
-
join(etc, name + 'rc')].forEach(addConfigFile)
|
|
39
|
-
if (home)
|
|
40
|
-
[join(home, '.config', name, 'config'),
|
|
41
|
-
join(home, '.config', name),
|
|
42
|
-
join(home, '.' + name, 'config'),
|
|
43
|
-
join(home, '.' + name + 'rc')].forEach(addConfigFile)
|
|
44
|
-
addConfigFile(cc.find('.'+name+'rc'))
|
|
45
|
-
if (env.config) addConfigFile(env.config)
|
|
46
|
-
if (argv.config) addConfigFile(argv.config)
|
|
47
|
-
|
|
48
|
-
return deepExtend.apply(null, configs.concat([
|
|
49
|
-
env,
|
|
50
|
-
argv,
|
|
51
|
-
configFiles.length ? {configs: configFiles, config: configFiles[configFiles.length - 1]} : undefined,
|
|
52
|
-
]))
|
|
53
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var fs = require('fs')
|
|
3
|
-
var ini = require('ini')
|
|
4
|
-
var path = require('path')
|
|
5
|
-
var stripJsonComments = require('strip-json-comments')
|
|
6
|
-
|
|
7
|
-
var parse = exports.parse = function (content) {
|
|
8
|
-
|
|
9
|
-
//if it ends in .json or starts with { then it must be json.
|
|
10
|
-
//must be done this way, because ini accepts everything.
|
|
11
|
-
//can't just try and parse it and let it throw if it's not ini.
|
|
12
|
-
//everything is ini. even json with a syntax error.
|
|
13
|
-
|
|
14
|
-
if(/^\s*{/.test(content))
|
|
15
|
-
return JSON.parse(stripJsonComments(content))
|
|
16
|
-
return ini.parse(content)
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
var file = exports.file = function () {
|
|
21
|
-
var args = [].slice.call(arguments).filter(function (arg) { return arg != null })
|
|
22
|
-
|
|
23
|
-
//path.join breaks if it's a not a string, so just skip this.
|
|
24
|
-
for(var i in args)
|
|
25
|
-
if('string' !== typeof args[i])
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
var file = path.join.apply(null, args)
|
|
29
|
-
var content
|
|
30
|
-
try {
|
|
31
|
-
return fs.readFileSync(file,'utf-8')
|
|
32
|
-
} catch (err) {
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var json = exports.json = function () {
|
|
38
|
-
var content = file.apply(null, arguments)
|
|
39
|
-
return content ? parse(content) : null
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var env = exports.env = function (prefix, env) {
|
|
43
|
-
env = env || process.env
|
|
44
|
-
var obj = {}
|
|
45
|
-
var l = prefix.length
|
|
46
|
-
for(var k in env) {
|
|
47
|
-
if(k.toLowerCase().indexOf(prefix.toLowerCase()) === 0) {
|
|
48
|
-
|
|
49
|
-
var keypath = k.substring(l).split('__')
|
|
50
|
-
|
|
51
|
-
// Trim empty strings from keypath array
|
|
52
|
-
var _emptyStringIndex
|
|
53
|
-
while ((_emptyStringIndex=keypath.indexOf('')) > -1) {
|
|
54
|
-
keypath.splice(_emptyStringIndex, 1)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
var cursor = obj
|
|
58
|
-
keypath.forEach(function _buildSubObj(_subkey,i){
|
|
59
|
-
|
|
60
|
-
// (check for _subkey first so we ignore empty strings)
|
|
61
|
-
// (check for cursor to avoid assignment to primitive objects)
|
|
62
|
-
if (!_subkey || typeof cursor !== 'object')
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
// If this is the last key, just stuff the value in there
|
|
66
|
-
// Assigns actual value from env variable to final key
|
|
67
|
-
// (unless it's just an empty string- in that case use the last valid key)
|
|
68
|
-
if (i === keypath.length-1)
|
|
69
|
-
cursor[_subkey] = env[k]
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// Build sub-object if nothing already exists at the keypath
|
|
73
|
-
if (cursor[_subkey] === undefined)
|
|
74
|
-
cursor[_subkey] = {}
|
|
75
|
-
|
|
76
|
-
// Increment cursor used to track the object at the current depth
|
|
77
|
-
cursor = cursor[_subkey]
|
|
78
|
-
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return obj
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
var find = exports.find = function () {
|
|
89
|
-
var rel = path.join.apply(null, [].slice.call(arguments))
|
|
90
|
-
|
|
91
|
-
function find(start, rel) {
|
|
92
|
-
var file = path.join(start, rel)
|
|
93
|
-
try {
|
|
94
|
-
fs.statSync(file)
|
|
95
|
-
return file
|
|
96
|
-
} catch (err) {
|
|
97
|
-
if(path.dirname(start) !== start) // root
|
|
98
|
-
return find(path.dirname(start), rel)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return find(process.cwd(), rel)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var singleComment = 1;
|
|
3
|
-
var multiComment = 2;
|
|
4
|
-
|
|
5
|
-
function stripWithoutWhitespace() {
|
|
6
|
-
return '';
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function stripWithWhitespace(str, start, end) {
|
|
10
|
-
return str.slice(start, end).replace(/\S/g, ' ');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
module.exports = function (str, opts) {
|
|
14
|
-
opts = opts || {};
|
|
15
|
-
|
|
16
|
-
var currentChar;
|
|
17
|
-
var nextChar;
|
|
18
|
-
var insideString = false;
|
|
19
|
-
var insideComment = false;
|
|
20
|
-
var offset = 0;
|
|
21
|
-
var ret = '';
|
|
22
|
-
var strip = opts.whitespace === false ? stripWithoutWhitespace : stripWithWhitespace;
|
|
23
|
-
|
|
24
|
-
for (var i = 0; i < str.length; i++) {
|
|
25
|
-
currentChar = str[i];
|
|
26
|
-
nextChar = str[i + 1];
|
|
27
|
-
|
|
28
|
-
if (!insideComment && currentChar === '"') {
|
|
29
|
-
var escaped = str[i - 1] === '\\' && str[i - 2] !== '\\';
|
|
30
|
-
if (!escaped) {
|
|
31
|
-
insideString = !insideString;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (insideString) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!insideComment && currentChar + nextChar === '//') {
|
|
40
|
-
ret += str.slice(offset, i);
|
|
41
|
-
offset = i;
|
|
42
|
-
insideComment = singleComment;
|
|
43
|
-
i++;
|
|
44
|
-
} else if (insideComment === singleComment && currentChar + nextChar === '\r\n') {
|
|
45
|
-
i++;
|
|
46
|
-
insideComment = false;
|
|
47
|
-
ret += strip(str, offset, i);
|
|
48
|
-
offset = i;
|
|
49
|
-
continue;
|
|
50
|
-
} else if (insideComment === singleComment && currentChar === '\n') {
|
|
51
|
-
insideComment = false;
|
|
52
|
-
ret += strip(str, offset, i);
|
|
53
|
-
offset = i;
|
|
54
|
-
} else if (!insideComment && currentChar + nextChar === '/*') {
|
|
55
|
-
ret += str.slice(offset, i);
|
|
56
|
-
offset = i;
|
|
57
|
-
insideComment = multiComment;
|
|
58
|
-
i++;
|
|
59
|
-
continue;
|
|
60
|
-
} else if (insideComment === multiComment && currentChar + nextChar === '*/') {
|
|
61
|
-
i++;
|
|
62
|
-
insideComment = false;
|
|
63
|
-
ret += strip(str, offset, i + 1);
|
|
64
|
-
offset = i + 1;
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return ret + (insideComment ? strip(str.substr(offset)) : str.substr(offset));
|
|
70
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "strip-json-comments",
|
|
3
|
-
"version": "2.0.1",
|
|
4
|
-
"description": "Strip comments from JSON. Lets you use comments in your JSON files!",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": "sindresorhus/strip-json-comments",
|
|
7
|
-
"author": {
|
|
8
|
-
"name": "Sindre Sorhus",
|
|
9
|
-
"email": "sindresorhus@gmail.com",
|
|
10
|
-
"url": "sindresorhus.com"
|
|
11
|
-
},
|
|
12
|
-
"engines": {
|
|
13
|
-
"node": ">=0.10.0"
|
|
14
|
-
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"test": "xo && ava"
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"index.js"
|
|
20
|
-
],
|
|
21
|
-
"keywords": [
|
|
22
|
-
"json",
|
|
23
|
-
"strip",
|
|
24
|
-
"remove",
|
|
25
|
-
"delete",
|
|
26
|
-
"trim",
|
|
27
|
-
"comments",
|
|
28
|
-
"multiline",
|
|
29
|
-
"parse",
|
|
30
|
-
"config",
|
|
31
|
-
"configuration",
|
|
32
|
-
"conf",
|
|
33
|
-
"settings",
|
|
34
|
-
"util",
|
|
35
|
-
"env",
|
|
36
|
-
"environment"
|
|
37
|
-
],
|
|
38
|
-
"devDependencies": {
|
|
39
|
-
"ava": "*",
|
|
40
|
-
"xo": "*"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# strip-json-comments [](https://travis-ci.org/sindresorhus/strip-json-comments)
|
|
2
|
-
|
|
3
|
-
> Strip comments from JSON. Lets you use comments in your JSON files!
|
|
4
|
-
|
|
5
|
-
This is now possible:
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
{
|
|
9
|
-
// rainbows
|
|
10
|
-
"unicorn": /* ❤ */ "cake"
|
|
11
|
-
}
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
It will replace single-line comments `//` and multi-line comments `/**/` with whitespace. This allows JSON error positions to remain as close as possible to the original source.
|
|
15
|
-
|
|
16
|
-
Also available as a [gulp](https://github.com/sindresorhus/gulp-strip-json-comments)/[grunt](https://github.com/sindresorhus/grunt-strip-json-comments)/[broccoli](https://github.com/sindresorhus/broccoli-strip-json-comments) plugin.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## Install
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
$ npm install --save strip-json-comments
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
## Usage
|
|
27
|
-
|
|
28
|
-
```js
|
|
29
|
-
const json = '{/*rainbows*/"unicorn":"cake"}';
|
|
30
|
-
|
|
31
|
-
JSON.parse(stripJsonComments(json));
|
|
32
|
-
//=> {unicorn: 'cake'}
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
## API
|
|
37
|
-
|
|
38
|
-
### stripJsonComments(input, [options])
|
|
39
|
-
|
|
40
|
-
#### input
|
|
41
|
-
|
|
42
|
-
Type: `string`
|
|
43
|
-
|
|
44
|
-
Accepts a string with JSON and returns a string without comments.
|
|
45
|
-
|
|
46
|
-
#### options
|
|
47
|
-
|
|
48
|
-
##### whitespace
|
|
49
|
-
|
|
50
|
-
Type: `boolean`
|
|
51
|
-
Default: `true`
|
|
52
|
-
|
|
53
|
-
Replace comments with whitespace instead of stripping them entirely.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
## Related
|
|
57
|
-
|
|
58
|
-
- [strip-json-comments-cli](https://github.com/sindresorhus/strip-json-comments-cli) - CLI for this module
|
|
59
|
-
- [strip-css-comments](https://github.com/sindresorhus/strip-css-comments) - Strip comments from CSS
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
## License
|
|
63
|
-
|
|
64
|
-
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "rc",
|
|
3
|
-
"version": "1.2.8",
|
|
4
|
-
"description": "hardwired configuration loader",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"browser": "browser.js",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "set -e; node test/test.js; node test/ini.js; node test/nested-env-vars.js"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "https://github.com/dominictarr/rc.git"
|
|
13
|
-
},
|
|
14
|
-
"license": "(BSD-2-Clause OR MIT OR Apache-2.0)",
|
|
15
|
-
"keywords": [
|
|
16
|
-
"config",
|
|
17
|
-
"rc",
|
|
18
|
-
"unix",
|
|
19
|
-
"defaults"
|
|
20
|
-
],
|
|
21
|
-
"bin": "./cli.js",
|
|
22
|
-
"author": "Dominic Tarr <dominic.tarr@gmail.com> (dominictarr.com)",
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"deep-extend": "^0.6.0",
|
|
25
|
-
"ini": "~1.3.0",
|
|
26
|
-
"minimist": "^1.2.0",
|
|
27
|
-
"strip-json-comments": "~2.0.1"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var cc =require('../lib/utils')
|
|
2
|
-
var INI = require('ini')
|
|
3
|
-
var assert = require('assert')
|
|
4
|
-
|
|
5
|
-
function test(obj) {
|
|
6
|
-
|
|
7
|
-
var _json, _ini
|
|
8
|
-
var json = cc.parse (_json = JSON.stringify(obj))
|
|
9
|
-
var ini = cc.parse (_ini = INI.stringify(obj))
|
|
10
|
-
console.log(_ini, _json)
|
|
11
|
-
assert.deepEqual(json, ini)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
test({hello: true})
|
|
16
|
-
|