protobufjs 6.11.1 → 7.0.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/README.md +7 -174
- package/dist/light/protobuf.js +40 -16
- package/dist/light/protobuf.js.map +1 -1
- package/dist/light/protobuf.min.js +3 -3
- package/dist/light/protobuf.min.js.map +1 -1
- package/dist/minimal/protobuf.js +27 -10
- package/dist/minimal/protobuf.js.map +1 -1
- package/dist/minimal/protobuf.min.js +3 -3
- package/dist/minimal/protobuf.min.js.map +1 -1
- package/dist/protobuf.js +109 -46
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/index.d.ts +1 -1
- package/package.json +11 -30
- package/scripts/postinstall.js +0 -3
- package/src/converter.js +1 -1
- package/src/decoder.js +4 -3
- package/src/field.js +3 -0
- package/src/namespace.js +1 -2
- package/src/parse.js +38 -14
- package/src/roots.js +1 -1
- package/src/tokenize.js +31 -16
- package/src/util/minimal.js +24 -7
- package/src/util.js +3 -0
- package/src/wrappers.js +2 -2
- package/CHANGELOG.md +0 -1014
- package/bin/pbjs +0 -6
- package/bin/pbts +0 -6
- package/cli/LICENSE +0 -33
- package/cli/README.md +0 -174
- package/cli/bin/pbjs +0 -6
- package/cli/bin/pbts +0 -6
- package/cli/index.d.ts +0 -3
- package/cli/index.js +0 -3
- package/cli/lib/tsd-jsdoc/LICENSE +0 -21
- package/cli/lib/tsd-jsdoc/README.md +0 -23
- package/cli/lib/tsd-jsdoc/plugin.js +0 -21
- package/cli/lib/tsd-jsdoc/publish.js +0 -705
- package/cli/lib/tsd-jsdoc.json +0 -18
- package/cli/node_modules/.package-lock.json +0 -256
- package/cli/node_modules/acorn/CHANGELOG.md +0 -620
- package/cli/node_modules/acorn/LICENSE +0 -21
- package/cli/node_modules/acorn/README.md +0 -269
- package/cli/node_modules/acorn/bin/acorn +0 -4
- package/cli/node_modules/acorn/dist/acorn.d.ts +0 -209
- package/cli/node_modules/acorn/dist/acorn.js +0 -5186
- package/cli/node_modules/acorn/dist/acorn.js.map +0 -1
- package/cli/node_modules/acorn/dist/acorn.mjs +0 -5155
- package/cli/node_modules/acorn/dist/acorn.mjs.d.ts +0 -2
- package/cli/node_modules/acorn/dist/acorn.mjs.map +0 -1
- package/cli/node_modules/acorn/dist/bin.js +0 -64
- package/cli/node_modules/acorn/package.json +0 -35
- package/cli/node_modules/acorn-jsx/LICENSE +0 -19
- package/cli/node_modules/acorn-jsx/README.md +0 -40
- package/cli/node_modules/acorn-jsx/index.js +0 -488
- package/cli/node_modules/acorn-jsx/package.json +0 -27
- package/cli/node_modules/acorn-jsx/xhtml.js +0 -255
- package/cli/node_modules/balanced-match/.npmignore +0 -5
- package/cli/node_modules/balanced-match/LICENSE.md +0 -21
- package/cli/node_modules/balanced-match/README.md +0 -91
- package/cli/node_modules/balanced-match/index.js +0 -59
- package/cli/node_modules/balanced-match/package.json +0 -49
- package/cli/node_modules/brace-expansion/LICENSE +0 -21
- package/cli/node_modules/brace-expansion/README.md +0 -129
- package/cli/node_modules/brace-expansion/index.js +0 -201
- package/cli/node_modules/brace-expansion/package.json +0 -47
- package/cli/node_modules/concat-map/.travis.yml +0 -4
- package/cli/node_modules/concat-map/LICENSE +0 -18
- package/cli/node_modules/concat-map/README.markdown +0 -62
- package/cli/node_modules/concat-map/example/map.js +0 -6
- package/cli/node_modules/concat-map/index.js +0 -13
- package/cli/node_modules/concat-map/package.json +0 -43
- package/cli/node_modules/concat-map/test/map.js +0 -39
- package/cli/node_modules/deep-is/.npmignore +0 -1
- package/cli/node_modules/deep-is/.travis.yml +0 -6
- package/cli/node_modules/deep-is/LICENSE +0 -22
- package/cli/node_modules/deep-is/README.markdown +0 -70
- package/cli/node_modules/deep-is/example/cmp.js +0 -11
- package/cli/node_modules/deep-is/index.js +0 -102
- package/cli/node_modules/deep-is/package.json +0 -61
- package/cli/node_modules/deep-is/test/NaN.js +0 -16
- package/cli/node_modules/deep-is/test/cmp.js +0 -23
- package/cli/node_modules/deep-is/test/neg-vs-pos-0.js +0 -15
- package/cli/node_modules/escodegen/LICENSE.BSD +0 -21
- package/cli/node_modules/escodegen/README.md +0 -84
- package/cli/node_modules/escodegen/bin/escodegen.js +0 -77
- package/cli/node_modules/escodegen/bin/esgenerate.js +0 -64
- package/cli/node_modules/escodegen/escodegen.js +0 -2647
- package/cli/node_modules/escodegen/package.json +0 -62
- package/cli/node_modules/eslint-visitor-keys/CHANGELOG.md +0 -25
- package/cli/node_modules/eslint-visitor-keys/LICENSE +0 -201
- package/cli/node_modules/eslint-visitor-keys/README.md +0 -98
- package/cli/node_modules/eslint-visitor-keys/lib/index.js +0 -81
- package/cli/node_modules/eslint-visitor-keys/lib/visitor-keys.json +0 -284
- package/cli/node_modules/eslint-visitor-keys/package.json +0 -40
- package/cli/node_modules/espree/CHANGELOG.md +0 -509
- package/cli/node_modules/espree/LICENSE +0 -25
- package/cli/node_modules/espree/README.md +0 -233
- package/cli/node_modules/espree/espree.js +0 -177
- package/cli/node_modules/espree/lib/ast-node-types.js +0 -96
- package/cli/node_modules/espree/lib/espree.js +0 -286
- package/cli/node_modules/espree/lib/features.js +0 -29
- package/cli/node_modules/espree/lib/options.js +0 -106
- package/cli/node_modules/espree/lib/token-translator.js +0 -263
- package/cli/node_modules/espree/lib/visitor-keys.js +0 -123
- package/cli/node_modules/espree/package.json +0 -64
- package/cli/node_modules/esprima/ChangeLog +0 -235
- package/cli/node_modules/esprima/LICENSE.BSD +0 -21
- package/cli/node_modules/esprima/README.md +0 -46
- package/cli/node_modules/esprima/bin/esparse.js +0 -139
- package/cli/node_modules/esprima/bin/esvalidate.js +0 -236
- package/cli/node_modules/esprima/dist/esprima.js +0 -6709
- package/cli/node_modules/esprima/package.json +0 -112
- package/cli/node_modules/estraverse/.jshintrc +0 -16
- package/cli/node_modules/estraverse/LICENSE.BSD +0 -19
- package/cli/node_modules/estraverse/README.md +0 -153
- package/cli/node_modules/estraverse/estraverse.js +0 -801
- package/cli/node_modules/estraverse/gulpfile.js +0 -70
- package/cli/node_modules/estraverse/package.json +0 -40
- package/cli/node_modules/esutils/LICENSE.BSD +0 -19
- package/cli/node_modules/esutils/README.md +0 -174
- package/cli/node_modules/esutils/lib/ast.js +0 -144
- package/cli/node_modules/esutils/lib/code.js +0 -135
- package/cli/node_modules/esutils/lib/keyword.js +0 -165
- package/cli/node_modules/esutils/lib/utils.js +0 -33
- package/cli/node_modules/esutils/package.json +0 -44
- package/cli/node_modules/fast-levenshtein/LICENSE.md +0 -25
- package/cli/node_modules/fast-levenshtein/README.md +0 -104
- package/cli/node_modules/fast-levenshtein/levenshtein.js +0 -136
- package/cli/node_modules/fast-levenshtein/package.json +0 -39
- package/cli/node_modules/fs.realpath/LICENSE +0 -43
- package/cli/node_modules/fs.realpath/README.md +0 -33
- package/cli/node_modules/fs.realpath/index.js +0 -66
- package/cli/node_modules/fs.realpath/old.js +0 -303
- package/cli/node_modules/fs.realpath/package.json +0 -26
- package/cli/node_modules/glob/LICENSE +0 -21
- package/cli/node_modules/glob/README.md +0 -375
- package/cli/node_modules/glob/changelog.md +0 -67
- package/cli/node_modules/glob/common.js +0 -240
- package/cli/node_modules/glob/glob.js +0 -790
- package/cli/node_modules/glob/package.json +0 -46
- package/cli/node_modules/glob/sync.js +0 -486
- package/cli/node_modules/inflight/LICENSE +0 -15
- package/cli/node_modules/inflight/README.md +0 -37
- package/cli/node_modules/inflight/inflight.js +0 -54
- package/cli/node_modules/inflight/package.json +0 -29
- package/cli/node_modules/inherits/LICENSE +0 -16
- package/cli/node_modules/inherits/README.md +0 -42
- package/cli/node_modules/inherits/inherits.js +0 -9
- package/cli/node_modules/inherits/inherits_browser.js +0 -27
- package/cli/node_modules/inherits/package.json +0 -29
- package/cli/node_modules/levn/LICENSE +0 -22
- package/cli/node_modules/levn/README.md +0 -196
- package/cli/node_modules/levn/lib/cast.js +0 -298
- package/cli/node_modules/levn/lib/coerce.js +0 -285
- package/cli/node_modules/levn/lib/index.js +0 -22
- package/cli/node_modules/levn/lib/parse-string.js +0 -113
- package/cli/node_modules/levn/lib/parse.js +0 -102
- package/cli/node_modules/levn/package.json +0 -47
- package/cli/node_modules/minimatch/LICENSE +0 -15
- package/cli/node_modules/minimatch/README.md +0 -209
- package/cli/node_modules/minimatch/minimatch.js +0 -923
- package/cli/node_modules/minimatch/package.json +0 -30
- package/cli/node_modules/once/LICENSE +0 -15
- package/cli/node_modules/once/README.md +0 -79
- package/cli/node_modules/once/once.js +0 -42
- package/cli/node_modules/once/package.json +0 -33
- package/cli/node_modules/optionator/CHANGELOG.md +0 -56
- package/cli/node_modules/optionator/LICENSE +0 -22
- package/cli/node_modules/optionator/README.md +0 -238
- package/cli/node_modules/optionator/lib/help.js +0 -260
- package/cli/node_modules/optionator/lib/index.js +0 -465
- package/cli/node_modules/optionator/lib/util.js +0 -54
- package/cli/node_modules/optionator/package.json +0 -44
- package/cli/node_modules/path-is-absolute/index.js +0 -20
- package/cli/node_modules/path-is-absolute/license +0 -21
- package/cli/node_modules/path-is-absolute/package.json +0 -43
- package/cli/node_modules/path-is-absolute/readme.md +0 -59
- package/cli/node_modules/prelude-ls/CHANGELOG.md +0 -99
- package/cli/node_modules/prelude-ls/LICENSE +0 -22
- package/cli/node_modules/prelude-ls/README.md +0 -15
- package/cli/node_modules/prelude-ls/lib/Func.js +0 -65
- package/cli/node_modules/prelude-ls/lib/List.js +0 -686
- package/cli/node_modules/prelude-ls/lib/Num.js +0 -130
- package/cli/node_modules/prelude-ls/lib/Obj.js +0 -154
- package/cli/node_modules/prelude-ls/lib/Str.js +0 -92
- package/cli/node_modules/prelude-ls/lib/index.js +0 -178
- package/cli/node_modules/prelude-ls/package.json +0 -52
- package/cli/node_modules/rimraf/CHANGELOG.md +0 -65
- package/cli/node_modules/rimraf/LICENSE +0 -15
- package/cli/node_modules/rimraf/README.md +0 -101
- package/cli/node_modules/rimraf/bin.js +0 -68
- package/cli/node_modules/rimraf/package.json +0 -32
- package/cli/node_modules/rimraf/rimraf.js +0 -360
- package/cli/node_modules/source-map/CHANGELOG.md +0 -301
- package/cli/node_modules/source-map/LICENSE +0 -28
- package/cli/node_modules/source-map/README.md +0 -742
- package/cli/node_modules/source-map/dist/source-map.debug.js +0 -3234
- package/cli/node_modules/source-map/dist/source-map.js +0 -3233
- package/cli/node_modules/source-map/dist/source-map.min.js +0 -2
- package/cli/node_modules/source-map/dist/source-map.min.js.map +0 -1
- package/cli/node_modules/source-map/lib/array-set.js +0 -121
- package/cli/node_modules/source-map/lib/base64-vlq.js +0 -140
- package/cli/node_modules/source-map/lib/base64.js +0 -67
- package/cli/node_modules/source-map/lib/binary-search.js +0 -111
- package/cli/node_modules/source-map/lib/mapping-list.js +0 -79
- package/cli/node_modules/source-map/lib/quick-sort.js +0 -114
- package/cli/node_modules/source-map/lib/source-map-consumer.js +0 -1145
- package/cli/node_modules/source-map/lib/source-map-generator.js +0 -425
- package/cli/node_modules/source-map/lib/source-node.js +0 -413
- package/cli/node_modules/source-map/lib/util.js +0 -488
- package/cli/node_modules/source-map/package.json +0 -73
- package/cli/node_modules/source-map/source-map.d.ts +0 -98
- package/cli/node_modules/source-map/source-map.js +0 -8
- package/cli/node_modules/tmp/CHANGELOG.md +0 -288
- package/cli/node_modules/tmp/LICENSE +0 -21
- package/cli/node_modules/tmp/README.md +0 -365
- package/cli/node_modules/tmp/lib/tmp.js +0 -780
- package/cli/node_modules/tmp/package.json +0 -58
- package/cli/node_modules/type-check/LICENSE +0 -22
- package/cli/node_modules/type-check/README.md +0 -210
- package/cli/node_modules/type-check/lib/check.js +0 -126
- package/cli/node_modules/type-check/lib/index.js +0 -16
- package/cli/node_modules/type-check/lib/parse-type.js +0 -196
- package/cli/node_modules/type-check/package.json +0 -40
- package/cli/node_modules/word-wrap/LICENSE +0 -21
- package/cli/node_modules/word-wrap/README.md +0 -182
- package/cli/node_modules/word-wrap/index.d.ts +0 -50
- package/cli/node_modules/word-wrap/index.js +0 -46
- package/cli/node_modules/word-wrap/package.json +0 -77
- package/cli/node_modules/wrappy/LICENSE +0 -15
- package/cli/node_modules/wrappy/README.md +0 -36
- package/cli/node_modules/wrappy/package.json +0 -29
- package/cli/node_modules/wrappy/wrappy.js +0 -33
- package/cli/package.json +0 -8
- package/cli/package.standalone.json +0 -32
- package/cli/pbjs.d.ts +0 -9
- package/cli/pbjs.js +0 -330
- package/cli/pbts.d.ts +0 -9
- package/cli/pbts.js +0 -197
- package/cli/targets/json-module.js +0 -38
- package/cli/targets/json.js +0 -8
- package/cli/targets/proto.js +0 -326
- package/cli/targets/proto2.js +0 -10
- package/cli/targets/proto3.js +0 -10
- package/cli/targets/static-module.js +0 -29
- package/cli/targets/static.js +0 -711
- package/cli/util.js +0 -183
- package/cli/wrappers/amd.js +0 -7
- package/cli/wrappers/closure.js +0 -7
- package/cli/wrappers/commonjs.js +0 -7
- package/cli/wrappers/default.js +0 -15
- package/cli/wrappers/es6.js +0 -5
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without
|
|
5
|
-
modification, are permitted provided that the following conditions are met:
|
|
6
|
-
|
|
7
|
-
* Redistributions of source code must retain the above copyright
|
|
8
|
-
notice, this list of conditions and the following disclaimer.
|
|
9
|
-
* Redistributions in binary form must reproduce the above copyright
|
|
10
|
-
notice, this list of conditions and the following disclaimer in the
|
|
11
|
-
documentation and/or other materials provided with the distribution.
|
|
12
|
-
|
|
13
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
14
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
15
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
16
|
-
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|
17
|
-
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
18
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
19
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
20
|
-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
21
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
22
|
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
(function () {
|
|
26
|
-
'use strict';
|
|
27
|
-
|
|
28
|
-
var code = require('./code');
|
|
29
|
-
|
|
30
|
-
function isStrictModeReservedWordES6(id) {
|
|
31
|
-
switch (id) {
|
|
32
|
-
case 'implements':
|
|
33
|
-
case 'interface':
|
|
34
|
-
case 'package':
|
|
35
|
-
case 'private':
|
|
36
|
-
case 'protected':
|
|
37
|
-
case 'public':
|
|
38
|
-
case 'static':
|
|
39
|
-
case 'let':
|
|
40
|
-
return true;
|
|
41
|
-
default:
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function isKeywordES5(id, strict) {
|
|
47
|
-
// yield should not be treated as keyword under non-strict mode.
|
|
48
|
-
if (!strict && id === 'yield') {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
return isKeywordES6(id, strict);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function isKeywordES6(id, strict) {
|
|
55
|
-
if (strict && isStrictModeReservedWordES6(id)) {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
switch (id.length) {
|
|
60
|
-
case 2:
|
|
61
|
-
return (id === 'if') || (id === 'in') || (id === 'do');
|
|
62
|
-
case 3:
|
|
63
|
-
return (id === 'var') || (id === 'for') || (id === 'new') || (id === 'try');
|
|
64
|
-
case 4:
|
|
65
|
-
return (id === 'this') || (id === 'else') || (id === 'case') ||
|
|
66
|
-
(id === 'void') || (id === 'with') || (id === 'enum');
|
|
67
|
-
case 5:
|
|
68
|
-
return (id === 'while') || (id === 'break') || (id === 'catch') ||
|
|
69
|
-
(id === 'throw') || (id === 'const') || (id === 'yield') ||
|
|
70
|
-
(id === 'class') || (id === 'super');
|
|
71
|
-
case 6:
|
|
72
|
-
return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
|
|
73
|
-
(id === 'switch') || (id === 'export') || (id === 'import');
|
|
74
|
-
case 7:
|
|
75
|
-
return (id === 'default') || (id === 'finally') || (id === 'extends');
|
|
76
|
-
case 8:
|
|
77
|
-
return (id === 'function') || (id === 'continue') || (id === 'debugger');
|
|
78
|
-
case 10:
|
|
79
|
-
return (id === 'instanceof');
|
|
80
|
-
default:
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function isReservedWordES5(id, strict) {
|
|
86
|
-
return id === 'null' || id === 'true' || id === 'false' || isKeywordES5(id, strict);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function isReservedWordES6(id, strict) {
|
|
90
|
-
return id === 'null' || id === 'true' || id === 'false' || isKeywordES6(id, strict);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function isRestrictedWord(id) {
|
|
94
|
-
return id === 'eval' || id === 'arguments';
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function isIdentifierNameES5(id) {
|
|
98
|
-
var i, iz, ch;
|
|
99
|
-
|
|
100
|
-
if (id.length === 0) { return false; }
|
|
101
|
-
|
|
102
|
-
ch = id.charCodeAt(0);
|
|
103
|
-
if (!code.isIdentifierStartES5(ch)) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
for (i = 1, iz = id.length; i < iz; ++i) {
|
|
108
|
-
ch = id.charCodeAt(i);
|
|
109
|
-
if (!code.isIdentifierPartES5(ch)) {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function decodeUtf16(lead, trail) {
|
|
117
|
-
return (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function isIdentifierNameES6(id) {
|
|
121
|
-
var i, iz, ch, lowCh, check;
|
|
122
|
-
|
|
123
|
-
if (id.length === 0) { return false; }
|
|
124
|
-
|
|
125
|
-
check = code.isIdentifierStartES6;
|
|
126
|
-
for (i = 0, iz = id.length; i < iz; ++i) {
|
|
127
|
-
ch = id.charCodeAt(i);
|
|
128
|
-
if (0xD800 <= ch && ch <= 0xDBFF) {
|
|
129
|
-
++i;
|
|
130
|
-
if (i >= iz) { return false; }
|
|
131
|
-
lowCh = id.charCodeAt(i);
|
|
132
|
-
if (!(0xDC00 <= lowCh && lowCh <= 0xDFFF)) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
ch = decodeUtf16(ch, lowCh);
|
|
136
|
-
}
|
|
137
|
-
if (!check(ch)) {
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
check = code.isIdentifierPartES6;
|
|
141
|
-
}
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function isIdentifierES5(id, strict) {
|
|
146
|
-
return isIdentifierNameES5(id) && !isReservedWordES5(id, strict);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function isIdentifierES6(id, strict) {
|
|
150
|
-
return isIdentifierNameES6(id) && !isReservedWordES6(id, strict);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
module.exports = {
|
|
154
|
-
isKeywordES5: isKeywordES5,
|
|
155
|
-
isKeywordES6: isKeywordES6,
|
|
156
|
-
isReservedWordES5: isReservedWordES5,
|
|
157
|
-
isReservedWordES6: isReservedWordES6,
|
|
158
|
-
isRestrictedWord: isRestrictedWord,
|
|
159
|
-
isIdentifierNameES5: isIdentifierNameES5,
|
|
160
|
-
isIdentifierNameES6: isIdentifierNameES6,
|
|
161
|
-
isIdentifierES5: isIdentifierES5,
|
|
162
|
-
isIdentifierES6: isIdentifierES6
|
|
163
|
-
};
|
|
164
|
-
}());
|
|
165
|
-
/* vim: set sw=4 ts=4 et tw=80 : */
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright (C) 2013 Yusuke Suzuki <utatane.tea@gmail.com>
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without
|
|
5
|
-
modification, are permitted provided that the following conditions are met:
|
|
6
|
-
|
|
7
|
-
* Redistributions of source code must retain the above copyright
|
|
8
|
-
notice, this list of conditions and the following disclaimer.
|
|
9
|
-
* Redistributions in binary form must reproduce the above copyright
|
|
10
|
-
notice, this list of conditions and the following disclaimer in the
|
|
11
|
-
documentation and/or other materials provided with the distribution.
|
|
12
|
-
|
|
13
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
14
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
15
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
16
|
-
ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|
17
|
-
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
18
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
19
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
20
|
-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
21
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
22
|
-
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(function () {
|
|
27
|
-
'use strict';
|
|
28
|
-
|
|
29
|
-
exports.ast = require('./ast');
|
|
30
|
-
exports.code = require('./code');
|
|
31
|
-
exports.keyword = require('./keyword');
|
|
32
|
-
}());
|
|
33
|
-
/* vim: set sw=4 ts=4 et tw=80 : */
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "esutils",
|
|
3
|
-
"description": "utility box for ECMAScript language tools",
|
|
4
|
-
"homepage": "https://github.com/estools/esutils",
|
|
5
|
-
"main": "lib/utils.js",
|
|
6
|
-
"version": "2.0.3",
|
|
7
|
-
"engines": {
|
|
8
|
-
"node": ">=0.10.0"
|
|
9
|
-
},
|
|
10
|
-
"directories": {
|
|
11
|
-
"lib": "./lib"
|
|
12
|
-
},
|
|
13
|
-
"files": [
|
|
14
|
-
"LICENSE.BSD",
|
|
15
|
-
"README.md",
|
|
16
|
-
"lib"
|
|
17
|
-
],
|
|
18
|
-
"maintainers": [
|
|
19
|
-
{
|
|
20
|
-
"name": "Yusuke Suzuki",
|
|
21
|
-
"email": "utatane.tea@gmail.com",
|
|
22
|
-
"web": "http://github.com/Constellation"
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"repository": {
|
|
26
|
-
"type": "git",
|
|
27
|
-
"url": "http://github.com/estools/esutils.git"
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"chai": "~1.7.2",
|
|
31
|
-
"coffee-script": "~1.6.3",
|
|
32
|
-
"jshint": "2.6.3",
|
|
33
|
-
"mocha": "~2.2.1",
|
|
34
|
-
"regenerate": "~1.3.1",
|
|
35
|
-
"unicode-9.0.0": "~0.7.0"
|
|
36
|
-
},
|
|
37
|
-
"license": "BSD-2-Clause",
|
|
38
|
-
"scripts": {
|
|
39
|
-
"test": "npm run-script lint && npm run-script unit-test",
|
|
40
|
-
"lint": "jshint lib/*.js",
|
|
41
|
-
"unit-test": "mocha --compilers coffee:coffee-script -R spec",
|
|
42
|
-
"generate-regex": "node tools/generate-identifier-regex.js"
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
(MIT License)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013 [Ramesh Nair](http://www.hiddentao.com/)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person
|
|
6
|
-
obtaining a copy of this software and associated documentation
|
|
7
|
-
files (the "Software"), to deal in the Software without
|
|
8
|
-
restriction, including without limitation the rights to use,
|
|
9
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
copies of the Software, and to permit persons to whom the
|
|
11
|
-
Software is furnished to do so, subject to the following
|
|
12
|
-
conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be
|
|
15
|
-
included in all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
|
25
|
-
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
# fast-levenshtein - Levenshtein algorithm in Javascript
|
|
2
|
-
|
|
3
|
-
[](http://travis-ci.org/hiddentao/fast-levenshtein)
|
|
4
|
-
[](https://badge.fury.io/js/fast-levenshtein)
|
|
5
|
-
[](https://www.npmjs.com/package/fast-levenshtein)
|
|
6
|
-
[](https://twitter.com/hiddentao)
|
|
7
|
-
|
|
8
|
-
An efficient Javascript implementation of the [Levenshtein algorithm](http://en.wikipedia.org/wiki/Levenshtein_distance) with locale-specific collator support.
|
|
9
|
-
|
|
10
|
-
## Features
|
|
11
|
-
|
|
12
|
-
* Works in node.js and in the browser.
|
|
13
|
-
* Better performance than other implementations by not needing to store the whole matrix ([more info](http://www.codeproject.com/Articles/13525/Fast-memory-efficient-Levenshtein-algorithm)).
|
|
14
|
-
* Locale-sensitive string comparisions if needed.
|
|
15
|
-
* Comprehensive test suite and performance benchmark.
|
|
16
|
-
* Small: <1 KB minified and gzipped
|
|
17
|
-
|
|
18
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
### node.js
|
|
21
|
-
|
|
22
|
-
Install using [npm](http://npmjs.org/):
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
$ npm install fast-levenshtein
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Browser
|
|
29
|
-
|
|
30
|
-
Using bower:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
$ bower install fast-levenshtein
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
If you are not using any module loader system then the API will then be accessible via the `window.Levenshtein` object.
|
|
37
|
-
|
|
38
|
-
## Examples
|
|
39
|
-
|
|
40
|
-
**Default usage**
|
|
41
|
-
|
|
42
|
-
```javascript
|
|
43
|
-
var levenshtein = require('fast-levenshtein');
|
|
44
|
-
|
|
45
|
-
var distance = levenshtein.get('back', 'book'); // 2
|
|
46
|
-
var distance = levenshtein.get('我愛你', '我叫你'); // 1
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
**Locale-sensitive string comparisons**
|
|
50
|
-
|
|
51
|
-
It supports using [Intl.Collator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator) for locale-sensitive string comparisons:
|
|
52
|
-
|
|
53
|
-
```javascript
|
|
54
|
-
var levenshtein = require('fast-levenshtein');
|
|
55
|
-
|
|
56
|
-
levenshtein.get('mikailovitch', 'Mikhaïlovitch', { useCollator: true});
|
|
57
|
-
// 1
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Building and Testing
|
|
61
|
-
|
|
62
|
-
To build the code and run the tests:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
$ npm install -g grunt-cli
|
|
66
|
-
$ npm install
|
|
67
|
-
$ npm run build
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Performance
|
|
71
|
-
|
|
72
|
-
_Thanks to [Titus Wormer](https://github.com/wooorm) for [encouraging me](https://github.com/hiddentao/fast-levenshtein/issues/1) to do this._
|
|
73
|
-
|
|
74
|
-
Benchmarked against other node.js levenshtein distance modules (on Macbook Air 2012, Core i7, 8GB RAM):
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
Running suite Implementation comparison [benchmark/speed.js]...
|
|
78
|
-
>> levenshtein-edit-distance x 234 ops/sec ±3.02% (73 runs sampled)
|
|
79
|
-
>> levenshtein-component x 422 ops/sec ±4.38% (83 runs sampled)
|
|
80
|
-
>> levenshtein-deltas x 283 ops/sec ±3.83% (78 runs sampled)
|
|
81
|
-
>> natural x 255 ops/sec ±0.76% (88 runs sampled)
|
|
82
|
-
>> levenshtein x 180 ops/sec ±3.55% (86 runs sampled)
|
|
83
|
-
>> fast-levenshtein x 1,792 ops/sec ±2.72% (95 runs sampled)
|
|
84
|
-
Benchmark done.
|
|
85
|
-
Fastest test is fast-levenshtein at 4.2x faster than levenshtein-component
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
You can run this benchmark yourself by doing:
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
$ npm install
|
|
92
|
-
$ npm run build
|
|
93
|
-
$ npm run benchmark
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Contributing
|
|
97
|
-
|
|
98
|
-
If you wish to submit a pull request please update and/or create new tests for any changes you make and ensure the grunt build passes.
|
|
99
|
-
|
|
100
|
-
See [CONTRIBUTING.md](https://github.com/hiddentao/fast-levenshtein/blob/master/CONTRIBUTING.md) for details.
|
|
101
|
-
|
|
102
|
-
## License
|
|
103
|
-
|
|
104
|
-
MIT - see [LICENSE.md](https://github.com/hiddentao/fast-levenshtein/blob/master/LICENSE.md)
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
(function() {
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var collator;
|
|
5
|
-
try {
|
|
6
|
-
collator = (typeof Intl !== "undefined" && typeof Intl.Collator !== "undefined") ? Intl.Collator("generic", { sensitivity: "base" }) : null;
|
|
7
|
-
} catch (err){
|
|
8
|
-
console.log("Collator could not be initialized and wouldn't be used");
|
|
9
|
-
}
|
|
10
|
-
// arrays to re-use
|
|
11
|
-
var prevRow = [],
|
|
12
|
-
str2Char = [];
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Based on the algorithm at http://en.wikipedia.org/wiki/Levenshtein_distance.
|
|
16
|
-
*/
|
|
17
|
-
var Levenshtein = {
|
|
18
|
-
/**
|
|
19
|
-
* Calculate levenshtein distance of the two strings.
|
|
20
|
-
*
|
|
21
|
-
* @param str1 String the first string.
|
|
22
|
-
* @param str2 String the second string.
|
|
23
|
-
* @param [options] Additional options.
|
|
24
|
-
* @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
|
|
25
|
-
* @return Integer the levenshtein distance (0 and above).
|
|
26
|
-
*/
|
|
27
|
-
get: function(str1, str2, options) {
|
|
28
|
-
var useCollator = (options && collator && options.useCollator);
|
|
29
|
-
|
|
30
|
-
var str1Len = str1.length,
|
|
31
|
-
str2Len = str2.length;
|
|
32
|
-
|
|
33
|
-
// base cases
|
|
34
|
-
if (str1Len === 0) return str2Len;
|
|
35
|
-
if (str2Len === 0) return str1Len;
|
|
36
|
-
|
|
37
|
-
// two rows
|
|
38
|
-
var curCol, nextCol, i, j, tmp;
|
|
39
|
-
|
|
40
|
-
// initialise previous row
|
|
41
|
-
for (i=0; i<str2Len; ++i) {
|
|
42
|
-
prevRow[i] = i;
|
|
43
|
-
str2Char[i] = str2.charCodeAt(i);
|
|
44
|
-
}
|
|
45
|
-
prevRow[str2Len] = str2Len;
|
|
46
|
-
|
|
47
|
-
var strCmp;
|
|
48
|
-
if (useCollator) {
|
|
49
|
-
// calculate current row distance from previous row using collator
|
|
50
|
-
for (i = 0; i < str1Len; ++i) {
|
|
51
|
-
nextCol = i + 1;
|
|
52
|
-
|
|
53
|
-
for (j = 0; j < str2Len; ++j) {
|
|
54
|
-
curCol = nextCol;
|
|
55
|
-
|
|
56
|
-
// substution
|
|
57
|
-
strCmp = 0 === collator.compare(str1.charAt(i), String.fromCharCode(str2Char[j]));
|
|
58
|
-
|
|
59
|
-
nextCol = prevRow[j] + (strCmp ? 0 : 1);
|
|
60
|
-
|
|
61
|
-
// insertion
|
|
62
|
-
tmp = curCol + 1;
|
|
63
|
-
if (nextCol > tmp) {
|
|
64
|
-
nextCol = tmp;
|
|
65
|
-
}
|
|
66
|
-
// deletion
|
|
67
|
-
tmp = prevRow[j + 1] + 1;
|
|
68
|
-
if (nextCol > tmp) {
|
|
69
|
-
nextCol = tmp;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// copy current col value into previous (in preparation for next iteration)
|
|
73
|
-
prevRow[j] = curCol;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// copy last col value into previous (in preparation for next iteration)
|
|
77
|
-
prevRow[j] = nextCol;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
// calculate current row distance from previous row without collator
|
|
82
|
-
for (i = 0; i < str1Len; ++i) {
|
|
83
|
-
nextCol = i + 1;
|
|
84
|
-
|
|
85
|
-
for (j = 0; j < str2Len; ++j) {
|
|
86
|
-
curCol = nextCol;
|
|
87
|
-
|
|
88
|
-
// substution
|
|
89
|
-
strCmp = str1.charCodeAt(i) === str2Char[j];
|
|
90
|
-
|
|
91
|
-
nextCol = prevRow[j] + (strCmp ? 0 : 1);
|
|
92
|
-
|
|
93
|
-
// insertion
|
|
94
|
-
tmp = curCol + 1;
|
|
95
|
-
if (nextCol > tmp) {
|
|
96
|
-
nextCol = tmp;
|
|
97
|
-
}
|
|
98
|
-
// deletion
|
|
99
|
-
tmp = prevRow[j + 1] + 1;
|
|
100
|
-
if (nextCol > tmp) {
|
|
101
|
-
nextCol = tmp;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// copy current col value into previous (in preparation for next iteration)
|
|
105
|
-
prevRow[j] = curCol;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// copy last col value into previous (in preparation for next iteration)
|
|
109
|
-
prevRow[j] = nextCol;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return nextCol;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
// amd
|
|
118
|
-
if (typeof define !== "undefined" && define !== null && define.amd) {
|
|
119
|
-
define(function() {
|
|
120
|
-
return Levenshtein;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
// commonjs
|
|
124
|
-
else if (typeof module !== "undefined" && module !== null && typeof exports !== "undefined" && module.exports === exports) {
|
|
125
|
-
module.exports = Levenshtein;
|
|
126
|
-
}
|
|
127
|
-
// web worker
|
|
128
|
-
else if (typeof self !== "undefined" && typeof self.postMessage === 'function' && typeof self.importScripts === 'function') {
|
|
129
|
-
self.Levenshtein = Levenshtein;
|
|
130
|
-
}
|
|
131
|
-
// browser main thread
|
|
132
|
-
else if (typeof window !== "undefined" && window !== null) {
|
|
133
|
-
window.Levenshtein = Levenshtein;
|
|
134
|
-
}
|
|
135
|
-
}());
|
|
136
|
-
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "fast-levenshtein",
|
|
3
|
-
"version": "2.0.6",
|
|
4
|
-
"description": "Efficient implementation of Levenshtein algorithm with locale-specific collator support.",
|
|
5
|
-
"main": "levenshtein.js",
|
|
6
|
-
"files": [
|
|
7
|
-
"levenshtein.js"
|
|
8
|
-
],
|
|
9
|
-
"scripts": {
|
|
10
|
-
"build": "grunt build",
|
|
11
|
-
"prepublish": "npm run build",
|
|
12
|
-
"benchmark": "grunt benchmark",
|
|
13
|
-
"test": "mocha"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"chai": "~1.5.0",
|
|
17
|
-
"grunt": "~0.4.1",
|
|
18
|
-
"grunt-benchmark": "~0.2.0",
|
|
19
|
-
"grunt-cli": "^1.2.0",
|
|
20
|
-
"grunt-contrib-jshint": "~0.4.3",
|
|
21
|
-
"grunt-contrib-uglify": "~0.2.0",
|
|
22
|
-
"grunt-mocha-test": "~0.2.2",
|
|
23
|
-
"grunt-npm-install": "~0.1.0",
|
|
24
|
-
"load-grunt-tasks": "~0.6.0",
|
|
25
|
-
"lodash": "^4.0.1",
|
|
26
|
-
"mocha": "~1.9.0"
|
|
27
|
-
},
|
|
28
|
-
"repository": {
|
|
29
|
-
"type": "git",
|
|
30
|
-
"url": "https://github.com/hiddentao/fast-levenshtein.git"
|
|
31
|
-
},
|
|
32
|
-
"keywords": [
|
|
33
|
-
"levenshtein",
|
|
34
|
-
"distance",
|
|
35
|
-
"string"
|
|
36
|
-
],
|
|
37
|
-
"author": "Ramesh Nair <ram@hiddentao.com> (http://www.hiddentao.com/)",
|
|
38
|
-
"license": "MIT"
|
|
39
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
The ISC License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Isaac Z. Schlueter and Contributors
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
15
|
-
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
-
|
|
17
|
-
----
|
|
18
|
-
|
|
19
|
-
This library bundles a version of the `fs.realpath` and `fs.realpathSync`
|
|
20
|
-
methods from Node.js v0.10 under the terms of the Node.js MIT license.
|
|
21
|
-
|
|
22
|
-
Node's license follows, also included at the header of `old.js` which contains
|
|
23
|
-
the licensed code:
|
|
24
|
-
|
|
25
|
-
Copyright Joyent, Inc. and other Node contributors.
|
|
26
|
-
|
|
27
|
-
Permission is hereby granted, free of charge, to any person obtaining a
|
|
28
|
-
copy of this software and associated documentation files (the "Software"),
|
|
29
|
-
to deal in the Software without restriction, including without limitation
|
|
30
|
-
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
31
|
-
and/or sell copies of the Software, and to permit persons to whom the
|
|
32
|
-
Software is furnished to do so, subject to the following conditions:
|
|
33
|
-
|
|
34
|
-
The above copyright notice and this permission notice shall be included in
|
|
35
|
-
all copies or substantial portions of the Software.
|
|
36
|
-
|
|
37
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
38
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
39
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
40
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
41
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
42
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
43
|
-
DEALINGS IN THE SOFTWARE.
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# fs.realpath
|
|
2
|
-
|
|
3
|
-
A backwards-compatible fs.realpath for Node v6 and above
|
|
4
|
-
|
|
5
|
-
In Node v6, the JavaScript implementation of fs.realpath was replaced
|
|
6
|
-
with a faster (but less resilient) native implementation. That raises
|
|
7
|
-
new and platform-specific errors and cannot handle long or excessively
|
|
8
|
-
symlink-looping paths.
|
|
9
|
-
|
|
10
|
-
This module handles those cases by detecting the new errors and
|
|
11
|
-
falling back to the JavaScript implementation. On versions of Node
|
|
12
|
-
prior to v6, it has no effect.
|
|
13
|
-
|
|
14
|
-
## USAGE
|
|
15
|
-
|
|
16
|
-
```js
|
|
17
|
-
var rp = require('fs.realpath')
|
|
18
|
-
|
|
19
|
-
// async version
|
|
20
|
-
rp.realpath(someLongAndLoopingPath, function (er, real) {
|
|
21
|
-
// the ELOOP was handled, but it was a bit slower
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
// sync version
|
|
25
|
-
var real = rp.realpathSync(someLongAndLoopingPath)
|
|
26
|
-
|
|
27
|
-
// monkeypatch at your own risk!
|
|
28
|
-
// This replaces the fs.realpath/fs.realpathSync builtins
|
|
29
|
-
rp.monkeypatch()
|
|
30
|
-
|
|
31
|
-
// un-do the monkeypatching
|
|
32
|
-
rp.unmonkeypatch()
|
|
33
|
-
```
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
module.exports = realpath
|
|
2
|
-
realpath.realpath = realpath
|
|
3
|
-
realpath.sync = realpathSync
|
|
4
|
-
realpath.realpathSync = realpathSync
|
|
5
|
-
realpath.monkeypatch = monkeypatch
|
|
6
|
-
realpath.unmonkeypatch = unmonkeypatch
|
|
7
|
-
|
|
8
|
-
var fs = require('fs')
|
|
9
|
-
var origRealpath = fs.realpath
|
|
10
|
-
var origRealpathSync = fs.realpathSync
|
|
11
|
-
|
|
12
|
-
var version = process.version
|
|
13
|
-
var ok = /^v[0-5]\./.test(version)
|
|
14
|
-
var old = require('./old.js')
|
|
15
|
-
|
|
16
|
-
function newError (er) {
|
|
17
|
-
return er && er.syscall === 'realpath' && (
|
|
18
|
-
er.code === 'ELOOP' ||
|
|
19
|
-
er.code === 'ENOMEM' ||
|
|
20
|
-
er.code === 'ENAMETOOLONG'
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function realpath (p, cache, cb) {
|
|
25
|
-
if (ok) {
|
|
26
|
-
return origRealpath(p, cache, cb)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (typeof cache === 'function') {
|
|
30
|
-
cb = cache
|
|
31
|
-
cache = null
|
|
32
|
-
}
|
|
33
|
-
origRealpath(p, cache, function (er, result) {
|
|
34
|
-
if (newError(er)) {
|
|
35
|
-
old.realpath(p, cache, cb)
|
|
36
|
-
} else {
|
|
37
|
-
cb(er, result)
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function realpathSync (p, cache) {
|
|
43
|
-
if (ok) {
|
|
44
|
-
return origRealpathSync(p, cache)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
return origRealpathSync(p, cache)
|
|
49
|
-
} catch (er) {
|
|
50
|
-
if (newError(er)) {
|
|
51
|
-
return old.realpathSync(p, cache)
|
|
52
|
-
} else {
|
|
53
|
-
throw er
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function monkeypatch () {
|
|
59
|
-
fs.realpath = realpath
|
|
60
|
-
fs.realpathSync = realpathSync
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function unmonkeypatch () {
|
|
64
|
-
fs.realpath = origRealpath
|
|
65
|
-
fs.realpathSync = origRealpathSync
|
|
66
|
-
}
|