aurix-ai 2.7.3 → 2.7.5
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/bin/aurix.js +2 -2
- package/dist/agent/AgentLoop.d.ts.map +1 -1
- package/dist/agent/AgentLoop.js +1 -52
- package/dist/agent/AgentLoop.js.map +1 -1
- package/dist/cli/App.d.ts.map +1 -1
- package/dist/cli/App.js +6 -0
- package/dist/cli/App.js.map +1 -1
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +7 -0
- package/dist/cli/commands.js.map +1 -1
- package/dist/tools/Browser.d.ts.map +1 -1
- package/dist/tools/Browser.js +44 -615
- package/dist/tools/Browser.js.map +1 -1
- package/dist/tools/captcha/CaptchaRouter.d.ts +6 -0
- package/dist/tools/captcha/CaptchaRouter.d.ts.map +1 -0
- package/dist/tools/captcha/CaptchaRouter.js +371 -0
- package/dist/tools/captcha/CaptchaRouter.js.map +1 -0
- package/dist/tools/captcha/RecaptchaSolver.d.ts +2 -0
- package/dist/tools/captcha/RecaptchaSolver.d.ts.map +1 -0
- package/dist/tools/captcha/RecaptchaSolver.js +1114 -0
- package/dist/tools/captcha/RecaptchaSolver.js.map +1 -0
- package/dist/tools/captcha/common.d.ts +35 -0
- package/dist/tools/captcha/common.d.ts.map +1 -0
- package/dist/tools/captcha/common.js +445 -0
- package/dist/tools/captcha/common.js.map +1 -0
- package/dist/tools/captcha/index.d.ts +5 -0
- package/dist/tools/captcha/index.d.ts.map +1 -0
- package/dist/tools/captcha/index.js +4 -0
- package/dist/tools/captcha/index.js.map +1 -0
- package/package.json +2 -2
- package/scripts/build.cjs +0 -15
- package/scripts/run-task.mjs +86 -0
- package/training/captcha-training.json +930 -0
- package/native/token-counter/index.d.ts +0 -7
- package/native/token-counter/index.js +0 -316
- package/native/token-counter/node_modules/.package-lock.json +0 -568
- package/native/token-counter/node_modules/2/array.js +0 -25
- package/native/token-counter/node_modules/2/index.js +0 -12
- package/native/token-counter/node_modules/2/iterator.js +0 -13
- package/native/token-counter/node_modules/2/license.txt +0 -21
- package/native/token-counter/node_modules/2/map.js +0 -27
- package/native/token-counter/node_modules/2/number.js +0 -109
- package/native/token-counter/node_modules/2/object.js +0 -23
- package/native/token-counter/node_modules/2/package.json +0 -60
- package/native/token-counter/node_modules/2/readme.md +0 -246
- package/native/token-counter/node_modules/2/string.js +0 -11
- package/native/token-counter/node_modules/2/test.js +0 -520
- package/native/token-counter/node_modules/@lamansky/every/index.js +0 -16
- package/native/token-counter/node_modules/@lamansky/every/license.txt +0 -21
- package/native/token-counter/node_modules/@lamansky/every/package.json +0 -38
- package/native/token-counter/node_modules/@lamansky/every/readme.md +0 -46
- package/native/token-counter/node_modules/@lamansky/flatten/index.js +0 -5
- package/native/token-counter/node_modules/@lamansky/flatten/license.txt +0 -21
- package/native/token-counter/node_modules/@lamansky/flatten/package.json +0 -35
- package/native/token-counter/node_modules/@lamansky/flatten/readme.md +0 -41
- package/native/token-counter/node_modules/@napi-rs/cli/LICENSE +0 -21
- package/native/token-counter/node_modules/@napi-rs/cli/README.md +0 -96
- package/native/token-counter/node_modules/@napi-rs/cli/package.json +0 -65
- package/native/token-counter/node_modules/@napi-rs/cli/scripts/index.js +0 -51371
- package/native/token-counter/node_modules/add-counter/index.js +0 -3
- package/native/token-counter/node_modules/add-counter/license.txt +0 -21
- package/native/token-counter/node_modules/add-counter/package.json +0 -34
- package/native/token-counter/node_modules/add-counter/readme.md +0 -36
- package/native/token-counter/node_modules/array-pad/LICENSE +0 -22
- package/native/token-counter/node_modules/array-pad/README.md +0 -80
- package/native/token-counter/node_modules/array-pad/index.js +0 -30
- package/native/token-counter/node_modules/array-pad/package.json +0 -28
- package/native/token-counter/node_modules/arrify/index.js +0 -8
- package/native/token-counter/node_modules/arrify/license +0 -21
- package/native/token-counter/node_modules/arrify/package.json +0 -33
- package/native/token-counter/node_modules/arrify/readme.md +0 -36
- package/native/token-counter/node_modules/case-insensitive/index.js +0 -72
- package/native/token-counter/node_modules/case-insensitive/license.txt +0 -21
- package/native/token-counter/node_modules/case-insensitive/package.json +0 -39
- package/native/token-counter/node_modules/case-insensitive/readme.md +0 -39
- package/native/token-counter/node_modules/case-insensitive/test.js +0 -114
- package/native/token-counter/node_modules/class-chain/index.js +0 -32
- package/native/token-counter/node_modules/class-chain/license.txt +0 -21
- package/native/token-counter/node_modules/class-chain/package.json +0 -39
- package/native/token-counter/node_modules/class-chain/readme.md +0 -23
- package/native/token-counter/node_modules/class-chain/test.js +0 -77
- package/native/token-counter/node_modules/copy-own/index.js +0 -10
- package/native/token-counter/node_modules/copy-own/license.txt +0 -21
- package/native/token-counter/node_modules/copy-own/package.json +0 -37
- package/native/token-counter/node_modules/copy-own/readme.md +0 -67
- package/native/token-counter/node_modules/def-props/index.js +0 -43
- package/native/token-counter/node_modules/def-props/license.txt +0 -21
- package/native/token-counter/node_modules/def-props/node_modules/is-obj/index.d.ts +0 -22
- package/native/token-counter/node_modules/def-props/node_modules/is-obj/index.js +0 -6
- package/native/token-counter/node_modules/def-props/node_modules/is-obj/license +0 -9
- package/native/token-counter/node_modules/def-props/node_modules/is-obj/package.json +0 -34
- package/native/token-counter/node_modules/def-props/node_modules/is-obj/readme.md +0 -39
- package/native/token-counter/node_modules/def-props/package.json +0 -51
- package/native/token-counter/node_modules/def-props/readme.md +0 -117
- package/native/token-counter/node_modules/empty-iterator/index.js +0 -3
- package/native/token-counter/node_modules/empty-iterator/license.txt +0 -21
- package/native/token-counter/node_modules/empty-iterator/package.json +0 -33
- package/native/token-counter/node_modules/empty-iterator/readme.md +0 -23
- package/native/token-counter/node_modules/enforce-range/index.js +0 -15
- package/native/token-counter/node_modules/enforce-range/license.txt +0 -21
- package/native/token-counter/node_modules/enforce-range/node_modules/2/array.js +0 -43
- package/native/token-counter/node_modules/enforce-range/node_modules/2/index.js +0 -10
- package/native/token-counter/node_modules/enforce-range/node_modules/2/iterator.js +0 -26
- package/native/token-counter/node_modules/enforce-range/node_modules/2/license.txt +0 -21
- package/native/token-counter/node_modules/enforce-range/node_modules/2/map.js +0 -47
- package/native/token-counter/node_modules/enforce-range/node_modules/2/number.js +0 -33
- package/native/token-counter/node_modules/enforce-range/node_modules/2/object.js +0 -61
- package/native/token-counter/node_modules/enforce-range/node_modules/2/package.json +0 -41
- package/native/token-counter/node_modules/enforce-range/node_modules/2/readme.md +0 -210
- package/native/token-counter/node_modules/enforce-range/node_modules/2/string.js +0 -37
- package/native/token-counter/node_modules/enforce-range/node_modules/2/test.js +0 -413
- package/native/token-counter/node_modules/enforce-range/package.json +0 -36
- package/native/token-counter/node_modules/enforce-range/readme.md +0 -53
- package/native/token-counter/node_modules/english-list/.travis.yml +0 -6
- package/native/token-counter/node_modules/english-list/LICENSE +0 -22
- package/native/token-counter/node_modules/english-list/README.md +0 -44
- package/native/token-counter/node_modules/english-list/index.js +0 -34
- package/native/token-counter/node_modules/english-list/package.json +0 -31
- package/native/token-counter/node_modules/english-list/test.log +0 -6
- package/native/token-counter/node_modules/errate/index.js +0 -19
- package/native/token-counter/node_modules/errate/license.txt +0 -21
- package/native/token-counter/node_modules/errate/package.json +0 -39
- package/native/token-counter/node_modules/errate/readme.md +0 -79
- package/native/token-counter/node_modules/ffn/index.js +0 -9
- package/native/token-counter/node_modules/ffn/license.txt +0 -21
- package/native/token-counter/node_modules/ffn/package.json +0 -34
- package/native/token-counter/node_modules/ffn/readme.md +0 -51
- package/native/token-counter/node_modules/get-own-property/index.js +0 -5
- package/native/token-counter/node_modules/get-own-property/license.txt +0 -21
- package/native/token-counter/node_modules/get-own-property/package.json +0 -31
- package/native/token-counter/node_modules/get-own-property/readme.md +0 -22
- package/native/token-counter/node_modules/has-duplicates/index.js +0 -11
- package/native/token-counter/node_modules/has-duplicates/license.txt +0 -21
- package/native/token-counter/node_modules/has-duplicates/package.json +0 -32
- package/native/token-counter/node_modules/has-duplicates/readme.md +0 -23
- package/native/token-counter/node_modules/has-duplicates/test.js +0 -30
- package/native/token-counter/node_modules/if-else-throw/index.js +0 -8
- package/native/token-counter/node_modules/if-else-throw/license.txt +0 -21
- package/native/token-counter/node_modules/if-else-throw/package.json +0 -37
- package/native/token-counter/node_modules/if-else-throw/readme.md +0 -32
- package/native/token-counter/node_modules/is-array-of-length/index.js +0 -7
- package/native/token-counter/node_modules/is-array-of-length/license.txt +0 -21
- package/native/token-counter/node_modules/is-array-of-length/package.json +0 -42
- package/native/token-counter/node_modules/is-array-of-length/readme.md +0 -41
- package/native/token-counter/node_modules/is-class-of/index.js +0 -7
- package/native/token-counter/node_modules/is-class-of/license.txt +0 -21
- package/native/token-counter/node_modules/is-class-of/package.json +0 -35
- package/native/token-counter/node_modules/is-class-of/readme.md +0 -57
- package/native/token-counter/node_modules/is-global-object/index.js +0 -6
- package/native/token-counter/node_modules/is-global-object/license.txt +0 -21
- package/native/token-counter/node_modules/is-global-object/package.json +0 -34
- package/native/token-counter/node_modules/is-global-object/readme.md +0 -22
- package/native/token-counter/node_modules/is-instance-of/index.js +0 -28
- package/native/token-counter/node_modules/is-instance-of/license.txt +0 -21
- package/native/token-counter/node_modules/is-instance-of/package.json +0 -44
- package/native/token-counter/node_modules/is-instance-of/readme.md +0 -55
- package/native/token-counter/node_modules/is-iterable/index.js +0 -5
- package/native/token-counter/node_modules/is-iterable/license +0 -21
- package/native/token-counter/node_modules/is-iterable/package.json +0 -30
- package/native/token-counter/node_modules/is-iterable/readme.md +0 -23
- package/native/token-counter/node_modules/is-nil/LICENSE +0 -21
- package/native/token-counter/node_modules/is-nil/README.md +0 -47
- package/native/token-counter/node_modules/is-nil/index.js +0 -6
- package/native/token-counter/node_modules/is-nil/package.json +0 -46
- package/native/token-counter/node_modules/is-obj/index.js +0 -5
- package/native/token-counter/node_modules/is-obj/license +0 -21
- package/native/token-counter/node_modules/is-obj/package.json +0 -33
- package/native/token-counter/node_modules/is-obj/readme.md +0 -34
- package/native/token-counter/node_modules/is-object/.eslintignore +0 -1
- package/native/token-counter/node_modules/is-object/.eslintrc +0 -5
- package/native/token-counter/node_modules/is-object/.nycrc +0 -13
- package/native/token-counter/node_modules/is-object/.testem.json +0 -14
- package/native/token-counter/node_modules/is-object/CHANGELOG.md +0 -121
- package/native/token-counter/node_modules/is-object/LICENSE +0 -19
- package/native/token-counter/node_modules/is-object/README.md +0 -48
- package/native/token-counter/node_modules/is-object/index.js +0 -5
- package/native/token-counter/node_modules/is-object/package.json +0 -78
- package/native/token-counter/node_modules/is-object/test/index.js +0 -44
- package/native/token-counter/node_modules/is-plain-object/LICENSE +0 -21
- package/native/token-counter/node_modules/is-plain-object/README.md +0 -104
- package/native/token-counter/node_modules/is-plain-object/index.d.ts +0 -5
- package/native/token-counter/node_modules/is-plain-object/index.js +0 -37
- package/native/token-counter/node_modules/is-plain-object/package.json +0 -79
- package/native/token-counter/node_modules/isobject/LICENSE +0 -21
- package/native/token-counter/node_modules/isobject/README.md +0 -122
- package/native/token-counter/node_modules/isobject/index.d.ts +0 -5
- package/native/token-counter/node_modules/isobject/index.js +0 -12
- package/native/token-counter/node_modules/isobject/package.json +0 -74
- package/native/token-counter/node_modules/lodash.set/LICENSE +0 -47
- package/native/token-counter/node_modules/lodash.set/README.md +0 -18
- package/native/token-counter/node_modules/lodash.set/index.js +0 -990
- package/native/token-counter/node_modules/lodash.set/package.json +0 -17
- package/native/token-counter/node_modules/longest-first/index.js +0 -3
- package/native/token-counter/node_modules/longest-first/license.txt +0 -21
- package/native/token-counter/node_modules/longest-first/package.json +0 -36
- package/native/token-counter/node_modules/longest-first/readme.md +0 -29
- package/native/token-counter/node_modules/m-o/index.js +0 -27
- package/native/token-counter/node_modules/m-o/license.txt +0 -21
- package/native/token-counter/node_modules/m-o/node_modules/new-object/index.js +0 -23
- package/native/token-counter/node_modules/m-o/node_modules/new-object/license.txt +0 -21
- package/native/token-counter/node_modules/m-o/node_modules/new-object/package.json +0 -40
- package/native/token-counter/node_modules/m-o/node_modules/new-object/readme.md +0 -55
- package/native/token-counter/node_modules/m-o/package.json +0 -45
- package/native/token-counter/node_modules/m-o/readme.md +0 -87
- package/native/token-counter/node_modules/map-iter/index.js +0 -6
- package/native/token-counter/node_modules/map-iter/license.txt +0 -21
- package/native/token-counter/node_modules/map-iter/package.json +0 -40
- package/native/token-counter/node_modules/map-iter/readme.md +0 -46
- package/native/token-counter/node_modules/new-object/index.js +0 -5
- package/native/token-counter/node_modules/new-object/license.txt +0 -21
- package/native/token-counter/node_modules/new-object/package.json +0 -49
- package/native/token-counter/node_modules/new-object/readme.md +0 -145
- package/native/token-counter/node_modules/ofn/index.js +0 -22
- package/native/token-counter/node_modules/ofn/license.txt +0 -21
- package/native/token-counter/node_modules/ofn/package.json +0 -40
- package/native/token-counter/node_modules/ofn/readme.md +0 -63
- package/native/token-counter/node_modules/otherwise/index.js +0 -11
- package/native/token-counter/node_modules/otherwise/license.txt +0 -21
- package/native/token-counter/node_modules/otherwise/package.json +0 -38
- package/native/token-counter/node_modules/otherwise/readme.md +0 -29
- package/native/token-counter/node_modules/parser-factory/index.js +0 -138
- package/native/token-counter/node_modules/parser-factory/license.txt +0 -21
- package/native/token-counter/node_modules/parser-factory/node_modules/arrify/index.d.ts +0 -38
- package/native/token-counter/node_modules/parser-factory/node_modules/arrify/index.js +0 -23
- package/native/token-counter/node_modules/parser-factory/node_modules/arrify/license +0 -9
- package/native/token-counter/node_modules/parser-factory/node_modules/arrify/package.json +0 -35
- package/native/token-counter/node_modules/parser-factory/node_modules/arrify/readme.md +0 -39
- package/native/token-counter/node_modules/parser-factory/package.json +0 -38
- package/native/token-counter/node_modules/parser-factory/readme.md +0 -15
- package/native/token-counter/node_modules/pfn/index.js +0 -5
- package/native/token-counter/node_modules/pfn/license.txt +0 -21
- package/native/token-counter/node_modules/pfn/package.json +0 -41
- package/native/token-counter/node_modules/pfn/readme.md +0 -111
- package/native/token-counter/node_modules/pfn/strict.js +0 -8
- package/native/token-counter/node_modules/plainify/index.js +0 -5
- package/native/token-counter/node_modules/plainify/license.txt +0 -21
- package/native/token-counter/node_modules/plainify/package.json +0 -36
- package/native/token-counter/node_modules/plainify/readme.md +0 -47
- package/native/token-counter/node_modules/possible-function/changelog.md +0 -7
- package/native/token-counter/node_modules/possible-function/index.js +0 -43
- package/native/token-counter/node_modules/possible-function/license.txt +0 -21
- package/native/token-counter/node_modules/possible-function/package.json +0 -34
- package/native/token-counter/node_modules/possible-function/readme.md +0 -77
- package/native/token-counter/node_modules/possible-function/test.js +0 -32
- package/native/token-counter/node_modules/qfn/index.js +0 -11
- package/native/token-counter/node_modules/qfn/license.txt +0 -21
- package/native/token-counter/node_modules/qfn/package.json +0 -40
- package/native/token-counter/node_modules/qfn/readme.md +0 -45
- package/native/token-counter/node_modules/roadblock/index.js +0 -3
- package/native/token-counter/node_modules/roadblock/license.txt +0 -21
- package/native/token-counter/node_modules/roadblock/package.json +0 -40
- package/native/token-counter/node_modules/roadblock/readme.md +0 -59
- package/native/token-counter/node_modules/round-to/index.d.ts +0 -56
- package/native/token-counter/node_modules/round-to/index.js +0 -37
- package/native/token-counter/node_modules/round-to/license +0 -9
- package/native/token-counter/node_modules/round-to/package.json +0 -38
- package/native/token-counter/node_modules/round-to/readme.md +0 -71
- package/native/token-counter/node_modules/rtrim-array/index.js +0 -10
- package/native/token-counter/node_modules/rtrim-array/license.txt +0 -21
- package/native/token-counter/node_modules/rtrim-array/package.json +0 -41
- package/native/token-counter/node_modules/rtrim-array/readme.md +0 -75
- package/native/token-counter/node_modules/sbo/index.js +0 -25
- package/native/token-counter/node_modules/sbo/license.txt +0 -21
- package/native/token-counter/node_modules/sbo/package.json +0 -50
- package/native/token-counter/node_modules/sbo/readme.md +0 -105
- package/native/token-counter/node_modules/sorp/index.js +0 -3
- package/native/token-counter/node_modules/sorp/license.txt +0 -21
- package/native/token-counter/node_modules/sorp/package.json +0 -34
- package/native/token-counter/node_modules/sorp/readme.md +0 -25
- package/native/token-counter/node_modules/trim-call/index.js +0 -6
- package/native/token-counter/node_modules/trim-call/license.txt +0 -21
- package/native/token-counter/node_modules/trim-call/package.json +0 -40
- package/native/token-counter/node_modules/trim-call/readme.md +0 -80
- package/native/token-counter/node_modules/type-error/LICENSE +0 -21
- package/native/token-counter/node_modules/type-error/README.md +0 -24
- package/native/token-counter/node_modules/type-error/index.js +0 -35
- package/native/token-counter/node_modules/type-error/package.json +0 -11
- package/native/token-counter/node_modules/vfn/index.js +0 -21
- package/native/token-counter/node_modules/vfn/license.txt +0 -21
- package/native/token-counter/node_modules/vfn/package.json +0 -40
- package/native/token-counter/node_modules/vfn/readme.md +0 -81
- package/native/token-counter/node_modules/wfn/index.js +0 -43
- package/native/token-counter/node_modules/wfn/license.txt +0 -21
- package/native/token-counter/node_modules/wfn/package.json +0 -38
- package/native/token-counter/node_modules/wfn/readme.md +0 -81
- package/native/token-counter/package-lock.json +0 -578
- package/native/token-counter/package.json +0 -21
- package/native/token-counter/token-counter.linux-x64-gnu.node +0 -0
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
# new-object
|
|
2
|
-
|
|
3
|
-
Creates an Object from a collection of key-value pairs or key-descriptor pairs.
|
|
4
|
-
|
|
5
|
-
The [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) constructor lets you specify initial keys and values via an `iterable` collection (e.g. an array) of key-value pairs, whereas the `Object` constructor does not. This module fills that gap, approximating [the ECMA-defined behavior for the Map constructor](https://tc39.github.io/ecma262/#sec-map-iterable) but for Objects. (Remember that, unlike Maps, Objects can only use strings and symbols as keys.) In its simplest mode, you can think of the `new-object` module as doing the opposite of [`Object.entries()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries):
|
|
6
|
-
|
|
7
|
-
```JavaScript
|
|
8
|
-
newObject(Object.entries({a: 1, b: 2})) // {a: 1, b: 2}
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
But in addition — since we’re working with Objects instead of Maps — `new-object` lets you customize the property definitions on the new object.
|
|
12
|
-
|
|
13
|
-
```JavaScript
|
|
14
|
-
newObject(Object.entries({a: 1, b: 2}), {descDefaults: {writable: false}}) // {a: 1, b: 2}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Installation
|
|
18
|
-
|
|
19
|
-
Requires [Node.js](https://nodejs.org/) 8.3.0 or above.
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
npm i new-object
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## API
|
|
26
|
-
|
|
27
|
-
The module exports a single function.
|
|
28
|
-
|
|
29
|
-
### Parameters
|
|
30
|
-
|
|
31
|
-
1. `entries` (iterable or other object): This must be one of the following:
|
|
32
|
-
* An array (or other iterable) of key-value pairs for the object.
|
|
33
|
-
* An array (or other iterable) of key-descriptor pairs for the object’s properties (if `descs` is set to `true`).
|
|
34
|
-
* An object whose values are property descriptors for the new object.
|
|
35
|
-
2. Optional: Object argument:
|
|
36
|
-
* `descDefaults` (plain object): A collection of descriptor settings (namely, `configurable`, `enumerable`, and/or `writable`) that will be applied to every property created on the new object. If you would like all these settings to be undefined, provide an empty object. Omit this option if you have specified complete descriptors in `entries` or if you want the module to use simple assignment. If you provided property descriptors in `entries`, the contents of `descDefaults` will serve as default values for those descriptors. If you specify `writable` in `descDefaults`, it will be automatically skipped for descriptors that contain getters or setters, since such descriptors cannot contain `writable`.
|
|
37
|
-
* `descs` (boolean): Used to disambiguate the purpose of the values in `entries`. If set to `true`, the values in `entries` will be interpreted as property descriptor objects. If set to `false`, the values in `entries` will be used as values for the new object. Defaults to `false` if `entries` is an iterable; defaults to `true` if `entries` is a non-iterable object.
|
|
38
|
-
* `throwIfEquivKeys` (Error, string, or boolean): Set this to throw an error if `entries` contains keys that would be considered duplicates in the context of an object. For example, a Map can have keys that are objects, but those keys will all likely evaluate to `[object Object]` and overwrite each other if made keys in an object. Similarly, a Map can have distinct `1` (number) and `'1'` (string) keys, but these would be considered the same in an object context. If such a conflict exists and if this option is set to an Error object, the provided Error will be thrown as-is. An error message string will be used to construct a `TypeError`. A value of `true` will throw a `TypeError` with a default error message. A value of `false` is the same as the default behavior, which is that later equivalent keys will silently overwrite the earlier ones.
|
|
39
|
-
|
|
40
|
-
### Return Value
|
|
41
|
-
|
|
42
|
-
Returns a plain object built with `entries`.
|
|
43
|
-
|
|
44
|
-
## Examples
|
|
45
|
-
|
|
46
|
-
### Array of Key-Value Pairs
|
|
47
|
-
|
|
48
|
-
This is the simplest use of the module, which is essentially performs the operation opposite that of [`Object.entries()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries).
|
|
49
|
-
|
|
50
|
-
```javascript
|
|
51
|
-
const newObject = require('new-object')
|
|
52
|
-
|
|
53
|
-
const entries = [['a', 1], ['b', 2]]
|
|
54
|
-
|
|
55
|
-
// What was possible for a Map...
|
|
56
|
-
const map = new Map(entries)
|
|
57
|
-
map.get('a') // 1
|
|
58
|
-
|
|
59
|
-
// ...is now also possible for an Object:
|
|
60
|
-
const obj = newObject(entries)
|
|
61
|
-
obj.a // 1
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Array of Key-Value Pairs With Global Descriptor Settings
|
|
65
|
-
|
|
66
|
-
This example creates the same object as above, but with read-only properties. Read more about property descriptor settings at [`Object.defineProperty()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty).
|
|
67
|
-
|
|
68
|
-
```javascript
|
|
69
|
-
const newObject = require('new-object')
|
|
70
|
-
|
|
71
|
-
const obj = newObject(
|
|
72
|
-
[['a', 1], ['b', 2]],
|
|
73
|
-
{descDefaults: {writable: false}}
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
obj.a // 1
|
|
77
|
-
obj.b // 2
|
|
78
|
-
|
|
79
|
-
obj.a = 123 // TypeError: Cannot set property a of #<Object> which has only a getter
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Array of Key-Descriptor Pairs
|
|
83
|
-
|
|
84
|
-
In addition to providing an array of key-value pairs as in the two examples above, you can also provide an array of keys paired with object property descriptors, if `descs` is set to `true`. Read more about property descriptor settings at [`Object.defineProperty()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty).
|
|
85
|
-
|
|
86
|
-
```javascript
|
|
87
|
-
const newObject = require('new-object')
|
|
88
|
-
|
|
89
|
-
const obj = newObject([
|
|
90
|
-
['a', {get: () => 1}],
|
|
91
|
-
['b', {get: () => 2}],
|
|
92
|
-
], {descs: true})
|
|
93
|
-
|
|
94
|
-
obj.a // 1
|
|
95
|
-
obj.b // 2
|
|
96
|
-
|
|
97
|
-
obj.a = 123 // TypeError: Cannot set property a of #<Object> which has only a getter
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### Object of Key-Descriptor Pairs
|
|
101
|
-
|
|
102
|
-
You can also do the same as above but with an object. An object is presumed to contain descriptors (if it contains values, why do you need this module again?), so you don’t need to set `descs` to `true`.
|
|
103
|
-
|
|
104
|
-
```javascript
|
|
105
|
-
const newObject = require('new-object')
|
|
106
|
-
|
|
107
|
-
const obj = newObject({
|
|
108
|
-
a: {get: () => 1},
|
|
109
|
-
b: {get: () => 2},
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
obj.a // 1
|
|
113
|
-
obj.b // 2
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### Supplementing Descriptors with Default Settings
|
|
117
|
-
|
|
118
|
-
Whenever you’re using the module in a property descriptor mode, you can specify settings to be applied to all property descriptors using `descDefaults`.
|
|
119
|
-
|
|
120
|
-
```javascript
|
|
121
|
-
const newObject = require('new-object')
|
|
122
|
-
|
|
123
|
-
const obj = newObject([
|
|
124
|
-
['a', {get: () => 1}], // `writable` (below) will be ignored for this property
|
|
125
|
-
['b', {value: 2}],
|
|
126
|
-
], {
|
|
127
|
-
descs: true, // We have to specify this because the entries are in an array
|
|
128
|
-
descDefaults: {configurable: true, writable: true},
|
|
129
|
-
})
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
Since trying to set `writable` in a descriptor that also specifies a getter or setter will throw an error, the module will ignore the value of `writable` in `descDefaults` when creating the descriptor for a get/set property, such as the `a` property in the example above.
|
|
133
|
-
|
|
134
|
-
## Version Migration Guide
|
|
135
|
-
|
|
136
|
-
Here are backward-incompatible changes you need to know about.
|
|
137
|
-
|
|
138
|
-
### 3.x ⇒ 4.x
|
|
139
|
-
|
|
140
|
-
* The minimum supported Node version is now 8.3.0 (instead of 6.0.0).
|
|
141
|
-
|
|
142
|
-
## Related
|
|
143
|
-
|
|
144
|
-
* [construct-map](https://github.com/lamansky/construct-map): Turns key-value pairs into a collection of the same type as another value, such as Map or Object.
|
|
145
|
-
* [def-props](https://github.com/lamansky/def-props): Same as this module, but modifies a existing object instead of creating a new one.
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const hasDuplicates = require('has-duplicates')
|
|
4
|
-
const wfn = require('wfn')
|
|
5
|
-
|
|
6
|
-
module.exports = function (argPrecedence, fn) {
|
|
7
|
-
if (!Array.isArray(argPrecedence)) throw new TypeError('ofn argument 1 must be an array')
|
|
8
|
-
if (hasDuplicates(argPrecedence)) throw new Error('ofn argument 1 array cannot have duplicates')
|
|
9
|
-
if (argPrecedence.some(i => !Number.isInteger(i))) throw new TypeError('ofn argument 1 array must contain only numbers')
|
|
10
|
-
if (argPrecedence.some(i => i < 0 || i >= argPrecedence.length)) throw new RangeError('ofn argument 1 array has a number out of range')
|
|
11
|
-
|
|
12
|
-
if (typeof fn !== 'function') throw new TypeError('ofn argument 2 must be a function')
|
|
13
|
-
|
|
14
|
-
return wfn(fn, function ofn () {
|
|
15
|
-
const callArgs = []
|
|
16
|
-
const argIndexes = argPrecedence.slice(0, arguments.length).sort()
|
|
17
|
-
for (let i = 0; i < arguments.length; i++) {
|
|
18
|
-
callArgs[i < argIndexes.length ? argIndexes[i] : i] = arguments[i]
|
|
19
|
-
}
|
|
20
|
-
return fn.apply(this, callArgs)
|
|
21
|
-
})
|
|
22
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright ©2018 John Lamansky
|
|
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 all
|
|
13
|
-
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 THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ofn",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "Overloads a function. Makes parameters optional.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"overload",
|
|
7
|
-
"function",
|
|
8
|
-
"optional",
|
|
9
|
-
"parameters"
|
|
10
|
-
],
|
|
11
|
-
"author": "John Lamansky",
|
|
12
|
-
"license": "MIT",
|
|
13
|
-
"homepage": "https://github.com/lamansky/ofn",
|
|
14
|
-
"repository": "lamansky/ofn",
|
|
15
|
-
"main": "index.js",
|
|
16
|
-
"files": [],
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": ">=6.0.0"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"has-duplicates": "^1.0.0",
|
|
22
|
-
"wfn": "^1.0.0"
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"eslint-config-lamansky": "^1.0.0",
|
|
26
|
-
"mocha": "^5.0.0"
|
|
27
|
-
},
|
|
28
|
-
"scripts": {
|
|
29
|
-
"test": "mocha"
|
|
30
|
-
},
|
|
31
|
-
"eslintConfig": {
|
|
32
|
-
"extends": "lamansky",
|
|
33
|
-
"env": {
|
|
34
|
-
"mocha": true
|
|
35
|
-
},
|
|
36
|
-
"rules": {
|
|
37
|
-
"no-invalid-this": 0
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# ofn
|
|
2
|
-
|
|
3
|
-
Overload a Function. Make parameters optional.
|
|
4
|
-
|
|
5
|
-
True overloading is not a feature of the JavaScript language, but the `ofn` module does give you one key feature of overloading: the ability to omit arguments at the beginning or in the middle of a function call.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
Requires [Node.js](https://nodejs.org/) 6.0.0 or above.
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm i ofn
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## API
|
|
16
|
-
|
|
17
|
-
The module exports a single function.
|
|
18
|
-
|
|
19
|
-
### Parameters
|
|
20
|
-
|
|
21
|
-
1. `argPrecedence` (Array): An array of unique integers ranging from 0 (inclusive) to `fn.length` (exclusive)
|
|
22
|
-
2. `fn` (Function): The function to be overloaded
|
|
23
|
-
|
|
24
|
-
### Return Value
|
|
25
|
-
|
|
26
|
-
A wrapper function that overloads the `fn` function based on the number of arguments with which it is called.
|
|
27
|
-
|
|
28
|
-
## Tutorial
|
|
29
|
-
|
|
30
|
-
JavaScript already lets you make parameters optional if they’re at the end:
|
|
31
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
function example (a, b, c = 'default') {}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
But let’s say you want both `a` and `b` to be optional, with default values of `1` and `2` respectively, and you want `b` to be the one omitted if there are only two arguments. Normally you’d see this implemented like so:
|
|
37
|
-
|
|
38
|
-
```javascript
|
|
39
|
-
function example (a, b, c) {
|
|
40
|
-
if (arguments.length === 1) [a, b, c] = [1, 2, a]
|
|
41
|
-
if (arguments.length === 2) [a, b, c] = [a, 2, b]
|
|
42
|
-
// ...
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Thankfully we have array destructuring in ES6 — things were a lot messier before that! But the `ofn` module makes things even easier and cleaner. With the `ofn` module, the above example would look like this:
|
|
47
|
-
|
|
48
|
-
```javascript
|
|
49
|
-
const ofn = require('ofn')
|
|
50
|
-
const example = ofn([2, 0, 1], (a = 1, b = 2, c) => {
|
|
51
|
-
// ...
|
|
52
|
-
})
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
See the array passed as the first argument to `ofn`? That tells `ofn` the _precedence_ of the parameters. The number 2 comes first. That means if `example()` is called with only 1 argument, it’ll be given to the parameter with a (zero-based) index of 2, which is `c`. Calling `example('three')` will result in argument values of `1`, `2`, and `three`. The `a` and `b` arguments have nothing passed to them, so they keep their default values of `1` and `2`.
|
|
56
|
-
|
|
57
|
-
The number 0 is the second in the list. That means if there are two arguments, the arguments will be passed as the 0th and 2nd parameters, `a` and `c`, in that order. So calling `example('one', 'three')` means the function will receive argument values of `one`, `2`, and `three` respectively.
|
|
58
|
-
|
|
59
|
-
And finally, we have number 1 third. If there are three arguments, then the parameter with an index of 1 (which is `b`) will get included. `example('one', 'two', three')` will result in `one` for `a`, `two` for `b`, and `three` for `c`.
|
|
60
|
-
|
|
61
|
-
## Related Modules
|
|
62
|
-
|
|
63
|
-
For more projects like this, check out the [xfn](https://github.com/lamansky/xfn) family of modules.
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const arrify = require('arrify')
|
|
4
|
-
const errate = require('errate')
|
|
5
|
-
const roadblock = require('roadblock')
|
|
6
|
-
|
|
7
|
-
module.exports = ({fallback, elseCall, elseReturn = fallback, elseThrow} = {}, {defaultErrorClass, args} = {}) =>
|
|
8
|
-
roadblock(elseCall, next => elseCall(next, ...arrify(args)), () => {
|
|
9
|
-
if (elseThrow) throw errate(elseThrow, defaultErrorClass, {forceClass: false})
|
|
10
|
-
return elseReturn
|
|
11
|
-
})
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright ©2018–2020 Fr. John Lamansky
|
|
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 all
|
|
13
|
-
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 THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "otherwise",
|
|
3
|
-
"version": "2.0.1",
|
|
4
|
-
"description": "Executes fallback behavior if a function was unsuccessful.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"else",
|
|
7
|
-
"fallback"
|
|
8
|
-
],
|
|
9
|
-
"author": {
|
|
10
|
-
"name": "Fr. John Lamansky",
|
|
11
|
-
"url": "lamansky.com"
|
|
12
|
-
},
|
|
13
|
-
"license": "MIT",
|
|
14
|
-
"repository": "lamansky/otherwise",
|
|
15
|
-
"main": "index.js",
|
|
16
|
-
"files": [],
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": ">=6.0.0"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"arrify": "^1.0.1",
|
|
22
|
-
"errate": "^1.1.0",
|
|
23
|
-
"roadblock": "^1.1.0"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
26
|
-
"eslint-config-lamansky": "^2.0.0",
|
|
27
|
-
"mocha": "^7.2.0"
|
|
28
|
-
},
|
|
29
|
-
"scripts": {
|
|
30
|
-
"test": "mocha"
|
|
31
|
-
},
|
|
32
|
-
"eslintConfig": {
|
|
33
|
-
"extends": "lamansky",
|
|
34
|
-
"env": {
|
|
35
|
-
"mocha": true
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# otherwise
|
|
2
|
-
|
|
3
|
-
Executes fallback behavior if a function was unsuccessful. Intended for use in modules that use option object arguments.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
Requires [Node.js](https://nodejs.org/) 6.0.0 or above.
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm i otherwise
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## API
|
|
14
|
-
|
|
15
|
-
The module exports a single function.
|
|
16
|
-
|
|
17
|
-
### Parameters
|
|
18
|
-
|
|
19
|
-
1. Optional: Object argument:
|
|
20
|
-
* `elseCall` (function): If provided, this function will be called with at least one argument: a function that will invoke the other fallbacks. (If `args` are specified, they will be provided as subsequent arguments.) If the function argument is not called, then `elseThrow` and `elseReturn` will not be taken into consideration, and the return value of the `elseCall` function will be forwarded.
|
|
21
|
-
* `elseThrow` (Error or string): An error to be thrown. A string will be wrapped in an `Error` object automatically.
|
|
22
|
-
* `elseReturn` (any): A value to return if `elseThrow` is omitted.
|
|
23
|
-
2. Optional: Object argument:
|
|
24
|
-
* `defaultErrorClass` (Class): An Error class in which to wrap `elseThrow` if it is a string.
|
|
25
|
-
* `args` (array): An array of arguments that should be passed on to `elseCall` if provided.
|
|
26
|
-
|
|
27
|
-
### Return Value
|
|
28
|
-
|
|
29
|
-
Returns the return value of `elseCall` (if provided) or returns `elseReturn`.
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const arrify = require('arrify')
|
|
4
|
-
const caseInsensitive = require('case-insensitive')
|
|
5
|
-
const enforceRange = require('enforce-range')
|
|
6
|
-
const isInstanceOf = require('is-instance-of')
|
|
7
|
-
const longestFirst = require('longest-first')
|
|
8
|
-
const {get, has} = require('m-o')
|
|
9
|
-
const vfn = require('vfn')
|
|
10
|
-
|
|
11
|
-
module.exports = (defaultController, controllers) => (userStr, ...userArgs) => (function parseStr (initialController, str, permArgObj, initialTempArgObj = {}) {
|
|
12
|
-
const r = enforceRange(0, str.length)
|
|
13
|
-
let pos = 0
|
|
14
|
-
let out
|
|
15
|
-
|
|
16
|
-
function callController (controllerId, tempArgObj) {
|
|
17
|
-
if (!has(controllers, controllerId)) throw new RangeError('Controller not registered: ' + controllerId)
|
|
18
|
-
|
|
19
|
-
const bracket = (nextControllerId, start, end, throughEndArg, subArg) => {
|
|
20
|
-
return sub(nextControllerId, throughEnd(start, end, throughEndArg), subArg)
|
|
21
|
-
}
|
|
22
|
-
const call = (nextControllerId, newTempArgObj) => callController(nextControllerId, newTempArgObj)
|
|
23
|
-
const char = (len = 1, offset = 0) => str.substring(...[r(pos + offset), r(pos + offset + len)].sort())
|
|
24
|
-
const consume = vfn({arg: 0, oo: true}, (substrings, options = {}) => {
|
|
25
|
-
for (const substring of longestFirst(substrings)) {
|
|
26
|
-
if (is(substring, options)) return shift(substring.length)
|
|
27
|
-
}
|
|
28
|
-
return ''
|
|
29
|
-
})
|
|
30
|
-
const consumeRest = vfn({arg: 0, oo: true}, (substrings, options = {}) => {
|
|
31
|
-
for (const substring of longestFirst(substrings)) {
|
|
32
|
-
if (isOnly(substring, options)) return shift(substring.length)
|
|
33
|
-
}
|
|
34
|
-
return ''
|
|
35
|
-
})
|
|
36
|
-
const consumeWhile = test => {
|
|
37
|
-
let substr = ''
|
|
38
|
-
if (typeof test === 'string') {
|
|
39
|
-
while (char() && test.includes(char())) substr += shift()
|
|
40
|
-
} else if (typeof test === 'function') {
|
|
41
|
-
while (char() && test(char())) substr += shift()
|
|
42
|
-
} else if (isInstanceOf(test, 'RegExp')) {
|
|
43
|
-
while (char() && test.test(char())) substr += shift()
|
|
44
|
-
} else {
|
|
45
|
-
throw new TypeError('consumeWhile() test must be RegExp, string, or function')
|
|
46
|
-
}
|
|
47
|
-
return substr
|
|
48
|
-
}
|
|
49
|
-
const is = vfn({arg: 0, oo: true}, (substrings, {ci} = {}) => substrings.some(ci ? ss => caseInsensitive(char(ss.length)).equals(ss) : ss => char(ss.length) === ss))
|
|
50
|
-
const isOnly = vfn({arg: 0, oo: true}, (substrings, {ci} = {}) => substrings.some(ci ? ss => caseInsensitive(char(Infinity)).equals(ss) : ss => char(Infinity) === ss))
|
|
51
|
-
const push = elem => {
|
|
52
|
-
if (typeof elem === 'string' && (typeof out === 'string' || typeof out === 'undefined')) {
|
|
53
|
-
if (typeof out === 'undefined') out = ''
|
|
54
|
-
out += elem
|
|
55
|
-
} else {
|
|
56
|
-
out = arrify(out)
|
|
57
|
-
out.push(...arrify(elem))
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const shift = (number = 1) => { const chars = char(number); pos = r(pos + number); return chars }
|
|
61
|
-
const sub = (subController, subStr, subTempArgObj) => parseStr(subController, subStr, permArgObj, subTempArgObj)
|
|
62
|
-
const through = vfn({arg: 0, oo: true}, (ends, options = {}) => {
|
|
63
|
-
return until(...ends, {...options, inclusive: true})
|
|
64
|
-
})
|
|
65
|
-
const throughEnd = (start, end, ...args) => {
|
|
66
|
-
const result = untilEnd(start, end, ...args)
|
|
67
|
-
consume(end)
|
|
68
|
-
return result
|
|
69
|
-
}
|
|
70
|
-
const until = vfn({arg: 0, oo: true}, (ends, {escape: esc, ignore, inclusive} = {}) => {
|
|
71
|
-
let substr = ''
|
|
72
|
-
while (char()) {
|
|
73
|
-
if (is(...ends)) {
|
|
74
|
-
if (inclusive) substr += consume(...ends)
|
|
75
|
-
break
|
|
76
|
-
}
|
|
77
|
-
let found = false
|
|
78
|
-
for (const end of ends) {
|
|
79
|
-
if (consume(esc + end)) {
|
|
80
|
-
substr += end
|
|
81
|
-
found = true
|
|
82
|
-
break
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (!found && !foundPair(ignore, x => { substr += x })) substr += shift()
|
|
86
|
-
}
|
|
87
|
-
return substr
|
|
88
|
-
})
|
|
89
|
-
const untilEnd = (start, end, {escape: esc, except, ignore} = {}) => {
|
|
90
|
-
except = arrify(except)
|
|
91
|
-
|
|
92
|
-
let substr = ''
|
|
93
|
-
let nestLevel = 0
|
|
94
|
-
|
|
95
|
-
if (ignore) ignore = ignore.filter(([startIgnore, endIgnore]) => startIgnore !== start && endIgnore !== end)
|
|
96
|
-
|
|
97
|
-
while (char()) {
|
|
98
|
-
const exception = except.length ? consume(...except) : false
|
|
99
|
-
if (exception) {
|
|
100
|
-
substr += exception
|
|
101
|
-
continue
|
|
102
|
-
} else if (is(start)) {
|
|
103
|
-
nestLevel++
|
|
104
|
-
} else if (is(end)) {
|
|
105
|
-
if (nestLevel-- === 0) return substr
|
|
106
|
-
} else if (esc) {
|
|
107
|
-
if (consume(esc + start)) {
|
|
108
|
-
substr += start
|
|
109
|
-
continue
|
|
110
|
-
}
|
|
111
|
-
if (consume(esc + end)) {
|
|
112
|
-
substr += end
|
|
113
|
-
continue
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (!foundPair(ignore, x => { substr += x })) substr += shift()
|
|
117
|
-
}
|
|
118
|
-
return substr
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function foundPair (pairs = [], append) {
|
|
122
|
-
for (const [start, end, options = {}] of pairs) {
|
|
123
|
-
if (is(start)) {
|
|
124
|
-
append(consume(start) + (start === end ? until(end, options) : untilEnd(start, end, options)) + consume(end))
|
|
125
|
-
return true
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return false
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return get(controllers, controllerId)({
|
|
132
|
-
bracket, call, char, consume, consumeRest, consumeWhile, is, isOnly, push, shift, sub, through, throughEnd, until, untilEnd,
|
|
133
|
-
}, permArgObj, tempArgObj)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const cbr = callController(initialController, initialTempArgObj)
|
|
137
|
-
return typeof cbr === 'undefined' ? out : cbr
|
|
138
|
-
})(defaultController, userStr, {userArgs})
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright ©2018–2019 Fr. John Lamansky
|
|
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 all
|
|
13
|
-
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 THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
Convert a value to an array.
|
|
3
|
-
|
|
4
|
-
_Supplying `null` or `undefined` results in an empty array._
|
|
5
|
-
|
|
6
|
-
@example
|
|
7
|
-
```
|
|
8
|
-
import arrify = require('arrify');
|
|
9
|
-
|
|
10
|
-
arrify('🦄');
|
|
11
|
-
//=> ['🦄']
|
|
12
|
-
|
|
13
|
-
arrify(['🦄']);
|
|
14
|
-
//=> ['🦄']
|
|
15
|
-
|
|
16
|
-
arrify(new Set(['🦄']));
|
|
17
|
-
//=> ['🦄']
|
|
18
|
-
|
|
19
|
-
arrify(null);
|
|
20
|
-
//=> []
|
|
21
|
-
|
|
22
|
-
arrify(undefined);
|
|
23
|
-
//=> []
|
|
24
|
-
```
|
|
25
|
-
*/
|
|
26
|
-
declare function arrify<ValueType>(
|
|
27
|
-
value: ValueType
|
|
28
|
-
): ValueType extends (null | undefined)
|
|
29
|
-
? []
|
|
30
|
-
: ValueType extends string
|
|
31
|
-
? [string]
|
|
32
|
-
: ValueType extends ReadonlyArray<unknown> // TODO: Use 'readonly unknown[]' in the next major version
|
|
33
|
-
? ValueType
|
|
34
|
-
: ValueType extends Iterable<infer T>
|
|
35
|
-
? T[]
|
|
36
|
-
: [ValueType];
|
|
37
|
-
|
|
38
|
-
export = arrify;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const arrify = value => {
|
|
4
|
-
if (value === null || value === undefined) {
|
|
5
|
-
return [];
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
if (Array.isArray(value)) {
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (typeof value === 'string') {
|
|
13
|
-
return [value];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (typeof value[Symbol.iterator] === 'function') {
|
|
17
|
-
return [...value];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return [value];
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
module.exports = arrify;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "arrify",
|
|
3
|
-
"version": "2.0.1",
|
|
4
|
-
"description": "Convert a value to an array",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": "sindresorhus/arrify",
|
|
7
|
-
"author": {
|
|
8
|
-
"name": "Sindre Sorhus",
|
|
9
|
-
"email": "sindresorhus@gmail.com",
|
|
10
|
-
"url": "sindresorhus.com"
|
|
11
|
-
},
|
|
12
|
-
"engines": {
|
|
13
|
-
"node": ">=8"
|
|
14
|
-
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"test": "xo && ava && tsd"
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"index.js",
|
|
20
|
-
"index.d.ts"
|
|
21
|
-
],
|
|
22
|
-
"keywords": [
|
|
23
|
-
"array",
|
|
24
|
-
"arrify",
|
|
25
|
-
"arrayify",
|
|
26
|
-
"convert",
|
|
27
|
-
"value",
|
|
28
|
-
"ensure"
|
|
29
|
-
],
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"ava": "^1.4.1",
|
|
32
|
-
"tsd": "^0.7.2",
|
|
33
|
-
"xo": "^0.24.0"
|
|
34
|
-
}
|
|
35
|
-
}
|