Added Gulp.js for compiling SCSS stylesheets

This commit is contained in:
2022-11-01 18:49:18 -04:00
parent 7c793dac88
commit 91f72d4893
2956 changed files with 361906 additions and 7 deletions

16
node_modules/type/.editorconfig generated vendored Normal file
View 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

90
node_modules/type/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,90 @@
# 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.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/type/LICENSE generated vendored Normal file
View File

@ -0,0 +1,15 @@
ISC License
Copyright (c) 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.

761
node_modules/type/README.md generated vendored Normal file
View File

@ -0,0 +1,761 @@
[![*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
### 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
Serves following kind of utilities:
##### `*/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 (`%v` can be used as a placeholder for input value)
---
### 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
```
---
### 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
```
---
### 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
```
---
### 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
```
---
#### Finite Number
Finite _number_ primitive
##### `finite/coerce`
Follows [`number/coerce`](#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
```
---
#### Integer Number
Integer _number_ primitive
##### `integer/coerce`
Follows [`finite/coerce`](#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
```
---
#### Safe Integer Number
Safe integer _number_ primitive
##### `safe-integer/coerce`
Follows [`integer/coerce`](#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
```
---
#### Natural Number
Natural _number_ primitive
##### `natural-number/coerce`
Follows [`integer/coerce`](#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
```
---
### 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({}); // {}
ensureArray("foo"); // Thrown TypeError: foo is not a plain object
```
---
### 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
```
---
#### 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-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
```
---
#### Array length
_number_ primitive that conforms as valid _array length_
##### `array-length/coerce`
Follows [`safe-integer/coerce`](#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: null is not a valid array length
```
---
### 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.
```javascript
const ensureIterable = require("type/iterable/ensure");
ensureIterable([]); // []
ensureIterable("foo", { allowString: true }); // "foo"
ensureIterable({}); // Thrown TypeError: null is not expected iterable
```
Additionally items can be coreced with `coerceItem` option. Note that in this case:
- A newly created array with coerced values is returned
- Validation crashes if any of the items is not coercible
```javascript
ensureIterable(new Set(["foo", 12])); // ["foo", "12"]
ensureIterable(new Set(["foo", {}])); // Thrown TypeError: Set({ "foo", {} }) is not expected iterable
```
---
### 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
```
---
### Time value
_number_ primitive which is a valid _time value_ (as used internally in _Date_ instances)
#### `time-value/coerce`
Follows [`integer/coerce`](#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
```
---
### 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
```
---
#### 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
```
---
### 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
```
---
### 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
```
---
#### 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
```
---
### 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
```
---
### 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
```
### 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/type/array-length/coerce.js generated vendored Normal file
View 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;
};

10
node_modules/type/array-length/ensure.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
"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;
return resolveException(value, "%v is not a valid array length", arguments[1]);
};

9
node_modules/type/array-like/ensure.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, is = require("./is");
module.exports = function (value/*, options*/) {
if (is(value, arguments[1])) return value;
return resolveException(value, "%v is not an array like value", arguments[1]);
};

21
node_modules/type/array-like/is.js generated vendored Normal file
View 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;
};

9
node_modules/type/array/ensure.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, is = require("./is");
module.exports = function (value/*, options*/) {
if (is(value)) return value;
return resolveException(value, "%v is not an array object", arguments[1]);
};

27
node_modules/type/array/is.js generated vendored Normal file
View 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);
};

9
node_modules/type/date/ensure.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, is = require("./is");
module.exports = function (value/*, options*/) {
if (is(value)) return value;
return resolveException(value, "%v is not a date object", arguments[1]);
};

26
node_modules/type/date/is.js generated vendored Normal file
View 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);
};

9
node_modules/type/error/ensure.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, is = require("./is");
module.exports = function (value/*, options*/) {
if (is(value)) return value;
return resolveException(value, "%v is not an error object", arguments[1]);
};

45
node_modules/type/error/is.js generated vendored Normal file
View 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/type/finite/coerce.js generated vendored Normal file
View File

@ -0,0 +1,8 @@
"use strict";
var coerceToNumber = require("../number/coerce");
module.exports = function (value) {
value = coerceToNumber(value);
return isFinite(value) ? value : null;
};

10
node_modules/type/finite/ensure.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
"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;
return resolveException(value, "%v is not a finite number", arguments[1]);
};

9
node_modules/type/function/ensure.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, is = require("./is");
module.exports = function (value/*, options*/) {
if (is(value)) return value;
return resolveException(value, "%v is not a function", arguments[1]);
};

19
node_modules/type/function/is.js generated vendored Normal file
View 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/type/integer/coerce.js generated vendored Normal file
View 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));
};

10
node_modules/type/integer/ensure.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
"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;
return resolveException(value, "%v is not an integer", arguments[1]);
};

29
node_modules/type/iterable/ensure.js generated vendored Normal file
View File

@ -0,0 +1,29 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, isValue = require("../value/is")
, is = require("./is");
var resolveCoercedValue = function (value, coerceItem) {
var coercedValue = [];
var iterator = value[Symbol.iterator]();
var item;
while (!(item = iterator.next()).done) {
var newItemValue = coerceItem(item.value);
if (!isValue(newItemValue)) throw new Error("Stop propagation");
coercedValue.push(newItemValue);
}
return coercedValue;
};
module.exports = function (value/*, options*/) {
var options = arguments[1];
if (is(value, options)) {
if (!options) return value;
if (typeof options.coerceItem !== "function") return value;
try { return resolveCoercedValue(value, options.coerceItem); }
catch (error) {
// Ignore, let validation error propagate
}
}
return resolveException(value, "%v is not expected iterable value", options);
};

32
node_modules/type/iterable/is.js generated vendored Normal file
View 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;
};

3
node_modules/type/lib/is-to-string-tag-supported.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
"use strict";
module.exports = typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol";

21
node_modules/type/lib/resolve-exception.js generated vendored Normal file
View File

@ -0,0 +1,21 @@
"use strict";
var isValue = require("../value/is")
, isObject = require("../object/is")
, stringCoerce = require("../string/coerce")
, toShortString = require("./to-short-string");
var resolveMessage = function (message, value) {
return message.replace("%v", toShortString(value));
};
module.exports = function (value, defaultMessage, inputOptions) {
if (!isObject(inputOptions)) throw new TypeError(resolveMessage(defaultMessage, value));
if (!isValue(value)) {
if ("default" in inputOptions) return inputOptions["default"];
if (inputOptions.isOptional) return null;
}
var errorMessage = stringCoerce(inputOptions.errorMessage);
if (!isValue(errorMessage)) errorMessage = defaultMessage;
throw new TypeError(resolveMessage(errorMessage, value));
};

10
node_modules/type/lib/safe-to-string.js generated vendored Normal file
View 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/type/lib/to-short-string.js generated vendored Normal file
View 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;
};

10
node_modules/type/natural-number/coerce.js generated vendored Normal file
View 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;
};

10
node_modules/type/natural-number/ensure.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
"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;
return resolveException(value, "%v is not a natural number", arguments[1]);
};

14
node_modules/type/number/coerce.js generated vendored Normal file
View 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;
};

10
node_modules/type/number/ensure.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
"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;
return resolveException(value, "%v is not a number", arguments[1]);
};

9
node_modules/type/object/ensure.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, is = require("./is");
module.exports = function (value/*, options*/) {
if (is(value)) return value;
return resolveException(value, "%v is not an object", arguments[1]);
};

11
node_modules/type/object/is.js generated vendored Normal file
View 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/type/package.json generated vendored Normal file
View File

@ -0,0 +1,96 @@
{
"name": "type",
"version": "1.2.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.2.0",
"eslint": "^6.4.0",
"eslint-config-medikoo": "^2.5.1",
"git-list-updated": "^1.2.1",
"husky": "^3.0.5",
"lint-staged": "^9.2.5",
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"prettier-elastic": "^1.18.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"
}

9
node_modules/type/plain-function/ensure.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, is = require("./is");
module.exports = function (value/*, options*/) {
if (is(value)) return value;
return resolveException(value, "%v is not a plain function", arguments[1]);
};

11
node_modules/type/plain-function/is.js generated vendored Normal file
View 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;
};

9
node_modules/type/plain-object/ensure.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, is = require("./is");
module.exports = function (value/*, options*/) {
if (is(value)) return value;
return resolveException(value, "%v is not a plain object", arguments[1]);
};

28
node_modules/type/plain-object/is.js generated vendored Normal file
View 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);
};

9
node_modules/type/promise/ensure.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, is = require("./is");
module.exports = function (value/*, options*/) {
if (is(value)) return value;
return resolveException(value, "%v is not a promise", arguments[1]);
};

27
node_modules/type/promise/is.js generated vendored Normal file
View 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/type/prototype/is.js generated vendored Normal file
View 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;
}
};

9
node_modules/type/reg-exp/ensure.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, is = require("./is");
module.exports = function (value/*, options*/) {
if (is(value)) return value;
return resolveException(value, "%v is not a regular expression object", arguments[1]);
};

37
node_modules/type/reg-exp/is.js generated vendored Normal file
View 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/type/safe-integer/coerce.js generated vendored Normal file
View 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;
};

10
node_modules/type/safe-integer/ensure.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
"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;
return resolveException(value, "%v is not a safe integer", arguments[1]);
};

23
node_modules/type/string/coerce.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
"use strict";
var isValue = require("../value/is")
, isObject = require("../object/is");
var objectToString = Object.prototype.toString;
module.exports = function (value) {
if (!isValue(value)) return null;
if (isObject(value)) {
// Reject Object.prototype.toString coercion
var valueToString = value.toString;
if (typeof valueToString !== "function") return null;
if (valueToString === objectToString) return null;
// Note: It can be object coming from other realm, still as there's no ES3 and CSP compliant
// way to resolve its realm's Object.prototype.toString it's left as not addressed edge case
}
try {
return "" + value; // Ensure implicit coercion
} catch (error) {
return null;
}
};

10
node_modules/type/string/ensure.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
"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;
return resolveException(value, "%v is not a string", arguments[1]);
};

View File

@ -0,0 +1,4 @@
"use strict";
try { module.exports = eval("(() => {})"); }
catch (error) {}

4
node_modules/type/test/_lib/class-if-supported.js generated vendored Normal file
View File

@ -0,0 +1,4 @@
"use strict";
try { module.exports = eval("(class {})"); }
catch (error) {}

47
node_modules/type/test/array-length/coerce.js generated vendored Normal file
View File

@ -0,0 +1,47 @@
"use strict";
var assert = require("chai").assert
, coerceToArrayLength = require("../../array-length/coerce");
describe("array-length/coerce", function () {
it("Should coerce float", function () {
assert.equal(coerceToArrayLength(123.123), 123);
assert.equal(coerceToArrayLength(123.823), 123);
});
it("Should coerce string", function () { assert.equal(coerceToArrayLength("12.123"), 12); });
it("Should coerce booleans", function () { assert.equal(coerceToArrayLength(true), 1); });
it("Should coerce number objects", function () {
assert.equal(coerceToArrayLength(new Number(343)), 343);
});
it("Should coerce objects", function () {
assert.equal(coerceToArrayLength({ valueOf: function () { return 23; } }), 23);
});
it("Should reject infinite number", function () {
assert.equal(coerceToArrayLength(Infinity), null);
});
it("Should reject number beyond Number.MAX_SAFE_INTEGER", function () {
assert.equal(coerceToArrayLength(9007199254740992), null);
});
it("Should reject negative number", function () {
assert.equal(coerceToArrayLength(-9), null);
});
it("Should reject NaN", function () { assert.equal(coerceToArrayLength(NaN), null); });
if (typeof Object.create === "function") {
it("Should not coerce objects with no number representation", function () {
assert.equal(coerceToArrayLength(Object.create(null)), null);
});
}
it("Should not coerce null", function () { assert.equal(coerceToArrayLength(null), null); });
it("Should not coerce undefined", function () {
assert.equal(coerceToArrayLength(undefined), null);
});
if (typeof Symbol === "function") {
it("Should not coerce symbols", function () {
assert.equal(coerceToArrayLength(Symbol("foo")), null);
});
}
});

19
node_modules/type/test/array-length/ensure.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
"use strict";
var assert = require("chai").assert
, ensureArrayLength = require("../../array-length/ensure");
describe("array-length/ensure", function () {
it("Should return coerced value", function () {
assert.equal(ensureArrayLength("12.23"), 12);
});
it("Should crash on no value", function () {
try {
ensureArrayLength(-20);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert.equal(error.message, "-20 is not a valid array length");
}
});
});

24
node_modules/type/test/array-like/ensure.js generated vendored Normal file
View File

@ -0,0 +1,24 @@
"use strict";
var assert = require("chai").assert
, ensureArrayLike = require("../../array-like/ensure");
describe("array-like/ensure", function () {
it("Should return input value", function () {
var value = [];
assert.equal(ensureArrayLike(value), value);
});
it("Should allow strings with allowString option", function () {
var value = "foo";
assert.equal(ensureArrayLike(value, { allowString: true }), value);
});
it("Should crash on invalid value", function () {
try {
ensureArrayLike("foo");
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert(error.message.includes("is not an array like value"));
}
});
});

47
node_modules/type/test/array-like/is.js generated vendored Normal file
View File

@ -0,0 +1,47 @@
"use strict";
var assert = require("chai").assert
, isArrayLike = require("../../array-like/is");
describe("array-like/is", function () {
it("Should return true on array", function () { assert.equal(isArrayLike([]), true); });
it("Should return true on array-like object", function () {
assert.equal(isArrayLike({ length: 1 }), true);
});
it("Should by default return false on string", function () {
assert.equal(isArrayLike("foo"), false);
});
it("Should accept strings if specified", function () {
assert.equal(isArrayLike("foo", { allowString: true }), true);
});
it("Should return false on objects with negative length", function () {
assert.equal(isArrayLike({ length: -1 }), false);
});
it("Should return false on plain object", function () {
assert.equal(isArrayLike({}), false);
});
it("Should return false on function", function () {
assert.equal(isArrayLike(function () { return true; }), false);
});
if (typeof Object.create === "function") {
it("Should return false on object with no prototype", function () {
assert.equal(isArrayLike(Object.create(null)), false);
});
}
it("Should return false on number", function () { assert.equal(isArrayLike(123), false); });
it("Should return false on NaN", function () { assert.equal(isArrayLike(NaN), false); });
it("Should return false on boolean", function () { assert.equal(isArrayLike(true), false); });
if (typeof Symbol === "function") {
it("Should return false on symbol", function () {
assert.equal(isArrayLike(Symbol("foo")), false);
});
}
it("Should return false on null", function () { assert.equal(isArrayLike(null), false); });
it("Should return false on undefined", function () {
assert.equal(isArrayLike(void 0), false);
});
});

20
node_modules/type/test/array/ensure.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var assert = require("chai").assert
, ensureArray = require("../../array/ensure");
describe("array/ensure", function () {
it("Should return input value", function () {
var value = [];
assert.equal(ensureArray(value), value);
});
it("Should crash on invalid value", function () {
try {
ensureArray(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert(error.message.includes("is not an array object"));
}
});
});

41
node_modules/type/test/array/is.js generated vendored Normal file
View File

@ -0,0 +1,41 @@
"use strict";
var assert = require("chai").assert
, isArray = require("../../array/is");
describe("array/is", function () {
it("Should return true on array", function () { assert.equal(isArray([]), true); });
it("Should return false on array with no common API exposed", function () {
var value = [];
value.push = null;
assert.equal(isArray(value), false);
});
it("Should return false on Array.prototype", function () {
assert.equal(isArray(Array.prototype), false);
});
it("Should return false on plain object", function () { assert.equal(isArray({}), false); });
it("Should return false on function", function () {
assert.equal(isArray(function () { return true; }), false);
});
if (typeof Object.create === "function") {
it("Should return false on object with no prototype", function () {
assert.equal(isArray(Object.create(null)), false);
});
}
it("Should return false on string", function () { assert.equal(isArray("foo"), false); });
it("Should return false on empty string", function () { assert.equal(isArray(""), false); });
it("Should return false on number", function () { assert.equal(isArray(123), false); });
it("Should return false on NaN", function () { assert.equal(isArray(NaN), false); });
it("Should return false on boolean", function () { assert.equal(isArray(true), false); });
if (typeof Symbol === "function") {
it("Should return false on symbol", function () {
assert.equal(isArray(Symbol("foo")), false);
});
}
it("Should return false on null", function () { assert.equal(isArray(null), false); });
it("Should return false on undefined", function () { assert.equal(isArray(void 0), false); });
});

20
node_modules/type/test/date/ensure.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var assert = require("chai").assert
, ensureDate = require("../../date/ensure");
describe("date/ensure", function () {
it("Should return input value", function () {
var value = new Date();
assert.equal(ensureDate(value), value);
});
it("Should crash on invalid value", function () {
try {
ensureDate(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert(error.message.includes("is not a date object"));
}
});
});

46
node_modules/type/test/date/is.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
"use strict";
var assert = require("chai").assert
, isDate = require("../../date/is");
describe("date/is", function () {
it("Should return true on date", function () { assert.equal(isDate(new Date()), true); });
it("Should return false on invalid date", function () {
assert.equal(isDate(new Date("foo")), false);
});
it("Should return false on native date with no common API exposed", function () {
var value = new Date();
value.getFullYear = null;
assert.equal(isDate(value), false);
});
it("Should return false on Date.prototype", function () {
assert.equal(isDate(Date.prototype), false);
});
it("Should return false on time value", function () { assert.equal(isDate(12312313), false); });
it("Should return false on plain object", function () { assert.equal(isDate({}), false); });
it("Should return false on function", function () {
assert.equal(isDate(function () { return true; }), false);
});
it("Should return false on array", function () { assert.equal(isDate([]), false); });
if (typeof Object.create === "function") {
it("Should return false on object with no prototype", function () {
assert.equal(isDate(Object.create(null)), false);
});
}
it("Should return false on string", function () { assert.equal(isDate("foo"), false); });
it("Should return false on empty string", function () { assert.equal(isDate(""), false); });
it("Should return false on number", function () { assert.equal(isDate(123), false); });
it("Should return false on NaN", function () { assert.equal(isDate(NaN), false); });
it("Should return false on boolean", function () { assert.equal(isDate(true), false); });
if (typeof Symbol === "function") {
it("Should return false on symbol", function () {
assert.equal(isDate(Symbol("foo")), false);
});
}
it("Should return false on null", function () { assert.equal(isDate(null), false); });
it("Should return false on undefined", function () { assert.equal(isDate(void 0), false); });
});

20
node_modules/type/test/error/ensure.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var assert = require("chai").assert
, ensureError = require("../../error/ensure");
describe("error/ensure", function () {
it("Should return input value", function () {
var value = new Error();
assert.equal(ensureError(value), value);
});
it("Should crash on invalid value", function () {
try {
ensureError(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert(error.message.includes("is not an error object"));
}
});
});

50
node_modules/type/test/error/is.js generated vendored Normal file
View File

@ -0,0 +1,50 @@
"use strict";
var assert = require("chai").assert
, isError = require("../../error/is");
describe("error/is", function () {
it("Should return true on error", function () { assert.equal(isError(new Error()), true); });
it("Should return false on native error with no common API exposed", function () {
var value = new Error();
value.message = null;
assert.equal(isError(value), false);
});
it("Should return false on Error.prototype", function () {
assert.equal(isError(Error.prototype), false);
});
if (typeof Object.create === "function") {
it("Should return true on custom built ES5 era error", function () {
var CustomEs5Error = function () { Error.call(this); };
CustomEs5Error.prototype = Object.create(Error.prototype);
assert.equal(isError(new CustomEs5Error()), true);
});
it("Should return false on object with no prototype", function () {
assert.equal(isError(Object.create(null)), false);
});
}
it("Should return false on plain object", function () { assert.equal(isError({}), false); });
it("Should return false on function", function () {
assert.equal(isError(function () { return true; }), false);
});
it("Should return false on array", function () { assert.equal(isError([]), false); });
it("Should return false on string", function () { assert.equal(isError("foo"), false); });
it("Should return false on empty string", function () { assert.equal(isError(""), false); });
it("Should return false on number", function () { assert.equal(isError(123), false); });
it("Should return false on NaN", function () { assert.equal(isError(NaN), false); });
it("Should return false on boolean", function () { assert.equal(isError(true), false); });
if (typeof Symbol === "function") {
it("Should return false on symbol", function () {
assert.equal(isError(Symbol("foo")), false);
});
}
it("Should return false on null", function () { assert.equal(isError(null), false); });
it("Should return false on undefined", function () { assert.equal(isError(void 0), false); });
});

40
node_modules/type/test/finite/coerce.js generated vendored Normal file
View File

@ -0,0 +1,40 @@
"use strict";
var assert = require("chai").assert
, coerceToFinite = require("../../finite/coerce");
describe("finite/coerce", function () {
it("Should return input number", function () {
assert.equal(coerceToFinite(123.123), 123.123);
});
it("Should coerce string", function () { assert.equal(coerceToFinite("12"), 12); });
it("Should coerce booleans", function () { assert.equal(coerceToFinite(true), 1); });
it("Should coerce number objects", function () {
assert.equal(coerceToFinite(new Number(343)), 343);
});
it("Should coerce objects", function () {
assert.equal(coerceToFinite({ valueOf: function () { return 23; } }), 23);
});
it("Should reject infinite number", function () {
assert.equal(coerceToFinite(Infinity), null);
});
it("Should reject NaN", function () { assert.equal(coerceToFinite(NaN), null); });
if (typeof Object.create === "function") {
it("Should not coerce objects with no number representation", function () {
assert.equal(coerceToFinite(Object.create(null)), null);
});
}
it("Should not coerce null", function () { assert.equal(coerceToFinite(null), null); });
it("Should not coerce undefined", function () {
assert.equal(coerceToFinite(undefined), null);
});
if (typeof Symbol === "function") {
it("Should not coerce symbols", function () {
assert.equal(coerceToFinite(Symbol("foo")), null);
});
}
});

17
node_modules/type/test/finite/ensure.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
"use strict";
var assert = require("chai").assert
, ensureFinite = require("../../finite/ensure");
describe("finite/ensure", function () {
it("Should return coerced value", function () { assert.equal(ensureFinite("12.23"), 12.23); });
it("Should crash on no value", function () {
try {
ensureFinite(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert.equal(error.message, "null is not a finite number");
}
});
});

20
node_modules/type/test/function/ensure.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var assert = require("chai").assert
, ensureFunction = require("../../function/ensure");
describe("function/ensure", function () {
it("Should return input value", function () {
var value = function () { return true; };
assert.equal(ensureFunction(value), value);
});
it("Should crash on invalid value", function () {
try {
ensureFunction(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert(error.message.includes("is not a function"));
}
});
});

46
node_modules/type/test/function/is.js generated vendored Normal file
View File

@ -0,0 +1,46 @@
"use strict";
var assert = require("chai").assert
, isFunction = require("../../function/is")
, arrowFunctionIfSupported = require("../_lib/arrow-function-if-supported")
, classIfSupported = require("../_lib/class-if-supported");
describe("function/is", function () {
it("Should return true on function", function () {
assert.equal(isFunction(function () { return true; }), true);
});
if (arrowFunctionIfSupported) {
it("Should return true on arrow function", function () {
assert.equal(isFunction(arrowFunctionIfSupported), true);
});
}
if (classIfSupported) {
it("Should return true on class", function () {
assert.equal(isFunction(classIfSupported), true);
});
}
it("Should return false on reg-exp", function () { assert.equal(isFunction(/foo/), false); });
it("Should return false on plain object", function () { assert.equal(isFunction({}), false); });
it("Should return false on array", function () { assert.equal(isFunction([]), false); });
if (typeof Object.create === "function") {
it("Should return false on object with no prototype", function () {
assert.equal(isFunction(Object.create(null)), false);
});
}
it("Should return false on string", function () { assert.equal(isFunction("foo"), false); });
it("Should return false on empty string", function () { assert.equal(isFunction(""), false); });
it("Should return false on number", function () { assert.equal(isFunction(123), false); });
it("Should return false on NaN", function () { assert.equal(isFunction(NaN), false); });
it("Should return false on boolean", function () { assert.equal(isFunction(true), false); });
if (typeof Symbol === "function") {
it("Should return false on symbol", function () {
assert.equal(isFunction(Symbol("foo")), false);
});
}
it("Should return false on null", function () { assert.equal(isFunction(null), false); });
it("Should return false on undefined", function () {
assert.equal(isFunction(void 0), false);
});
});

49
node_modules/type/test/integer/coerce.js generated vendored Normal file
View File

@ -0,0 +1,49 @@
"use strict";
var assert = require("chai").assert
, coerceToInteger = require("../../integer/coerce");
describe("integer/coerce", function () {
it("Should coerce float to integer", function () {
assert.equal(coerceToInteger(123.123), 123);
assert.equal(coerceToInteger(123.823), 123);
assert.equal(coerceToInteger(-123.123), -123);
assert.equal(coerceToInteger(-123.823), -123);
});
it("Should coerce string", function () { assert.equal(coerceToInteger("12.123"), 12); });
it("Should coerce booleans", function () { assert.equal(coerceToInteger(true), 1); });
it("Should coerce number objects", function () {
assert.equal(coerceToInteger(new Number(343)), 343);
});
it("Should coerce objects", function () {
assert.equal(coerceToInteger({ valueOf: function () { return 23; } }), 23);
});
it("Should coerce number beyond Number.MAX_SAFE_INTEGER", function () {
assert.equal(coerceToInteger(9007199254740992), 9007199254740992);
});
it("Should coerce number beyond Number.MIN_SAFE_INTEGER", function () {
assert.equal(coerceToInteger(-9007199254740992), -9007199254740992);
});
it("Should reject infinite number", function () {
assert.equal(coerceToInteger(Infinity), null);
});
it("Should reject NaN", function () { assert.equal(coerceToInteger(NaN), null); });
if (typeof Object.create === "function") {
it("Should not coerce objects with no number representation", function () {
assert.equal(coerceToInteger(Object.create(null)), null);
});
}
it("Should not coerce null", function () { assert.equal(coerceToInteger(null), null); });
it("Should not coerce undefined", function () {
assert.equal(coerceToInteger(undefined), null);
});
if (typeof Symbol === "function") {
it("Should not coerce symbols", function () {
assert.equal(coerceToInteger(Symbol("foo")), null);
});
}
});

17
node_modules/type/test/integer/ensure.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
"use strict";
var assert = require("chai").assert
, ensureInteger = require("../../integer/ensure");
describe("integer/ensure", function () {
it("Should return coerced value", function () { assert.equal(ensureInteger("12.23"), 12); });
it("Should crash on no value", function () {
try {
ensureInteger(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert.equal(error.message, "null is not an integer");
}
});
});

42
node_modules/type/test/iterable/ensure.js generated vendored Normal file
View File

@ -0,0 +1,42 @@
"use strict";
var assert = require("chai").assert
, coerceString = require("../../string/coerce")
, isArray = require("../../array/is")
, ensureIterable = require("../../iterable/ensure");
describe("iterable/ensure", function () {
it("Should return input value", function () {
var value = [];
assert.equal(ensureIterable(value), value);
});
it("Should allow strings with allowString option", function () {
var value = "foo";
assert.equal(ensureIterable(value, { allowString: true }), value);
});
it("Should crash on invalid value", function () {
try {
ensureIterable("foo");
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert(error.message.includes("is not expected iterable value"));
}
});
describe("Should support 'coerceItem' option", function () {
it("Should resolve coerced array", function () {
var coercedValue = ensureIterable(new Set(["foo", 12]), { coerceItem: coerceString });
assert(isArray(coercedValue));
assert.deepEqual(coercedValue, ["foo", "12"]);
});
it("Should crash if some value is non coercible", function () {
try {
ensureIterable(["foo", {}], { coerceItem: coerceString });
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert(error.message.includes("is not expected iterable value"));
}
});
});
});

57
node_modules/type/test/iterable/is.js generated vendored Normal file
View File

@ -0,0 +1,57 @@
"use strict";
var assert = require("chai").assert
, isIterable = require("../../iterable/is");
describe("iterable/is", function () {
it("Should return true on array", function () { assert.equal(isIterable([]), true); });
it("Should return true on arguments", function () {
assert.equal(isIterable((function () { return arguments; })()), true);
});
it("Should by default return false on string", function () {
assert.equal(isIterable("foo"), false);
});
it("Should accept strings if specified", function () {
assert.equal(isIterable("foo", { allowString: true }), true);
});
it("Should support denyEmpty option", function () {
assert.equal(isIterable([], { denyEmpty: true }), false);
assert.equal(isIterable([null], { denyEmpty: true }), true);
assert.equal(isIterable("", { allowString: true, denyEmpty: true }), false);
assert.equal(isIterable("foo", { allowString: true, denyEmpty: true }), true);
});
if (typeof Set === "function") {
it("Should return true on set", function () { assert.equal(isIterable(new Set()), true); });
}
if (typeof Map === "function") {
it("Should return true on set", function () { assert.equal(isIterable(new Map()), true); });
}
it("Should return false on plain object", function () { assert.equal(isIterable({}), false); });
it("Should return false on function", function () {
assert.equal(isIterable(function () { return true; }), false);
});
if (typeof Object.create === "function") {
it("Should return false on object with no prototype", function () {
assert.equal(isIterable(Object.create(null)), false);
});
}
it("Should return false on string", function () { assert.equal(isIterable("foo"), false); });
it("Should return false on empty string", function () { assert.equal(isIterable(""), false); });
it("Should return false on number", function () { assert.equal(isIterable(123), false); });
it("Should return false on NaN", function () { assert.equal(isIterable(NaN), false); });
it("Should return false on boolean", function () { assert.equal(isIterable(true), false); });
if (typeof Symbol === "function") {
it("Should return false on symbol", function () {
assert.equal(isIterable(Symbol("foo")), false);
});
}
it("Should return false on null", function () { assert.equal(isIterable(null), false); });
it("Should return false on undefined", function () {
assert.equal(isIterable(void 0), false);
});
});

View File

@ -0,0 +1,10 @@
"use strict";
var assert = require("chai").assert
, isToStringTagSupported = require("../../lib/is-to-string-tag-supported");
describe("lib/is-to-string-tag-supported", function () {
it("Should return boolean", function () {
assert(typeof isToStringTagSupported === "boolean");
});
});

39
node_modules/type/test/lib/resolve-exception.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
"use strict";
var assert = require("chai").assert
, handleException = require("../../lib/resolve-exception");
describe("lib/handle-exception", function () {
it("Should throw TypeError", function () {
try {
handleException(12, "Invalid value");
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert.equal(error.message, "Invalid value");
}
});
it("Should resolve value in default message", function () {
try {
handleException(12, "%v is invalid", {});
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.message, "12 is invalid");
}
});
it("Should support optional values via inputOptions.isOptional", function () {
assert.equal(handleException(null, "%v is invalid", { isOptional: true }, null));
});
it("Should support optional values via inputOptions.default", function () {
// prettier-ignore
assert.equal(handleException(null, "%v is invalid", { "default": "bar" }), "bar");
});
it("Should support custome error message via inputOptions.errorMessage", function () {
try {
handleException(null, "%v is invalid", { errorMessage: "%v is not supported age" });
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.message, "null is not supported age");
}
});
});

32
node_modules/type/test/lib/safe-to-string.js generated vendored Normal file
View File

@ -0,0 +1,32 @@
"use strict";
var assert = require("chai").assert
, safeToString = require("../../lib/safe-to-string");
describe("lib/safe-to-string", function () {
it("Should return input string", function () { assert.equal(safeToString("foo"), "foo"); });
it("Should coerce numbers", function () { assert.equal(safeToString(12), "12"); });
it("Should coerce booleans", function () { assert.equal(safeToString(true), "true"); });
it("Should coerce string objects", function () {
assert.equal(safeToString(new String("bar")), "bar");
});
it("Should coerce objects", function () {
assert.equal(
safeToString({ toString: function () { return "Some object"; } }), "Some object"
);
});
it("Should coerce null", function () { assert.equal(safeToString(null), "null"); });
it("Should coerce undefined", function () {
assert.equal(safeToString(undefined), "undefined");
});
if (typeof Symbol === "function") {
it("Should coerce symbols", function () {
// eslint-disable-next-line no-undef
assert.equal(safeToString(Symbol()), "Symbol()");
});
}
it("Should return null for non coercible values", function () {
assert.equal(safeToString({ toString: null }), null);
});
});

41
node_modules/type/test/lib/to-short-string.js generated vendored Normal file
View File

@ -0,0 +1,41 @@
"use strict";
var assert = require("chai").assert
, toShortString = require("../../lib/to-short-string");
describe("lib/to-short-string", function () {
it("Should return input string", function () { assert.equal(toShortString("foo"), "foo"); });
it("Should coerce numbers", function () { assert.equal(toShortString(12), "12"); });
it("Should coerce booleans", function () { assert.equal(toShortString(true), "true"); });
it("Should coerce string objects", function () {
assert.equal(toShortString(new String("bar")), "bar");
});
it("Should coerce objects", function () {
assert.equal(
toShortString({ toString: function () { return "Some object"; } }), "Some object"
);
});
it("Should coerce null", function () { assert.equal(toShortString(null), "null"); });
it("Should coerce undefined", function () {
assert.equal(toShortString(undefined), "undefined");
});
if (typeof Symbol === "function") {
it("Should coerce symbols", function () {
// eslint-disable-next-line no-undef
assert.equal(toShortString(Symbol()), "Symbol()");
});
}
it("Should return replacement non coercible values", function () {
assert.equal(toShortString({ toString: null }), "<Non-coercible to string value>");
});
it("Should replace new line characters", function () {
assert.equal(toShortString("foo\n\r\u2028\u2029bar"), "foo\\n\\r\\u2028\\u2029bar");
});
it("Should truncate long string", function () {
var str = Math.random().toString(36);
while (str.length < 200) str += str;
assert.equal(toShortString(str).length, 100);
});
});

47
node_modules/type/test/natural-number/coerce.js generated vendored Normal file
View File

@ -0,0 +1,47 @@
"use strict";
var assert = require("chai").assert
, coerceToNaturalNumber = require("../../natural-number/coerce");
describe("natural-number/coerce", function () {
it("Should coerce float to integer", function () {
assert.equal(coerceToNaturalNumber(123.123), 123);
assert.equal(coerceToNaturalNumber(123.823), 123);
});
it("Should coerce string", function () { assert.equal(coerceToNaturalNumber("12.123"), 12); });
it("Should coerce booleans", function () { assert.equal(coerceToNaturalNumber(true), 1); });
it("Should coerce number objects", function () {
assert.equal(coerceToNaturalNumber(new Number(343)), 343);
});
it("Should coerce objects", function () {
assert.equal(coerceToNaturalNumber({ valueOf: function () { return 23; } }), 23);
});
it("Should coerce number beyond Number.MAX_SAFE_INTEGER", function () {
assert.equal(coerceToNaturalNumber(9007199254740992), 9007199254740992);
});
it("Should reject negative number", function () {
assert.equal(coerceToNaturalNumber(-1), null);
});
it("Should reject infinite number", function () {
assert.equal(coerceToNaturalNumber(Infinity), null);
});
it("Should reject NaN", function () { assert.equal(coerceToNaturalNumber(NaN), null); });
if (typeof Object.create === "function") {
it("Should not coerce objects with no number representation", function () {
assert.equal(coerceToNaturalNumber(Object.create(null)), null);
});
}
it("Should not coerce null", function () { assert.equal(coerceToNaturalNumber(null), null); });
it("Should not coerce undefined", function () {
assert.equal(coerceToNaturalNumber(undefined), null);
});
if (typeof Symbol === "function") {
it("Should not coerce symbols", function () {
assert.equal(coerceToNaturalNumber(Symbol("foo")), null);
});
}
});

19
node_modules/type/test/natural-number/ensure.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
"use strict";
var assert = require("chai").assert
, ensureNaturalNumber = require("../../natural-number/ensure");
describe("natural-number/ensure", function () {
it("Should return coerced value", function () {
assert.equal(ensureNaturalNumber("12.23"), 12);
});
it("Should crash on no value", function () {
try {
ensureNaturalNumber(-20);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert.equal(error.message, "-20 is not a natural number");
}
});
});

40
node_modules/type/test/number/coerce.js generated vendored Normal file
View File

@ -0,0 +1,40 @@
"use strict";
var assert = require("chai").assert
, coerceToNumber = require("../../number/coerce");
describe("number/coerce", function () {
it("Should return input number", function () {
assert.equal(coerceToNumber(123.123), 123.123);
});
it("Should return input infinite number", function () {
assert.equal(coerceToNumber(Infinity), Infinity);
});
it("Should coerce string", function () { assert.equal(coerceToNumber("12"), 12); });
it("Should coerce booleans", function () { assert.equal(coerceToNumber(true), 1); });
it("Should coerce number objects", function () {
assert.equal(coerceToNumber(new Number(343)), 343);
});
it("Should coerce objects", function () {
assert.equal(coerceToNumber({ valueOf: function () { return 23; } }), 23);
});
it("Should reject NaN", function () { assert.equal(coerceToNumber(NaN), null); });
if (typeof Object.create === "function") {
it("Should not coerce objects with no number representation", function () {
assert.equal(coerceToNumber(Object.create(null)), null);
});
}
it("Should not coerce null", function () { assert.equal(coerceToNumber(null), null); });
it("Should not coerce undefined", function () {
assert.equal(coerceToNumber(undefined), null);
});
if (typeof Symbol === "function") {
it("Should not coerce symbols", function () {
assert.equal(coerceToNumber(Symbol("foo")), null);
});
}
});

17
node_modules/type/test/number/ensure.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
"use strict";
var assert = require("chai").assert
, ensureNumber = require("../../number/ensure");
describe("number/ensure", function () {
it("Should return coerced value", function () { assert.equal(ensureNumber("12.23"), 12.23); });
it("Should crash on no value", function () {
try {
ensureNumber(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert.equal(error.message, "null is not a number");
}
});
});

20
node_modules/type/test/object/ensure.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var assert = require("chai").assert
, ensureObject = require("../../object/ensure");
describe("object/ensure", function () {
it("Should return input value", function () {
var value = {};
assert.equal(ensureObject(value), value);
});
it("Should crash on no value", function () {
try {
ensureObject(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert.equal(error.message, "null is not an object");
}
});
});

30
node_modules/type/test/object/is.js generated vendored Normal file
View File

@ -0,0 +1,30 @@
"use strict";
var assert = require("chai").assert
, isObject = require("../../object/is");
describe("object/is", function () {
it("Should return true on object", function () { assert.equal(isObject({}), true); });
it("Should return true on function", function () {
assert.equal(isObject(function () { return true; }), true);
});
it("Should return true on array", function () { assert.equal(isObject([]), true); });
if (typeof Object.create === "function") {
it("Should return true on object with no prototype", function () {
assert.equal(isObject(Object.create(null)), true);
});
}
it("Should return false on string", function () { assert.equal(isObject("foo"), false); });
it("Should return false on empty string", function () { assert.equal(isObject(""), false); });
it("Should return false on number", function () { assert.equal(isObject(123), false); });
it("Should return false on NaN", function () { assert.equal(isObject(NaN), false); });
it("Should return false on boolean", function () { assert.equal(isObject(true), false); });
if (typeof Symbol === "function") {
it("Should return false on symbol", function () {
assert.equal(isObject(Symbol("foo")), false);
});
}
it("Should return false on null", function () { assert.equal(isObject(null), false); });
it("Should return false on undefined", function () { assert.equal(isObject(void 0), false); });
});

20
node_modules/type/test/plain-function/ensure.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var assert = require("chai").assert
, ensurePlainFunction = require("../../plain-function/ensure");
describe("plain-function/ensure", function () {
it("Should return input value", function () {
var value = function () { return true; };
assert.equal(ensurePlainFunction(value), value);
});
it("Should crash on invalid value", function () {
try {
ensurePlainFunction(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert(error.message.includes("is not a plain function"));
}
});
});

56
node_modules/type/test/plain-function/is.js generated vendored Normal file
View File

@ -0,0 +1,56 @@
"use strict";
var assert = require("chai").assert
, isPlainFunction = require("../../plain-function/is")
, arrowFunctionIfSupported = require("../_lib/arrow-function-if-supported")
, classIfSupported = require("../_lib/class-if-supported");
describe("plain-function/is", function () {
it("Should return true on function", function () {
assert.equal(isPlainFunction(function () { return true; }), true);
});
if (arrowFunctionIfSupported) {
it("Should return true on arrow function", function () {
assert.equal(isPlainFunction(arrowFunctionIfSupported), true);
});
}
if (classIfSupported) {
it("Should return false on class", function () {
assert.equal(isPlainFunction(classIfSupported), false);
});
}
it("Should return false on reg-exp", function () {
assert.equal(isPlainFunction(/foo/), false);
});
it("Should return false on plain object", function () {
assert.equal(isPlainFunction({}), false);
});
it("Should return false on array", function () { assert.equal(isPlainFunction([]), false); });
if (typeof Object.create === "function") {
it("Should return false on object with no prototype", function () {
assert.equal(isPlainFunction(Object.create(null)), false);
});
}
it("Should return false on string", function () {
assert.equal(isPlainFunction("foo"), false);
});
it("Should return false on empty string", function () {
assert.equal(isPlainFunction(""), false);
});
it("Should return false on number", function () { assert.equal(isPlainFunction(123), false); });
it("Should return false on NaN", function () { assert.equal(isPlainFunction(NaN), false); });
it("Should return false on boolean", function () {
assert.equal(isPlainFunction(true), false);
});
if (typeof Symbol === "function") {
it("Should return false on symbol", function () {
assert.equal(isPlainFunction(Symbol("foo")), false);
});
}
it("Should return false on null", function () { assert.equal(isPlainFunction(null), false); });
it("Should return false on undefined", function () {
assert.equal(isPlainFunction(void 0), false);
});
});

20
node_modules/type/test/plain-object/ensure.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var assert = require("chai").assert
, ensurePlainObject = require("../../plain-object/ensure");
describe("plain-object/ensure", function () {
it("Should return input value", function () {
var value = {};
assert.equal(ensurePlainObject(value), value);
});
it("Should crash on invalid value", function () {
try {
ensurePlainObject(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert(error.message.includes("is not a plain object"));
}
});
});

47
node_modules/type/test/plain-object/is.js generated vendored Normal file
View File

@ -0,0 +1,47 @@
"use strict";
var assert = require("chai").assert
, isPlainObject = require("../../plain-object/is");
describe("plain-object/is", function () {
it("Should return true on plain object", function () {
assert.equal(isPlainObject({}), true);
});
if (typeof Object.create === "function") {
it("Should return true on object with no prototype", function () {
assert.equal(isPlainObject(Object.create(null)), true);
});
it(
"Should return false on object that inherits from object with no prototype",
function () { assert.equal(isPlainObject(Object.create(Object.create(null))), false); }
);
}
it("Should return false on Object.prototype", function () {
assert.equal(isPlainObject(Object.prototype), false);
});
it("Should return false on prototype that derives from Object.prototype", function () {
assert.equal(isPlainObject(RegExp.prototype), false);
});
it("Should return false on function", function () {
assert.equal(isPlainObject(function () { return true; }), false);
});
it("Should return false on string", function () { assert.equal(isPlainObject("foo"), false); });
it("Should return false on empty string", function () {
assert.equal(isPlainObject(""), false);
});
it("Should return false on number", function () { assert.equal(isPlainObject(123), false); });
it("Should return false on NaN", function () { assert.equal(isPlainObject(NaN), false); });
it("Should return false on boolean", function () { assert.equal(isPlainObject(true), false); });
if (typeof Symbol === "function") {
it("Should return false on symbol", function () {
assert.equal(isPlainObject(Symbol("foo")), false);
});
}
it("Should return false on null", function () { assert.equal(isPlainObject(null), false); });
it("Should return false on undefined", function () {
assert.equal(isPlainObject(void 0), false);
});
});

20
node_modules/type/test/promise/ensure.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var assert = require("chai").assert
, ensurePromise = require("../../promise/ensure");
describe("promise/ensure", function () {
it("Should return input value", function () {
var value = Promise.resolve();
assert.equal(ensurePromise(value), value);
});
it("Should crash on no value", function () {
try {
ensurePromise({});
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert.equal(error.message, "[object Object] is not a promise");
}
});
});

39
node_modules/type/test/promise/is.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
"use strict";
var assert = require("chai").assert
, isPromise = require("../../promise/is");
describe("promise/is", function () {
if (typeof Promise === "function") {
it("Should return true on promise", function () {
assert.equal(isPromise(Promise.resolve()), true);
});
}
it("Should return false on non-promise thenable", function () {
assert.equal(isPromise({ then: function () { return true; } }), false);
});
it("Should return false on plain object", function () { assert.equal(isPromise({}), false); });
it("Should return false on function", function () {
assert.equal(isPromise(function () { return true; }), false);
});
it("Should return false on array", function () { assert.equal(isPromise([]), false); });
if (typeof Object.create === "function") {
it("Should return false on object with no prototype", function () {
assert.equal(isPromise(Object.create(null)), false);
});
}
it("Should return false on string", function () { assert.equal(isPromise("foo"), false); });
it("Should return false on empty string", function () { assert.equal(isPromise(""), false); });
it("Should return false on number", function () { assert.equal(isPromise(123), false); });
it("Should return false on NaN", function () { assert.equal(isPromise(NaN), false); });
it("Should return false on boolean", function () { assert.equal(isPromise(true), false); });
if (typeof Symbol === "function") {
it("Should return false on symbol", function () {
assert.equal(isPromise(Symbol("foo")), false);
});
}
it("Should return false on null", function () { assert.equal(isPromise(null), false); });
it("Should return false on undefined", function () { assert.equal(isPromise(void 0), false); });
});

39
node_modules/type/test/prototype/is.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
"use strict";
var assert = require("chai").assert
, isPrototype = require("../../prototype/is");
describe("prototype/is", function () {
it("Should return true on prototype", function () {
assert.equal(isPrototype(Object.prototype), true);
});
it("Should return false on plain object", function () {
assert.equal(isPrototype({}), false);
});
it("Should return false on function", function () {
assert.equal(isPrototype(function () { return true; }), false);
});
it("Should return false on array", function () { assert.equal(isPrototype([]), false); });
if (typeof Object.create === "function") {
it("Should return false on object with no prototype", function () {
assert.equal(isPrototype(Object.create(null)), false);
});
}
it("Should return false on string", function () { assert.equal(isPrototype("foo"), false); });
it("Should return false on empty string", function () {
assert.equal(isPrototype(""), false);
});
it("Should return false on number", function () { assert.equal(isPrototype(123), false); });
it("Should return false on NaN", function () { assert.equal(isPrototype(NaN), false); });
it("Should return false on boolean", function () { assert.equal(isPrototype(true), false); });
if (typeof Symbol === "function") {
it("Should return false on symbol", function () {
assert.equal(isPrototype(Symbol("foo")), false);
});
}
it("Should return false on null", function () { assert.equal(isPrototype(null), false); });
it("Should return false on undefined", function () {
assert.equal(isPrototype(void 0), false);
});
});

20
node_modules/type/test/reg-exp/ensure.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var assert = require("chai").assert
, ensureRegExp = require("../../reg-exp/ensure");
describe("reg-exp/ensure", function () {
it("Should return input value", function () {
var value = /foo/;
assert.equal(ensureRegExp(value), value);
});
it("Should crash on invalid value", function () {
try {
ensureRegExp(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert(error.message.includes("is not a regular expression object"));
}
});
});

47
node_modules/type/test/reg-exp/is.js generated vendored Normal file
View File

@ -0,0 +1,47 @@
"use strict";
var assert = require("chai").assert
, isRegExp = require("../../reg-exp/is");
describe("reg-exp/is", function () {
it("Should return true on regular expression", function () {
assert.equal(isRegExp(/foo/), true);
});
it("Should return false on native regular expression with no common API exposed", function () {
var re = /foo/;
re.test = null;
assert.equal(isRegExp(re), false);
});
it("Should return false on RegExp.prototype", function () {
assert.equal(isRegExp(RegExp.prototype), false);
});
it("Should return false on regexp like string", function () {
assert.equal(isRegExp("/foo/"), false);
});
it("Should return false on plain object", function () { assert.equal(isRegExp({}), false); });
it("Should return false on function", function () {
assert.equal(isRegExp(function () { return true; }), false);
});
it("Should return false on array", function () { assert.equal(isRegExp([]), false); });
if (typeof Object.create === "function") {
it("Should return false on object with no prototype", function () {
assert.equal(isRegExp(Object.create(null)), false);
});
}
it("Should return false on string", function () { assert.equal(isRegExp("foo"), false); });
it("Should return false on empty string", function () { assert.equal(isRegExp(""), false); });
it("Should return false on number", function () { assert.equal(isRegExp(123), false); });
it("Should return false on NaN", function () { assert.equal(isRegExp(NaN), false); });
it("Should return false on boolean", function () { assert.equal(isRegExp(true), false); });
if (typeof Symbol === "function") {
it("Should return false on symbol", function () {
assert.equal(isRegExp(Symbol("foo")), false);
});
}
it("Should return false on null", function () { assert.equal(isRegExp(null), false); });
it("Should return false on undefined", function () { assert.equal(isRegExp(void 0), false); });
});

49
node_modules/type/test/safe-integer/coerce.js generated vendored Normal file
View File

@ -0,0 +1,49 @@
"use strict";
var assert = require("chai").assert
, coerceToSafeInteger = require("../../safe-integer/coerce");
describe("safe-integer/coerce", function () {
it("Should coerce float to integer", function () {
assert.equal(coerceToSafeInteger(123.123), 123);
assert.equal(coerceToSafeInteger(123.823), 123);
assert.equal(coerceToSafeInteger(-123.123), -123);
assert.equal(coerceToSafeInteger(-123.823), -123);
});
it("Should coerce string", function () { assert.equal(coerceToSafeInteger("12.123"), 12); });
it("Should coerce booleans", function () { assert.equal(coerceToSafeInteger(true), 1); });
it("Should coerce number objects", function () {
assert.equal(coerceToSafeInteger(new Number(343)), 343);
});
it("Should coerce objects", function () {
assert.equal(coerceToSafeInteger({ valueOf: function () { return 23; } }), 23);
});
it("Should reject infinite number", function () {
assert.equal(coerceToSafeInteger(Infinity), null);
});
it("Should reject number beyond Number.MAX_SAFE_INTEGER", function () {
assert.equal(coerceToSafeInteger(9007199254740992), null);
});
it("Should reject number beyond Number.MIN_SAFE_INTEGER", function () {
assert.equal(coerceToSafeInteger(-9007199254740992), null);
});
it("Should reject NaN", function () { assert.equal(coerceToSafeInteger(NaN), null); });
if (typeof Object.create === "function") {
it("Should not coerce objects with no number representation", function () {
assert.equal(coerceToSafeInteger(Object.create(null)), null);
});
}
it("Should not coerce null", function () { assert.equal(coerceToSafeInteger(null), null); });
it("Should not coerce undefined", function () {
assert.equal(coerceToSafeInteger(undefined), null);
});
if (typeof Symbol === "function") {
it("Should not coerce symbols", function () {
assert.equal(coerceToSafeInteger(Symbol("foo")), null);
});
}
});

19
node_modules/type/test/safe-integer/ensure.js generated vendored Normal file
View File

@ -0,0 +1,19 @@
"use strict";
var assert = require("chai").assert
, ensureSafeInteger = require("../../safe-integer/ensure");
describe("safe-integer/ensure", function () {
it("Should return coerced value", function () {
assert.equal(ensureSafeInteger("12.23"), 12);
});
it("Should crash on no value", function () {
try {
ensureSafeInteger(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert.equal(error.message, "null is not a safe integer");
}
});
});

36
node_modules/type/test/string/coerce.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
"use strict";
var assert = require("chai").assert
, coerceToString = require("../../string/coerce");
describe("string/coerce", function () {
it("Should return input string", function () { assert.equal(coerceToString("foo"), "foo"); });
it("Should coerce numbers", function () { assert.equal(coerceToString(12), "12"); });
it("Should coerce booleans", function () { assert.equal(coerceToString(true), "true"); });
it("Should coerce string objects", function () {
assert.equal(coerceToString(new String("bar")), "bar");
});
it("Should coerce objects", function () {
assert.equal(
coerceToString({ toString: function () { return "Some object"; } }), "Some object"
);
});
if (typeof Object.create === "function") {
it("Should not coerce objects with no toString", function () {
assert.equal(coerceToString(Object.create(null)), null);
});
}
it("Should not coerce objects with no custom toString", function () {
assert.equal(coerceToString({}), null);
});
it("Should not coerce null", function () { assert.equal(coerceToString(null), null); });
it("Should not coerce undefined", function () {
assert.equal(coerceToString(undefined), null);
});
if (typeof Symbol === "function") {
it("Should not coerce symbols", function () {
assert.equal(coerceToString(Symbol("foo")), null);
});
}
});

17
node_modules/type/test/string/ensure.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
"use strict";
var assert = require("chai").assert
, ensureString = require("../../string/ensure");
describe("string/ensure", function () {
it("Should return coerced value", function () { assert.equal(ensureString(12), "12"); });
it("Should crash on no value", function () {
try {
ensureString(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert.equal(error.message, "null is not a string");
}
});
});

20
node_modules/type/test/thenable/ensure.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var assert = require("chai").assert
, ensureThenable = require("../../thenable/ensure");
describe("thenable/ensure", function () {
it("Should return input value", function () {
var value = { then: function () { return true; } };
assert.equal(ensureThenable(value), value);
});
it("Should crash on no value", function () {
try {
ensureThenable({});
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert.equal(error.message, "[object Object] is not a thenable object");
}
});
});

44
node_modules/type/test/thenable/is.js generated vendored Normal file
View File

@ -0,0 +1,44 @@
"use strict";
var assert = require("chai").assert
, isThenable = require("../../thenable/is");
describe("thenable/is", function () {
it("Should return true on object with `then` method", function () {
assert.equal(isThenable({ then: function () { return true; } }), true);
});
if (typeof Promise === "function") {
it("Should return true on promise", function () {
assert.equal(isThenable(Promise.resolve()), true);
});
}
it("Should return false on object with `then` non callable property", function () {
assert.equal(isThenable({ then: {} }), false);
});
it("Should return false on plain object", function () { assert.equal(isThenable({}), false); });
it("Should return false on function", function () {
assert.equal(isThenable(function () { return true; }), false);
});
it("Should return false on array", function () { assert.equal(isThenable([]), false); });
if (typeof Object.create === "function") {
it("Should return false on object with no prototype", function () {
assert.equal(isThenable(Object.create(null)), false);
});
}
it("Should return false on string", function () { assert.equal(isThenable("foo"), false); });
it("Should return false on empty string", function () { assert.equal(isThenable(""), false); });
it("Should return false on number", function () { assert.equal(isThenable(123), false); });
it("Should return false on NaN", function () { assert.equal(isThenable(NaN), false); });
it("Should return false on boolean", function () { assert.equal(isThenable(true), false); });
if (typeof Symbol === "function") {
it("Should return false on symbol", function () {
assert.equal(isThenable(Symbol("foo")), false);
});
}
it("Should return false on null", function () { assert.equal(isThenable(null), false); });
it("Should return false on undefined", function () {
assert.equal(isThenable(void 0), false);
});
});

47
node_modules/type/test/time-value/coerce.js generated vendored Normal file
View File

@ -0,0 +1,47 @@
"use strict";
var assert = require("chai").assert
, coerceToTimeValue = require("../../time-value/coerce");
describe("time-value/coerce", function () {
it("Should coerce float to time value", function () {
assert.equal(coerceToTimeValue(123.123), 123);
assert.equal(coerceToTimeValue(123.823), 123);
assert.equal(coerceToTimeValue(-123.123), -123);
assert.equal(coerceToTimeValue(-123.823), -123);
});
it("Should coerce string", function () { assert.equal(coerceToTimeValue("12.123"), 12); });
it("Should coerce booleans", function () { assert.equal(coerceToTimeValue(true), 1); });
it("Should coerce number objects", function () {
assert.equal(coerceToTimeValue(new Number(343)), 343);
});
it("Should coerce objects", function () {
assert.equal(coerceToTimeValue({ valueOf: function () { return 23; } }), 23);
});
it("Should reject infinite number", function () {
assert.equal(coerceToTimeValue(Infinity), null);
});
it("Should reject number beyond 100,000,000 days from unix epox", function () {
assert.equal(coerceToTimeValue(8.64e15 + 1), null);
assert.equal(coerceToTimeValue(-8.64e15 - 1), null);
});
it("Should reject NaN", function () { assert.equal(coerceToTimeValue(NaN), null); });
if (typeof Object.create === "function") {
it("Should not coerce objects with no number representation", function () {
assert.equal(coerceToTimeValue(Object.create(null)), null);
});
}
it("Should not coerce null", function () { assert.equal(coerceToTimeValue(null), null); });
it("Should not coerce undefined", function () {
assert.equal(coerceToTimeValue(undefined), null);
});
if (typeof Symbol === "function") {
it("Should not coerce symbols", function () {
assert.equal(coerceToTimeValue(Symbol("foo")), null);
});
}
});

17
node_modules/type/test/time-value/ensure.js generated vendored Normal file
View File

@ -0,0 +1,17 @@
"use strict";
var assert = require("chai").assert
, ensureTimeValue = require("../../time-value/ensure");
describe("time-value/ensure", function () {
it("Should return coerced value", function () { assert.equal(ensureTimeValue("12.23"), 12); });
it("Should crash on no value", function () {
try {
ensureTimeValue("foo");
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert.equal(error.message, "foo is not a time value");
}
});
});

20
node_modules/type/test/value/ensure.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
"use strict";
var assert = require("chai").assert
, ensureValue = require("../../value/ensure");
describe("value/ensure", function () {
it("Should return input value", function () {
var value = {};
assert.equal(ensureValue(value), value);
});
it("Should crash on no value", function () {
try {
ensureValue(null);
throw new Error("Unexpected");
} catch (error) {
assert.equal(error.name, "TypeError");
assert.equal(error.message, "Cannot use null");
}
});
});

29
node_modules/type/test/value/is.js generated vendored Normal file
View File

@ -0,0 +1,29 @@
"use strict";
var assert = require("chai").assert
, isValue = require("../../value/is");
describe("value/is", function () {
it("Should return true on object", function () { assert.equal(isValue({}), true); });
it("Should return true on function", function () {
assert.equal(isValue(function () { return true; }), true);
});
it("Should return true on array", function () { assert.equal(isValue([]), true); });
if (typeof Object.create === "function") {
it("Should return true on object with no prototype", function () {
assert.equal(isValue(Object.create(null)), true);
});
}
it("Should return true on string", function () { assert.equal(isValue("foo"), true); });
it("Should return true on empty string", function () { assert.equal(isValue(""), true); });
it("Should return true on number", function () { assert.equal(isValue(123), true); });
it("Should return true on NaN", function () { assert.equal(isValue(NaN), true); });
it("Should return true on boolean", function () { assert.equal(isValue(false), true); });
if (typeof Symbol === "function") {
// eslint-disable-next-line no-undef
it("Should return true on symbol", function () { assert.equal(isValue(Symbol()), true); });
}
it("Should return false on null", function () { assert.equal(isValue(null), false); });
it("Should return false on undefined", function () { assert.equal(isValue(void 0), false); });
});

9
node_modules/type/thenable/ensure.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, is = require("./is");
module.exports = function (value/*, options*/) {
if (is(value)) return value;
return resolveException(value, "%v is not a thenable object", arguments[1]);
};

9
node_modules/type/thenable/is.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
var isObject = require("../object/is");
module.exports = function (value) {
if (!isObject(value)) return false;
try { return typeof value.then === "function"; }
catch (error) { return false; }
};

12
node_modules/type/time-value/coerce.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
"use strict";
var coerceToInteger = require("../integer/coerce");
var abs = Math.abs;
module.exports = function (value) {
value = coerceToInteger(value);
if (!value) return value;
if (abs(value) > 8.64e15) return null;
return value;
};

10
node_modules/type/time-value/ensure.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
"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;
return resolveException(value, "%v is not a time value", arguments[1]);
};

9
node_modules/type/value/ensure.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
var resolveException = require("../lib/resolve-exception")
, is = require("./is");
module.exports = function (value/*, options*/) {
if (is(value)) return value;
return resolveException(value, "Cannot use %v", arguments[1]);
};

Some files were not shown because too many files have changed in this diff Show More