protobufjs 6.11.2 → 7.1.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.
Files changed (259) hide show
  1. package/README.md +7 -174
  2. package/dist/light/protobuf.js +77 -29
  3. package/dist/light/protobuf.js.map +1 -1
  4. package/dist/light/protobuf.min.js +3 -3
  5. package/dist/light/protobuf.min.js.map +1 -1
  6. package/dist/minimal/protobuf.js +27 -10
  7. package/dist/minimal/protobuf.js.map +1 -1
  8. package/dist/minimal/protobuf.min.js +3 -3
  9. package/dist/minimal/protobuf.min.js.map +1 -1
  10. package/dist/protobuf.js +163 -61
  11. package/dist/protobuf.js.map +1 -1
  12. package/dist/protobuf.min.js +3 -3
  13. package/dist/protobuf.min.js.map +1 -1
  14. package/index.d.ts +9 -7
  15. package/package.json +14 -33
  16. package/scripts/postinstall.js +0 -3
  17. package/src/converter.js +10 -4
  18. package/src/decoder.js +4 -3
  19. package/src/enum.js +24 -7
  20. package/src/field.js +6 -3
  21. package/src/namespace.js +3 -3
  22. package/src/parse.js +55 -16
  23. package/src/roots.js +1 -1
  24. package/src/tokenize.js +31 -16
  25. package/src/util/minimal.js +24 -7
  26. package/src/util.js +3 -0
  27. package/src/wrappers.js +2 -2
  28. package/tsconfig.json +2 -1
  29. package/CHANGELOG.md +0 -1019
  30. package/bin/pbjs +0 -6
  31. package/bin/pbts +0 -6
  32. package/cli/LICENSE +0 -33
  33. package/cli/README.md +0 -174
  34. package/cli/bin/pbjs +0 -6
  35. package/cli/bin/pbts +0 -6
  36. package/cli/index.d.ts +0 -3
  37. package/cli/index.js +0 -3
  38. package/cli/lib/tsd-jsdoc/LICENSE +0 -21
  39. package/cli/lib/tsd-jsdoc/README.md +0 -23
  40. package/cli/lib/tsd-jsdoc/plugin.js +0 -21
  41. package/cli/lib/tsd-jsdoc/publish.js +0 -705
  42. package/cli/lib/tsd-jsdoc.json +0 -18
  43. package/cli/node_modules/.package-lock.json +0 -256
  44. package/cli/node_modules/acorn/CHANGELOG.md +0 -620
  45. package/cli/node_modules/acorn/LICENSE +0 -21
  46. package/cli/node_modules/acorn/README.md +0 -269
  47. package/cli/node_modules/acorn/bin/acorn +0 -4
  48. package/cli/node_modules/acorn/dist/acorn.d.ts +0 -209
  49. package/cli/node_modules/acorn/dist/acorn.js +0 -5186
  50. package/cli/node_modules/acorn/dist/acorn.js.map +0 -1
  51. package/cli/node_modules/acorn/dist/acorn.mjs +0 -5155
  52. package/cli/node_modules/acorn/dist/acorn.mjs.d.ts +0 -2
  53. package/cli/node_modules/acorn/dist/acorn.mjs.map +0 -1
  54. package/cli/node_modules/acorn/dist/bin.js +0 -64
  55. package/cli/node_modules/acorn/package.json +0 -35
  56. package/cli/node_modules/acorn-jsx/LICENSE +0 -19
  57. package/cli/node_modules/acorn-jsx/README.md +0 -40
  58. package/cli/node_modules/acorn-jsx/index.js +0 -488
  59. package/cli/node_modules/acorn-jsx/package.json +0 -27
  60. package/cli/node_modules/acorn-jsx/xhtml.js +0 -255
  61. package/cli/node_modules/balanced-match/.npmignore +0 -5
  62. package/cli/node_modules/balanced-match/LICENSE.md +0 -21
  63. package/cli/node_modules/balanced-match/README.md +0 -91
  64. package/cli/node_modules/balanced-match/index.js +0 -59
  65. package/cli/node_modules/balanced-match/package.json +0 -49
  66. package/cli/node_modules/brace-expansion/LICENSE +0 -21
  67. package/cli/node_modules/brace-expansion/README.md +0 -129
  68. package/cli/node_modules/brace-expansion/index.js +0 -201
  69. package/cli/node_modules/brace-expansion/package.json +0 -47
  70. package/cli/node_modules/concat-map/.travis.yml +0 -4
  71. package/cli/node_modules/concat-map/LICENSE +0 -18
  72. package/cli/node_modules/concat-map/README.markdown +0 -62
  73. package/cli/node_modules/concat-map/example/map.js +0 -6
  74. package/cli/node_modules/concat-map/index.js +0 -13
  75. package/cli/node_modules/concat-map/package.json +0 -43
  76. package/cli/node_modules/concat-map/test/map.js +0 -39
  77. package/cli/node_modules/deep-is/.npmignore +0 -1
  78. package/cli/node_modules/deep-is/.travis.yml +0 -6
  79. package/cli/node_modules/deep-is/LICENSE +0 -22
  80. package/cli/node_modules/deep-is/README.markdown +0 -70
  81. package/cli/node_modules/deep-is/example/cmp.js +0 -11
  82. package/cli/node_modules/deep-is/index.js +0 -102
  83. package/cli/node_modules/deep-is/package.json +0 -61
  84. package/cli/node_modules/deep-is/test/NaN.js +0 -16
  85. package/cli/node_modules/deep-is/test/cmp.js +0 -23
  86. package/cli/node_modules/deep-is/test/neg-vs-pos-0.js +0 -15
  87. package/cli/node_modules/escodegen/LICENSE.BSD +0 -21
  88. package/cli/node_modules/escodegen/README.md +0 -84
  89. package/cli/node_modules/escodegen/bin/escodegen.js +0 -77
  90. package/cli/node_modules/escodegen/bin/esgenerate.js +0 -64
  91. package/cli/node_modules/escodegen/escodegen.js +0 -2647
  92. package/cli/node_modules/escodegen/package.json +0 -62
  93. package/cli/node_modules/eslint-visitor-keys/CHANGELOG.md +0 -25
  94. package/cli/node_modules/eslint-visitor-keys/LICENSE +0 -201
  95. package/cli/node_modules/eslint-visitor-keys/README.md +0 -98
  96. package/cli/node_modules/eslint-visitor-keys/lib/index.js +0 -81
  97. package/cli/node_modules/eslint-visitor-keys/lib/visitor-keys.json +0 -284
  98. package/cli/node_modules/eslint-visitor-keys/package.json +0 -40
  99. package/cli/node_modules/espree/CHANGELOG.md +0 -509
  100. package/cli/node_modules/espree/LICENSE +0 -25
  101. package/cli/node_modules/espree/README.md +0 -233
  102. package/cli/node_modules/espree/espree.js +0 -177
  103. package/cli/node_modules/espree/lib/ast-node-types.js +0 -96
  104. package/cli/node_modules/espree/lib/espree.js +0 -286
  105. package/cli/node_modules/espree/lib/features.js +0 -29
  106. package/cli/node_modules/espree/lib/options.js +0 -106
  107. package/cli/node_modules/espree/lib/token-translator.js +0 -263
  108. package/cli/node_modules/espree/lib/visitor-keys.js +0 -123
  109. package/cli/node_modules/espree/package.json +0 -64
  110. package/cli/node_modules/esprima/ChangeLog +0 -235
  111. package/cli/node_modules/esprima/LICENSE.BSD +0 -21
  112. package/cli/node_modules/esprima/README.md +0 -46
  113. package/cli/node_modules/esprima/bin/esparse.js +0 -139
  114. package/cli/node_modules/esprima/bin/esvalidate.js +0 -236
  115. package/cli/node_modules/esprima/dist/esprima.js +0 -6709
  116. package/cli/node_modules/esprima/package.json +0 -112
  117. package/cli/node_modules/estraverse/.jshintrc +0 -16
  118. package/cli/node_modules/estraverse/LICENSE.BSD +0 -19
  119. package/cli/node_modules/estraverse/README.md +0 -153
  120. package/cli/node_modules/estraverse/estraverse.js +0 -801
  121. package/cli/node_modules/estraverse/gulpfile.js +0 -70
  122. package/cli/node_modules/estraverse/package.json +0 -40
  123. package/cli/node_modules/esutils/LICENSE.BSD +0 -19
  124. package/cli/node_modules/esutils/README.md +0 -174
  125. package/cli/node_modules/esutils/lib/ast.js +0 -144
  126. package/cli/node_modules/esutils/lib/code.js +0 -135
  127. package/cli/node_modules/esutils/lib/keyword.js +0 -165
  128. package/cli/node_modules/esutils/lib/utils.js +0 -33
  129. package/cli/node_modules/esutils/package.json +0 -44
  130. package/cli/node_modules/fast-levenshtein/LICENSE.md +0 -25
  131. package/cli/node_modules/fast-levenshtein/README.md +0 -104
  132. package/cli/node_modules/fast-levenshtein/levenshtein.js +0 -136
  133. package/cli/node_modules/fast-levenshtein/package.json +0 -39
  134. package/cli/node_modules/fs.realpath/LICENSE +0 -43
  135. package/cli/node_modules/fs.realpath/README.md +0 -33
  136. package/cli/node_modules/fs.realpath/index.js +0 -66
  137. package/cli/node_modules/fs.realpath/old.js +0 -303
  138. package/cli/node_modules/fs.realpath/package.json +0 -26
  139. package/cli/node_modules/glob/LICENSE +0 -21
  140. package/cli/node_modules/glob/README.md +0 -375
  141. package/cli/node_modules/glob/changelog.md +0 -67
  142. package/cli/node_modules/glob/common.js +0 -240
  143. package/cli/node_modules/glob/glob.js +0 -790
  144. package/cli/node_modules/glob/package.json +0 -46
  145. package/cli/node_modules/glob/sync.js +0 -486
  146. package/cli/node_modules/inflight/LICENSE +0 -15
  147. package/cli/node_modules/inflight/README.md +0 -37
  148. package/cli/node_modules/inflight/inflight.js +0 -54
  149. package/cli/node_modules/inflight/package.json +0 -29
  150. package/cli/node_modules/inherits/LICENSE +0 -16
  151. package/cli/node_modules/inherits/README.md +0 -42
  152. package/cli/node_modules/inherits/inherits.js +0 -9
  153. package/cli/node_modules/inherits/inherits_browser.js +0 -27
  154. package/cli/node_modules/inherits/package.json +0 -29
  155. package/cli/node_modules/levn/LICENSE +0 -22
  156. package/cli/node_modules/levn/README.md +0 -196
  157. package/cli/node_modules/levn/lib/cast.js +0 -298
  158. package/cli/node_modules/levn/lib/coerce.js +0 -285
  159. package/cli/node_modules/levn/lib/index.js +0 -22
  160. package/cli/node_modules/levn/lib/parse-string.js +0 -113
  161. package/cli/node_modules/levn/lib/parse.js +0 -102
  162. package/cli/node_modules/levn/package.json +0 -47
  163. package/cli/node_modules/minimatch/LICENSE +0 -15
  164. package/cli/node_modules/minimatch/README.md +0 -209
  165. package/cli/node_modules/minimatch/minimatch.js +0 -923
  166. package/cli/node_modules/minimatch/package.json +0 -30
  167. package/cli/node_modules/once/LICENSE +0 -15
  168. package/cli/node_modules/once/README.md +0 -79
  169. package/cli/node_modules/once/once.js +0 -42
  170. package/cli/node_modules/once/package.json +0 -33
  171. package/cli/node_modules/optionator/CHANGELOG.md +0 -56
  172. package/cli/node_modules/optionator/LICENSE +0 -22
  173. package/cli/node_modules/optionator/README.md +0 -238
  174. package/cli/node_modules/optionator/lib/help.js +0 -260
  175. package/cli/node_modules/optionator/lib/index.js +0 -465
  176. package/cli/node_modules/optionator/lib/util.js +0 -54
  177. package/cli/node_modules/optionator/package.json +0 -44
  178. package/cli/node_modules/path-is-absolute/index.js +0 -20
  179. package/cli/node_modules/path-is-absolute/license +0 -21
  180. package/cli/node_modules/path-is-absolute/package.json +0 -43
  181. package/cli/node_modules/path-is-absolute/readme.md +0 -59
  182. package/cli/node_modules/prelude-ls/CHANGELOG.md +0 -99
  183. package/cli/node_modules/prelude-ls/LICENSE +0 -22
  184. package/cli/node_modules/prelude-ls/README.md +0 -15
  185. package/cli/node_modules/prelude-ls/lib/Func.js +0 -65
  186. package/cli/node_modules/prelude-ls/lib/List.js +0 -686
  187. package/cli/node_modules/prelude-ls/lib/Num.js +0 -130
  188. package/cli/node_modules/prelude-ls/lib/Obj.js +0 -154
  189. package/cli/node_modules/prelude-ls/lib/Str.js +0 -92
  190. package/cli/node_modules/prelude-ls/lib/index.js +0 -178
  191. package/cli/node_modules/prelude-ls/package.json +0 -52
  192. package/cli/node_modules/rimraf/CHANGELOG.md +0 -65
  193. package/cli/node_modules/rimraf/LICENSE +0 -15
  194. package/cli/node_modules/rimraf/README.md +0 -101
  195. package/cli/node_modules/rimraf/bin.js +0 -68
  196. package/cli/node_modules/rimraf/package.json +0 -32
  197. package/cli/node_modules/rimraf/rimraf.js +0 -360
  198. package/cli/node_modules/source-map/CHANGELOG.md +0 -301
  199. package/cli/node_modules/source-map/LICENSE +0 -28
  200. package/cli/node_modules/source-map/README.md +0 -742
  201. package/cli/node_modules/source-map/dist/source-map.debug.js +0 -3234
  202. package/cli/node_modules/source-map/dist/source-map.js +0 -3233
  203. package/cli/node_modules/source-map/dist/source-map.min.js +0 -2
  204. package/cli/node_modules/source-map/dist/source-map.min.js.map +0 -1
  205. package/cli/node_modules/source-map/lib/array-set.js +0 -121
  206. package/cli/node_modules/source-map/lib/base64-vlq.js +0 -140
  207. package/cli/node_modules/source-map/lib/base64.js +0 -67
  208. package/cli/node_modules/source-map/lib/binary-search.js +0 -111
  209. package/cli/node_modules/source-map/lib/mapping-list.js +0 -79
  210. package/cli/node_modules/source-map/lib/quick-sort.js +0 -114
  211. package/cli/node_modules/source-map/lib/source-map-consumer.js +0 -1145
  212. package/cli/node_modules/source-map/lib/source-map-generator.js +0 -425
  213. package/cli/node_modules/source-map/lib/source-node.js +0 -413
  214. package/cli/node_modules/source-map/lib/util.js +0 -488
  215. package/cli/node_modules/source-map/package.json +0 -73
  216. package/cli/node_modules/source-map/source-map.d.ts +0 -98
  217. package/cli/node_modules/source-map/source-map.js +0 -8
  218. package/cli/node_modules/tmp/CHANGELOG.md +0 -288
  219. package/cli/node_modules/tmp/LICENSE +0 -21
  220. package/cli/node_modules/tmp/README.md +0 -365
  221. package/cli/node_modules/tmp/lib/tmp.js +0 -780
  222. package/cli/node_modules/tmp/package.json +0 -58
  223. package/cli/node_modules/type-check/LICENSE +0 -22
  224. package/cli/node_modules/type-check/README.md +0 -210
  225. package/cli/node_modules/type-check/lib/check.js +0 -126
  226. package/cli/node_modules/type-check/lib/index.js +0 -16
  227. package/cli/node_modules/type-check/lib/parse-type.js +0 -196
  228. package/cli/node_modules/type-check/package.json +0 -40
  229. package/cli/node_modules/word-wrap/LICENSE +0 -21
  230. package/cli/node_modules/word-wrap/README.md +0 -182
  231. package/cli/node_modules/word-wrap/index.d.ts +0 -50
  232. package/cli/node_modules/word-wrap/index.js +0 -46
  233. package/cli/node_modules/word-wrap/package.json +0 -77
  234. package/cli/node_modules/wrappy/LICENSE +0 -15
  235. package/cli/node_modules/wrappy/README.md +0 -36
  236. package/cli/node_modules/wrappy/package.json +0 -29
  237. package/cli/node_modules/wrappy/wrappy.js +0 -33
  238. package/cli/package.json +0 -8
  239. package/cli/package.standalone.json +0 -32
  240. package/cli/pbjs.d.ts +0 -9
  241. package/cli/pbjs.js +0 -330
  242. package/cli/pbts.d.ts +0 -9
  243. package/cli/pbts.js +0 -197
  244. package/cli/targets/json-module.js +0 -38
  245. package/cli/targets/json.js +0 -8
  246. package/cli/targets/proto.js +0 -326
  247. package/cli/targets/proto2.js +0 -10
  248. package/cli/targets/proto3.js +0 -10
  249. package/cli/targets/static-module.js +0 -29
  250. package/cli/targets/static.js +0 -711
  251. package/cli/util.js +0 -183
  252. package/cli/wrappers/amd.js +0 -7
  253. package/cli/wrappers/closure.js +0 -7
  254. package/cli/wrappers/commonjs.js +0 -7
  255. package/cli/wrappers/default.js +0 -15
  256. package/cli/wrappers/es6.js +0 -5
  257. package/dist/README.md +0 -31
  258. package/dist/light/README.md +0 -31
  259. package/dist/minimal/README.md +0 -31
