Add production dependencies
This commit is contained in:
parent
5a0114f3e2
commit
579ccdc29f
12113 changed files with 978046 additions and 3 deletions
16
node_modules/ext/.editorconfig
generated
vendored
Normal file
16
node_modules/ext/.editorconfig
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = tab
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
trim_trailing_whitespace = false
|
1
node_modules/ext/.github/FUNDING.yml
generated
vendored
Normal file
1
node_modules/ext/.github/FUNDING.yml
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
github: medikoo
|
82
node_modules/ext/CHANGELOG.md
generated
vendored
Normal file
82
node_modules/ext/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [1.6.0](https://github.com/medikoo/es5-ext/compare/v1.5.0...v1.6.0) (2021-09-24)
|
||||
|
||||
### Features
|
||||
|
||||
- `Object.clear` util ([a955da4](https://github.com/medikoo/es5-ext/commit/a955da41e65a25ad87a46234bae065f096abd1d2))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fix `Object.entries` to not return non enumerable properties ([44fb872](https://github.com/medikoo/es5-ext/commit/44fb87266617378d2f47a1a5baad6280bf6298a8))
|
||||
|
||||
## [1.5.0](https://github.com/medikoo/es5-ext/compare/v1.3.0...v1.5.0) (2021-08-23)
|
||||
|
||||
### Features
|
||||
|
||||
- `Promise.limit` ([060a05d](https://github.com/medikoo/es5-ext/commit/060a05d4751cd291c6dd7641f5a73ba9338ea7ab))
|
||||
- `String.prototype.includes` ([ceebe8d](https://github.com/medikoo/es5-ext/commit/ceebe8dfd6f479d6a7e7b6cd79369291869ee2dd))
|
||||
- `charset` option for `String.random` ([2a20eeb](https://github.com/medikoo/es5-ext/commit/2a20eebc5ae784e5c1aacd2c54433fe92a9464c9))
|
||||
|
||||
## [1.4.0](https://github.com///compare/v1.3.0...v1.4.0) (2019-11-29)
|
||||
|
||||
### Features
|
||||
|
||||
- `charset` option for `String.random` ([2a20eeb](https://github.com///commit/2a20eebc5ae784e5c1aacd2c54433fe92a9464c9))
|
||||
- `String.prototype.includes` implementation ([ceebe8d](https://github.com///commit/ceebe8dfd6f479d6a7e7b6cd79369291869ee2dd))
|
||||
|
||||
## [1.3.0](https://github.com///compare/v1.2.1...v1.3.0) (2019-11-28)
|
||||
|
||||
### Features
|
||||
|
||||
- `String.random` util ([5b5860a](https://github.com///commit/5b5860ac545b05f00527e00295fdb4f97e4a4e5b))
|
||||
|
||||
### [1.2.1](https://github.com///compare/v1.2.0...v1.2.1) (2019-11-26)
|
||||
|
||||
## [1.2.0](https://github.com/medikoo/ext/compare/v1.1.2...v1.2.0) (2019-11-07)
|
||||
|
||||
### Features
|
||||
|
||||
- ceil10, floor10 and round10 for Math ([6a2bc4b](https://github.com/medikoo/ext/commit/6a2bc4b))
|
||||
|
||||
### [1.1.2](https://github.com/medikoo/ext/compare/v1.1.1...v1.1.2) (2019-10-29)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Improve globalThis detection ([470862d](https://github.com/medikoo/ext/commit/470862d))
|
||||
|
||||
### [1.1.1](https://github.com/medikoo/ext/compare/v1.1.0...v1.1.1) (2019-10-29)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Provide naive fallback for sealed Object.prototype case ([a8d528b](https://github.com/medikoo/ext/commit/a8d528b))
|
||||
- Workaournd Safari incompatibility case ([0b051e6](https://github.com/medikoo/ext/commit/0b051e6))
|
||||
|
||||
## [1.1.0](https://github.com/medikoo/ext/compare/v1.0.3...v1.1.0) (2019-10-21)
|
||||
|
||||
### Features
|
||||
|
||||
- Object.entries implementation ([cf51e45](https://github.com/medikoo/ext/commit/cf51e45))
|
||||
|
||||
### [1.0.3](https://github.com/medikoo/ext/compare/v1.0.1...v1.0.3) (2019-07-03)
|
||||
|
||||
Remove obsolete files from publication
|
||||
|
||||
### [1.0.2](https://github.com/medikoo/ext/compare/v1.0.1...v1.0.2) (2019-07-03)
|
||||
|
||||
(no changes)
|
||||
|
||||
### [1.0.1](https://github.com/medikoo/ext/compare/v1.0.0...v1.0.1) (2019-07-03)
|
||||
|
||||
Prettify
|
||||
|
||||
## 1.0.0 (2019-07-03)
|
||||
|
||||
### Features
|
||||
|
||||
- `function/identity` (adapted from `es5-ext`) ([f0102af](https://github.com/medikoo/ext/commit/f0102af))
|
||||
- `thenable/finally` (adapted from `es5-ext`) ([a8494ac](https://github.com/medikoo/ext/commit/a8494ac))
|
||||
- `global-this/is-implemented` ([3a80904](https://github.com/medikoo/ext/commit/3a80904))
|
||||
- `globalThis` (mostly adapted from `es5-ext`) ([6559bd3](https://github.com/medikoo/ext/commit/6559bd3))
|
15
node_modules/ext/LICENSE
generated
vendored
Normal file
15
node_modules/ext/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
ISC License
|
||||
|
||||
Copyright (c) 2011-2019, Mariusz Nowak, @medikoo, medikoo.com
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
36
node_modules/ext/README.md
generated
vendored
Normal file
36
node_modules/ext/README.md
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
# ext
|
||||
|
||||
_(Previously known as `es5-ext`)_
|
||||
|
||||
## JavaScript language extensions (with respect to evolving standard)
|
||||
|
||||
Non-standard or soon to be standard language utilities in a future proof, non-invasive form.
|
||||
|
||||
Doesn't enforce transpilation step. Where it's applicable utilities/extensions are safe to use in all ES3+ implementations.
|
||||
|
||||
### Installation
|
||||
|
||||
```bash
|
||||
npm install ext
|
||||
```
|
||||
|
||||
### Utilities
|
||||
|
||||
- [`globalThis`](docs/global-this.md)
|
||||
- `Function`
|
||||
- [`identity`](docs/function/identity.md)
|
||||
- `Math`
|
||||
- [`ceil10`](docs/math/ceil-10.md)
|
||||
- [`floor10`](docs/math/floor-10.md)
|
||||
- [`round10`](docs/math/round-10.md)
|
||||
- `Object`
|
||||
- [`clear`](docs/object/clear.md)
|
||||
- [`entries`](docs/object/entries.md)
|
||||
- `Promise`
|
||||
- [`limit`](docs/promise/limit.md)
|
||||
- `String`
|
||||
- [`random`](docs/string/random.md)
|
||||
- `String.prototype`
|
||||
- [`includes`](docs/string_/includes.md)
|
||||
- `Thenable.prototype`
|
||||
- [`finally`](docs/thenable_/finally.md)
|
9
node_modules/ext/docs/function/identity.md
generated
vendored
Normal file
9
node_modules/ext/docs/function/identity.md
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
# `Function.identity` _(ext/function/identity)_
|
||||
|
||||
Returns input argument.
|
||||
|
||||
```javascript
|
||||
const identity = require("ext/function/identity");
|
||||
|
||||
identity("foo"); // "foo"
|
||||
```
|
9
node_modules/ext/docs/global-this.md
generated
vendored
Normal file
9
node_modules/ext/docs/global-this.md
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
# `globalThis` _(ext/global-this)_
|
||||
|
||||
Returns global object. Resolve native [globalThis](https://github.com/tc39/proposal-global) if implemented, otherwise fallback to internal resolution of a global object.
|
||||
|
||||
```javascript
|
||||
const globalThis = require("ext/global-this");
|
||||
|
||||
globalThis.Array === Array; // true
|
||||
```
|
10
node_modules/ext/docs/math/ceil-10.md
generated
vendored
Normal file
10
node_modules/ext/docs/math/ceil-10.md
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
# `Math.ceil10` _(ext/math/ceil-10)_
|
||||
|
||||
Decimal ceil
|
||||
|
||||
```javascript
|
||||
const ceil10 = require("ext/math/ceil-10");
|
||||
|
||||
ceil10(55.51, -1); // 55.6
|
||||
ceil10(-59, 1); // -50;
|
||||
```
|
10
node_modules/ext/docs/math/floor-10.md
generated
vendored
Normal file
10
node_modules/ext/docs/math/floor-10.md
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
# `Math.floor10` _(ext/math/floor-10)_
|
||||
|
||||
Decimal floor
|
||||
|
||||
```javascript
|
||||
const floor10 = require("ext/math/floor-10");
|
||||
|
||||
floor10(55.59, -1); // 55.5
|
||||
floor10(59, 1); // 50
|
||||
```
|
10
node_modules/ext/docs/math/round-10.md
generated
vendored
Normal file
10
node_modules/ext/docs/math/round-10.md
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
# `Math.round10` _(ext/math/round-10)_
|
||||
|
||||
Decimal round
|
||||
|
||||
```javascript
|
||||
const round10 = require("ext/math/round-10");
|
||||
|
||||
round10(55.549, -1); // 55.5
|
||||
round10(1.005, -2); // 1.01
|
||||
```
|
12
node_modules/ext/docs/object/clear.md
generated
vendored
Normal file
12
node_modules/ext/docs/object/clear.md
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
# `Object.clear` _(ext/object/clear)_
|
||||
|
||||
Deletes all own, enumerable, non-symbol properties in the object
|
||||
|
||||
```javascript
|
||||
const clear = require("ext/object/clear");
|
||||
|
||||
const obj = { foo: "bar" };
|
||||
|
||||
clear(obj);
|
||||
Object.keys(obj); // []
|
||||
```
|
11
node_modules/ext/docs/object/entries.md
generated
vendored
Normal file
11
node_modules/ext/docs/object/entries.md
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
# `Object.entries` _(ext/object/entries)_
|
||||
|
||||
[Object.entries](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries) implementation.
|
||||
|
||||
Returns native `Object.entries` if it's implemented, otherwise library implementation is returned
|
||||
|
||||
```javascript
|
||||
const entries = require("ext/object/entries");
|
||||
|
||||
entries({ foo: "bar" }); // [["foo", "bar"]]
|
||||
```
|
13
node_modules/ext/docs/promise/limit.md
generated
vendored
Normal file
13
node_modules/ext/docs/promise/limit.md
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
# `Promise.limit` _(ext/promise/limit)_
|
||||
|
||||
Helps to limit concurrency of asynchronous operations.
|
||||
|
||||
```javascript
|
||||
const limit = require("ext/promise/limit").bind(Promise);
|
||||
|
||||
const limittedAsyncFunction = limit(2, asyncFunction);
|
||||
|
||||
imittedAsyncFunction(); // Async operation started
|
||||
imittedAsyncFunction(); // Async operation started
|
||||
imittedAsyncFunction(); // On hold until one of previously started finalizes
|
||||
```
|
31
node_modules/ext/docs/string/random.md
generated
vendored
Normal file
31
node_modules/ext/docs/string/random.md
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
# `String.random(options = { ... })` _(ext/string/random)_
|
||||
|
||||
Returns generated random string, contained only of ascii cars `a-z` and `0-1`.
|
||||
By default returns string of length `10`.
|
||||
|
||||
```javascript
|
||||
const random = require("ext/string/random");
|
||||
|
||||
random(); // "upcfns0i4t"
|
||||
random({ length: 3 }); // "5tw"
|
||||
```
|
||||
|
||||
## Supported options:
|
||||
|
||||
### `isUnique: false`
|
||||
|
||||
Ensures generated string is unique among ones already returned.
|
||||
|
||||
_Note: When not applying this setting, accidental generation of same string is still highly unlikely. Provided option is just to provide a mean to eliminate possibility of an edge case of duplicate string being returned_
|
||||
|
||||
### `length: 10`
|
||||
|
||||
Desired length of result string
|
||||
|
||||
### `charset: null`
|
||||
|
||||
Fixed list of possible characters
|
||||
|
||||
```javascript
|
||||
random({ charset: "abc" }); // "bacbccbbac"
|
||||
```
|
10
node_modules/ext/docs/string_/includes.md
generated
vendored
Normal file
10
node_modules/ext/docs/string_/includes.md
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
# `string.includes(position = 0)` _(ext/string\_/includes)_
|
||||
|
||||
`includes` method for strings. Resolve native [includes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) if implemented, otherwise fallback to shim implementation.
|
||||
|
||||
```javascript
|
||||
const includes = require("ext/string_/includes");
|
||||
|
||||
includes.call("razdwa", "raz"); // true
|
||||
includes.call("razdwa", "trzy"); // false
|
||||
```
|
9
node_modules/ext/docs/thenable_/finally.md
generated
vendored
Normal file
9
node_modules/ext/docs/thenable_/finally.md
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
# `thenable.finally` _(ext/thenable\_/finally)_
|
||||
|
||||
`finally` method for any _thenable_ input
|
||||
|
||||
```javascript
|
||||
const finally = require("ext/thenable_/finally");
|
||||
|
||||
finally.call(thenable, () => console.log("Thenable resolved"));
|
||||
```
|
3
node_modules/ext/function/identity.js
generated
vendored
Normal file
3
node_modules/ext/function/identity.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = function (value) { return value; };
|
31
node_modules/ext/global-this/implementation.js
generated
vendored
Normal file
31
node_modules/ext/global-this/implementation.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
var naiveFallback = function () {
|
||||
if (typeof self === "object" && self) return self;
|
||||
if (typeof window === "object" && window) return window;
|
||||
throw new Error("Unable to resolve global `this`");
|
||||
};
|
||||
|
||||
module.exports = (function () {
|
||||
if (this) return this;
|
||||
|
||||
// Unexpected strict mode (may happen if e.g. bundled into ESM module)
|
||||
|
||||
// Thanks @mathiasbynens -> https://mathiasbynens.be/notes/globalthis
|
||||
// In all ES5+ engines global object inherits from Object.prototype
|
||||
// (if you approached one that doesn't please report)
|
||||
try {
|
||||
Object.defineProperty(Object.prototype, "__global__", {
|
||||
get: function () { return this; },
|
||||
configurable: true
|
||||
});
|
||||
} catch (error) {
|
||||
// Unfortunate case of Object.prototype being sealed (via preventExtensions, seal or freeze)
|
||||
return naiveFallback();
|
||||
}
|
||||
try {
|
||||
// Safari case (window.__global__ is resolved with global context, but __global__ does not)
|
||||
if (!__global__) return naiveFallback();
|
||||
return __global__;
|
||||
} finally {
|
||||
delete Object.prototype.__global__;
|
||||
}
|
||||
})();
|
3
node_modules/ext/global-this/index.js
generated
vendored
Normal file
3
node_modules/ext/global-this/index.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = require("./is-implemented")() ? globalThis : require("./implementation");
|
7
node_modules/ext/global-this/is-implemented.js
generated
vendored
Normal file
7
node_modules/ext/global-this/is-implemented.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = function () {
|
||||
if (typeof globalThis !== "object") return false;
|
||||
if (!globalThis) return false;
|
||||
return globalThis.Array === Array;
|
||||
};
|
29
node_modules/ext/lib/private/decimal-adjust.js
generated
vendored
Normal file
29
node_modules/ext/lib/private/decimal-adjust.js
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Credit:
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round
|
||||
// #Decimal_rounding
|
||||
|
||||
"use strict";
|
||||
|
||||
var isValue = require("type/object/is")
|
||||
, ensureInteger = require("type/integer/ensure");
|
||||
|
||||
var split = String.prototype.split;
|
||||
|
||||
module.exports = function (type) {
|
||||
return function (value/*, exp*/) {
|
||||
value = Number(value);
|
||||
var exp = arguments[1];
|
||||
if (isValue(exp)) exp = ensureInteger(exp);
|
||||
if (!value) return value;
|
||||
if (!exp) return Math[type](value);
|
||||
if (!isFinite(value)) return value;
|
||||
|
||||
// Shift
|
||||
var tokens = split.call(value, "e");
|
||||
value = Math[type](tokens[0] + "e" + ((tokens[1] || 0) - exp));
|
||||
|
||||
// Shift back
|
||||
tokens = value.toString().split("e");
|
||||
return Number(tokens[0] + "e" + (Number(tokens[1] || 0) + exp));
|
||||
};
|
||||
};
|
56
node_modules/ext/lib/private/define-function-length.js
generated
vendored
Normal file
56
node_modules/ext/lib/private/define-function-length.js
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
|||
"use strict";
|
||||
|
||||
var test = function (arg1, arg2) { return arg2; };
|
||||
|
||||
try {
|
||||
Object.defineProperty(test, "length", {
|
||||
configurable: true,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
value: 1
|
||||
});
|
||||
}
|
||||
catch (ignore) {}
|
||||
|
||||
if (test.length === 1) {
|
||||
// ES2015+
|
||||
var desc = { configurable: true, writable: false, enumerable: false };
|
||||
module.exports = function (length, fn) {
|
||||
if (fn.length === length) return fn;
|
||||
desc.value = length;
|
||||
return Object.defineProperty(fn, "length", desc);
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
module.exports = function (length, fn) {
|
||||
if (fn.length === length) return fn;
|
||||
switch (length) {
|
||||
case 0:
|
||||
return function () { return fn.apply(this, arguments); };
|
||||
case 1:
|
||||
return function (ignored1) { return fn.apply(this, arguments); };
|
||||
case 2:
|
||||
return function (ignored1, ignored2) { return fn.apply(this, arguments); };
|
||||
case 3:
|
||||
return function (ignored1, ignored2, ignored3) { return fn.apply(this, arguments); };
|
||||
case 4:
|
||||
return function (ignored1, ignored2, ignored3, ignored4) {
|
||||
return fn.apply(this, arguments);
|
||||
};
|
||||
case 5:
|
||||
return function (ignored1, ignored2, ignored3, ignored4, ignored5) {
|
||||
return fn.apply(this, arguments);
|
||||
};
|
||||
case 6:
|
||||
return function (ignored1, ignored2, ignored3, ignored4, ignored5, ignored6) {
|
||||
return fn.apply(this, arguments);
|
||||
};
|
||||
case 7:
|
||||
return function (ignored1, ignored2, ignored3, ignored4, ignored5, ignored6, ignored7) {
|
||||
return fn.apply(this, arguments);
|
||||
};
|
||||
default:
|
||||
throw new Error("Usupported function length");
|
||||
}
|
||||
};
|
3
node_modules/ext/math/ceil-10.js
generated
vendored
Normal file
3
node_modules/ext/math/ceil-10.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = require("../lib/private/decimal-adjust")("ceil");
|
3
node_modules/ext/math/floor-10.js
generated
vendored
Normal file
3
node_modules/ext/math/floor-10.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = require("../lib/private/decimal-adjust")("floor");
|
3
node_modules/ext/math/round-10.js
generated
vendored
Normal file
3
node_modules/ext/math/round-10.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = require("../lib/private/decimal-adjust")("round");
|
142
node_modules/ext/node_modules/type/CHANGELOG.md
generated
vendored
Normal file
142
node_modules/ext/node_modules/type/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,142 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [2.5.0](https://github.com/medikoo/type/compare/v2.4.0...v2.5.0) (2021-03-08)
|
||||
|
||||
### Features
|
||||
|
||||
- `errorCode` option for `ensure*` utils ([777a1f2](https://github.com/medikoo/type/commit/777a1f2c9fd76defcd24d3a30cce49491947fef7))
|
||||
|
||||
## [2.4.0](https://github.com/medikoo/type/compare/v2.3.0...v2.4.0) (2021-03-08)
|
||||
|
||||
### Features
|
||||
|
||||
- `set/is` and `set/ensure` utils ([083ec23](https://github.com/medikoo/type/commit/083ec2351718c310f316dcfd8c624a13201e227f))
|
||||
|
||||
## [2.3.0](https://github.com/medikoo/type/compare/v2.2.0...v2.3.0) (2021-02-16)
|
||||
|
||||
### Features
|
||||
|
||||
- `map/is` and `map/ensure` utils ([aafd1cb](https://github.com/medikoo/type/commit/aafd1cbd8c888fda98d39fd17e59f38b078d7bcf))
|
||||
|
||||
## [2.2.0](https://github.com/medikoo/type/compare/v2.1.0...v2.2.0) (2021-02-11)
|
||||
|
||||
### Features
|
||||
|
||||
- Support `ensureItem` option in `array/ensure` ([8f74973](https://github.com/medikoo/type/commit/8f749739df9bfebf44087093e09c8f7341a33a09))
|
||||
|
||||
## [2.1.0](https://github.com/medikoo/type/compare/v2.0.0...v2.1.0) (2020-08-21)
|
||||
|
||||
### Features
|
||||
|
||||
- `ensure` util for cumulated input validation ([814c5a8](https://github.com/medikoo/type/commit/814c5a801ecac23d06d8a5f4bcafc4763a04408c))
|
||||
- Provide an alternative error message with `options.name` ([c7751c0](https://github.com/medikoo/type/commit/c7751c084ee4f3d3ed10500db0edde2ff00e03a1))
|
||||
- Support `%n` (meaningful name) token in error message resolver ([b0f374e](https://github.com/medikoo/type/commit/b0f374e54345c714fe37a90887ecfe60577ce133))
|
||||
- Support `min` validation for natural numbers ([e703512](https://github.com/medikoo/type/commit/e70351248818d3e113110106ad174b42c5fd9b25))
|
||||
- Support custom Error constructors ([c6ecb90](https://github.com/medikoo/type/commit/c6ecb90e21c1c778210934204cbe393fb89ef2f6))
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Fix typo in error message ([2735533](https://github.com/medikoo/type/commit/2735533de28d33dfa13222743698169c92d08c09))
|
||||
|
||||
## [2.0.0](https://github.com/medikoo/type/compare/v1.2.0...v2.0.0) (2019-10-10)
|
||||
|
||||
### Features
|
||||
|
||||
- `allowedKeys` option for plain-object/ensure ([f81e72e](https://github.com/medikoo/type/commit/f81e72e))
|
||||
- `ensurePropertyValue` option for plain-object/ensure ([c5ff8fb](https://github.com/medikoo/type/commit/c5ff8fb))
|
||||
- Replace `coerceItem` with `ensureItem` option in iterable/ensure ([721494f](https://github.com/medikoo/type/commit/721494f))
|
||||
- Seclude lib/resolve-error-message ([12636d9](https://github.com/medikoo/type/commit/12636d9))
|
||||
- Validate options.ensureItem in iterable/ensure ([78da6c1](https://github.com/medikoo/type/commit/78da6c1))
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
- iterable/ensure no longer supports `coerceItem` option. Instead `ensureItem` was introduced
|
||||
|
||||
## [1.2.0](https://github.com/medikoo/type/compare/v1.1.0...v1.2.0) (2019-09-20)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Improve error message so it's not confusing ([97cd6b9](https://github.com/medikoo/type/commit/97cd6b9))
|
||||
|
||||
### Features
|
||||
|
||||
- 'coerceItem' option for iterable/ensure ([0818860](https://github.com/medikoo/type/commit/0818860))
|
||||
|
||||
## [1.1.0](https://github.com/medikoo/type/compare/v1.0.3...v1.1.0) (2019-09-20)
|
||||
|
||||
### Features
|
||||
|
||||
- `denyEmpty` option for iterables validation ([301d071](https://github.com/medikoo/type/commit/301d071))
|
||||
|
||||
### [1.0.3](https://github.com/medikoo/type/compare/v1.0.2...v1.0.3) (2019-08-06)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Recognize custom built ES5 era errors ([6462fac](https://github.com/medikoo/type/commit/6462fac))
|
||||
|
||||
### [1.0.2](https://github.com/medikoo/type/compare/v1.0.1...v1.0.2) (2019-08-06)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- Recognize host errors (e.g. DOMException) ([96ef399](https://github.com/medikoo/type/commit/96ef399))
|
||||
|
||||
## [1.0.1](https://github.com/medikoo/type/compare/v1.0.0...v1.0.1) (2019-04-08)
|
||||
|
||||
# 1.0.0 (2019-04-05)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- ensure 'is' functions can't crash ([59ceb78](https://github.com/medikoo/type/commit/59ceb78))
|
||||
|
||||
### Features
|
||||
|
||||
- array-length/coerce ([af8ddec](https://github.com/medikoo/type/commit/af8ddec))
|
||||
- array-length/ensure ([d313eb6](https://github.com/medikoo/type/commit/d313eb6))
|
||||
- array-like/ensure ([45f1ddd](https://github.com/medikoo/type/commit/45f1ddd))
|
||||
- array-like/is ([9a026a5](https://github.com/medikoo/type/commit/9a026a5))
|
||||
- array/ensure ([9db1515](https://github.com/medikoo/type/commit/9db1515))
|
||||
- array/is ([9672839](https://github.com/medikoo/type/commit/9672839))
|
||||
- date/ensure ([44e25a0](https://github.com/medikoo/type/commit/44e25a0))
|
||||
- date/is ([0316558](https://github.com/medikoo/type/commit/0316558))
|
||||
- ensure to not crash ([3998348](https://github.com/medikoo/type/commit/3998348))
|
||||
- ensure/number ([134b5cb](https://github.com/medikoo/type/commit/134b5cb))
|
||||
- error/ensure ([d5c8a30](https://github.com/medikoo/type/commit/d5c8a30))
|
||||
- error/is-error ([4d6b899](https://github.com/medikoo/type/commit/4d6b899))
|
||||
- finite/coerce ([accaad1](https://github.com/medikoo/type/commit/accaad1))
|
||||
- finite/ensure ([51e4174](https://github.com/medikoo/type/commit/51e4174))
|
||||
- function/ensure ([b624c9a](https://github.com/medikoo/type/commit/b624c9a))
|
||||
- function/is ([dab8026](https://github.com/medikoo/type/commit/dab8026))
|
||||
- integer/coerce ([89dea2e](https://github.com/medikoo/type/commit/89dea2e))
|
||||
- integer/ensure ([44a7071](https://github.com/medikoo/type/commit/44a7071))
|
||||
- iterable/ensure ([3d48841](https://github.com/medikoo/type/commit/3d48841))
|
||||
- iterable/is ([cf09513](https://github.com/medikoo/type/commit/cf09513))
|
||||
- lib/is-to-string-tag-supported ([c8c001d](https://github.com/medikoo/type/commit/c8c001d))
|
||||
- natural-number/coerce ([d08fdd9](https://github.com/medikoo/type/commit/d08fdd9))
|
||||
- natural-number/ensure ([6c24d12](https://github.com/medikoo/type/commit/6c24d12))
|
||||
- number/coerce ([86ccf08](https://github.com/medikoo/type/commit/86ccf08))
|
||||
- object/ensure ([a9e8eed](https://github.com/medikoo/type/commit/a9e8eed))
|
||||
- object/is ([d2d7251](https://github.com/medikoo/type/commit/d2d7251))
|
||||
- plain-function/ensure ([5186518](https://github.com/medikoo/type/commit/5186518))
|
||||
- plain-function/is ([51bc791](https://github.com/medikoo/type/commit/51bc791))
|
||||
- plain-object/ensure ([91cf5e5](https://github.com/medikoo/type/commit/91cf5e5))
|
||||
- plain-object/is ([4dcf393](https://github.com/medikoo/type/commit/4dcf393))
|
||||
- promise/ensure ([8d096a4](https://github.com/medikoo/type/commit/8d096a4))
|
||||
- promise/is ([a00de02](https://github.com/medikoo/type/commit/a00de02))
|
||||
- prototype/is ([b23bdcc](https://github.com/medikoo/type/commit/b23bdcc))
|
||||
- reg-exp/ensure ([6f7bbcb](https://github.com/medikoo/type/commit/6f7bbcb))
|
||||
- reg-exp/is ([9728519](https://github.com/medikoo/type/commit/9728519))
|
||||
- safe-integer/coerce ([b8549c4](https://github.com/medikoo/type/commit/b8549c4))
|
||||
- safe-integer/ensure ([a70ef3f](https://github.com/medikoo/type/commit/a70ef3f))
|
||||
- string/coerce ([b25c71f](https://github.com/medikoo/type/commit/b25c71f))
|
||||
- string/ensure ([b62577d](https://github.com/medikoo/type/commit/b62577d))
|
||||
- support 'default' in resolveException ([e08332a](https://github.com/medikoo/type/commit/e08332a))
|
||||
- switch config to ES3 based ([37606d9](https://github.com/medikoo/type/commit/37606d9))
|
||||
- thenable/ensure ([6762c0d](https://github.com/medikoo/type/commit/6762c0d))
|
||||
- thenable/is ([2711d70](https://github.com/medikoo/type/commit/2711d70))
|
||||
- time-value/coerce ([27fd109](https://github.com/medikoo/type/commit/27fd109))
|
||||
- time-value/ensure ([1f6a8ea](https://github.com/medikoo/type/commit/1f6a8ea))
|
||||
- **string/coerce:** restrict toString acceptance ([2a87100](https://github.com/medikoo/type/commit/2a87100))
|
||||
- value/ensure ([dd6d8cb](https://github.com/medikoo/type/commit/dd6d8cb))
|
||||
- value/is ([fdf4763](https://github.com/medikoo/type/commit/fdf4763))
|
15
node_modules/ext/node_modules/type/LICENSE
generated
vendored
Normal file
15
node_modules/ext/node_modules/type/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
ISC License
|
||||
|
||||
Copyright (c) 2019-2020, Mariusz Nowak, @medikoo, medikoo.com
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
165
node_modules/ext/node_modules/type/README.md
generated
vendored
Normal file
165
node_modules/ext/node_modules/type/README.md
generated
vendored
Normal file
|
@ -0,0 +1,165 @@
|
|||
[![*nix build status][nix-build-image]][nix-build-url]
|
||||
[![Windows build status][win-build-image]][win-build-url]
|
||||
[![Tests coverage][cov-image]][cov-url]
|
||||
[![npm version][npm-image]][npm-url]
|
||||
|
||||
# type
|
||||
|
||||
## Runtime validation and processing of JavaScript types
|
||||
|
||||
- Respects language nature and acknowledges its quirks
|
||||
- Allows coercion in restricted forms (rejects clearly invalid input, normalizes permissible type deviations)
|
||||
- No transpilation implied, written to work in all ECMAScript 3+ engines
|
||||
|
||||
## Use case
|
||||
|
||||
Validate arguments input in public API endpoints.
|
||||
|
||||
_For validation of more sophisticated input structures (as deeply nested configuration objects) it's recommended to consider more powerful schema based utlities (as [AJV](https://ajv.js.org/) or [@hapi/joi](https://hapi.dev/family/joi/))_
|
||||
|
||||
### Example usage
|
||||
|
||||
Bulletproof input arguments normalization and validation:
|
||||
|
||||
```javascript
|
||||
const ensureString = require('type/string/ensure')
|
||||
, ensureDate = require('type/date/ensure')
|
||||
, ensureNaturalNumber = require('type/natural-number/ensure')
|
||||
, isObject = require('type/object/is');
|
||||
|
||||
module.exports = (path, options = { min: 0 }) {
|
||||
path = ensureString(path, { errorMessage: "%v is not a path" });
|
||||
if (!isObject(options)) options = {};
|
||||
const min = ensureNaturalNumber(options.min, { default: 0 })
|
||||
, max = ensureNaturalNumber(options.max, { isOptional: true })
|
||||
, startTime = ensureDate(options.startTime, { isOptional: true });
|
||||
|
||||
// ...logic
|
||||
};
|
||||
```
|
||||
|
||||
### Installation
|
||||
|
||||
```bash
|
||||
npm install type
|
||||
```
|
||||
|
||||
## Utilities
|
||||
|
||||
Aside of general [`ensure`](docs/ensure.md) validation util, following kind of utilities for recognized JavaScript types are provided:
|
||||
|
||||
##### `*/coerce`
|
||||
|
||||
Restricted coercion into primitive type. Returns coerced value or `null` if value is not coercible per rules.
|
||||
|
||||
##### `*/is`
|
||||
|
||||
Object type/kind confirmation, returns either `true` or `false`.
|
||||
|
||||
##### `*/ensure`
|
||||
|
||||
Value validation. Returns input value (in primitive cases possibly coerced) or if value doesn't meet the constraints throws `TypeError` .
|
||||
|
||||
Each `*/ensure` utility, accepts following options (eventually passed with second argument):
|
||||
|
||||
- `isOptional` - Makes `null` or `undefined` accepted as valid value. In such case instead of `TypeError` being thrown, `null` is returned.
|
||||
- `default` - A value to be returned if `null` or `undefined` is passed as an input value.
|
||||
- `errorMessage` - Custom error message. Following placeholders can be used:
|
||||
- `%v` - To be replaced with short string representation of invalid value
|
||||
- `%n` - To be replaced with meaninfgul name (to be passed with `name` option) of validated value. Not effective if `name` option is not present
|
||||
- `errorCode` - Eventual error code to be exposed on `.code` error property
|
||||
- `name` - Meaningful name for validated value, to be used in error message, assuming it contains `%n` placeholder
|
||||
- `Error` - Alternative error constructor to be used (defaults to `TypeError`)
|
||||
|
||||
### Index
|
||||
|
||||
#### General utils:
|
||||
|
||||
- [`ensure`](docs/ensure.md)
|
||||
|
||||
#### Type specific utils:
|
||||
|
||||
- **Value**
|
||||
- [`value/is`](docs/value.md#valueis)
|
||||
- [`value/ensure`](docs/value.md#valueensure)
|
||||
- **Object**
|
||||
- [`object/is`](docs/object.md#objectis)
|
||||
- [`object/ensure`](docs/object.md#objectensure)
|
||||
- **Plain Object**
|
||||
- [`plain-object/is`](docs/plain-object.md#plain-objectis)
|
||||
- [`plain-object/ensure`](docs/plain-object.md#plain-objectensure)
|
||||
- **String**
|
||||
- [`string/coerce`](docs/string.md#stringcoerce)
|
||||
- [`string/ensure`](docs/string.md#stringensure)
|
||||
- **Number**
|
||||
- [`number/coerce`](docs/number.md#numbercoerce)
|
||||
- [`number/ensure`](docs/number.md#numberensure)
|
||||
- **Finite Number**
|
||||
- [`finite/coerce`](docs/finite.md#finitecoerce)
|
||||
- [`finite/ensure`](docs/finite.md#finiteensure)
|
||||
- **Integer Number**
|
||||
- [`integer/coerce`](docs/integer.md#integercoerce)
|
||||
- [`integer/ensure`](docs/integer.md#integerensure)
|
||||
- **Safe Integer Number**
|
||||
- [`safe-integer/coerce`](docs/safe-integer.md#safe-integercoerce)
|
||||
- [`safe-integer/ensure`](docs/.md#safe-integerensure)
|
||||
- **Natural Number**
|
||||
- [`natural-number/coerce`](docs/natural-number.md#natural-numbercoerce)
|
||||
- [`natural-number/ensure`](docs/natural-number.md#natural-numberensure)
|
||||
- **Array Length**
|
||||
- [`array-length/coerce`](docs/array-length.md#array-lengthcoerce)
|
||||
- [`array-length/ensure`](docs/array-length.md#array-lengthensure)
|
||||
- **Time Value**
|
||||
- [`time-value/coerce`](docs/time-value.md#time-valuecoerce)
|
||||
- [`time-value/ensure`](docs/time-value.md#time-valueensure)
|
||||
- **Array Like**
|
||||
- [`array-like/is`](docs/array-like.md#array-likeis)
|
||||
- [`array-like/ensure`](docs/array-like.md#array-likeensure)
|
||||
- **Array**
|
||||
- [`array/is`](docs/array.md#arrayis)
|
||||
- [`array/ensure`](docs/array.md#arrayensure)
|
||||
- **Iterable**
|
||||
- [`iterable/is`](docs/iterable.md#iterableis)
|
||||
- [`iterable/ensure`](docs/iterable.md#iterableensure)
|
||||
- **Set**
|
||||
- [`set/is`](docs/set.md#setis)
|
||||
- [`set/ensure`](docs/set.md#setensure)
|
||||
- **Map**
|
||||
- [`map/is`](docs/map.md#mapis)
|
||||
- [`map/ensure`](docs/map.md#mapensure)
|
||||
- **Date**
|
||||
- [`date/is`](docs/date.md#dateis)
|
||||
- [`date/ensure`](docs/date.md#dateensure)
|
||||
- **Function**
|
||||
- [`function/is`](docs/function.md#functionis)
|
||||
- [`function/ensure`](docs/function.md#functionensure)
|
||||
- **Plain Function**
|
||||
- [`plain-function/is`](docs/plain-function.md#plain-functionis)
|
||||
- [`plain-function/ensure`](docs/plain-function.md#plain-functionensure)
|
||||
- **Reg Exp**
|
||||
- [`reg-exp/is`](docs/reg-exp.md#reg-expis)
|
||||
- [`reg-exp/ensure`](docs/.md#reg-expensure)
|
||||
- **Thenable**
|
||||
- [`thenable/is`](docs/thenable.md#thenableis)
|
||||
- [`thenable/ensure`](docs/thenable.md#thenableensure)
|
||||
- **Promise**
|
||||
- [`promise/is`](docs/promise.md#promiseis)
|
||||
- [`promise/ensure`](docs/promise.md#promiseensure)
|
||||
- **Error**
|
||||
- [`error/is`](docs/error.md#erroris)
|
||||
- [`error/ensure`](docs/error.md#errorensure)
|
||||
- **Prototype**
|
||||
- [`prototype/is`](docs/prototype.md#prototypeis)
|
||||
|
||||
### Tests
|
||||
|
||||
$ npm test
|
||||
|
||||
[nix-build-image]: https://semaphoreci.com/api/v1/medikoo-org/type/branches/master/shields_badge.svg
|
||||
[nix-build-url]: https://semaphoreci.com/medikoo-org/type
|
||||
[win-build-image]: https://ci.appveyor.com/api/projects/status/8nrtluuwsb5k9l8d?svg=true
|
||||
[win-build-url]: https://ci.appveyor.com/api/project/medikoo/type
|
||||
[cov-image]: https://img.shields.io/codecov/c/github/medikoo/type.svg
|
||||
[cov-url]: https://codecov.io/gh/medikoo/type
|
||||
[npm-image]: https://img.shields.io/npm/v/type.svg
|
||||
[npm-url]: https://www.npmjs.com/package/type
|
10
node_modules/ext/node_modules/type/array-length/coerce.js
generated
vendored
Normal file
10
node_modules/ext/node_modules/type/array-length/coerce.js
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
"use strict";
|
||||
|
||||
var coerceToSafeInteger = require("../safe-integer/coerce");
|
||||
|
||||
module.exports = function (value) {
|
||||
value = coerceToSafeInteger(value);
|
||||
if (!value) return value;
|
||||
if (value < 0) return null;
|
||||
return value;
|
||||
};
|
15
node_modules/ext/node_modules/type/array-length/ensure.js
generated
vendored
Normal file
15
node_modules/ext/node_modules/type/array-length/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, coerce = require("./coerce");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
var coerced = coerce(value);
|
||||
if (coerced !== null) return coerced;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name
|
||||
? "Expected an array length for %n, received %v"
|
||||
: "%v is not an array length";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
14
node_modules/ext/node_modules/type/array-like/ensure.js
generated
vendored
Normal file
14
node_modules/ext/node_modules/type/array-like/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, is = require("./is");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
if (is(value, arguments[1])) return value;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name
|
||||
? "Expected an array like for %n, received %v"
|
||||
: "%v is not an array like";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
21
node_modules/ext/node_modules/type/array-like/is.js
generated
vendored
Normal file
21
node_modules/ext/node_modules/type/array-like/is.js
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
"use strict";
|
||||
|
||||
var coerceToArrayLength = require("../array-length/coerce")
|
||||
, isObject = require("../object/is");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
if (!isObject(value)) {
|
||||
var options = arguments[1];
|
||||
if (isObject(options) && options.allowString && typeof value === "string") return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof value === "function") return false;
|
||||
|
||||
var length;
|
||||
try { length = value.length; }
|
||||
catch (error) { return false; }
|
||||
|
||||
if (coerceToArrayLength(length) === null) return false;
|
||||
return true;
|
||||
};
|
43
node_modules/ext/node_modules/type/array/ensure.js
generated
vendored
Normal file
43
node_modules/ext/node_modules/type/array/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, resolveErrorMessage = require("../lib/resolve-error-message")
|
||||
, toShortString = require("../lib/to-short-string")
|
||||
, ensurePlainFunction = require("../plain-function/ensure")
|
||||
, is = require("./is");
|
||||
|
||||
var objHasOwnProperty = Object.prototype.hasOwnProperty, invalidItemsLimit = 3;
|
||||
|
||||
module.exports = function (value /*, options*/) {
|
||||
var options = arguments[1];
|
||||
var mainErrorMessage =
|
||||
options && options.name ? "Expected an array for %n, received %v" : "%v is not an array";
|
||||
if (!is(value)) return resolveException(value, mainErrorMessage, options);
|
||||
if (!options) return value;
|
||||
|
||||
var ensureItem = ensurePlainFunction(options.ensureItem, { isOptional: true });
|
||||
if (ensureItem) {
|
||||
var coercedValue = [], invalidItems;
|
||||
for (var index = 0, length = value.length; index < length; ++index) {
|
||||
if (!objHasOwnProperty.call(value, index)) continue;
|
||||
var coercedItem;
|
||||
try {
|
||||
coercedItem = ensureItem(value[index]);
|
||||
} catch (error) {
|
||||
if (!invalidItems) invalidItems = [];
|
||||
if (invalidItems.push(toShortString(value[index])) === invalidItemsLimit) break;
|
||||
}
|
||||
if (invalidItems) continue;
|
||||
coercedValue[index] = coercedItem;
|
||||
}
|
||||
if (invalidItems) {
|
||||
throw new TypeError(
|
||||
resolveErrorMessage(mainErrorMessage, value, options) +
|
||||
".\n Following items are invalid: " +
|
||||
invalidItems.join(", ")
|
||||
);
|
||||
}
|
||||
return coercedValue;
|
||||
}
|
||||
return value;
|
||||
};
|
27
node_modules/ext/node_modules/type/array/is.js
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/array/is.js
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
"use strict";
|
||||
|
||||
var isPrototype = require("../prototype/is");
|
||||
|
||||
var isArray;
|
||||
if (typeof Array.isArray === "function") {
|
||||
isArray = Array.isArray;
|
||||
} else {
|
||||
var objectToString = Object.prototype.toString, objectTaggedString = objectToString.call([]);
|
||||
isArray = function (value) { return objectToString.call(value) === objectTaggedString; };
|
||||
}
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!isArray(value)) return false;
|
||||
|
||||
// Sanity check (reject objects which do not expose common Array interface)
|
||||
if (!hasOwnProperty.call(value, "length")) return false;
|
||||
try {
|
||||
if (typeof value.length !== "number") return false;
|
||||
if (typeof value.push !== "function") return false;
|
||||
if (typeof value.splice !== "function") return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !isPrototype(value);
|
||||
};
|
12
node_modules/ext/node_modules/type/date/ensure.js
generated
vendored
Normal file
12
node_modules/ext/node_modules/type/date/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, is = require("./is");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
if (is(value)) return value;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name ? "Expected a date for %n, received %v" : "%v is not a date";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
26
node_modules/ext/node_modules/type/date/is.js
generated
vendored
Normal file
26
node_modules/ext/node_modules/type/date/is.js
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
"use strict";
|
||||
|
||||
var isPrototype = require("../prototype/is");
|
||||
|
||||
var dateValueOf = Date.prototype.valueOf;
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!value) return false;
|
||||
|
||||
try {
|
||||
// Sanity check (reject objects which do not expose common Date interface)
|
||||
if (typeof value.getFullYear !== "function") return false;
|
||||
if (typeof value.getTimezoneOffset !== "function") return false;
|
||||
if (typeof value.setFullYear !== "function") return false;
|
||||
|
||||
// Ensure its native Date object (has [[DateValue]] slot)
|
||||
dateValueOf.call(value);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure it hosts valid date
|
||||
if (isNaN(value)) return false;
|
||||
|
||||
return !isPrototype(value);
|
||||
};
|
27
node_modules/ext/node_modules/type/docs/array-length.md
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/docs/array-length.md
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Array length
|
||||
|
||||
_number_ primitive that conforms as valid _array length_
|
||||
|
||||
## `array-length/coerce`
|
||||
|
||||
Follows [`safe-integer/coerce`](safe-integer.md#safe-integercoerce) but returns `null` in place of values which are below `0`
|
||||
|
||||
```javascript
|
||||
const coerceToArrayLength = require("type/safe-integer/coerce");
|
||||
|
||||
coerceToArrayLength("12.95"); // 12
|
||||
coerceToArrayLength(9007199254740992); // null
|
||||
coerceToArrayLength(null); // null
|
||||
```
|
||||
|
||||
## `array-length/ensure`
|
||||
|
||||
If given argument is an _array length_ coercible value (via [`array-length/coerce`](#array-lengthcoerce)) returns result number.
|
||||
Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureArrayLength = require("type/array-length/ensure");
|
||||
|
||||
ensureArrayLength(12.93); // "12"
|
||||
ensureArrayLength(9007199254740992); // Thrown TypeError: 9007199254740992 is not a valid array length
|
||||
```
|
33
node_modules/ext/node_modules/type/docs/array-like.md
generated
vendored
Normal file
33
node_modules/ext/node_modules/type/docs/array-like.md
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Array Like
|
||||
|
||||
_Array-like_ value (any value with `length` property)
|
||||
|
||||
## `array-like/is`
|
||||
|
||||
Restricted _array-like_ confirmation. Returns true for every value that meets following contraints
|
||||
|
||||
- is an _object_ (or with `allowString` option, a _string_)
|
||||
- is not a _function_
|
||||
- Exposes `length` that meets [`array-length`](array-length.md#array-lengthcoerce) constraints
|
||||
|
||||
```javascript
|
||||
const isArrayLike = require("type/array-like/is");
|
||||
|
||||
isArrayLike([]); // true
|
||||
isArrayLike({}); // false
|
||||
isArrayLike({ length: 0 }); // true
|
||||
isArrayLike("foo"); // false
|
||||
isArrayLike("foo", { allowString: true }); // true
|
||||
```
|
||||
|
||||
## `array-like/ensure`
|
||||
|
||||
If given argument is an _array-like_, it is returned back. Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureArrayLike = require("type/array-like/ensure");
|
||||
|
||||
ensureArrayLike({ length: 0 }); // { length: 0 }
|
||||
ensureArrayLike("foo", { allowString: true }); // "foo"
|
||||
ensureArrayLike({}); // Thrown TypeError: null is not an iterable
|
||||
```
|
46
node_modules/ext/node_modules/type/docs/array.md
generated
vendored
Normal file
46
node_modules/ext/node_modules/type/docs/array.md
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
# Array
|
||||
|
||||
_Array_ instance
|
||||
|
||||
## `array/is`
|
||||
|
||||
Confirms if given object is a native array
|
||||
|
||||
```javascript
|
||||
const isArray = require("type/array/is");
|
||||
|
||||
isArray([]); // true
|
||||
isArray({}); // false
|
||||
isArray("foo"); // false
|
||||
```
|
||||
|
||||
## `array/ensure`
|
||||
|
||||
If given argument is an array, it is returned back. Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureArray = require("type/array/ensure");
|
||||
|
||||
ensureArray(["foo"]); // ["foo"]
|
||||
ensureArray("foo"); // Thrown TypeError: foo is not an array
|
||||
```
|
||||
|
||||
### Confirming on items
|
||||
|
||||
Items can be validated by passing `ensureItem` option. Note that in this case:
|
||||
|
||||
- A newly created instance of an array with coerced item values is returned
|
||||
- Error message lists up to three items which are invalid
|
||||
|
||||
```javascript
|
||||
const ensureString = require("type/string/ensure");
|
||||
|
||||
ensureArray([12], { ensureItem: ensureString }); // ["12"]
|
||||
|
||||
/*
|
||||
Below invocation with crash with:
|
||||
TypeError: 23, [object Object], [object Object] is not a valid array.
|
||||
Following items are invalid: [object Object], [object Object]
|
||||
*/
|
||||
ensureArray([23, {}, {}], { ensureItem: ensureString });
|
||||
```
|
28
node_modules/ext/node_modules/type/docs/date.md
generated
vendored
Normal file
28
node_modules/ext/node_modules/type/docs/date.md
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Date
|
||||
|
||||
_Date_ instance
|
||||
|
||||
## `date/is`
|
||||
|
||||
Confirms if given object is a native date, and is not an _Invalid Date_
|
||||
|
||||
```javascript
|
||||
const isDate = require("type/date/is");
|
||||
|
||||
isDate(new Date()); // true
|
||||
isDate(new Date("Invalid date")); // false
|
||||
isDate(Date.now()); // false
|
||||
isDate("foo"); // false
|
||||
```
|
||||
|
||||
## `date/ensure`
|
||||
|
||||
If given argument is a date object, it is returned back. Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureDate = require("type/date/ensure");
|
||||
|
||||
const date = new Date();
|
||||
ensureDate(date); // date
|
||||
ensureDate(123123); // Thrown TypeError: 123123 is not a date object
|
||||
```
|
40
node_modules/ext/node_modules/type/docs/ensure.md
generated
vendored
Normal file
40
node_modules/ext/node_modules/type/docs/ensure.md
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
# `ensure(validationDatum1[, ...validationDatumN[, options]])`
|
||||
|
||||
Provides a complete cumulated input validation for an API endpoint. Validates multiple input arguments and consolidates eventual errors into one.
|
||||
|
||||
## Arguments
|
||||
|
||||
### `validationDatum1[, ...validationDatumN]`
|
||||
|
||||
For each argument to be validated a `validationDatum` of following stucture should be defined:
|
||||
|
||||
```javascript
|
||||
[argumentName, inputValue, ensureFunction, (options = {})];
|
||||
```
|
||||
|
||||
- `argumentName` - Name of validated argument (used for meaningful error messaging)
|
||||
- `inputValue` - An argument value as passed to function
|
||||
- `ensureFunction` - An `ensureX` function with which argument should be validated (e.g. if we're after string, then we need [string/ensure](string.md#stringensure))
|
||||
- `options` - Optional, extra options to be passed to `ensureX` function
|
||||
|
||||
### `[options]`
|
||||
|
||||
Eventual options be passed to underlying `ensureX` functions. If custom error constructor is passed with an `Error` option, then cumulated error is created with this constructor.
|
||||
|
||||
## Usage example
|
||||
|
||||
```javascript
|
||||
const ensure = require("type/ensure");
|
||||
const ensureString = require("type/string/ensure");
|
||||
const ensureNaturalNumber = require("type/natural-number/ensure");
|
||||
|
||||
const resolveRepositoryIssue = (repoName, issueNumber) => {
|
||||
// Validate input
|
||||
[repoName, issueNumber] = ensure(
|
||||
["repoName", repoName, ensureString],
|
||||
["issueNumber", issueNumber, ensureNaturalNumber],
|
||||
{ Error: UserError }
|
||||
);
|
||||
// ... logic
|
||||
};
|
||||
```
|
26
node_modules/ext/node_modules/type/docs/error.md
generated
vendored
Normal file
26
node_modules/ext/node_modules/type/docs/error.md
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Error
|
||||
|
||||
_Error_ instance
|
||||
|
||||
## `error/is`
|
||||
|
||||
Confirms if given object is a native error object
|
||||
|
||||
```javascript
|
||||
const isError = require("type/error/is");
|
||||
|
||||
isError(new Error()); // true
|
||||
isError({ message: "Fake error" }); // false
|
||||
```
|
||||
|
||||
## `error/ensure`
|
||||
|
||||
If given argument is an error object, it is returned back. Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureError = require("type/error/ensure");
|
||||
|
||||
const someError = new Error("Some error");
|
||||
ensureError(someError); // someError
|
||||
ensureError({ message: "Fake error" }); // Thrown TypeError: [object Object] is not an error object
|
||||
```
|
27
node_modules/ext/node_modules/type/docs/finite.md
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/docs/finite.md
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Finite Number
|
||||
|
||||
Finite _number_ primitive
|
||||
|
||||
## `finite/coerce`
|
||||
|
||||
Follows [`number/coerce`](number.md#numbercoerce) additionally rejecting `Infinity` and `-Infinity` values (`null` is returned if given values coerces to them)
|
||||
|
||||
```javascript
|
||||
const coerceToFinite = require("type/finite/coerce");
|
||||
|
||||
coerceToFinite("12"); // 12
|
||||
coerceToFinite(Infinity); // null
|
||||
coerceToFinite(null); // null
|
||||
```
|
||||
|
||||
## `finite/ensure`
|
||||
|
||||
If given argument is a finite number coercible value (via [`finite/coerce`](#finitecoerce)) returns result number.
|
||||
Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureFinite = require("type/finite/ensure");
|
||||
|
||||
ensureFinite(12); // "12"
|
||||
ensureFinite(null); // Thrown TypeError: null is not a finite number
|
||||
```
|
28
node_modules/ext/node_modules/type/docs/function.md
generated
vendored
Normal file
28
node_modules/ext/node_modules/type/docs/function.md
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Function
|
||||
|
||||
_Function_ instance
|
||||
|
||||
## `function/is`
|
||||
|
||||
Confirms if given object is a native function
|
||||
|
||||
```javascript
|
||||
const isFunction = require("type/function/is");
|
||||
|
||||
isFunction(function () {}); // true
|
||||
isFunction(() => {}); // true
|
||||
isFunction(class {}); // true
|
||||
isFunction("foo"); // false
|
||||
```
|
||||
|
||||
## `function/ensure`
|
||||
|
||||
If given argument is a function object, it is returned back. Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureFunction = require("type/function/ensure");
|
||||
|
||||
const fn = function () {};
|
||||
ensureFunction(fn); // fn
|
||||
ensureFunction(/foo/); // Thrown TypeError: /foo/ is not a function
|
||||
```
|
27
node_modules/ext/node_modules/type/docs/integer.md
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/docs/integer.md
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Integer Number
|
||||
|
||||
Integer _number_ primitive
|
||||
|
||||
## `integer/coerce`
|
||||
|
||||
Follows [`finite/coerce`](finite.md#finitecoerce) additionally stripping decimal part from the number
|
||||
|
||||
```javascript
|
||||
const coerceToInteger = require("type/integer/coerce");
|
||||
|
||||
coerceToInteger("12.95"); // 12
|
||||
coerceToInteger(Infinity); // null
|
||||
coerceToInteger(null); // null
|
||||
```
|
||||
|
||||
## `integer/ensure`
|
||||
|
||||
If given argument is an integer coercible value (via [`integer/coerce`](#integercoerce)) returns result number.
|
||||
Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureInteger = require("type/integer/ensure");
|
||||
|
||||
ensureInteger(12.93); // "12"
|
||||
ensureInteger(null); // Thrown TypeError: null is not an integer
|
||||
```
|
65
node_modules/ext/node_modules/type/docs/iterable.md
generated
vendored
Normal file
65
node_modules/ext/node_modules/type/docs/iterable.md
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
# Iterable
|
||||
|
||||
Value which implements _iterable_ protocol
|
||||
|
||||
## `iterable/is`
|
||||
|
||||
Confirms if given object is an _iterable_ and is not a _string_ (unless `allowString` option is passed)
|
||||
|
||||
```javascript
|
||||
const isIterable = require("type/iterable/is");
|
||||
|
||||
isIterable([]); // true
|
||||
isIterable({}); // false
|
||||
isIterable("foo"); // false
|
||||
isIterable("foo", { allowString: true }); // true
|
||||
```
|
||||
|
||||
Supports also `denyEmpty` option
|
||||
|
||||
```javascript
|
||||
isIterable([], { denyEmpty: true }); // false
|
||||
isIterable(["foo"], { denyEmpty: true }); // true
|
||||
```
|
||||
|
||||
## `iterable/ensure`
|
||||
|
||||
If given argument is an _iterable_, it is returned back. Otherwise `TypeError` is thrown.
|
||||
By default _string_ primitives are rejected unless `allowString` option is passed.
|
||||
|
||||
```javascript
|
||||
const ensureIterable = require("type/iterable/ensure");
|
||||
|
||||
ensureIterable([]); // []
|
||||
ensureIterable("foo", { allowString: true }); // "foo"
|
||||
ensureIterable({}); // Thrown TypeError: null is not expected iterable
|
||||
```
|
||||
|
||||
### Denying empty iterables
|
||||
|
||||
Pass `denyEmpty` option to require non empty iterables
|
||||
|
||||
```javascript
|
||||
ensureIterable([], { denyEmpty: true }); // Thrown TypeError: [] is not expected iterable
|
||||
```
|
||||
|
||||
### Confirming on items
|
||||
|
||||
Items can be validated by passing `ensureItem` option. Note that in this case:
|
||||
|
||||
- A newly created instance of array with coerced values is returned
|
||||
- Error message lists up to three invalid items
|
||||
|
||||
```javascript
|
||||
const ensureString = require("type/string/ensure");
|
||||
|
||||
ensureIterable(new Set(["foo", 12]), { ensureItem: ensureString }); // ["foo", "12"]
|
||||
|
||||
/*
|
||||
Below invocation with crash with:
|
||||
TypeError: [object Set] is not expected iterable value.
|
||||
Following items are invalid:
|
||||
- [object Object]
|
||||
*/
|
||||
ensureIterable(new Set(["foo", {}]), { ensureItem: ensureString });
|
||||
```
|
27
node_modules/ext/node_modules/type/docs/map.md
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/docs/map.md
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Map
|
||||
|
||||
_Map_ instance
|
||||
|
||||
## `map/is`
|
||||
|
||||
Confirms if given object is a native _map_
|
||||
|
||||
```javascript
|
||||
const isMap = require("type/map/is");
|
||||
|
||||
isMap(new Map()); // true
|
||||
isMap(new Set()); // false
|
||||
isMap({}); // false
|
||||
```
|
||||
|
||||
## `map/ensure`
|
||||
|
||||
If given argument is a _map_, it is returned back. Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureMap = require("type/map/ensure");
|
||||
|
||||
const map = new Map();
|
||||
ensureMap(map); // map
|
||||
eensureMap({}); // Thrown TypeError: [object Object] is not a map
|
||||
```
|
27
node_modules/ext/node_modules/type/docs/natural-number.md
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/docs/natural-number.md
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Natural Number
|
||||
|
||||
Natural _number_ primitive
|
||||
|
||||
## `natural-number/coerce`
|
||||
|
||||
Follows [`integer/coerce`](integer.md#integercoerce) but returns `null` for values below `0`
|
||||
|
||||
```javascript
|
||||
const coerceToNaturalNumber = require("type/natural-number/coerce");
|
||||
|
||||
coerceToNaturalNumber("12.95"); // 12
|
||||
coerceToNaturalNumber(-120); // null
|
||||
coerceToNaturalNumber(null); // null
|
||||
```
|
||||
|
||||
## `natural-number/ensure`
|
||||
|
||||
If given argument is a natural number coercible value (via [`natural-number/coerce`](#natural-numbercoerce)) returns result number.
|
||||
Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureNaturalNumber = require("type/natural-number/ensure");
|
||||
|
||||
ensureNaturalNumber(12.93); // "12"
|
||||
ensureNaturalNumber(-230); // Thrown TypeError: null is not a natural number
|
||||
```
|
33
node_modules/ext/node_modules/type/docs/number.md
generated
vendored
Normal file
33
node_modules/ext/node_modules/type/docs/number.md
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Number
|
||||
|
||||
_number_ primitive
|
||||
|
||||
## `number/coerce`
|
||||
|
||||
Restricted number coercion. Returns number presentation for every value that follows below constraints
|
||||
|
||||
- is implicitly coercible to number
|
||||
- is neither `null` nor `undefined`
|
||||
- is not `NaN` and doesn't coerce to `NaN`
|
||||
|
||||
For all other values `null` is returned
|
||||
|
||||
```javascript
|
||||
const coerceToNumber = require("type/number/coerce");
|
||||
|
||||
coerceToNumber("12"); // 12
|
||||
coerceToNumber({}); // null
|
||||
coerceToNumber(null); // null
|
||||
```
|
||||
|
||||
## `number/ensure`
|
||||
|
||||
If given argument is a number coercible value (via [`number/coerce`](#numbercoerce)) returns result number.
|
||||
Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureNumber = require("type/number/ensure");
|
||||
|
||||
ensureNumber(12); // "12"
|
||||
ensureNumber(null); // Thrown TypeError: null is not a number
|
||||
```
|
28
node_modules/ext/node_modules/type/docs/object.md
generated
vendored
Normal file
28
node_modules/ext/node_modules/type/docs/object.md
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Object
|
||||
|
||||
_Object_, any non-primitive value
|
||||
|
||||
## `object/is`
|
||||
|
||||
Confirms if passed value is an object
|
||||
|
||||
```javascript
|
||||
const isObject = require("type/object/is");
|
||||
|
||||
isObject({}); // true
|
||||
isObject(true); // false
|
||||
isObject(null); // false
|
||||
```
|
||||
|
||||
## `object/ensure`
|
||||
|
||||
If given argument is an object, it is returned back. Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureObject = require("type/object/ensure");
|
||||
|
||||
const obj = {};
|
||||
|
||||
ensureObject(obj); // obj
|
||||
ensureString(null); // Thrown TypeError: null is not an object
|
||||
```
|
28
node_modules/ext/node_modules/type/docs/plain-function.md
generated
vendored
Normal file
28
node_modules/ext/node_modules/type/docs/plain-function.md
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Plain Function
|
||||
|
||||
A _Function_ instance that is not a _Class_
|
||||
|
||||
## `plain-function/is`
|
||||
|
||||
Confirms if given object is a _plain function_
|
||||
|
||||
```javascript
|
||||
const isPlainFunction = require("type/plain-function/is");
|
||||
|
||||
isPlainFunction(function () {}); // true
|
||||
isPlainFunction(() => {}); // true
|
||||
isPlainFunction(class {}); // false
|
||||
isPlainFunction("foo"); // false
|
||||
```
|
||||
|
||||
## `plain-function/ensure`
|
||||
|
||||
If given argument is a _plain function_ object, it is returned back. Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensurePlainFunction = require("type/function/ensure");
|
||||
|
||||
const fn = function () {};
|
||||
ensurePlainFunction(fn); // fn
|
||||
ensurePlainFunction(class {}); // Thrown TypeError: class is not a plain function
|
||||
```
|
69
node_modules/ext/node_modules/type/docs/plain-object.md
generated
vendored
Normal file
69
node_modules/ext/node_modules/type/docs/plain-object.md
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
# Plain Object
|
||||
|
||||
A _plain object_
|
||||
|
||||
- Inherits directly from `Object.prototype` or `null`
|
||||
- Is not a constructor's `prototype` property
|
||||
|
||||
## `plain-object/is`
|
||||
|
||||
Confirms if given object is a _plain object_
|
||||
|
||||
```javascript
|
||||
const isPlainObject = require("type/plain-object/is");
|
||||
|
||||
isPlainObject({}); // true
|
||||
isPlainObject(Object.create(null)); // true
|
||||
isPlainObject([]); // false
|
||||
```
|
||||
|
||||
## `plain-object/ensure`
|
||||
|
||||
If given argument is a plain object it is returned back. Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensurePlainObject = require("type/plain-object/ensure");
|
||||
|
||||
ensurePlainObject({}); // {}
|
||||
ensurePlainObject("foo"); // Thrown TypeError: foo is not a plain object
|
||||
```
|
||||
|
||||
### Confirming on keys
|
||||
|
||||
Keys can be validated by passing `allowedKeys` option. Note that in this case:
|
||||
|
||||
- Error message lists up to three invalid keys
|
||||
|
||||
```javascript
|
||||
const allowedKeys = ["foo"];
|
||||
|
||||
ensurePlainObject({}, { allowedKeys }); // {}
|
||||
ensurePlainObject({ foo: "bar" }, { allowedKeys }); // { foo: 'bar' }
|
||||
|
||||
/*
|
||||
Below invocation with crash with:
|
||||
TypeError: [object Object] is not a valid plain object.
|
||||
Following keys are unexpected: lorem, ipsum
|
||||
*/
|
||||
ensurePlainObject({ foo: "bar", lorem: 1, ipsum: 2 }, { allowedKeys });
|
||||
```
|
||||
|
||||
### Confirming on property values
|
||||
|
||||
Property values can be validated by passing `ensurePropertyValue` option. Note that in this case:
|
||||
|
||||
- A newly created instance of plain object with coerced values is returned
|
||||
- Error message lists up to three keys that contain invalid values
|
||||
|
||||
```javascript
|
||||
const ensureString = require("type/string/ensure");
|
||||
|
||||
ensurePlainObject({ foo: 12 }, { ensurePropertyValue: ensureString }); // { foo: '12' }
|
||||
|
||||
/*
|
||||
Below invocation with crash with:
|
||||
TypeError: [object Object] is not a valid plain object.
|
||||
Valuees for following keys are invalid: lorem, ipsum
|
||||
*/
|
||||
ensurePlainObject({ foo: 23, lorem: {}, ipsum: {} }, { ensurePropertyValue: ensureString });
|
||||
```
|
27
node_modules/ext/node_modules/type/docs/promise.md
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/docs/promise.md
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Promise
|
||||
|
||||
_Promise_ instance
|
||||
|
||||
## `promise/is`
|
||||
|
||||
Confirms if given object is a native _promise_
|
||||
|
||||
```javascript
|
||||
const isPromise = require("type/promise/is");
|
||||
|
||||
isPromise(Promise.resolve()); // true
|
||||
isPromise({ then: () => {} }); // false
|
||||
isPromise({}); // false
|
||||
```
|
||||
|
||||
## `promise/ensure`
|
||||
|
||||
If given argument is a promise, it is returned back. Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensurePromise = require("type/promise/ensure");
|
||||
|
||||
const promise = Promise.resolve();
|
||||
ensurePromise(promise); // promise
|
||||
eensurePromise({}); // Thrown TypeError: [object Object] is not a promise
|
||||
```
|
15
node_modules/ext/node_modules/type/docs/prototype.md
generated
vendored
Normal file
15
node_modules/ext/node_modules/type/docs/prototype.md
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Prototype
|
||||
|
||||
Some constructor's `prototype` property
|
||||
|
||||
## `prototype/is`
|
||||
|
||||
Confirms if given object serves as a _prototype_ property
|
||||
|
||||
```javascript
|
||||
const isPrototype = require("type/prototype/is");
|
||||
|
||||
isPrototype({}); // false
|
||||
isPrototype(Object.prototype); // true
|
||||
isPrototype(Array.prototype); // true
|
||||
```
|
26
node_modules/ext/node_modules/type/docs/reg-exp.md
generated
vendored
Normal file
26
node_modules/ext/node_modules/type/docs/reg-exp.md
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
# RegExp
|
||||
|
||||
_RegExp_ instance
|
||||
|
||||
## `reg-exp/is`
|
||||
|
||||
Confirms if given object is a native regular expression object
|
||||
|
||||
```javascript
|
||||
const isRegExp = require("type/reg-exp/is");
|
||||
|
||||
isRegExp(/foo/);
|
||||
isRegExp({}); // false
|
||||
isRegExp("foo"); // false
|
||||
```
|
||||
|
||||
## `reg-exp/ensure`
|
||||
|
||||
If given argument is a regular expression object, it is returned back. Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureRegExp = require("type/reg-exp/ensure");
|
||||
|
||||
ensureRegExp(/foo/); // /foo/
|
||||
ensureRegExp("foo"); // Thrown TypeError: null is not a regular expression object
|
||||
```
|
27
node_modules/ext/node_modules/type/docs/safe-integer.md
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/docs/safe-integer.md
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Safe Integer Number
|
||||
|
||||
Safe integer _number_ primitive
|
||||
|
||||
## `safe-integer/coerce`
|
||||
|
||||
Follows [`integer/coerce`](integer.md#integercoerce) but returns `null` in place of values which are beyond `Number.MIN_SAFE_INTEGER` and `Number.MAX_SAFE_INTEGER` range.
|
||||
|
||||
```javascript
|
||||
const coerceToSafeInteger = require("type/safe-integer/coerce");
|
||||
|
||||
coerceToInteger("12.95"); // 12
|
||||
coerceToInteger(9007199254740992); // null
|
||||
coerceToInteger(null); // null
|
||||
```
|
||||
|
||||
## `safe-integer/ensure`
|
||||
|
||||
If given argument is a safe integer coercible value (via [`safe-integer/coerce`](#safe-integercoerce)) returns result number.
|
||||
Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureSafeInteger = require("type/safe-integer/ensure");
|
||||
|
||||
ensureSafeInteger(12.93); // "12"
|
||||
ensureSafeInteger(9007199254740992); // Thrown TypeError: null is not a safe integer
|
||||
```
|
27
node_modules/ext/node_modules/type/docs/set.md
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/docs/set.md
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Set
|
||||
|
||||
_Set_ instance
|
||||
|
||||
## `set/is`
|
||||
|
||||
Confirms if given object is a native set\_
|
||||
|
||||
```javascript
|
||||
const isSet = require("type/set/is");
|
||||
|
||||
isSet(new Set()); // true
|
||||
isSet(new Set()); // false
|
||||
isSet({}); // false
|
||||
```
|
||||
|
||||
## `Set/ensure`
|
||||
|
||||
If given argument is a _set_, it is returned back. Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureSet = require("type/set/ensure");
|
||||
|
||||
const set = new Set();
|
||||
ensureSet(set); // set
|
||||
eensureSet({}); // Thrown TypeError: [object Object] is not a set
|
||||
```
|
32
node_modules/ext/node_modules/type/docs/string.md
generated
vendored
Normal file
32
node_modules/ext/node_modules/type/docs/string.md
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
# String
|
||||
|
||||
_string_ primitive
|
||||
|
||||
## `string/coerce`
|
||||
|
||||
Restricted string coercion. Returns string presentation for every value that follows below constraints
|
||||
|
||||
- is implicitly coercible to string
|
||||
- is neither`null` nor `undefined`
|
||||
- its `toString` method is not `Object.prototype.toString`
|
||||
|
||||
For all other values `null` is returned
|
||||
|
||||
```javascript
|
||||
const coerceToString = require("type/string/coerce");
|
||||
|
||||
coerceToString(12); // "12"
|
||||
coerceToString(undefined); // null
|
||||
```
|
||||
|
||||
## `string/ensure`
|
||||
|
||||
If given argument is a string coercible value (via [`string/coerce`](#stringcoerce)) returns result string.
|
||||
Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureString = require("type/string/ensure");
|
||||
|
||||
ensureString(12); // "12"
|
||||
ensureString(null); // Thrown TypeError: null is not a string
|
||||
```
|
27
node_modules/ext/node_modules/type/docs/thenable.md
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/docs/thenable.md
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Thenable
|
||||
|
||||
_Thenable_ object (an object with `then` method)
|
||||
|
||||
## `thenable/is`
|
||||
|
||||
Confirms if given object is a _thenable_
|
||||
|
||||
```javascript
|
||||
const isThenable = require("type/thenable/is");
|
||||
|
||||
isThenable(Promise.resolve()); // true
|
||||
isThenable({ then: () => {} }); // true
|
||||
isThenable({}); // false
|
||||
```
|
||||
|
||||
## `thenable/ensure`
|
||||
|
||||
If given argument is a _thenable_ object, it is returned back. Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureThenable = require("type/thenable/ensure");
|
||||
|
||||
const promise = Promise.resolve();
|
||||
ensureThenable(promise); // promise
|
||||
ensureThenable({}); // Thrown TypeError: [object Object] is not a thenable object
|
||||
```
|
27
node_modules/ext/node_modules/type/docs/time-value.md
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/docs/time-value.md
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Time value
|
||||
|
||||
_number_ primitive which is a valid _time value_ (as used internally in _Date_ instances)
|
||||
|
||||
## `time-value/coerce`
|
||||
|
||||
Follows [`integer/coerce`](integer.md#integercoerce) but returns `null` in place of values which go beyond 100 000 0000 days from unix epoch
|
||||
|
||||
```javascript
|
||||
const coerceToTimeValue = require("type/time-value/coerce");
|
||||
|
||||
coerceToTimeValue(12312312); // true
|
||||
coerceToTimeValue(Number.MAX_SAFE_INTEGER); // false
|
||||
coerceToTimeValue("foo"); // false
|
||||
```
|
||||
|
||||
## `time-value/ensure`
|
||||
|
||||
If given argument is a _time value_ coercible value (via [`time-value/coerce`](#time-valuecoerce)) returns result number.
|
||||
Otherwise `TypeError` is thrown.
|
||||
|
||||
```javascript
|
||||
const ensureTimeValue = require("type/time-value/ensure");
|
||||
|
||||
ensureTimeValue(12.93); // "12"
|
||||
ensureTimeValue(Number.MAX_SAFE_INTEGER); // Thrown TypeError: null is not a natural number
|
||||
```
|
27
node_modules/ext/node_modules/type/docs/value.md
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/docs/value.md
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Value
|
||||
|
||||
_Value_, any value that's neither `null` nor `undefined` .
|
||||
|
||||
## `value/is`
|
||||
|
||||
Confirms whether passed argument is a _value_
|
||||
|
||||
```javascript
|
||||
const isValue = require("type/value/is");
|
||||
|
||||
isValue({}); // true
|
||||
isValue(null); // false
|
||||
```
|
||||
|
||||
## `value/ensure`
|
||||
|
||||
Ensures if given argument is a _value_. If it's a value it is returned back, if not `TypeError` is thrown
|
||||
|
||||
```javascript
|
||||
const ensureValue = require("type/value/ensure");
|
||||
|
||||
const obj = {};
|
||||
|
||||
ensureValue(obj); // obj
|
||||
ensureValue(null); // Thrown TypeError: Cannot use null
|
||||
```
|
51
node_modules/ext/node_modules/type/ensure.js
generated
vendored
Normal file
51
node_modules/ext/node_modules/type/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
"use strict";
|
||||
|
||||
var isArray = require("./array/is")
|
||||
, toShortString = require("./lib/to-short-string");
|
||||
|
||||
var objPropertyIsEnumerable = Object.prototype.propertyIsEnumerable;
|
||||
|
||||
var assign = function (target, source) {
|
||||
for (var key in source) {
|
||||
if (objPropertyIsEnumerable.call(source, key)) target[key] = source[key];
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function (validationDatum1/*, ...validationDatumN, options */) {
|
||||
var validationData = [validationDatum1];
|
||||
var globalOptions;
|
||||
if (arguments.length > 1) {
|
||||
var hasOptions = !isArray(arguments[arguments.length - 1]);
|
||||
if (hasOptions) globalOptions = arguments[arguments.length - 1];
|
||||
var lastDatumIndex = hasOptions ? arguments.length - 2 : arguments.length - 1;
|
||||
for (var i = 1; i <= lastDatumIndex; ++i) validationData.push(arguments[i]);
|
||||
}
|
||||
var result = [], errors;
|
||||
for (var j = 0; j < validationData.length; ++j) {
|
||||
var validationDatum = validationData[j];
|
||||
var options = { name: validationDatum[0] };
|
||||
if (globalOptions) assign(options, globalOptions);
|
||||
if (validationDatum[3]) assign(options, validationDatum[3]);
|
||||
var resultItem;
|
||||
if (typeof validationDatum[2] !== "function") {
|
||||
throw new TypeError(toShortString(validationDatum[2]) + " is not a function");
|
||||
}
|
||||
try {
|
||||
resultItem = validationDatum[2](validationDatum[1], options);
|
||||
} catch (error) {
|
||||
if (!errors) errors = [];
|
||||
errors.push(error);
|
||||
}
|
||||
if (errors) continue;
|
||||
result.push(resultItem);
|
||||
}
|
||||
if (!errors) return result;
|
||||
|
||||
if (errors.length === 1) throw errors[0];
|
||||
var ErrorConstructor = (globalOptions && globalOptions.Error) || TypeError;
|
||||
var errorMessage = "Approached following errors:";
|
||||
for (var k = 0; k < errors.length; ++k) {
|
||||
errorMessage += "\n - " + errors[k].message.split("\n").join("\n ");
|
||||
}
|
||||
throw new ErrorConstructor(errorMessage);
|
||||
};
|
12
node_modules/ext/node_modules/type/error/ensure.js
generated
vendored
Normal file
12
node_modules/ext/node_modules/type/error/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, is = require("./is");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
if (is(value)) return value;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name ? "Expected an error for %n, received %v" : "%v is not an error";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
45
node_modules/ext/node_modules/type/error/is.js
generated
vendored
Normal file
45
node_modules/ext/node_modules/type/error/is.js
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
"use strict";
|
||||
|
||||
var isPrototype = require("../prototype/is")
|
||||
, isPlainObject = require("../plain-object/is");
|
||||
|
||||
var objectToString = Object.prototype.toString;
|
||||
|
||||
// Recognize host specific errors (e.g. DOMException)
|
||||
var errorTaggedStringRe = /^\[object .*(?:Error|Exception)\]$/
|
||||
, errorNameRe = /^[^\s]*(?:Error|Exception)$/;
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!value) return false;
|
||||
|
||||
var name;
|
||||
// Sanity check (reject objects which do not expose common Error interface)
|
||||
try {
|
||||
name = value.name;
|
||||
if (typeof name !== "string") return false;
|
||||
if (typeof value.message !== "string") return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure its a native-like Error object
|
||||
// (has [[ErrorData]] slot, or was created to resemble one)
|
||||
// Note: It's not a 100% bulletproof check of confirming that as:
|
||||
// - In ES2015+ string tag can be overriden via Symbol.toStringTag property
|
||||
// - Host errors do not share native error tag. Still we rely on assumption that
|
||||
// tag for each error will end either with `Error` or `Exception` string
|
||||
// - In pre ES2015 era, no custom errors will share the error tag.
|
||||
if (!errorTaggedStringRe.test(objectToString.call(value))) {
|
||||
// Definitely not an ES2015 error instance, but could still be an error
|
||||
// (created via e.g. CustomError.prototype = Object.create(Error.prototype))
|
||||
try {
|
||||
if (name !== value.constructor.name) return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
if (!errorNameRe.test(name)) return false;
|
||||
if (isPlainObject(value)) return false;
|
||||
}
|
||||
|
||||
return !isPrototype(value);
|
||||
};
|
8
node_modules/ext/node_modules/type/finite/coerce.js
generated
vendored
Normal file
8
node_modules/ext/node_modules/type/finite/coerce.js
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
"use strict";
|
||||
|
||||
var coerceToNumber = require("../number/coerce");
|
||||
|
||||
module.exports = function (value) {
|
||||
value = coerceToNumber(value);
|
||||
return isFinite(value) ? value : null;
|
||||
};
|
15
node_modules/ext/node_modules/type/finite/ensure.js
generated
vendored
Normal file
15
node_modules/ext/node_modules/type/finite/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, coerce = require("./coerce");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
var coerced = coerce(value);
|
||||
if (coerced !== null) return coerced;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name
|
||||
? "Expected a finite number for %n, received %v"
|
||||
: "%v is not a finite number";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
14
node_modules/ext/node_modules/type/function/ensure.js
generated
vendored
Normal file
14
node_modules/ext/node_modules/type/function/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, is = require("./is");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
if (is(value)) return value;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name
|
||||
? "Expected a function for %n, received %v"
|
||||
: "%v is not a function";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
19
node_modules/ext/node_modules/type/function/is.js
generated
vendored
Normal file
19
node_modules/ext/node_modules/type/function/is.js
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
"use strict";
|
||||
|
||||
var isPrototype = require("../prototype/is");
|
||||
|
||||
module.exports = function (value) {
|
||||
if (typeof value !== "function") return false;
|
||||
|
||||
if (!hasOwnProperty.call(value, "length")) return false;
|
||||
|
||||
try {
|
||||
if (typeof value.length !== "number") return false;
|
||||
if (typeof value.call !== "function") return false;
|
||||
if (typeof value.apply !== "function") return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !isPrototype(value);
|
||||
};
|
11
node_modules/ext/node_modules/type/integer/coerce.js
generated
vendored
Normal file
11
node_modules/ext/node_modules/type/integer/coerce.js
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
var coerceToFinite = require("../finite/coerce");
|
||||
|
||||
var abs = Math.abs, floor = Math.floor;
|
||||
|
||||
module.exports = function (value) {
|
||||
value = coerceToFinite(value);
|
||||
if (!value) return value;
|
||||
return (value > 0 ? 1 : -1) * floor(abs(value));
|
||||
};
|
15
node_modules/ext/node_modules/type/integer/ensure.js
generated
vendored
Normal file
15
node_modules/ext/node_modules/type/integer/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, coerce = require("./coerce");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
var coerced = coerce(value);
|
||||
if (coerced !== null) return coerced;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name
|
||||
? "Expected an integer for %n, received %v"
|
||||
: "%v is not an integer";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
49
node_modules/ext/node_modules/type/iterable/ensure.js
generated
vendored
Normal file
49
node_modules/ext/node_modules/type/iterable/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, resolveErrorMessage = require("../lib/resolve-error-message")
|
||||
, toShortString = require("../lib/to-short-string")
|
||||
, ensurePlainFunction = require("../plain-function/ensure")
|
||||
, is = require("./is");
|
||||
|
||||
var invalidItemsLimit = 3;
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
var options = arguments[1];
|
||||
var mainErrorMessage =
|
||||
options && options.name
|
||||
? "Expected an iterable for %n, received %v"
|
||||
: "%v is not expected iterable";
|
||||
if (!is(value, options)) return resolveException(value, mainErrorMessage, options);
|
||||
if (!options) return value;
|
||||
|
||||
var ensureItem = ensurePlainFunction(options.ensureItem, { isOptional: true });
|
||||
if (ensureItem) {
|
||||
var coercedValue = [];
|
||||
var iterator = value[Symbol.iterator]();
|
||||
var item, invalidItems;
|
||||
while (!(item = iterator.next()).done) {
|
||||
var newItemValue;
|
||||
try {
|
||||
newItemValue = ensureItem(item.value);
|
||||
} catch (error) {
|
||||
if (!invalidItems) invalidItems = [];
|
||||
if (invalidItems.push(item.value) === invalidItemsLimit) break;
|
||||
}
|
||||
if (invalidItems) continue;
|
||||
coercedValue.push(newItemValue);
|
||||
}
|
||||
if (invalidItems) {
|
||||
var errorMessage =
|
||||
resolveErrorMessage(mainErrorMessage, value, options) +
|
||||
".\n Following items are invalid:";
|
||||
for (var i = 0; i < invalidItems.length; ++i) {
|
||||
errorMessage += "\n - " + toShortString(invalidItems[i]);
|
||||
}
|
||||
throw new TypeError(errorMessage);
|
||||
}
|
||||
return coercedValue;
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
32
node_modules/ext/node_modules/type/iterable/is.js
generated
vendored
Normal file
32
node_modules/ext/node_modules/type/iterable/is.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Polyfills friendly, therefore ES5 syntax
|
||||
|
||||
"use strict";
|
||||
|
||||
var isObject = require("../object/is");
|
||||
|
||||
var iteratorSymbol = Symbol.iterator;
|
||||
|
||||
if (!iteratorSymbol) {
|
||||
throw new Error("Cannot initialize iterator/is due to Symbol.iterator not being implemented");
|
||||
}
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
var options = arguments[1];
|
||||
if (!isObject(value)) {
|
||||
if (!isObject(options) || !options.allowString || typeof value !== "string") return false;
|
||||
}
|
||||
try {
|
||||
if (typeof value[iteratorSymbol] !== "function") return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
if (!options) return true;
|
||||
if (options.denyEmpty) {
|
||||
try {
|
||||
if (value[iteratorSymbol]().next().done) return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
12
node_modules/ext/node_modules/type/lib/ensure/min.js
generated
vendored
Normal file
12
node_modules/ext/node_modules/type/lib/ensure/min.js
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../resolve-exception");
|
||||
|
||||
module.exports = function (value, coerced, options) {
|
||||
if (coerced >= options.min) return coerced;
|
||||
var errorMessage =
|
||||
options && options.name
|
||||
? "Expected %n to be greater or equal " + options.min + ", received %v"
|
||||
: "%v is not greater or equal " + options.min;
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
3
node_modules/ext/node_modules/type/lib/is-to-string-tag-supported.js
generated
vendored
Normal file
3
node_modules/ext/node_modules/type/lib/is-to-string-tag-supported.js
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol";
|
52
node_modules/ext/node_modules/type/lib/resolve-error-message.js
generated
vendored
Normal file
52
node_modules/ext/node_modules/type/lib/resolve-error-message.js
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
"use strict";
|
||||
|
||||
var stringCoerce = require("../string/coerce")
|
||||
, toShortString = require("./to-short-string");
|
||||
|
||||
module.exports = function (errorMessage, value, inputOptions) {
|
||||
if (inputOptions && inputOptions.errorMessage) {
|
||||
errorMessage = stringCoerce(inputOptions.errorMessage);
|
||||
}
|
||||
|
||||
var valueInsertIndex = errorMessage.indexOf("%v");
|
||||
var valueToken = valueInsertIndex > -1 ? toShortString(value) : null;
|
||||
if (inputOptions && inputOptions.name) {
|
||||
var nameInsertIndex = errorMessage.indexOf("%n");
|
||||
if (nameInsertIndex > -1) {
|
||||
if (valueInsertIndex > -1) {
|
||||
var firstToken, secondToken, firstInsertIndex, secondInsertIndex;
|
||||
if (nameInsertIndex > valueInsertIndex) {
|
||||
firstToken = valueToken;
|
||||
firstInsertIndex = valueInsertIndex;
|
||||
secondToken = inputOptions.name;
|
||||
secondInsertIndex = nameInsertIndex;
|
||||
} else {
|
||||
firstToken = inputOptions.name;
|
||||
firstInsertIndex = nameInsertIndex;
|
||||
secondToken = valueToken;
|
||||
secondInsertIndex = valueInsertIndex;
|
||||
}
|
||||
return (
|
||||
errorMessage.slice(0, firstInsertIndex) +
|
||||
firstToken +
|
||||
errorMessage.slice(firstInsertIndex + 2, secondInsertIndex) +
|
||||
secondToken +
|
||||
errorMessage.slice(secondInsertIndex + 2)
|
||||
);
|
||||
}
|
||||
return (
|
||||
errorMessage.slice(0, nameInsertIndex) +
|
||||
inputOptions.name +
|
||||
errorMessage.slice(nameInsertIndex + 2)
|
||||
);
|
||||
}
|
||||
}
|
||||
if (valueInsertIndex > -1) {
|
||||
return (
|
||||
errorMessage.slice(0, valueInsertIndex) +
|
||||
valueToken +
|
||||
errorMessage.slice(valueInsertIndex + 2)
|
||||
);
|
||||
}
|
||||
return errorMessage;
|
||||
};
|
15
node_modules/ext/node_modules/type/lib/resolve-exception.js
generated
vendored
Normal file
15
node_modules/ext/node_modules/type/lib/resolve-exception.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
|
||||
var isValue = require("../value/is")
|
||||
, resolveErrorMessage = require("./resolve-error-message");
|
||||
|
||||
module.exports = function (value, defaultMessage, inputOptions) {
|
||||
if (inputOptions && !isValue(value)) {
|
||||
if ("default" in inputOptions) return inputOptions["default"];
|
||||
if (inputOptions.isOptional) return null;
|
||||
}
|
||||
var ErrorConstructor = (inputOptions && inputOptions.Error) || TypeError;
|
||||
var error = new ErrorConstructor(resolveErrorMessage(defaultMessage, value, inputOptions));
|
||||
if (inputOptions && inputOptions.errorCode) error.code = inputOptions.errorCode;
|
||||
throw error;
|
||||
};
|
10
node_modules/ext/node_modules/type/lib/safe-to-string.js
generated
vendored
Normal file
10
node_modules/ext/node_modules/type/lib/safe-to-string.js
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = function (value) {
|
||||
try {
|
||||
return value.toString();
|
||||
} catch (error) {
|
||||
try { return String(value); }
|
||||
catch (error2) { return null; }
|
||||
}
|
||||
};
|
29
node_modules/ext/node_modules/type/lib/to-short-string.js
generated
vendored
Normal file
29
node_modules/ext/node_modules/type/lib/to-short-string.js
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
"use strict";
|
||||
|
||||
var safeToString = require("./safe-to-string");
|
||||
|
||||
var reNewLine = /[\n\r\u2028\u2029]/g;
|
||||
|
||||
module.exports = function (value) {
|
||||
var string = safeToString(value);
|
||||
if (string === null) return "<Non-coercible to string value>";
|
||||
// Trim if too long
|
||||
if (string.length > 100) string = string.slice(0, 99) + "…";
|
||||
// Replace eventual new lines
|
||||
string = string.replace(reNewLine, function (char) {
|
||||
switch (char) {
|
||||
case "\n":
|
||||
return "\\n";
|
||||
case "\r":
|
||||
return "\\r";
|
||||
case "\u2028":
|
||||
return "\\u2028";
|
||||
case "\u2029":
|
||||
return "\\u2029";
|
||||
/* istanbul ignore next */
|
||||
default:
|
||||
throw new Error("Unexpected character");
|
||||
}
|
||||
});
|
||||
return string;
|
||||
};
|
12
node_modules/ext/node_modules/type/map/ensure.js
generated
vendored
Normal file
12
node_modules/ext/node_modules/type/map/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, is = require("./is");
|
||||
|
||||
module.exports = function (value /*, options*/) {
|
||||
if (is(value)) return value;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name ? "Expected a map for %n, received %v" : "%v is not a map";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
28
node_modules/ext/node_modules/type/map/is.js
generated
vendored
Normal file
28
node_modules/ext/node_modules/type/map/is.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
"use strict";
|
||||
|
||||
var isPrototype = require("../prototype/is");
|
||||
|
||||
// In theory we could rely on Symbol.toStringTag directly,
|
||||
// still early native implementation (e.g. in FF) predated symbols
|
||||
var objectToString = Object.prototype.toString, objectTaggedString = objectToString.call(new Map());
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!value) return false;
|
||||
|
||||
// Sanity check (reject objects which do not expose common Promise interface)
|
||||
try {
|
||||
if (typeof value.set !== "function") return false;
|
||||
if (typeof value.get !== "function") return false;
|
||||
if (typeof value.has !== "function") return false;
|
||||
if (typeof value.clear !== "function") return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure its native Promise object (has [[MapData]] slot)
|
||||
// Note: it's not 100% precise as string tag may be overriden
|
||||
// and other objects could be hacked to expose it
|
||||
if (objectToString.call(value) !== objectTaggedString) return false;
|
||||
|
||||
return !isPrototype(value);
|
||||
};
|
10
node_modules/ext/node_modules/type/natural-number/coerce.js
generated
vendored
Normal file
10
node_modules/ext/node_modules/type/natural-number/coerce.js
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
"use strict";
|
||||
|
||||
var coerceToInteger = require("../integer/coerce");
|
||||
|
||||
module.exports = function (value) {
|
||||
value = coerceToInteger(value);
|
||||
if (!value) return value;
|
||||
if (value < 0) return null;
|
||||
return value;
|
||||
};
|
21
node_modules/ext/node_modules/type/natural-number/ensure.js
generated
vendored
Normal file
21
node_modules/ext/node_modules/type/natural-number/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, ensureMin = require("../lib/ensure/min")
|
||||
, coerce = require("./coerce");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
var coerced = coerce(value), options = arguments[1];
|
||||
if (coerced !== null) {
|
||||
if (options) {
|
||||
if (options.min) ensureMin(value, coerced, options);
|
||||
}
|
||||
return coerced;
|
||||
}
|
||||
|
||||
var errorMessage =
|
||||
options && options.name
|
||||
? "Expected a natural number for %n, received %v"
|
||||
: "%v is not a natural number";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
14
node_modules/ext/node_modules/type/number/coerce.js
generated
vendored
Normal file
14
node_modules/ext/node_modules/type/number/coerce.js
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
var isValue = require("../value/is");
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!isValue(value)) return null;
|
||||
try {
|
||||
value = +value; // Ensure implicit coercion
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
if (isNaN(value)) return null;
|
||||
return value;
|
||||
};
|
13
node_modules/ext/node_modules/type/number/ensure.js
generated
vendored
Normal file
13
node_modules/ext/node_modules/type/number/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, coerce = require("./coerce");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
var coerced = coerce(value);
|
||||
if (coerced !== null) return coerced;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name ? "Expected a number for %n, received %v" : "%v is not a number";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
12
node_modules/ext/node_modules/type/object/ensure.js
generated
vendored
Normal file
12
node_modules/ext/node_modules/type/object/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, is = require("./is");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
if (is(value)) return value;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name ? "Expected an object for %n, received %v" : "%v is not an object";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
11
node_modules/ext/node_modules/type/object/is.js
generated
vendored
Normal file
11
node_modules/ext/node_modules/type/object/is.js
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
var isValue = require("../value/is");
|
||||
|
||||
// prettier-ignore
|
||||
var possibleTypes = { "object": true, "function": true, "undefined": true /* document.all */ };
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!isValue(value)) return false;
|
||||
return hasOwnProperty.call(possibleTypes, typeof value);
|
||||
};
|
96
node_modules/ext/node_modules/type/package.json
generated
vendored
Normal file
96
node_modules/ext/node_modules/type/package.json
generated
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
{
|
||||
"name": "type",
|
||||
"version": "2.5.0",
|
||||
"description": "Runtime validation and processing of JavaScript types",
|
||||
"author": "Mariusz Nowak <medyk@medikoo.com> (https://www.medikoo.com/)",
|
||||
"keywords": [
|
||||
"type",
|
||||
"coercion"
|
||||
],
|
||||
"repository": "medikoo/type",
|
||||
"devDependencies": {
|
||||
"chai": "^4.3.3",
|
||||
"eslint": "^7.21.0",
|
||||
"eslint-config-medikoo": "^4.0.0",
|
||||
"git-list-updated": "^1.2.1",
|
||||
"husky": "^4.3.8",
|
||||
"lint-staged": "^10.5.4",
|
||||
"mocha": "^6.2.3",
|
||||
"nyc": "^15.1.0",
|
||||
"prettier-elastic": "^2.1.2"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"eslint"
|
||||
],
|
||||
"*.{css,html,js,json,md,yaml,yml}": [
|
||||
"prettier -c"
|
||||
]
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "medikoo/es3",
|
||||
"root": true,
|
||||
"globals": {
|
||||
"Map": true,
|
||||
"Promise": true,
|
||||
"Set": true,
|
||||
"Symbol": true
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": "test/**/*.js",
|
||||
"env": {
|
||||
"mocha": true
|
||||
},
|
||||
"rules": {
|
||||
"no-eval": "off",
|
||||
"no-new-wrappers": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"string/coerce.js",
|
||||
"number/coerce.js"
|
||||
],
|
||||
"rules": {
|
||||
"no-implicit-coercion": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": "plain-object/is.js",
|
||||
"rules": {
|
||||
"no-proto": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"printWidth": 100,
|
||||
"tabWidth": 4,
|
||||
"overrides": [
|
||||
{
|
||||
"files": [
|
||||
"*.md"
|
||||
],
|
||||
"options": {
|
||||
"tabWidth": 2
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "nyc --reporter=lcov --reporter=html --reporter=text-summary npm test",
|
||||
"check-coverage": "npm run coverage && nyc check-coverage --statements 80 --function 80 --branches 80 --lines 80",
|
||||
"lint": "eslint --ignore-path=.gitignore .",
|
||||
"lint-updated": "pipe-git-updated --ext=js -- eslint --ignore-pattern '!*'",
|
||||
"prettier-check-updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c",
|
||||
"prettify": "prettier --write --ignore-path .gitignore '**/*.{css,html,js,json,md,yaml,yml}'",
|
||||
"test": "mocha --recursive"
|
||||
},
|
||||
"license": "ISC"
|
||||
}
|
14
node_modules/ext/node_modules/type/plain-function/ensure.js
generated
vendored
Normal file
14
node_modules/ext/node_modules/type/plain-function/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, is = require("./is");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
if (is(value)) return value;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name
|
||||
? "Expected a plain function for %n, received %v"
|
||||
: "%v is not a plain function";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
11
node_modules/ext/node_modules/type/plain-function/is.js
generated
vendored
Normal file
11
node_modules/ext/node_modules/type/plain-function/is.js
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
"use strict";
|
||||
|
||||
var isFunction = require("../function/is");
|
||||
|
||||
var classRe = /^\s*class[\s{/}]/, functionToString = Function.prototype.toString;
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!isFunction(value)) return false;
|
||||
if (classRe.test(functionToString.call(value))) return false;
|
||||
return true;
|
||||
};
|
67
node_modules/ext/node_modules/type/plain-object/ensure.js
generated
vendored
Normal file
67
node_modules/ext/node_modules/type/plain-object/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,67 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, resolveErrorMessage = require("../lib/resolve-error-message")
|
||||
, ensurePlainFunction = require("../plain-function/ensure")
|
||||
, ensureArray = require("../array/ensure")
|
||||
, is = require("./is");
|
||||
|
||||
var objHasOwnProperty = Object.prototype.hasOwnProperty, invalidItemsLimit = 3;
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
var options = arguments[1];
|
||||
var mainErrorMessage =
|
||||
options && options.name
|
||||
? "Expected a plain object for %n, received %v"
|
||||
: "%v is not a plain object";
|
||||
if (!is(value)) return resolveException(value, mainErrorMessage, options);
|
||||
if (!options) return value;
|
||||
|
||||
var invalidKeys, key, errorMessage;
|
||||
var allowedKeys = ensureArray(options.allowedKeys, { isOptional: true });
|
||||
if (allowedKeys) {
|
||||
for (key in value) {
|
||||
if (!objHasOwnProperty.call(value, key)) continue;
|
||||
if (allowedKeys.indexOf(key) > -1) continue;
|
||||
if (!invalidKeys) invalidKeys = [];
|
||||
if (invalidKeys.push(key) === invalidItemsLimit) break;
|
||||
}
|
||||
if (invalidKeys) {
|
||||
errorMessage =
|
||||
resolveErrorMessage(mainErrorMessage, value, options) +
|
||||
".\n Following keys are unexpected: " +
|
||||
invalidKeys.join(", ");
|
||||
throw new TypeError(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
var ensurePropertyValue = ensurePlainFunction(options.ensurePropertyValue, {
|
||||
isOptional: true
|
||||
});
|
||||
if (ensurePropertyValue) {
|
||||
var coercedValue = {};
|
||||
for (key in value) {
|
||||
if (!objHasOwnProperty.call(value, key)) continue;
|
||||
var coercedPropertyValue;
|
||||
try {
|
||||
coercedPropertyValue = ensurePropertyValue(value[key]);
|
||||
} catch (error) {
|
||||
if (!invalidKeys) invalidKeys = [];
|
||||
if (invalidKeys.push(key) === invalidItemsLimit) break;
|
||||
}
|
||||
if (invalidKeys) continue;
|
||||
coercedValue[key] = coercedPropertyValue;
|
||||
}
|
||||
if (invalidKeys) {
|
||||
errorMessage =
|
||||
resolveErrorMessage(mainErrorMessage, value, options) +
|
||||
".\n Values for following keys are invalid: " +
|
||||
invalidKeys.join(", ");
|
||||
throw new TypeError(errorMessage);
|
||||
}
|
||||
|
||||
return coercedValue;
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
28
node_modules/ext/node_modules/type/plain-object/is.js
generated
vendored
Normal file
28
node_modules/ext/node_modules/type/plain-object/is.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
"use strict";
|
||||
|
||||
var isObject = require("../object/is")
|
||||
, isPrototype = require("../prototype/is");
|
||||
|
||||
var getPrototypeOf;
|
||||
if (typeof Object.getPrototypeOf === "function") {
|
||||
getPrototypeOf = Object.getPrototypeOf;
|
||||
} else if ({}.__proto__ === Object.prototype) {
|
||||
getPrototypeOf = function (object) { return object.__proto__; };
|
||||
}
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!isObject(value)) return false;
|
||||
var prototype;
|
||||
if (getPrototypeOf) {
|
||||
prototype = getPrototypeOf(value);
|
||||
} else {
|
||||
try {
|
||||
var valueConstructor = value.constructor;
|
||||
if (valueConstructor) prototype = valueConstructor.prototype;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (prototype && !hasOwnProperty.call(prototype, "propertyIsEnumerable")) return false;
|
||||
return !isPrototype(value);
|
||||
};
|
12
node_modules/ext/node_modules/type/promise/ensure.js
generated
vendored
Normal file
12
node_modules/ext/node_modules/type/promise/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, is = require("./is");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
if (is(value)) return value;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name ? "Expected a promise for %n, received %v" : "%v is not a promise";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
27
node_modules/ext/node_modules/type/promise/is.js
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/promise/is.js
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
"use strict";
|
||||
|
||||
var isPrototype = require("../prototype/is");
|
||||
|
||||
// In theory we could rely on Symbol.toStringTag directly,
|
||||
// still early native implementation (e.g. in FF) predated symbols
|
||||
var objectToString = Object.prototype.toString
|
||||
, objectTaggedString = objectToString.call(Promise.resolve());
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!value) return false;
|
||||
|
||||
// Sanity check (reject objects which do not expose common Promise interface)
|
||||
try {
|
||||
if (typeof value.then !== "function") return false;
|
||||
if (typeof value["catch"] !== "function") return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure its native Promise object (has [[PromiseState]] slot)
|
||||
// Note: it's not 100% precise as string tag may be overriden
|
||||
// and other objects could be hacked to expose it
|
||||
if (objectToString.call(value) !== objectTaggedString) return false;
|
||||
|
||||
return !isPrototype(value);
|
||||
};
|
13
node_modules/ext/node_modules/type/prototype/is.js
generated
vendored
Normal file
13
node_modules/ext/node_modules/type/prototype/is.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
|
||||
var isObject = require("../object/is");
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!isObject(value)) return false;
|
||||
try {
|
||||
if (!value.constructor) return false;
|
||||
return value.constructor.prototype === value;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
};
|
14
node_modules/ext/node_modules/type/reg-exp/ensure.js
generated
vendored
Normal file
14
node_modules/ext/node_modules/type/reg-exp/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, is = require("./is");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
if (is(value)) return value;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name
|
||||
? "Expected a regular expression for %n, received %v"
|
||||
: "%v is not a regular expression";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
37
node_modules/ext/node_modules/type/reg-exp/is.js
generated
vendored
Normal file
37
node_modules/ext/node_modules/type/reg-exp/is.js
generated
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
"use strict";
|
||||
|
||||
var isToStringTagSupported = require("../lib/is-to-string-tag-supported")
|
||||
, isPrototype = require("../prototype/is");
|
||||
|
||||
var regExpTest = RegExp.prototype.test
|
||||
, objectToString = Object.prototype.toString
|
||||
, objectTaggedString = objectToString.call(/a/);
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!value) return false;
|
||||
|
||||
// Sanity check (reject objects which do not expose common RegExp interface)
|
||||
if (!hasOwnProperty.call(value, "lastIndex")) return false;
|
||||
try {
|
||||
if (typeof value.lastIndex !== "number") return false;
|
||||
if (typeof value.test !== "function") return false;
|
||||
if (typeof value.exec !== "function") return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure its native RegExp object (has [[RegExpMatcher]] slot)
|
||||
if (isToStringTagSupported && typeof value[Symbol.toStringTag] === "string") {
|
||||
// Edge case (possibly a regExp with custom Symbol.toStringTag)
|
||||
try {
|
||||
var lastIndex = value.lastIndex;
|
||||
regExpTest.call(value, "");
|
||||
if (value.lastIndex !== lastIndex) value.lastIndex = lastIndex;
|
||||
return true;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (objectToString.call(value) !== objectTaggedString) return false;
|
||||
return !isPrototype(value);
|
||||
};
|
13
node_modules/ext/node_modules/type/safe-integer/coerce.js
generated
vendored
Normal file
13
node_modules/ext/node_modules/type/safe-integer/coerce.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
|
||||
var coerceToInteger = require("../integer/coerce");
|
||||
|
||||
var MAX_SAFE_INTEGER = 9007199254740991, MIN_SAFE_INTEGER = -9007199254740991;
|
||||
|
||||
module.exports = function (value) {
|
||||
value = coerceToInteger(value);
|
||||
if (!value) return value;
|
||||
if (value > MAX_SAFE_INTEGER) return null;
|
||||
if (value < MIN_SAFE_INTEGER) return null;
|
||||
return value;
|
||||
};
|
15
node_modules/ext/node_modules/type/safe-integer/ensure.js
generated
vendored
Normal file
15
node_modules/ext/node_modules/type/safe-integer/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, coerce = require("./coerce");
|
||||
|
||||
module.exports = function (value/*, options*/) {
|
||||
var coerced = coerce(value);
|
||||
if (coerced !== null) return coerced;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name
|
||||
? "Expected a safe integer for %n, received %v"
|
||||
: "%v is not a safe integer";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
12
node_modules/ext/node_modules/type/set/ensure.js
generated
vendored
Normal file
12
node_modules/ext/node_modules/type/set/ensure.js
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
|
||||
var resolveException = require("../lib/resolve-exception")
|
||||
, is = require("./is");
|
||||
|
||||
module.exports = function (value /*, options*/) {
|
||||
if (is(value)) return value;
|
||||
var options = arguments[1];
|
||||
var errorMessage =
|
||||
options && options.name ? "Expected a set for %n, received %v" : "%v is not a set";
|
||||
return resolveException(value, errorMessage, options);
|
||||
};
|
27
node_modules/ext/node_modules/type/set/is.js
generated
vendored
Normal file
27
node_modules/ext/node_modules/type/set/is.js
generated
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
"use strict";
|
||||
|
||||
var isPrototype = require("../prototype/is");
|
||||
|
||||
// In theory we could rely on Symbol.toStringTag directly,
|
||||
// still early native implementation (e.g. in FF) predated symbols
|
||||
var objectToString = Object.prototype.toString, objectTaggedString = objectToString.call(new Set());
|
||||
|
||||
module.exports = function (value) {
|
||||
if (!value) return false;
|
||||
|
||||
// Sanity check (reject objects which do not expose common Promise interface)
|
||||
try {
|
||||
if (typeof value.add !== "function") return false;
|
||||
if (typeof value.has !== "function") return false;
|
||||
if (typeof value.clear !== "function") return false;
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ensure its native Promise object (has [[SetData]] slot)
|
||||
// Note: it's not 100% precise as string tag may be overriden
|
||||
// and other objects could be hacked to expose it
|
||||
if (objectToString.call(value) !== objectTaggedString) return false;
|
||||
|
||||
return !isPrototype(value);
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue