protobufjs 6.11.2 → 6.11.3

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 (202) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/bin/pbjs +0 -0
  3. package/bin/pbts +0 -0
  4. package/package-lock.json +7870 -0
  5. package/package.json +3 -3
  6. package/scripts/changelog.js +150 -0
  7. package/src/util.js +3 -0
  8. package/cli/node_modules/.package-lock.json +0 -256
  9. package/cli/node_modules/acorn/CHANGELOG.md +0 -620
  10. package/cli/node_modules/acorn/LICENSE +0 -21
  11. package/cli/node_modules/acorn/README.md +0 -269
  12. package/cli/node_modules/acorn/bin/acorn +0 -4
  13. package/cli/node_modules/acorn/dist/acorn.d.ts +0 -209
  14. package/cli/node_modules/acorn/dist/acorn.js +0 -5186
  15. package/cli/node_modules/acorn/dist/acorn.js.map +0 -1
  16. package/cli/node_modules/acorn/dist/acorn.mjs +0 -5155
  17. package/cli/node_modules/acorn/dist/acorn.mjs.d.ts +0 -2
  18. package/cli/node_modules/acorn/dist/acorn.mjs.map +0 -1
  19. package/cli/node_modules/acorn/dist/bin.js +0 -64
  20. package/cli/node_modules/acorn/package.json +0 -35
  21. package/cli/node_modules/acorn-jsx/LICENSE +0 -19
  22. package/cli/node_modules/acorn-jsx/README.md +0 -40
  23. package/cli/node_modules/acorn-jsx/index.js +0 -488
  24. package/cli/node_modules/acorn-jsx/package.json +0 -27
  25. package/cli/node_modules/acorn-jsx/xhtml.js +0 -255
  26. package/cli/node_modules/balanced-match/.npmignore +0 -5
  27. package/cli/node_modules/balanced-match/LICENSE.md +0 -21
  28. package/cli/node_modules/balanced-match/README.md +0 -91
  29. package/cli/node_modules/balanced-match/index.js +0 -59
  30. package/cli/node_modules/balanced-match/package.json +0 -49
  31. package/cli/node_modules/brace-expansion/LICENSE +0 -21
  32. package/cli/node_modules/brace-expansion/README.md +0 -129
  33. package/cli/node_modules/brace-expansion/index.js +0 -201
  34. package/cli/node_modules/brace-expansion/package.json +0 -47
  35. package/cli/node_modules/concat-map/.travis.yml +0 -4
  36. package/cli/node_modules/concat-map/LICENSE +0 -18
  37. package/cli/node_modules/concat-map/README.markdown +0 -62
  38. package/cli/node_modules/concat-map/example/map.js +0 -6
  39. package/cli/node_modules/concat-map/index.js +0 -13
  40. package/cli/node_modules/concat-map/package.json +0 -43
  41. package/cli/node_modules/concat-map/test/map.js +0 -39
  42. package/cli/node_modules/deep-is/.npmignore +0 -1
  43. package/cli/node_modules/deep-is/.travis.yml +0 -6
  44. package/cli/node_modules/deep-is/LICENSE +0 -22
  45. package/cli/node_modules/deep-is/README.markdown +0 -70
  46. package/cli/node_modules/deep-is/example/cmp.js +0 -11
  47. package/cli/node_modules/deep-is/index.js +0 -102
  48. package/cli/node_modules/deep-is/package.json +0 -61
  49. package/cli/node_modules/deep-is/test/NaN.js +0 -16
  50. package/cli/node_modules/deep-is/test/cmp.js +0 -23
  51. package/cli/node_modules/deep-is/test/neg-vs-pos-0.js +0 -15
  52. package/cli/node_modules/escodegen/LICENSE.BSD +0 -21
  53. package/cli/node_modules/escodegen/README.md +0 -84
  54. package/cli/node_modules/escodegen/bin/escodegen.js +0 -77
  55. package/cli/node_modules/escodegen/bin/esgenerate.js +0 -64
  56. package/cli/node_modules/escodegen/escodegen.js +0 -2647
  57. package/cli/node_modules/escodegen/package.json +0 -62
  58. package/cli/node_modules/eslint-visitor-keys/CHANGELOG.md +0 -25
  59. package/cli/node_modules/eslint-visitor-keys/LICENSE +0 -201
  60. package/cli/node_modules/eslint-visitor-keys/README.md +0 -98
  61. package/cli/node_modules/eslint-visitor-keys/lib/index.js +0 -81
  62. package/cli/node_modules/eslint-visitor-keys/lib/visitor-keys.json +0 -284
  63. package/cli/node_modules/eslint-visitor-keys/package.json +0 -40
  64. package/cli/node_modules/espree/CHANGELOG.md +0 -509
  65. package/cli/node_modules/espree/LICENSE +0 -25
  66. package/cli/node_modules/espree/README.md +0 -233
  67. package/cli/node_modules/espree/espree.js +0 -177
  68. package/cli/node_modules/espree/lib/ast-node-types.js +0 -96
  69. package/cli/node_modules/espree/lib/espree.js +0 -286
  70. package/cli/node_modules/espree/lib/features.js +0 -29
  71. package/cli/node_modules/espree/lib/options.js +0 -106
  72. package/cli/node_modules/espree/lib/token-translator.js +0 -263
  73. package/cli/node_modules/espree/lib/visitor-keys.js +0 -123
  74. package/cli/node_modules/espree/package.json +0 -64
  75. package/cli/node_modules/esprima/ChangeLog +0 -235
  76. package/cli/node_modules/esprima/LICENSE.BSD +0 -21
  77. package/cli/node_modules/esprima/README.md +0 -46
  78. package/cli/node_modules/esprima/bin/esparse.js +0 -139
  79. package/cli/node_modules/esprima/bin/esvalidate.js +0 -236
  80. package/cli/node_modules/esprima/dist/esprima.js +0 -6709
  81. package/cli/node_modules/esprima/package.json +0 -112
  82. package/cli/node_modules/estraverse/.jshintrc +0 -16
  83. package/cli/node_modules/estraverse/LICENSE.BSD +0 -19
  84. package/cli/node_modules/estraverse/README.md +0 -153
  85. package/cli/node_modules/estraverse/estraverse.js +0 -801
  86. package/cli/node_modules/estraverse/gulpfile.js +0 -70
  87. package/cli/node_modules/estraverse/package.json +0 -40
  88. package/cli/node_modules/esutils/LICENSE.BSD +0 -19
  89. package/cli/node_modules/esutils/README.md +0 -174
  90. package/cli/node_modules/esutils/lib/ast.js +0 -144
  91. package/cli/node_modules/esutils/lib/code.js +0 -135
  92. package/cli/node_modules/esutils/lib/keyword.js +0 -165
  93. package/cli/node_modules/esutils/lib/utils.js +0 -33
  94. package/cli/node_modules/esutils/package.json +0 -44
  95. package/cli/node_modules/fast-levenshtein/LICENSE.md +0 -25
  96. package/cli/node_modules/fast-levenshtein/README.md +0 -104
  97. package/cli/node_modules/fast-levenshtein/levenshtein.js +0 -136
  98. package/cli/node_modules/fast-levenshtein/package.json +0 -39
  99. package/cli/node_modules/fs.realpath/LICENSE +0 -43
  100. package/cli/node_modules/fs.realpath/README.md +0 -33
  101. package/cli/node_modules/fs.realpath/index.js +0 -66
  102. package/cli/node_modules/fs.realpath/old.js +0 -303
  103. package/cli/node_modules/fs.realpath/package.json +0 -26
  104. package/cli/node_modules/glob/LICENSE +0 -21
  105. package/cli/node_modules/glob/README.md +0 -375
  106. package/cli/node_modules/glob/changelog.md +0 -67
  107. package/cli/node_modules/glob/common.js +0 -240
  108. package/cli/node_modules/glob/glob.js +0 -790
  109. package/cli/node_modules/glob/package.json +0 -46
  110. package/cli/node_modules/glob/sync.js +0 -486
  111. package/cli/node_modules/inflight/LICENSE +0 -15
  112. package/cli/node_modules/inflight/README.md +0 -37
  113. package/cli/node_modules/inflight/inflight.js +0 -54
  114. package/cli/node_modules/inflight/package.json +0 -29
  115. package/cli/node_modules/inherits/LICENSE +0 -16
  116. package/cli/node_modules/inherits/README.md +0 -42
  117. package/cli/node_modules/inherits/inherits.js +0 -9
  118. package/cli/node_modules/inherits/inherits_browser.js +0 -27
  119. package/cli/node_modules/inherits/package.json +0 -29
  120. package/cli/node_modules/levn/LICENSE +0 -22
  121. package/cli/node_modules/levn/README.md +0 -196
  122. package/cli/node_modules/levn/lib/cast.js +0 -298
  123. package/cli/node_modules/levn/lib/coerce.js +0 -285
  124. package/cli/node_modules/levn/lib/index.js +0 -22
  125. package/cli/node_modules/levn/lib/parse-string.js +0 -113
  126. package/cli/node_modules/levn/lib/parse.js +0 -102
  127. package/cli/node_modules/levn/package.json +0 -47
  128. package/cli/node_modules/minimatch/LICENSE +0 -15
  129. package/cli/node_modules/minimatch/README.md +0 -209
  130. package/cli/node_modules/minimatch/minimatch.js +0 -923
  131. package/cli/node_modules/minimatch/package.json +0 -30
  132. package/cli/node_modules/once/LICENSE +0 -15
  133. package/cli/node_modules/once/README.md +0 -79
  134. package/cli/node_modules/once/once.js +0 -42
  135. package/cli/node_modules/once/package.json +0 -33
  136. package/cli/node_modules/optionator/CHANGELOG.md +0 -56
  137. package/cli/node_modules/optionator/LICENSE +0 -22
  138. package/cli/node_modules/optionator/README.md +0 -238
  139. package/cli/node_modules/optionator/lib/help.js +0 -260
  140. package/cli/node_modules/optionator/lib/index.js +0 -465
  141. package/cli/node_modules/optionator/lib/util.js +0 -54
  142. package/cli/node_modules/optionator/package.json +0 -44
  143. package/cli/node_modules/path-is-absolute/index.js +0 -20
  144. package/cli/node_modules/path-is-absolute/license +0 -21
  145. package/cli/node_modules/path-is-absolute/package.json +0 -43
  146. package/cli/node_modules/path-is-absolute/readme.md +0 -59
  147. package/cli/node_modules/prelude-ls/CHANGELOG.md +0 -99
  148. package/cli/node_modules/prelude-ls/LICENSE +0 -22
  149. package/cli/node_modules/prelude-ls/README.md +0 -15
  150. package/cli/node_modules/prelude-ls/lib/Func.js +0 -65
  151. package/cli/node_modules/prelude-ls/lib/List.js +0 -686
  152. package/cli/node_modules/prelude-ls/lib/Num.js +0 -130
  153. package/cli/node_modules/prelude-ls/lib/Obj.js +0 -154
  154. package/cli/node_modules/prelude-ls/lib/Str.js +0 -92
  155. package/cli/node_modules/prelude-ls/lib/index.js +0 -178
  156. package/cli/node_modules/prelude-ls/package.json +0 -52
  157. package/cli/node_modules/rimraf/CHANGELOG.md +0 -65
  158. package/cli/node_modules/rimraf/LICENSE +0 -15
  159. package/cli/node_modules/rimraf/README.md +0 -101
  160. package/cli/node_modules/rimraf/bin.js +0 -68
  161. package/cli/node_modules/rimraf/package.json +0 -32
  162. package/cli/node_modules/rimraf/rimraf.js +0 -360
  163. package/cli/node_modules/source-map/CHANGELOG.md +0 -301
  164. package/cli/node_modules/source-map/LICENSE +0 -28
  165. package/cli/node_modules/source-map/README.md +0 -742
  166. package/cli/node_modules/source-map/dist/source-map.debug.js +0 -3234
  167. package/cli/node_modules/source-map/dist/source-map.js +0 -3233
  168. package/cli/node_modules/source-map/dist/source-map.min.js +0 -2
  169. package/cli/node_modules/source-map/dist/source-map.min.js.map +0 -1
  170. package/cli/node_modules/source-map/lib/array-set.js +0 -121
  171. package/cli/node_modules/source-map/lib/base64-vlq.js +0 -140
  172. package/cli/node_modules/source-map/lib/base64.js +0 -67
  173. package/cli/node_modules/source-map/lib/binary-search.js +0 -111
  174. package/cli/node_modules/source-map/lib/mapping-list.js +0 -79
  175. package/cli/node_modules/source-map/lib/quick-sort.js +0 -114
  176. package/cli/node_modules/source-map/lib/source-map-consumer.js +0 -1145
  177. package/cli/node_modules/source-map/lib/source-map-generator.js +0 -425
  178. package/cli/node_modules/source-map/lib/source-node.js +0 -413
  179. package/cli/node_modules/source-map/lib/util.js +0 -488
  180. package/cli/node_modules/source-map/package.json +0 -73
  181. package/cli/node_modules/source-map/source-map.d.ts +0 -98
  182. package/cli/node_modules/source-map/source-map.js +0 -8
  183. package/cli/node_modules/tmp/CHANGELOG.md +0 -288
  184. package/cli/node_modules/tmp/LICENSE +0 -21
  185. package/cli/node_modules/tmp/README.md +0 -365
  186. package/cli/node_modules/tmp/lib/tmp.js +0 -780
  187. package/cli/node_modules/tmp/package.json +0 -58
  188. package/cli/node_modules/type-check/LICENSE +0 -22
  189. package/cli/node_modules/type-check/README.md +0 -210
  190. package/cli/node_modules/type-check/lib/check.js +0 -126
  191. package/cli/node_modules/type-check/lib/index.js +0 -16
  192. package/cli/node_modules/type-check/lib/parse-type.js +0 -196
  193. package/cli/node_modules/type-check/package.json +0 -40
  194. package/cli/node_modules/word-wrap/LICENSE +0 -21
  195. package/cli/node_modules/word-wrap/README.md +0 -182
  196. package/cli/node_modules/word-wrap/index.d.ts +0 -50
  197. package/cli/node_modules/word-wrap/index.js +0 -46
  198. package/cli/node_modules/word-wrap/package.json +0 -77
  199. package/cli/node_modules/wrappy/LICENSE +0 -15
  200. package/cli/node_modules/wrappy/README.md +0 -36
  201. package/cli/node_modules/wrappy/package.json +0 -29
  202. package/cli/node_modules/wrappy/wrappy.js +0 -33
@@ -1,58 +0,0 @@
1
- {
2
- "name": "tmp",
3
- "version": "0.2.1",
4
- "description": "Temporary file and directory creator",
5
- "author": "KARASZI István <github@spam.raszi.hu> (http://raszi.hu/)",
6
- "contributors": [
7
- "Carsten Klein <trancesilken@gmail.com> (https://github.com/silkentrance)"
8
- ],
9
- "keywords": [
10
- "temporary",
11
- "tmp",
12
- "temp",
13
- "tempdir",
14
- "tempfile",
15
- "tmpdir",
16
- "tmpfile"
17
- ],
18
- "license": "MIT",
19
- "repository": "https://github.com/raszi/node-tmp.git",
20
- "homepage": "http://github.com/raszi/node-tmp",
21
- "bugs": {
22
- "url": "http://github.com/raszi/node-tmp/issues"
23
- },
24
- "engines": {
25
- "node": ">=8.17.0"
26
- },
27
- "dependencies": {
28
- "rimraf": "^3.0.0"
29
- },
30
- "devDependencies": {
31
- "eslint": "^6.3.0",
32
- "eslint-plugin-mocha": "^6.1.1",
33
- "istanbul": "^0.4.5",
34
- "lerna-changelog": "^1.0.1",
35
- "mocha": "^6.2.0"
36
- },
37
- "main": "lib/tmp.js",
38
- "files": [
39
- "lib/"
40
- ],
41
- "changelog": {
42
- "labels": {
43
- "breaking": ":boom: Breaking Change",
44
- "enhancement": ":rocket: Enhancement",
45
- "bug": ":bug: Bug Fix",
46
- "documentation": ":memo: Documentation",
47
- "internal": ":house: Internal"
48
- },
49
- "cacheDir": ".changelog"
50
- },
51
- "scripts": {
52
- "changelog": "lerna-changelog",
53
- "lint": "eslint lib --env mocha test",
54
- "clean": "rm -Rf ./coverage",
55
- "test": "npm run clean && istanbul cover ./node_modules/mocha/bin/_mocha --report none --print none --dir ./coverage/json -u exports -R test/*-test.js && istanbul report --root ./coverage/json html && istanbul report text-summary",
56
- "doc": "jsdoc -c .jsdoc.json"
57
- }
58
- }
@@ -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,210 +0,0 @@
1
- # type-check [![Build Status](https://travis-ci.org/gkz/type-check.png?branch=master)](https://travis-ci.org/gkz/type-check)
2
-
3
- <a name="type-check" />
4
-
5
- `type-check` is a library which allows you to check the types of JavaScript values at runtime with a Haskell like type syntax. It is great for checking external input, for testing, or even for adding a bit of safety to your internal code. It is a major component of [levn](https://github.com/gkz/levn). MIT license. Version 0.3.2. Check out the [demo](http://gkz.github.io/type-check/).
6
-
7
- For updates on `type-check`, [follow me on twitter](https://twitter.com/gkzahariev).
8
-
9
- npm install type-check
10
-
11
- ## Quick Examples
12
-
13
- ```js
14
- // Basic types:
15
- var typeCheck = require('type-check').typeCheck;
16
- typeCheck('Number', 1); // true
17
- typeCheck('Number', 'str'); // false
18
- typeCheck('Error', new Error); // true
19
- typeCheck('Undefined', undefined); // true
20
-
21
- // Comment
22
- typeCheck('count::Number', 1); // true
23
-
24
- // One type OR another type:
25
- typeCheck('Number | String', 2); // true
26
- typeCheck('Number | String', 'str'); // true
27
-
28
- // Wildcard, matches all types:
29
- typeCheck('*', 2) // true
30
-
31
- // Array, all elements of a single type:
32
- typeCheck('[Number]', [1, 2, 3]); // true
33
- typeCheck('[Number]', [1, 'str', 3]); // false
34
-
35
- // Tuples, or fixed length arrays with elements of different types:
36
- typeCheck('(String, Number)', ['str', 2]); // true
37
- typeCheck('(String, Number)', ['str']); // false
38
- typeCheck('(String, Number)', ['str', 2, 5]); // false
39
-
40
- // Object properties:
41
- typeCheck('{x: Number, y: Boolean}', {x: 2, y: false}); // true
42
- typeCheck('{x: Number, y: Boolean}', {x: 2}); // false
43
- typeCheck('{x: Number, y: Maybe Boolean}', {x: 2}); // true
44
- typeCheck('{x: Number, y: Boolean}', {x: 2, y: false, z: 3}); // false
45
- typeCheck('{x: Number, y: Boolean, ...}', {x: 2, y: false, z: 3}); // true
46
-
47
- // A particular type AND object properties:
48
- typeCheck('RegExp{source: String, ...}', /re/i); // true
49
- typeCheck('RegExp{source: String, ...}', {source: 're'}); // false
50
-
51
- // Custom types:
52
- var opt = {customTypes:
53
- {Even: { typeOf: 'Number', validate: function(x) { return x % 2 === 0; }}}};
54
- typeCheck('Even', 2, opt); // true
55
-
56
- // Nested:
57
- var type = '{a: (String, [Number], {y: Array, ...}), b: Error{message: String, ...}}'
58
- typeCheck(type, {a: ['hi', [1, 2, 3], {y: [1, 'ms']}], b: new Error('oh no')}); // true
59
- ```
60
-
61
- Check out the [type syntax format](#syntax) and [guide](#guide).
62
-
63
- ## Usage
64
-
65
- `require('type-check');` returns an object that exposes four properties. `VERSION` is the current version of the library as a string. `typeCheck`, `parseType`, and `parsedTypeCheck` are functions.
66
-
67
- ```js
68
- // typeCheck(type, input, options);
69
- typeCheck('Number', 2); // true
70
-
71
- // parseType(type);
72
- var parsedType = parseType('Number'); // object
73
-
74
- // parsedTypeCheck(parsedType, input, options);
75
- parsedTypeCheck(parsedType, 2); // true
76
- ```
77
-
78
- ### typeCheck(type, input, options)
79
-
80
- `typeCheck` checks a JavaScript value `input` against `type` written in the [type format](#type-format) (and taking account the optional `options`) and returns whether the `input` matches the `type`.
81
-
82
- ##### arguments
83
- * type - `String` - the type written in the [type format](#type-format) which to check against
84
- * input - `*` - any JavaScript value, which is to be checked against the type
85
- * options - `Maybe Object` - an optional parameter specifying additional options, currently the only available option is specifying [custom types](#custom-types)
86
-
87
- ##### returns
88
- `Boolean` - whether the input matches the type
89
-
90
- ##### example
91
- ```js
92
- typeCheck('Number', 2); // true
93
- ```
94
-
95
- ### parseType(type)
96
-
97
- `parseType` parses string `type` written in the [type format](#type-format) into an object representing the parsed type.
98
-
99
- ##### arguments
100
- * type - `String` - the type written in the [type format](#type-format) which to parse
101
-
102
- ##### returns
103
- `Object` - an object in the parsed type format representing the parsed type
104
-
105
- ##### example
106
- ```js
107
- parseType('Number'); // [{type: 'Number'}]
108
- ```
109
- ### parsedTypeCheck(parsedType, input, options)
110
-
111
- `parsedTypeCheck` checks a JavaScript value `input` against parsed `type` in the parsed type format (and taking account the optional `options`) and returns whether the `input` matches the `type`. Use this in conjunction with `parseType` if you are going to use a type more than once.
112
-
113
- ##### arguments
114
- * type - `Object` - the type in the parsed type format which to check against
115
- * input - `*` - any JavaScript value, which is to be checked against the type
116
- * options - `Maybe Object` - an optional parameter specifying additional options, currently the only available option is specifying [custom types](#custom-types)
117
-
118
- ##### returns
119
- `Boolean` - whether the input matches the type
120
-
121
- ##### example
122
- ```js
123
- parsedTypeCheck([{type: 'Number'}], 2); // true
124
- var parsedType = parseType('String');
125
- parsedTypeCheck(parsedType, 'str'); // true
126
- ```
127
-
128
- <a name="type-format" />
129
- ## Type Format
130
-
131
- ### Syntax
132
-
133
- White space is ignored. The root node is a __Types__.
134
-
135
- * __Identifier__ = `[\$\w]+` - a group of any lower or upper case letters, numbers, underscores, or dollar signs - eg. `String`
136
- * __Type__ = an `Identifier`, an `Identifier` followed by a `Structure`, just a `Structure`, or a wildcard `*` - eg. `String`, `Object{x: Number}`, `{x: Number}`, `Array{0: String, 1: Boolean, length: Number}`, `*`
137
- * __Types__ = optionally a comment (an `Indentifier` followed by a `::`), optionally the identifier `Maybe`, one or more `Type`, separated by `|` - eg. `Number`, `String | Date`, `Maybe Number`, `Maybe Boolean | String`
138
- * __Structure__ = `Fields`, or a `Tuple`, or an `Array` - eg. `{x: Number}`, `(String, Number)`, `[Date]`
139
- * __Fields__ = a `{`, followed one or more `Field` separated by a comma `,` (trailing comma `,` is permitted), optionally an `...` (always preceded by a comma `,`), followed by a `}` - eg. `{x: Number, y: String}`, `{k: Function, ...}`
140
- * __Field__ = an `Identifier`, followed by a colon `:`, followed by `Types` - eg. `x: Date | String`, `y: Boolean`
141
- * __Tuple__ = a `(`, followed by one or more `Types` separated by a comma `,` (trailing comma `,` is permitted), followed by a `)` - eg `(Date)`, `(Number, Date)`
142
- * __Array__ = a `[` followed by exactly one `Types` followed by a `]` - eg. `[Boolean]`, `[Boolean | Null]`
143
-
144
- ### Guide
145
-
146
- `type-check` uses `Object.toString` to find out the basic type of a value. Specifically,
147
-
148
- ```js
149
- {}.toString.call(VALUE).slice(8, -1)
150
- {}.toString.call(true).slice(8, -1) // 'Boolean'
151
- ```
152
- A basic type, eg. `Number`, uses this check. This is much more versatile than using `typeof` - for example, with `document`, `typeof` produces `'object'` which isn't that useful, and our technique produces `'HTMLDocument'`.
153
-
154
- You may check for multiple types by separating types with a `|`. The checker proceeds from left to right, and passes if the value is any of the types - eg. `String | Boolean` first checks if the value is a string, and then if it is a boolean. If it is none of those, then it returns false.
155
-
156
- Adding a `Maybe` in front of a list of multiple types is the same as also checking for `Null` and `Undefined` - eg. `Maybe String` is equivalent to `Undefined | Null | String`.
157
-
158
- You may add a comment to remind you of what the type is for by following an identifier with a `::` before a type (or multiple types). The comment is simply thrown out.
159
-
160
- The wildcard `*` matches all types.
161
-
162
- There are three types of structures for checking the contents of a value: 'fields', 'tuple', and 'array'.
163
-
164
- If used by itself, a 'fields' structure will pass with any type of object as long as it is an instance of `Object` and the properties pass - this allows for duck typing - eg. `{x: Boolean}`.
165
-
166
- To check if the properties pass, and the value is of a certain type, you can specify the type - eg. `Error{message: String}`.
167
-
168
- If you want to make a field optional, you can simply use `Maybe` - eg. `{x: Boolean, y: Maybe String}` will still pass if `y` is undefined (or null).
169
-
170
- If you don't care if the value has properties beyond what you have specified, you can use the 'etc' operator `...` - eg. `{x: Boolean, ...}` will match an object with an `x` property that is a boolean, and with zero or more other properties.
171
-
172
- For an array, you must specify one or more types (separated by `|`) - it will pass for something of any length as long as each element passes the types provided - eg. `[Number]`, `[Number | String]`.
173
-
174
- A tuple checks for a fixed number of elements, each of a potentially different type. Each element is separated by a comma - eg. `(String, Number)`.
175
-
176
- An array and tuple structure check that the value is of type `Array` by default, but if another type is specified, they will check for that instead - eg. `Int32Array[Number]`. You can use the wildcard `*` to search for any type at all.
177
-
178
- Check out the [type precedence](https://github.com/zaboco/type-precedence) library for type-check.
179
-
180
- ## Options
181
-
182
- Options is an object. It is an optional parameter to the `typeCheck` and `parsedTypeCheck` functions. The only current option is `customTypes`.
183
-
184
- <a name="custom-types" />
185
- ### Custom Types
186
-
187
- __Example:__
188
-
189
- ```js
190
- var options = {
191
- customTypes: {
192
- Even: {
193
- typeOf: 'Number',
194
- validate: function(x) {
195
- return x % 2 === 0;
196
- }
197
- }
198
- }
199
- };
200
- typeCheck('Even', 2, options); // true
201
- typeCheck('Even', 3, options); // false
202
- ```
203
-
204
- `customTypes` allows you to set up custom types for validation. The value of this is an object. The keys of the object are the types you will be matching. Each value of the object will be an object having a `typeOf` property - a string, and `validate` property - a function.
205
-
206
- The `typeOf` property is the type the value should be, and `validate` is a function which should return true if the value is of that type. `validate` receives one parameter, which is the value that we are checking.
207
-
208
- ## Technical About
209
-
210
- `type-check` is written in [LiveScript](http://livescript.net/) - a language that compiles to JavaScript. It also uses the [prelude.ls](http://preludels.com/) library.
@@ -1,126 +0,0 @@
1
- // Generated by LiveScript 1.4.0
2
- (function(){
3
- var ref$, any, all, isItNaN, types, defaultType, customTypes, toString$ = {}.toString;
4
- ref$ = require('prelude-ls'), any = ref$.any, all = ref$.all, isItNaN = ref$.isItNaN;
5
- types = {
6
- Number: {
7
- typeOf: 'Number',
8
- validate: function(it){
9
- return !isItNaN(it);
10
- }
11
- },
12
- NaN: {
13
- typeOf: 'Number',
14
- validate: isItNaN
15
- },
16
- Int: {
17
- typeOf: 'Number',
18
- validate: function(it){
19
- return !isItNaN(it) && it % 1 === 0;
20
- }
21
- },
22
- Float: {
23
- typeOf: 'Number',
24
- validate: function(it){
25
- return !isItNaN(it);
26
- }
27
- },
28
- Date: {
29
- typeOf: 'Date',
30
- validate: function(it){
31
- return !isItNaN(it.getTime());
32
- }
33
- }
34
- };
35
- defaultType = {
36
- array: 'Array',
37
- tuple: 'Array'
38
- };
39
- function checkArray(input, type){
40
- return all(function(it){
41
- return checkMultiple(it, type.of);
42
- }, input);
43
- }
44
- function checkTuple(input, type){
45
- var i, i$, ref$, len$, types;
46
- i = 0;
47
- for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) {
48
- types = ref$[i$];
49
- if (!checkMultiple(input[i], types)) {
50
- return false;
51
- }
52
- i++;
53
- }
54
- return input.length <= i;
55
- }
56
- function checkFields(input, type){
57
- var inputKeys, numInputKeys, k, numOfKeys, key, ref$, types;
58
- inputKeys = {};
59
- numInputKeys = 0;
60
- for (k in input) {
61
- inputKeys[k] = true;
62
- numInputKeys++;
63
- }
64
- numOfKeys = 0;
65
- for (key in ref$ = type.of) {
66
- types = ref$[key];
67
- if (!checkMultiple(input[key], types)) {
68
- return false;
69
- }
70
- if (inputKeys[key]) {
71
- numOfKeys++;
72
- }
73
- }
74
- return type.subset || numInputKeys === numOfKeys;
75
- }
76
- function checkStructure(input, type){
77
- if (!(input instanceof Object)) {
78
- return false;
79
- }
80
- switch (type.structure) {
81
- case 'fields':
82
- return checkFields(input, type);
83
- case 'array':
84
- return checkArray(input, type);
85
- case 'tuple':
86
- return checkTuple(input, type);
87
- }
88
- }
89
- function check(input, typeObj){
90
- var type, structure, setting, that;
91
- type = typeObj.type, structure = typeObj.structure;
92
- if (type) {
93
- if (type === '*') {
94
- return true;
95
- }
96
- setting = customTypes[type] || types[type];
97
- if (setting) {
98
- return setting.typeOf === toString$.call(input).slice(8, -1) && setting.validate(input);
99
- } else {
100
- return type === toString$.call(input).slice(8, -1) && (!structure || checkStructure(input, typeObj));
101
- }
102
- } else if (structure) {
103
- if (that = defaultType[structure]) {
104
- if (that !== toString$.call(input).slice(8, -1)) {
105
- return false;
106
- }
107
- }
108
- return checkStructure(input, typeObj);
109
- } else {
110
- throw new Error("No type defined. Input: " + input + ".");
111
- }
112
- }
113
- function checkMultiple(input, types){
114
- if (toString$.call(types).slice(8, -1) !== 'Array') {
115
- throw new Error("Types must be in an array. Input: " + input + ".");
116
- }
117
- return any(function(it){
118
- return check(input, it);
119
- }, types);
120
- }
121
- module.exports = function(parsedType, input, options){
122
- options == null && (options = {});
123
- customTypes = options.customTypes || {};
124
- return checkMultiple(input, parsedType);
125
- };
126
- }).call(this);
@@ -1,16 +0,0 @@
1
- // Generated by LiveScript 1.4.0
2
- (function(){
3
- var VERSION, parseType, parsedTypeCheck, typeCheck;
4
- VERSION = '0.3.2';
5
- parseType = require('./parse-type');
6
- parsedTypeCheck = require('./check');
7
- typeCheck = function(type, input, options){
8
- return parsedTypeCheck(parseType(type), input, options);
9
- };
10
- module.exports = {
11
- VERSION: VERSION,
12
- typeCheck: typeCheck,
13
- parsedTypeCheck: parsedTypeCheck,
14
- parseType: parseType
15
- };
16
- }).call(this);
@@ -1,196 +0,0 @@
1
- // Generated by LiveScript 1.4.0
2
- (function(){
3
- var identifierRegex, tokenRegex;
4
- identifierRegex = /[\$\w]+/;
5
- function peek(tokens){
6
- var token;
7
- token = tokens[0];
8
- if (token == null) {
9
- throw new Error('Unexpected end of input.');
10
- }
11
- return token;
12
- }
13
- function consumeIdent(tokens){
14
- var token;
15
- token = peek(tokens);
16
- if (!identifierRegex.test(token)) {
17
- throw new Error("Expected text, got '" + token + "' instead.");
18
- }
19
- return tokens.shift();
20
- }
21
- function consumeOp(tokens, op){
22
- var token;
23
- token = peek(tokens);
24
- if (token !== op) {
25
- throw new Error("Expected '" + op + "', got '" + token + "' instead.");
26
- }
27
- return tokens.shift();
28
- }
29
- function maybeConsumeOp(tokens, op){
30
- var token;
31
- token = tokens[0];
32
- if (token === op) {
33
- return tokens.shift();
34
- } else {
35
- return null;
36
- }
37
- }
38
- function consumeArray(tokens){
39
- var types;
40
- consumeOp(tokens, '[');
41
- if (peek(tokens) === ']') {
42
- throw new Error("Must specify type of Array - eg. [Type], got [] instead.");
43
- }
44
- types = consumeTypes(tokens);
45
- consumeOp(tokens, ']');
46
- return {
47
- structure: 'array',
48
- of: types
49
- };
50
- }
51
- function consumeTuple(tokens){
52
- var components;
53
- components = [];
54
- consumeOp(tokens, '(');
55
- if (peek(tokens) === ')') {
56
- throw new Error("Tuple must be of at least length 1 - eg. (Type), got () instead.");
57
- }
58
- for (;;) {
59
- components.push(consumeTypes(tokens));
60
- maybeConsumeOp(tokens, ',');
61
- if (')' === peek(tokens)) {
62
- break;
63
- }
64
- }
65
- consumeOp(tokens, ')');
66
- return {
67
- structure: 'tuple',
68
- of: components
69
- };
70
- }
71
- function consumeFields(tokens){
72
- var fields, subset, ref$, key, types;
73
- fields = {};
74
- consumeOp(tokens, '{');
75
- subset = false;
76
- for (;;) {
77
- if (maybeConsumeOp(tokens, '...')) {
78
- subset = true;
79
- break;
80
- }
81
- ref$ = consumeField(tokens), key = ref$[0], types = ref$[1];
82
- fields[key] = types;
83
- maybeConsumeOp(tokens, ',');
84
- if ('}' === peek(tokens)) {
85
- break;
86
- }
87
- }
88
- consumeOp(tokens, '}');
89
- return {
90
- structure: 'fields',
91
- of: fields,
92
- subset: subset
93
- };
94
- }
95
- function consumeField(tokens){
96
- var key, types;
97
- key = consumeIdent(tokens);
98
- consumeOp(tokens, ':');
99
- types = consumeTypes(tokens);
100
- return [key, types];
101
- }
102
- function maybeConsumeStructure(tokens){
103
- switch (tokens[0]) {
104
- case '[':
105
- return consumeArray(tokens);
106
- case '(':
107
- return consumeTuple(tokens);
108
- case '{':
109
- return consumeFields(tokens);
110
- }
111
- }
112
- function consumeType(tokens){
113
- var token, wildcard, type, structure;
114
- token = peek(tokens);
115
- wildcard = token === '*';
116
- if (wildcard || identifierRegex.test(token)) {
117
- type = wildcard
118
- ? consumeOp(tokens, '*')
119
- : consumeIdent(tokens);
120
- structure = maybeConsumeStructure(tokens);
121
- if (structure) {
122
- return structure.type = type, structure;
123
- } else {
124
- return {
125
- type: type
126
- };
127
- }
128
- } else {
129
- structure = maybeConsumeStructure(tokens);
130
- if (!structure) {
131
- throw new Error("Unexpected character: " + token);
132
- }
133
- return structure;
134
- }
135
- }
136
- function consumeTypes(tokens){
137
- var lookahead, types, typesSoFar, typeObj, type;
138
- if ('::' === peek(tokens)) {
139
- throw new Error("No comment before comment separator '::' found.");
140
- }
141
- lookahead = tokens[1];
142
- if (lookahead != null && lookahead === '::') {
143
- tokens.shift();
144
- tokens.shift();
145
- }
146
- types = [];
147
- typesSoFar = {};
148
- if ('Maybe' === peek(tokens)) {
149
- tokens.shift();
150
- types = [
151
- {
152
- type: 'Undefined'
153
- }, {
154
- type: 'Null'
155
- }
156
- ];
157
- typesSoFar = {
158
- Undefined: true,
159
- Null: true
160
- };
161
- }
162
- for (;;) {
163
- typeObj = consumeType(tokens), type = typeObj.type;
164
- if (!typesSoFar[type]) {
165
- types.push(typeObj);
166
- }
167
- typesSoFar[type] = true;
168
- if (!maybeConsumeOp(tokens, '|')) {
169
- break;
170
- }
171
- }
172
- return types;
173
- }
174
- tokenRegex = RegExp('\\.\\.\\.|::|->|' + identifierRegex.source + '|\\S', 'g');
175
- module.exports = function(input){
176
- var tokens, e;
177
- if (!input.length) {
178
- throw new Error('No type specified.');
179
- }
180
- tokens = input.match(tokenRegex) || [];
181
- if (in$('->', tokens)) {
182
- throw new Error("Function types are not supported.\ To validate that something is a function, you may use 'Function'.");
183
- }
184
- try {
185
- return consumeTypes(tokens);
186
- } catch (e$) {
187
- e = e$;
188
- throw new Error(e.message + " - Remaining tokens: " + JSON.stringify(tokens) + " - Initial input: '" + input + "'");
189
- }
190
- };
191
- function in$(x, xs){
192
- var i = -1, l = xs.length >>> 0;
193
- while (++i < l) if (x === xs[i]) return true;
194
- return false;
195
- }
196
- }).call(this);
@@ -1,40 +0,0 @@
1
- {
2
- "name": "type-check",
3
- "version": "0.3.2",
4
- "author": "George Zahariev <z@georgezahariev.com>",
5
- "description": "type-check allows you to check the types of JavaScript values at runtime with a Haskell like type syntax.",
6
- "homepage": "https://github.com/gkz/type-check",
7
- "keywords": [
8
- "type",
9
- "check",
10
- "checking",
11
- "library"
12
- ],
13
- "files": [
14
- "lib",
15
- "README.md",
16
- "LICENSE"
17
- ],
18
- "main": "./lib/",
19
- "bugs": "https://github.com/gkz/type-check/issues",
20
- "license": "MIT",
21
- "engines": {
22
- "node": ">= 0.8.0"
23
- },
24
- "repository": {
25
- "type": "git",
26
- "url": "git://github.com/gkz/type-check.git"
27
- },
28
- "scripts": {
29
- "test": "make test"
30
- },
31
- "dependencies": {
32
- "prelude-ls": "~1.1.2"
33
- },
34
- "devDependencies": {
35
- "livescript": "~1.4.0",
36
- "mocha": "~2.3.4",
37
- "istanbul": "~0.4.1",
38
- "browserify": "~12.0.1"
39
- }
40
- }
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2014-2017, Jon Schlinkert
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.