@@ -1,30 +0,0 @@
1
- {
2
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
3
- "name": "minimatch",
4
- "description": "a glob matcher in javascript",
5
- "version": "3.0.4",
6
- "repository": {
7
- "type": "git",
8
- "url": "git://github.com/isaacs/minimatch.git"
9
- },
10
- "main": "minimatch.js",
11
- "scripts": {
12
- "test": "tap test/*.js --cov",
13
- "preversion": "npm test",
14
- "postversion": "npm publish",
15
- "postpublish": "git push origin --all; git push origin --tags"
16
- },
17
- "engines": {
18
- "node": "*"
19
- },
20
- "dependencies": {
21
- "brace-expansion": "^1.1.7"
22
- },
23
- "devDependencies": {
24
- "tap": "^10.3.2"
25
- },
26
- "license": "ISC",
27
- "files": [
28
- "minimatch.js"
29
- ]
30
- }
@@ -1,15 +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.
@@ -1,79 +0,0 @@
1
- # once
2
-
3
- Only call a function once.
4
-
5
- ## usage
6
-
7
- ```javascript
8
- var once = require('once')
9
-
10
- function load (file, cb) {
11
- cb = once(cb)
12
- loader.load('file')
13
- loader.once('load', cb)
14
- loader.once('error', cb)
15
- }
16
- ```
17
-
18
- Or add to the Function.prototype in a responsible way:
19
-
20
- ```javascript
21
- // only has to be done once
22
- require('once').proto()
23
-
24
- function load (file, cb) {
25
- cb = cb.once()
26
- loader.load('file')
27
- loader.once('load', cb)
28
- loader.once('error', cb)
29
- }
30
- ```
31
-
32
- Ironically, the prototype feature makes this module twice as
33
- complicated as necessary.
34
-
35
- To check whether you function has been called, use `fn.called`. Once the
36
- function is called for the first time the return value of the original
37
- function is saved in `fn.value` and subsequent calls will continue to
38
- return this value.
39
-
40
- ```javascript
41
- var once = require('once')
42
-
43
- function load (cb) {
44
- cb = once(cb)
45
- var stream = createStream()
46
- stream.once('data', cb)
47
- stream.once('end', function () {
48
- if (!cb.called) cb(new Error('not found'))
49
- })
50
- }
51
- ```
52
-
53
- ## `once.strict(func)`
54
-
55
- Throw an error if the function is called twice.
56
-
57
- Some functions are expected to be called only once. Using `once` for them would
58
- potentially hide logical errors.
59
-
60
- In the example below, the `greet` function has to call the callback only once:
61
-
62
- ```javascript
63
- function greet (name, cb) {
64
- // return is missing from the if statement
65
- // when no name is passed, the callback is called twice
66
- if (!name) cb('Hello anonymous')
67
- cb('Hello ' + name)
68
- }
69
-
70
- function log (msg) {
71
- console.log(msg)
72
- }
73
-
74
- // this will print 'Hello anonymous' but the logical error will be missed
75
- greet(null, once(msg))
76
-
77
- // once.strict will print 'Hello anonymous' and throw an error when the callback will be called the second time
78
- greet(null, once.strict(msg))
79
- ```
@@ -1,42 +0,0 @@
1
- var wrappy = require('wrappy')
2
- module.exports = wrappy(once)
3
- module.exports.strict = wrappy(onceStrict)
4
-
5
- once.proto = once(function () {
6
- Object.defineProperty(Function.prototype, 'once', {
7
- value: function () {
8
- return once(this)
9
- },
10
- configurable: true
11
- })
12
-
13
- Object.defineProperty(Function.prototype, 'onceStrict', {
14
- value: function () {
15
- return onceStrict(this)
16
- },
17
- configurable: true
18
- })
19
- })
20
-
21
- function once (fn) {
22
- var f = function () {
23
- if (f.called) return f.value
24
- f.called = true
25
- return f.value = fn.apply(this, arguments)
26
- }
27
- f.called = false
28
- return f
29
- }
30
-
31
- function onceStrict (fn) {
32
- var f = function () {
33
- if (f.called)
34
- throw new Error(f.onceError)
35
- f.called = true
36
- return f.value = fn.apply(this, arguments)
37
- }
38
- var name = fn.name || 'Function wrapped with `once`'
39
- f.onceError = name + " shouldn't be called more than once"
40
- f.called = false
41
- return f
42
- }
@@ -1,33 +0,0 @@
1
- {
2
- "name": "once",
3
- "version": "1.4.0",
4
- "description": "Run a function exactly one time",
5
- "main": "once.js",
6
- "directories": {
7
- "test": "test"
8
- },
9
- "dependencies": {
10
- "wrappy": "1"
11
- },
12
- "devDependencies": {
13
- "tap": "^7.0.1"
14
- },
15
- "scripts": {
16
- "test": "tap test/*.js"
17
- },
18
- "files": [
19
- "once.js"
20
- ],
21
- "repository": {
22
- "type": "git",
23
- "url": "git://github.com/isaacs/once"
24
- },
25
- "keywords": [
26
- "once",
27
- "function",
28
- "one",
29
- "single"
30
- ],
31
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
32
- "license": "ISC"
33
- }
@@ -1,56 +0,0 @@
1
- # 0.8.3
2
- - changes dependency from `wordwrap` to `word-wrap` due to license issue
3
- - update dependencies
4
-
5
- # 0.8.2
6
- - fix bug #18 - detect missing value when flag is last item
7
- - update dependencies
8
-
9
- # 0.8.1
10
- - update `fast-levenshtein` dependency
11
-
12
- # 0.8.0
13
- - update `levn` dependency - supplying a float value to an option with type `Int` now throws an error, instead of silently converting to an `Int`
14
-
15
- # 0.7.1
16
- - fix bug with use of `defaults` and `concatRepeatedArrays` or `mergeRepeatedObjects`
17
-
18
- # 0.7.0
19
- - added `concatrepeatedarrays` option: `oneValuePerFlag`, only allows one array value per flag
20
- - added `typeAliases` option
21
- - added `parseArgv` which takes an array and parses with the first two items sliced off
22
- - changed enum help style
23
- - bug fixes (#12)
24
- - use of `concatRepeatedArrays` and `mergeRepeatedObjects` at the top level is deprecated, use it as either a per-option option, or set them in the `defaults` object to set them for all objects
25
-
26
- # 0.6.0
27
- - added `defaults` lib-option flag, allowing one to set default properties for all options
28
- - added `concatRepeatedArrays` and `mergeRepeatedObjects` as option level properties, allowing you to turn this feature on for specific options only
29
-
30
- # 0.5.0
31
- - `Boolean` flags with `default: 'true'`, and no short aliases, will by default show the `--no` version in help
32
-
33
- # 0.4.0
34
- - add `mergeRepeatedObjects` setting
35
-
36
- # 0.3.0
37
- - add `concatRepeatedArrays` setting
38
- - add `overrideRequired` option setting
39
- - use just Levenshtein string compare algo rather than Levenshtein Damerau to due dependency license issue
40
-
41
- # 0.2.2
42
- - bug fixes
43
-
44
- # 0.2.1
45
- - improved interpolation
46
- - added changelog
47
-
48
- # 0.2.0
49
- - add dependency checks to options - added `dependsOn` as an option property
50
- - add interpolation for `prepend` and `append` text with new `generateHelp` option, `interpolate`
51
-
52
- # 0.1.1
53
- - update dependencies
54
-
55
- # 0.1.0
56
- - initial release
@@ -1,22 +0,0 @@
1
- Copyright (c) George Zahariev
2
-
3
- Permission is hereby granted, free of charge, to any person
4
- obtaining a copy of this software and associated documentation
5
- files (the "Software"), to deal in the Software without
6
- restriction, including without limitation the rights to use,
7
- copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the
9
- Software is furnished to do so, subject to the following
10
- conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
@@ -1,238 +0,0 @@
1
- # Optionator
2
- <a name="optionator" />
3
-
4
- Optionator is a JavaScript/Node.js option parsing and help generation library used by [eslint](http://eslint.org), [Grasp](http://graspjs.com), [LiveScript](http://livescript.net), [esmangle](https://github.com/estools/esmangle), [escodegen](https://github.com/estools/escodegen), and [many more](https://www.npmjs.com/browse/depended/optionator).
5
-
6
- For an online demo, check out the [Grasp online demo](http://www.graspjs.com/#demo).
7
-
8
- [About](#about) &middot; [Usage](#usage) &middot; [Settings Format](#settings-format) &middot; [Argument Format](#argument-format)
9
-
10
- ## Why?
11
- The problem with other option parsers, such as `yargs` or `minimist`, is they just accept all input, valid or not.
12
- With Optionator, if you mistype an option, it will give you an error (with a suggestion for what you meant).
13
- If you give the wrong type of argument for an option, it will give you an error rather than supplying the wrong input to your application.
14
-
15
- $ cmd --halp
16
- Invalid option '--halp' - perhaps you meant '--help'?
17
-
18
- $ cmd --count str
19
- Invalid value for option 'count' - expected type Int, received value: str.
20
-
21
- Other helpful features include reformatting the help text based on the size of the console, so that it fits even if the console is narrow, and accepting not just an array (eg. process.argv), but a string or object as well, making things like testing much easier.
22
-
23
- ## About
24
- Optionator uses [type-check](https://github.com/gkz/type-check) and [levn](https://github.com/gkz/levn) behind the scenes to cast and verify input according the specified types.
25
-
26
- MIT license. Version 0.8.3
27
-
28
- npm install optionator
29
-
30
- For updates on Optionator, [follow me on twitter](https://twitter.com/gkzahariev).
31
-
32
- Optionator is a Node.js module, but can be used in the browser as well if packed with webpack/browserify.
33
-
34
- ## Usage
35
- `require('optionator');` returns a function. It has one property, `VERSION`, the current version of the library as a string. This function is called with an object specifying your options and other information, see the [settings format section](#settings-format). This in turn returns an object with three properties, `parse`, `parseArgv`, `generateHelp`, and `generateHelpForOption`, which are all functions.
36
-
37
- ```js
38
- var optionator = require('optionator')({
39
- prepend: 'Usage: cmd [options]',
40
- append: 'Version 1.0.0',
41
- options: [{
42
- option: 'help',
43
- alias: 'h',
44
- type: 'Boolean',
45
- description: 'displays help'
46
- }, {
47
- option: 'count',
48
- alias: 'c',
49
- type: 'Int',
50
- description: 'number of things',
51
- example: 'cmd --count 2'
52
- }]
53
- });
54
-
55
- var options = optionator.parseArgv(process.argv);
56
- if (options.help) {
57
- console.log(optionator.generateHelp());
58
- }
59
- ...
60
- ```
61
-
62
- ### parse(input, parseOptions)
63
- `parse` processes the `input` according to your settings, and returns an object with the results.
64
-
65
- ##### arguments
66
- * input - `[String] | Object | String` - the input you wish to parse
67
- * parseOptions - `{slice: Int}` - all options optional
68
- - `slice` specifies how much to slice away from the beginning if the input is an array or string - by default `0` for string, `2` for array (works with `process.argv`)
69
-
70
- ##### returns
71
- `Object` - the parsed options, each key is a camelCase version of the option name (specified in dash-case), and each value is the processed value for that option. Positional values are in an array under the `_` key.
72
-
73
- ##### example
74
- ```js
75
- parse(['node', 't.js', '--count', '2', 'positional']); // {count: 2, _: ['positional']}
76
- parse('--count 2 positional'); // {count: 2, _: ['positional']}
77
- parse({count: 2, _:['positional']}); // {count: 2, _: ['positional']}
78
- ```
79
-
80
- ### parseArgv(input)
81
- `parseArgv` works exactly like `parse`, but only for array input and it slices off the first two elements.
82
-
83
- ##### arguments
84
- * input - `[String]` - the input you wish to parse
85
-
86
- ##### returns
87
- See "returns" section in "parse"
88
-
89
- ##### example
90
- ```js
91
- parseArgv(process.argv);
92
- ```
93
-
94
- ### generateHelp(helpOptions)
95
- `generateHelp` produces help text based on your settings.
96
-
97
- ##### arguments
98
- * helpOptions - `{showHidden: Boolean, interpolate: Object}` - all options optional
99
- - `showHidden` specifies whether to show options with `hidden: true` specified, by default it is `false`
100
- - `interpolate` specify data to be interpolated in `prepend` and `append` text, `{{key}}` is the format - eg. `generateHelp({interpolate:{version: '0.4.2'}})`, will change this `append` text: `Version {{version}}` to `Version 0.4.2`
101
-
102
- ##### returns
103
- `String` - the generated help text
104
-
105
- ##### example
106
- ```js
107
- generateHelp(); /*
108
- "Usage: cmd [options] positional
109
-
110
- -h, --help displays help
111
- -c, --count Int number of things
112
-
113
- Version 1.0.0
114
- "*/
115
- ```
116
-
117
- ### generateHelpForOption(optionName)
118
- `generateHelpForOption` produces expanded help text for the specified with `optionName` option. If an `example` was specified for the option, it will be displayed, and if a `longDescription` was specified, it will display that instead of the `description`.
119
-
120
- ##### arguments
121
- * optionName - `String` - the name of the option to display
122
-
123
- ##### returns
124
- `String` - the generated help text for the option
125
-
126
- ##### example
127
- ```js
128
- generateHelpForOption('count'); /*
129
- "-c, --count Int
130
- description: number of things
131
- example: cmd --count 2
132
- "*/
133
- ```
134
-
135
- ## Settings Format
136
- When your `require('optionator')`, you get a function that takes in a settings object. This object has the type:
137
-
138
- {
139
- prepend: String,
140
- append: String,
141
- options: [{heading: String} | {
142
- option: String,
143
- alias: [String] | String,
144
- type: String,
145
- enum: [String],
146
- default: String,
147
- restPositional: Boolean,
148
- required: Boolean,
149
- overrideRequired: Boolean,
150
- dependsOn: [String] | String,
151
- concatRepeatedArrays: Boolean | (Boolean, Object),
152
- mergeRepeatedObjects: Boolean,
153
- description: String,
154
- longDescription: String,
155
- example: [String] | String
156
- }],
157
- helpStyle: {
158
- aliasSeparator: String,
159
- typeSeparator: String,
160
- descriptionSeparator: String,
161
- initialIndent: Int,
162
- secondaryIndent: Int,
163
- maxPadFactor: Number
164
- },
165
- mutuallyExclusive: [[String | [String]]],
166
- concatRepeatedArrays: Boolean | (Boolean, Object), // deprecated, set in defaults object
167
- mergeRepeatedObjects: Boolean, // deprecated, set in defaults object
168
- positionalAnywhere: Boolean,
169
- typeAliases: Object,
170
- defaults: Object
171
- }
172
-
173
- All of the properties are optional (the `Maybe` has been excluded for brevities sake), except for having either `heading: String` or `option: String` in each object in the `options` array.
174
-
175
- ### Top Level Properties
176
- * `prepend` is an optional string to be placed before the options in the help text
177
- * `append` is an optional string to be placed after the options in the help text
178
- * `options` is a required array specifying your options and headings, the options and headings will be displayed in the order specified
179
- * `helpStyle` is an optional object which enables you to change the default appearance of some aspects of the help text
180
- * `mutuallyExclusive` is an optional array of arrays of either strings or arrays of strings. The top level array is a list of rules, each rule is a list of elements - each element can be either a string (the name of an option), or a list of strings (a group of option names) - there will be an error if more than one element is present
181
- * `concatRepeatedArrays` see description under the "Option Properties" heading - use at the top level is deprecated, if you want to set this for all options, use the `defaults` property
182
- * `mergeRepeatedObjects` see description under the "Option Properties" heading - use at the top level is deprecated, if you want to set this for all options, use the `defaults` property
183
- * `positionalAnywhere` is an optional boolean (defaults to `true`) - when `true` it allows positional arguments anywhere, when `false`, all arguments after the first positional one are taken to be positional as well, even if they look like a flag. For example, with `positionalAnywhere: false`, the arguments `--flag --boom 12 --crack` would have two positional arguments: `12` and `--crack`
184
- * `typeAliases` is an optional object, it allows you to set aliases for types, eg. `{Path: 'String'}` would allow you to use the type `Path` as an alias for the type `String`
185
- * `defaults` is an optional object following the option properties format, which specifies default values for all options. A default will be overridden if manually set. For example, you can do `default: { type: "String" }` to set the default type of all options to `String`, and then override that default in an individual option by setting the `type` property
186
-
187
- #### Heading Properties
188
- * `heading` a required string, the name of the heading
189
-
190
- #### Option Properties
191
- * `option` the required name of the option - use dash-case, without the leading dashes
192
- * `alias` is an optional string or array of strings which specify any aliases for the option
193
- * `type` is a required string in the [type check](https://github.com/gkz/type-check) [format](https://github.com/gkz/type-check#type-format), this will be used to cast the inputted value and validate it
194
- * `enum` is an optional array of strings, each string will be parsed by [levn](https://github.com/gkz/levn) - the argument value must be one of the resulting values - each potential value must validate against the specified `type`
195
- * `default` is a optional string, which will be parsed by [levn](https://github.com/gkz/levn) and used as the default value if none is set - the value must validate against the specified `type`
196
- * `restPositional` is an optional boolean - if set to `true`, everything after the option will be taken to be a positional argument, even if it looks like a named argument
197
- * `required` is an optional boolean - if set to `true`, the option parsing will fail if the option is not defined
198
- * `overrideRequired` is a optional boolean - if set to `true` and the option is used, and there is another option which is required but not set, it will override the need for the required option and there will be no error - this is useful if you have required options and want to use `--help` or `--version` flags
199
- * `concatRepeatedArrays` is an optional boolean or tuple with boolean and options object (defaults to `false`) - when set to `true` and an option contains an array value and is repeated, the subsequent values for the flag will be appended rather than overwriting the original value - eg. option `g` of type `[String]`: `-g a -g b -g c,d` will result in `['a','b','c','d']`
200
-
201
- You can supply an options object by giving the following value: `[true, options]`. The one currently supported option is `oneValuePerFlag`, this only allows one array value per flag. This is useful if your potential values contain a comma.
202
- * `mergeRepeatedObjects` is an optional boolean (defaults to `false`) - when set to `true` and an option contains an object value and is repeated, the subsequent values for the flag will be merged rather than overwriting the original value - eg. option `g` of type `Object`: `-g a:1 -g b:2 -g c:3,d:4` will result in `{a: 1, b: 2, c: 3, d: 4}`
203
- * `dependsOn` is an optional string or array of strings - if simply a string (the name of another option), it will make sure that that other option is set, if an array of strings, depending on whether `'and'` or `'or'` is first, it will either check whether all (`['and', 'option-a', 'option-b']`), or at least one (`['or', 'option-a', 'option-b']`) other options are set
204
- * `description` is an optional string, which will be displayed next to the option in the help text
205
- * `longDescription` is an optional string, it will be displayed instead of the `description` when `generateHelpForOption` is used
206
- * `example` is an optional string or array of strings with example(s) for the option - these will be displayed when `generateHelpForOption` is used
207
-
208
- #### Help Style Properties
209
- * `aliasSeparator` is an optional string, separates multiple names from each other - default: ' ,'
210
- * `typeSeparator` is an optional string, separates the type from the names - default: ' '
211
- * `descriptionSeparator` is an optional string , separates the description from the padded name and type - default: ' '
212
- * `initialIndent` is an optional int - the amount of indent for options - default: 2
213
- * `secondaryIndent` is an optional int - the amount of indent if wrapped fully (in addition to the initial indent) - default: 4
214
- * `maxPadFactor` is an optional number - affects the default level of padding for the names/type, it is multiplied by the average of the length of the names/type - default: 1.5
215
-
216
- ## Argument Format
217
- At the highest level there are two types of arguments: named, and positional.
218
-
219
- Name arguments of any length are prefixed with `--` (eg. `--go`), and those of one character may be prefixed with either `--` or `-` (eg. `-g`).
220
-
221
- There are two types of named arguments: boolean flags (eg. `--problemo`, `-p`) which take no value and result in a `true` if they are present, the falsey `undefined` if they are not present, or `false` if present and explicitly prefixed with `no` (eg. `--no-problemo`). Named arguments with values (eg. `--tseries 800`, `-t 800`) are the other type. If the option has a type `Boolean` it will automatically be made into a boolean flag. Any other type results in a named argument that takes a value.
222
-
223
- For more information about how to properly set types to get the value you want, take a look at the [type check](https://github.com/gkz/type-check) and [levn](https://github.com/gkz/levn) pages.
224
-
225
- You can group single character arguments that use a single `-`, however all except the last must be boolean flags (which take no value). The last may be a boolean flag, or an argument which takes a value - eg. `-ba 2` is equivalent to `-b -a 2`.
226
-
227
- Positional arguments are all those values which do not fall under the above - they can be anywhere, not just at the end. For example, in `cmd -b one -a 2 two` where `b` is a boolean flag, and `a` has the type `Number`, there are two positional arguments, `one` and `two`.
228
-
229
- Everything after an `--` is positional, even if it looks like a named argument.
230
-
231
- You may optionally use `=` to separate option names from values, for example: `--count=2`.
232
-
233
- If you specify the option `NUM`, then any argument using a single `-` followed by a number will be valid and will set the value of `NUM`. Eg. `-2` will be parsed into `NUM: 2`.
234
-
235
- If duplicate named arguments are present, the last one will be taken.
236
-
237
- ## Technical About
238
- `optionator` is written in [LiveScript](http://livescript.net/) - a language that compiles to JavaScript. It uses [levn](https://github.com/gkz/levn) to cast arguments to their specified type, and uses [type-check](https://github.com/gkz/type-check) to validate values. It also uses the [prelude.ls](http://preludels.com/) library.