yeet
This commit is contained in:
21
node_modules/jest-validate/LICENSE
generated
vendored
Normal file
21
node_modules/jest-validate/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Facebook, Inc. and its affiliates.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
193
node_modules/jest-validate/README.md
generated
vendored
Normal file
193
node_modules/jest-validate/README.md
generated
vendored
Normal file
@ -0,0 +1,193 @@
|
||||
# jest-validate
|
||||
|
||||
Generic configuration validation tool that helps you with warnings, errors and deprecation messages as well as showing users examples of correct configuration.
|
||||
|
||||
```bash
|
||||
npm install --save jest-validate
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import {validate} from 'jest-validate';
|
||||
|
||||
validate((config: Object), (options: ValidationOptions)); // => {hasDeprecationWarnings: boolean, isValid: boolean}
|
||||
```
|
||||
|
||||
Where `ValidationOptions` are:
|
||||
|
||||
```js
|
||||
type ValidationOptions = {
|
||||
blacklist?: Array<string>,
|
||||
comment?: string,
|
||||
condition?: (option: any, validOption: any) => boolean,
|
||||
deprecate?: (
|
||||
config: Object,
|
||||
option: string,
|
||||
deprecatedOptions: Object,
|
||||
options: ValidationOptions,
|
||||
) => true,
|
||||
deprecatedConfig?: {[key: string]: Function},
|
||||
error?: (
|
||||
option: string,
|
||||
received: any,
|
||||
defaultValue: any,
|
||||
options: ValidationOptions,
|
||||
) => void,
|
||||
exampleConfig: Object,
|
||||
recursive?: boolean,
|
||||
title?: Title,
|
||||
unknown?: (
|
||||
config: Object,
|
||||
exampleConfig: Object,
|
||||
option: string,
|
||||
options: ValidationOptions,
|
||||
) => void,
|
||||
};
|
||||
|
||||
type Title = {|
|
||||
deprecation?: string,
|
||||
error?: string,
|
||||
warning?: string,
|
||||
|};
|
||||
```
|
||||
|
||||
`exampleConfig` is the only option required.
|
||||
|
||||
## API
|
||||
|
||||
By default `jest-validate` will print generic warning and error messages. You can however customize this behavior by providing `options: ValidationOptions` object as a second argument:
|
||||
|
||||
Almost anything can be overwritten to suite your needs.
|
||||
|
||||
### Options
|
||||
|
||||
- `recursiveBlacklist` – optional array of string keyPaths that should be excluded from deep (recursive) validation.
|
||||
- `comment` – optional string to be rendered below error/warning message.
|
||||
- `condition` – an optional function with validation condition.
|
||||
- `deprecate`, `error`, `unknown` – optional functions responsible for displaying warning and error messages.
|
||||
- `deprecatedConfig` – optional object with deprecated config keys.
|
||||
- `exampleConfig` – the only **required** option with configuration against which you'd like to test.
|
||||
- `recursive` - optional boolean determining whether recursively compare `exampleConfig` to `config` (default: `true`).
|
||||
- `title` – optional object of titles for errors and messages.
|
||||
|
||||
You will find examples of `condition`, `deprecate`, `error`, `unknown`, and `deprecatedConfig` inside source of this repository, named respectively.
|
||||
|
||||
## exampleConfig syntax
|
||||
|
||||
`exampleConfig` should be an object with key/value pairs that contain an example of a valid value for each key. A configuration value is considered valid when:
|
||||
|
||||
- it matches the JavaScript type of the example value, e.g. `string`, `number`, `array`, `boolean`, `function`, or `object`
|
||||
- it is `null` or `undefined`
|
||||
- it matches the Javascript type of any of arguments passed to `MultipleValidOptions(...)`
|
||||
|
||||
The last condition is a special syntax that allows validating where more than one type is permissible; see example below. It's acceptable to have multiple values of the same type in the example, so you can also use this syntax to provide more than one example. When a validation failure occurs, the error message will show all other values in the array as examples.
|
||||
|
||||
## Examples
|
||||
|
||||
Minimal example:
|
||||
|
||||
```js
|
||||
validate(config, {exampleConfig});
|
||||
```
|
||||
|
||||
Example with slight modifications:
|
||||
|
||||
```js
|
||||
validate(config, {
|
||||
comment: ' Documentation: http://custom-docs.com',
|
||||
deprecatedConfig,
|
||||
exampleConfig,
|
||||
title: {
|
||||
deprecation: 'Custom Deprecation',
|
||||
// leaving 'error' and 'warning' as default
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
This will output:
|
||||
|
||||
#### Warning:
|
||||
|
||||
```bash
|
||||
● Validation Warning:
|
||||
|
||||
Unknown option transformx with value "<rootDir>/node_modules/babel-jest" was found.
|
||||
This is either a typing error or a user mistake. Fixing it will remove this message.
|
||||
|
||||
Documentation: http://custom-docs.com
|
||||
```
|
||||
|
||||
#### Error:
|
||||
|
||||
```bash
|
||||
● Validation Error:
|
||||
|
||||
Option transform must be of type:
|
||||
object
|
||||
but instead received:
|
||||
string
|
||||
|
||||
Example:
|
||||
{
|
||||
"transform": {
|
||||
"^.+\\.js$": "<rootDir>/preprocessor.js"
|
||||
}
|
||||
}
|
||||
|
||||
Documentation: http://custom-docs.com
|
||||
```
|
||||
|
||||
## Example validating multiple types
|
||||
|
||||
```js
|
||||
import {multipleValidOptions} from 'jest-validate';
|
||||
|
||||
validate(config, {
|
||||
// `bar` will accept either a string or a number
|
||||
bar: multipleValidOptions('string is ok', 2),
|
||||
});
|
||||
```
|
||||
|
||||
#### Error:
|
||||
|
||||
```bash
|
||||
● Validation Error:
|
||||
|
||||
Option foo must be of type:
|
||||
string or number
|
||||
but instead received:
|
||||
array
|
||||
|
||||
Example:
|
||||
{
|
||||
"bar": "string is ok"
|
||||
}
|
||||
|
||||
or
|
||||
|
||||
{
|
||||
"bar": 2
|
||||
}
|
||||
|
||||
Documentation: http://custom-docs.com
|
||||
```
|
||||
|
||||
#### Deprecation
|
||||
|
||||
Based on `deprecatedConfig` object with proper deprecation messages. Note custom title:
|
||||
|
||||
```bash
|
||||
Custom Deprecation:
|
||||
|
||||
Option scriptPreprocessor was replaced by transform, which support multiple preprocessors.
|
||||
|
||||
Jest now treats your current configuration as:
|
||||
{
|
||||
"transform": {".*": "xxx"}
|
||||
}
|
||||
|
||||
Please update your configuration.
|
||||
|
||||
Documentation: http://custom-docs.com
|
||||
```
|
9
node_modules/jest-validate/build/condition.d.ts
generated
vendored
Normal file
9
node_modules/jest-validate/build/condition.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export declare function getValues<T = unknown>(validOption: T): Array<T>;
|
||||
export declare function validationCondition(option: unknown, validOption: unknown): boolean;
|
||||
export declare function multipleValidOptions<T extends Array<any>>(...args: T): T[number];
|
48
node_modules/jest-validate/build/condition.js
generated
vendored
Normal file
48
node_modules/jest-validate/build/condition.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.getValues = getValues;
|
||||
exports.validationCondition = validationCondition;
|
||||
exports.multipleValidOptions = multipleValidOptions;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const toString = Object.prototype.toString;
|
||||
const MULTIPLE_VALID_OPTIONS_SYMBOL = Symbol('JEST_MULTIPLE_VALID_OPTIONS');
|
||||
|
||||
function validationConditionSingle(option, validOption) {
|
||||
return (
|
||||
option === null ||
|
||||
option === undefined ||
|
||||
(typeof option === 'function' && typeof validOption === 'function') ||
|
||||
toString.call(option) === toString.call(validOption)
|
||||
);
|
||||
}
|
||||
|
||||
function getValues(validOption) {
|
||||
if (
|
||||
Array.isArray(validOption) && // @ts-ignore
|
||||
validOption[MULTIPLE_VALID_OPTIONS_SYMBOL]
|
||||
) {
|
||||
return validOption;
|
||||
}
|
||||
|
||||
return [validOption];
|
||||
}
|
||||
|
||||
function validationCondition(option, validOption) {
|
||||
return getValues(validOption).some(e => validationConditionSingle(option, e));
|
||||
}
|
||||
|
||||
function multipleValidOptions(...args) {
|
||||
const options = [...args]; // @ts-ignore
|
||||
|
||||
options[MULTIPLE_VALID_OPTIONS_SYMBOL] = true;
|
||||
return options;
|
||||
}
|
9
node_modules/jest-validate/build/defaultConfig.d.ts
generated
vendored
Normal file
9
node_modules/jest-validate/build/defaultConfig.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { ValidationOptions } from './types';
|
||||
declare const validationOptions: ValidationOptions;
|
||||
export default validationOptions;
|
42
node_modules/jest-validate/build/defaultConfig.js
generated
vendored
Normal file
42
node_modules/jest-validate/build/defaultConfig.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _deprecated = require('./deprecated');
|
||||
|
||||
var _warnings = require('./warnings');
|
||||
|
||||
var _errors = require('./errors');
|
||||
|
||||
var _condition = require('./condition');
|
||||
|
||||
var _utils = require('./utils');
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const validationOptions = {
|
||||
comment: '',
|
||||
condition: _condition.validationCondition,
|
||||
deprecate: _deprecated.deprecationWarning,
|
||||
deprecatedConfig: {},
|
||||
error: _errors.errorMessage,
|
||||
exampleConfig: {},
|
||||
recursive: true,
|
||||
// Allow NPM-sanctioned comments in package.json. Use a "//" key.
|
||||
recursiveBlacklist: ['//'],
|
||||
title: {
|
||||
deprecation: _utils.DEPRECATION,
|
||||
error: _utils.ERROR,
|
||||
warning: _utils.WARNING
|
||||
},
|
||||
unknown: _warnings.unknownOptionWarning
|
||||
};
|
||||
var _default = validationOptions;
|
||||
exports.default = _default;
|
8
node_modules/jest-validate/build/deprecated.d.ts
generated
vendored
Normal file
8
node_modules/jest-validate/build/deprecated.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { ValidationOptions } from './types';
|
||||
export declare const deprecationWarning: (config: Record<string, any>, option: string, deprecatedOptions: Record<string, Function>, options: ValidationOptions) => boolean;
|
32
node_modules/jest-validate/build/deprecated.js
generated
vendored
Normal file
32
node_modules/jest-validate/build/deprecated.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.deprecationWarning = void 0;
|
||||
|
||||
var _utils = require('./utils');
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const deprecationMessage = (message, options) => {
|
||||
const comment = options.comment;
|
||||
const name =
|
||||
(options.title && options.title.deprecation) || _utils.DEPRECATION;
|
||||
(0, _utils.logValidationWarning)(name, message, comment);
|
||||
};
|
||||
|
||||
const deprecationWarning = (config, option, deprecatedOptions, options) => {
|
||||
if (option in deprecatedOptions) {
|
||||
deprecationMessage(deprecatedOptions[option](config), options);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.deprecationWarning = deprecationWarning;
|
8
node_modules/jest-validate/build/errors.d.ts
generated
vendored
Normal file
8
node_modules/jest-validate/build/errors.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { ValidationOptions } from './types';
|
||||
export declare const errorMessage: (option: string, received: unknown, defaultValue: unknown, options: ValidationOptions, path?: string[] | undefined) => void;
|
75
node_modules/jest-validate/build/errors.js
generated
vendored
Normal file
75
node_modules/jest-validate/build/errors.js
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.errorMessage = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestGetType() {
|
||||
const data = _interopRequireDefault(require('jest-get-type'));
|
||||
|
||||
_jestGetType = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _utils = require('./utils');
|
||||
|
||||
var _condition = require('./condition');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const errorMessage = (option, received, defaultValue, options, path) => {
|
||||
const conditions = (0, _condition.getValues)(defaultValue);
|
||||
const validTypes = Array.from(
|
||||
new Set(conditions.map(_jestGetType().default))
|
||||
);
|
||||
const message = ` Option ${_chalk().default.bold(
|
||||
`"${path && path.length > 0 ? path.join('.') + '.' : ''}${option}"`
|
||||
)} must be of type:
|
||||
${validTypes.map(e => _chalk().default.bold.green(e)).join(' or ')}
|
||||
but instead received:
|
||||
${_chalk().default.bold.red((0, _jestGetType().default)(received))}
|
||||
|
||||
Example:
|
||||
${formatExamples(option, conditions)}`;
|
||||
const comment = options.comment;
|
||||
const name = (options.title && options.title.error) || _utils.ERROR;
|
||||
throw new _utils.ValidationError(name, message, comment);
|
||||
};
|
||||
|
||||
exports.errorMessage = errorMessage;
|
||||
|
||||
function formatExamples(option, examples) {
|
||||
return examples.map(
|
||||
e => ` {
|
||||
${_chalk().default.bold(`"${option}"`)}: ${_chalk().default.bold(
|
||||
(0, _utils.formatPrettyObject)(e)
|
||||
)}
|
||||
}`
|
||||
).join(`
|
||||
|
||||
or
|
||||
|
||||
`);
|
||||
}
|
9
node_modules/jest-validate/build/exampleConfig.d.ts
generated
vendored
Normal file
9
node_modules/jest-validate/build/exampleConfig.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { ValidationOptions } from './types';
|
||||
declare const config: ValidationOptions;
|
||||
export default config;
|
36
node_modules/jest-validate/build/exampleConfig.js
generated
vendored
Normal file
36
node_modules/jest-validate/build/exampleConfig.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const config = {
|
||||
comment: ' A comment',
|
||||
condition: () => true,
|
||||
deprecate: () => false,
|
||||
deprecatedConfig: {
|
||||
key: () => {}
|
||||
},
|
||||
error: () => {},
|
||||
exampleConfig: {
|
||||
key: 'value',
|
||||
test: 'case'
|
||||
},
|
||||
recursive: true,
|
||||
recursiveBlacklist: [],
|
||||
title: {
|
||||
deprecation: 'Deprecation Warning',
|
||||
error: 'Validation Error',
|
||||
warning: 'Validation Warning'
|
||||
},
|
||||
unknown: () => {}
|
||||
};
|
||||
var _default = config;
|
||||
exports.default = _default;
|
10
node_modules/jest-validate/build/index.d.ts
generated
vendored
Normal file
10
node_modules/jest-validate/build/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export { ValidationError, createDidYouMeanMessage, format, logValidationWarning, } from './utils';
|
||||
export { default as validate } from './validate';
|
||||
export { default as validateCLIOptions } from './validateCLIOptions';
|
||||
export { multipleValidOptions } from './condition';
|
61
node_modules/jest-validate/build/index.js
generated
vendored
Normal file
61
node_modules/jest-validate/build/index.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, 'ValidationError', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _utils.ValidationError;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'createDidYouMeanMessage', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _utils.createDidYouMeanMessage;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'format', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _utils.format;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'logValidationWarning', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _utils.logValidationWarning;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'validate', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _validate.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'validateCLIOptions', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _validateCLIOptions.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'multipleValidOptions', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _condition.multipleValidOptions;
|
||||
}
|
||||
});
|
||||
|
||||
var _utils = require('./utils');
|
||||
|
||||
var _validate = _interopRequireDefault(require('./validate'));
|
||||
|
||||
var _validateCLIOptions = _interopRequireDefault(
|
||||
require('./validateCLIOptions')
|
||||
);
|
||||
|
||||
var _condition = require('./condition');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
9
node_modules/jest-validate/build/ts3.4/condition.d.ts
generated
vendored
Normal file
9
node_modules/jest-validate/build/ts3.4/condition.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export declare function getValues<T = unknown>(validOption: T): Array<T>;
|
||||
export declare function validationCondition(option: unknown, validOption: unknown): boolean;
|
||||
export declare function multipleValidOptions<T extends Array<any>>(...args: T): T[number];
|
9
node_modules/jest-validate/build/ts3.4/defaultConfig.d.ts
generated
vendored
Normal file
9
node_modules/jest-validate/build/ts3.4/defaultConfig.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { ValidationOptions } from './types';
|
||||
declare const validationOptions: ValidationOptions;
|
||||
export default validationOptions;
|
8
node_modules/jest-validate/build/ts3.4/deprecated.d.ts
generated
vendored
Normal file
8
node_modules/jest-validate/build/ts3.4/deprecated.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { ValidationOptions } from './types';
|
||||
export declare const deprecationWarning: (config: Record<string, any>, option: string, deprecatedOptions: Record<string, Function>, options: ValidationOptions) => boolean;
|
8
node_modules/jest-validate/build/ts3.4/errors.d.ts
generated
vendored
Normal file
8
node_modules/jest-validate/build/ts3.4/errors.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { ValidationOptions } from './types';
|
||||
export declare const errorMessage: (option: string, received: unknown, defaultValue: unknown, options: ValidationOptions, path?: string[] | undefined) => void;
|
9
node_modules/jest-validate/build/ts3.4/exampleConfig.d.ts
generated
vendored
Normal file
9
node_modules/jest-validate/build/ts3.4/exampleConfig.d.ts
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { ValidationOptions } from './types';
|
||||
declare const config: ValidationOptions;
|
||||
export default config;
|
10
node_modules/jest-validate/build/ts3.4/index.d.ts
generated
vendored
Normal file
10
node_modules/jest-validate/build/ts3.4/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export { ValidationError, createDidYouMeanMessage, format, logValidationWarning, } from './utils';
|
||||
export { default as validate } from './validate';
|
||||
export { default as validateCLIOptions } from './validateCLIOptions';
|
||||
export { multipleValidOptions } from './condition';
|
25
node_modules/jest-validate/build/ts3.4/types.d.ts
generated
vendored
Normal file
25
node_modules/jest-validate/build/ts3.4/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
declare type Title = {
|
||||
deprecation?: string;
|
||||
error?: string;
|
||||
warning?: string;
|
||||
};
|
||||
export declare type DeprecatedOptions = Record<string, Function>;
|
||||
export declare type ValidationOptions = {
|
||||
comment?: string;
|
||||
condition?: (option: any, validOption: any) => boolean;
|
||||
deprecate?: (config: Record<string, any>, option: string, deprecatedOptions: DeprecatedOptions, options: ValidationOptions) => boolean;
|
||||
deprecatedConfig?: DeprecatedOptions;
|
||||
error?: (option: string, received: any, defaultValue: any, options: ValidationOptions, path?: Array<string>) => void;
|
||||
exampleConfig: Record<string, any>;
|
||||
recursive?: boolean;
|
||||
recursiveBlacklist?: Array<string>;
|
||||
title?: Title;
|
||||
unknown?: (config: Record<string, any>, exampleConfig: Record<string, any>, option: string, options: ValidationOptions, path?: Array<string>) => void;
|
||||
};
|
||||
export {};
|
18
node_modules/jest-validate/build/ts3.4/utils.d.ts
generated
vendored
Normal file
18
node_modules/jest-validate/build/ts3.4/utils.d.ts
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export declare const DEPRECATION: string;
|
||||
export declare const ERROR: string;
|
||||
export declare const WARNING: string;
|
||||
export declare const format: (value: unknown) => string;
|
||||
export declare const formatPrettyObject: (value: unknown) => string;
|
||||
export declare class ValidationError extends Error {
|
||||
name: string;
|
||||
message: string;
|
||||
constructor(name: string, message: string, comment?: string | null);
|
||||
}
|
||||
export declare const logValidationWarning: (name: string, message: string, comment?: string | null | undefined) => void;
|
||||
export declare const createDidYouMeanMessage: (unrecognized: string, allowedOptions: string[]) => string;
|
12
node_modules/jest-validate/build/ts3.4/validate.d.ts
generated
vendored
Normal file
12
node_modules/jest-validate/build/ts3.4/validate.d.ts
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { ValidationOptions } from './types';
|
||||
declare const validate: (config: Record<string, any>, options: ValidationOptions) => {
|
||||
hasDeprecationWarnings: boolean;
|
||||
isValid: boolean;
|
||||
};
|
||||
export default validate;
|
14
node_modules/jest-validate/build/ts3.4/validateCLIOptions.d.ts
generated
vendored
Normal file
14
node_modules/jest-validate/build/ts3.4/validateCLIOptions.d.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { Config } from '@jest/types';
|
||||
import { Options } from 'yargs';
|
||||
import { DeprecatedOptions } from './types';
|
||||
export declare const DOCUMENTATION_NOTE: string;
|
||||
export default function validateCLIOptions(argv: Config.Argv, options: {
|
||||
deprecationEntries: DeprecatedOptions;
|
||||
[s: string]: Options;
|
||||
}, rawArgv?: Array<string>): boolean;
|
8
node_modules/jest-validate/build/ts3.4/warnings.d.ts
generated
vendored
Normal file
8
node_modules/jest-validate/build/ts3.4/warnings.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { ValidationOptions } from './types';
|
||||
export declare const unknownOptionWarning: (config: Record<string, any>, exampleConfig: Record<string, any>, option: string, options: ValidationOptions, path?: string[] | undefined) => void;
|
25
node_modules/jest-validate/build/types.d.ts
generated
vendored
Normal file
25
node_modules/jest-validate/build/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
declare type Title = {
|
||||
deprecation?: string;
|
||||
error?: string;
|
||||
warning?: string;
|
||||
};
|
||||
export declare type DeprecatedOptions = Record<string, Function>;
|
||||
export declare type ValidationOptions = {
|
||||
comment?: string;
|
||||
condition?: (option: any, validOption: any) => boolean;
|
||||
deprecate?: (config: Record<string, any>, option: string, deprecatedOptions: DeprecatedOptions, options: ValidationOptions) => boolean;
|
||||
deprecatedConfig?: DeprecatedOptions;
|
||||
error?: (option: string, received: any, defaultValue: any, options: ValidationOptions, path?: Array<string>) => void;
|
||||
exampleConfig: Record<string, any>;
|
||||
recursive?: boolean;
|
||||
recursiveBlacklist?: Array<string>;
|
||||
title?: Title;
|
||||
unknown?: (config: Record<string, any>, exampleConfig: Record<string, any>, option: string, options: ValidationOptions, path?: Array<string>) => void;
|
||||
};
|
||||
export {};
|
1
node_modules/jest-validate/build/types.js
generated
vendored
Normal file
1
node_modules/jest-validate/build/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
'use strict';
|
18
node_modules/jest-validate/build/utils.d.ts
generated
vendored
Normal file
18
node_modules/jest-validate/build/utils.d.ts
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export declare const DEPRECATION: string;
|
||||
export declare const ERROR: string;
|
||||
export declare const WARNING: string;
|
||||
export declare const format: (value: unknown) => string;
|
||||
export declare const formatPrettyObject: (value: unknown) => string;
|
||||
export declare class ValidationError extends Error {
|
||||
name: string;
|
||||
message: string;
|
||||
constructor(name: string, message: string, comment?: string | null);
|
||||
}
|
||||
export declare const logValidationWarning: (name: string, message: string, comment?: string | null | undefined) => void;
|
||||
export declare const createDidYouMeanMessage: (unrecognized: string, allowedOptions: string[]) => string;
|
121
node_modules/jest-validate/build/utils.js
generated
vendored
Normal file
121
node_modules/jest-validate/build/utils.js
generated
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.createDidYouMeanMessage = exports.logValidationWarning = exports.ValidationError = exports.formatPrettyObject = exports.format = exports.WARNING = exports.ERROR = exports.DEPRECATION = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _prettyFormat() {
|
||||
const data = _interopRequireDefault(require('pretty-format'));
|
||||
|
||||
_prettyFormat = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _leven() {
|
||||
const data = _interopRequireDefault(require('leven'));
|
||||
|
||||
_leven = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
const BULLET = _chalk().default.bold('\u25cf');
|
||||
|
||||
const DEPRECATION = `${BULLET} Deprecation Warning`;
|
||||
exports.DEPRECATION = DEPRECATION;
|
||||
const ERROR = `${BULLET} Validation Error`;
|
||||
exports.ERROR = ERROR;
|
||||
const WARNING = `${BULLET} Validation Warning`;
|
||||
exports.WARNING = WARNING;
|
||||
|
||||
const format = value =>
|
||||
typeof value === 'function'
|
||||
? value.toString()
|
||||
: (0, _prettyFormat().default)(value, {
|
||||
min: true
|
||||
});
|
||||
|
||||
exports.format = format;
|
||||
|
||||
const formatPrettyObject = value =>
|
||||
typeof value === 'function'
|
||||
? value.toString()
|
||||
: JSON.stringify(value, null, 2).split('\n').join('\n ');
|
||||
|
||||
exports.formatPrettyObject = formatPrettyObject;
|
||||
|
||||
class ValidationError extends Error {
|
||||
constructor(name, message, comment) {
|
||||
super();
|
||||
|
||||
_defineProperty(this, 'name', void 0);
|
||||
|
||||
_defineProperty(this, 'message', void 0);
|
||||
|
||||
comment = comment ? '\n\n' + comment : '\n';
|
||||
this.name = '';
|
||||
this.message = _chalk().default.red(
|
||||
_chalk().default.bold(name) + ':\n\n' + message + comment
|
||||
);
|
||||
Error.captureStackTrace(this, () => {});
|
||||
}
|
||||
}
|
||||
|
||||
exports.ValidationError = ValidationError;
|
||||
|
||||
const logValidationWarning = (name, message, comment) => {
|
||||
comment = comment ? '\n\n' + comment : '\n';
|
||||
console.warn(
|
||||
_chalk().default.yellow(
|
||||
_chalk().default.bold(name) + ':\n\n' + message + comment
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
exports.logValidationWarning = logValidationWarning;
|
||||
|
||||
const createDidYouMeanMessage = (unrecognized, allowedOptions) => {
|
||||
const suggestion = allowedOptions.find(option => {
|
||||
const steps = (0, _leven().default)(option, unrecognized);
|
||||
return steps < 3;
|
||||
});
|
||||
return suggestion
|
||||
? `Did you mean ${_chalk().default.bold(format(suggestion))}?`
|
||||
: '';
|
||||
};
|
||||
|
||||
exports.createDidYouMeanMessage = createDidYouMeanMessage;
|
12
node_modules/jest-validate/build/validate.d.ts
generated
vendored
Normal file
12
node_modules/jest-validate/build/validate.d.ts
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { ValidationOptions } from './types';
|
||||
declare const validate: (config: Record<string, any>, options: ValidationOptions) => {
|
||||
hasDeprecationWarnings: boolean;
|
||||
isValid: boolean;
|
||||
};
|
||||
export default validate;
|
131
node_modules/jest-validate/build/validate.js
generated
vendored
Normal file
131
node_modules/jest-validate/build/validate.js
generated
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var _defaultConfig = _interopRequireDefault(require('./defaultConfig'));
|
||||
|
||||
var _utils = require('./utils');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
let hasDeprecationWarnings = false;
|
||||
|
||||
const shouldSkipValidationForPath = (path, key, blacklist) =>
|
||||
blacklist ? blacklist.includes([...path, key].join('.')) : false;
|
||||
|
||||
const _validate = (config, exampleConfig, options, path = []) => {
|
||||
if (
|
||||
typeof config !== 'object' ||
|
||||
config == null ||
|
||||
typeof exampleConfig !== 'object' ||
|
||||
exampleConfig == null
|
||||
) {
|
||||
return {
|
||||
hasDeprecationWarnings
|
||||
};
|
||||
}
|
||||
|
||||
for (const key in config) {
|
||||
if (
|
||||
options.deprecatedConfig &&
|
||||
key in options.deprecatedConfig &&
|
||||
typeof options.deprecate === 'function'
|
||||
) {
|
||||
const isDeprecatedKey = options.deprecate(
|
||||
config,
|
||||
key,
|
||||
options.deprecatedConfig,
|
||||
options
|
||||
);
|
||||
hasDeprecationWarnings = hasDeprecationWarnings || isDeprecatedKey;
|
||||
} else if (allowsMultipleTypes(key)) {
|
||||
const value = config[key];
|
||||
|
||||
if (
|
||||
typeof options.condition === 'function' &&
|
||||
typeof options.error === 'function'
|
||||
) {
|
||||
if (key === 'maxWorkers' && !isOfTypeStringOrNumber(value)) {
|
||||
throw new _utils.ValidationError(
|
||||
'Validation Error',
|
||||
`${key} has to be of type string or number`,
|
||||
`maxWorkers=50% or\nmaxWorkers=3`
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if (Object.hasOwnProperty.call(exampleConfig, key)) {
|
||||
if (
|
||||
typeof options.condition === 'function' &&
|
||||
typeof options.error === 'function' &&
|
||||
!options.condition(config[key], exampleConfig[key])
|
||||
) {
|
||||
options.error(key, config[key], exampleConfig[key], options, path);
|
||||
}
|
||||
} else if (
|
||||
shouldSkipValidationForPath(path, key, options.recursiveBlacklist)
|
||||
) {
|
||||
// skip validating unknown options inside blacklisted paths
|
||||
} else {
|
||||
options.unknown &&
|
||||
options.unknown(config, exampleConfig, key, options, path);
|
||||
}
|
||||
|
||||
if (
|
||||
options.recursive &&
|
||||
!Array.isArray(exampleConfig[key]) &&
|
||||
options.recursiveBlacklist &&
|
||||
!shouldSkipValidationForPath(path, key, options.recursiveBlacklist)
|
||||
) {
|
||||
_validate(config[key], exampleConfig[key], options, [...path, key]);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
hasDeprecationWarnings
|
||||
};
|
||||
};
|
||||
|
||||
const allowsMultipleTypes = key => key === 'maxWorkers';
|
||||
|
||||
const isOfTypeStringOrNumber = value =>
|
||||
typeof value === 'number' || typeof value === 'string';
|
||||
|
||||
const validate = (config, options) => {
|
||||
hasDeprecationWarnings = false; // Preserve default blacklist entries even with user-supplied blacklist
|
||||
|
||||
const combinedBlacklist = [
|
||||
...(_defaultConfig.default.recursiveBlacklist || []),
|
||||
...(options.recursiveBlacklist || [])
|
||||
];
|
||||
const defaultedOptions = Object.assign({
|
||||
..._defaultConfig.default,
|
||||
...options,
|
||||
recursiveBlacklist: combinedBlacklist,
|
||||
title: options.title || _defaultConfig.default.title
|
||||
});
|
||||
|
||||
const {hasDeprecationWarnings: hdw} = _validate(
|
||||
config,
|
||||
options.exampleConfig,
|
||||
defaultedOptions
|
||||
);
|
||||
|
||||
return {
|
||||
hasDeprecationWarnings: hdw,
|
||||
isValid: true
|
||||
};
|
||||
};
|
||||
|
||||
var _default = validate;
|
||||
exports.default = _default;
|
14
node_modules/jest-validate/build/validateCLIOptions.d.ts
generated
vendored
Normal file
14
node_modules/jest-validate/build/validateCLIOptions.d.ts
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { Config } from '@jest/types';
|
||||
import type { Options } from 'yargs';
|
||||
import type { DeprecatedOptions } from './types';
|
||||
export declare const DOCUMENTATION_NOTE: string;
|
||||
export default function validateCLIOptions(argv: Config.Argv, options: {
|
||||
deprecationEntries: DeprecatedOptions;
|
||||
[s: string]: Options;
|
||||
}, rawArgv?: Array<string>): boolean;
|
133
node_modules/jest-validate/build/validateCLIOptions.js
generated
vendored
Normal file
133
node_modules/jest-validate/build/validateCLIOptions.js
generated
vendored
Normal file
@ -0,0 +1,133 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = validateCLIOptions;
|
||||
exports.DOCUMENTATION_NOTE = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _camelcase() {
|
||||
const data = _interopRequireDefault(require('camelcase'));
|
||||
|
||||
_camelcase = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _utils = require('./utils');
|
||||
|
||||
var _deprecated = require('./deprecated');
|
||||
|
||||
var _defaultConfig = _interopRequireDefault(require('./defaultConfig'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const BULLET = _chalk().default.bold('\u25cf');
|
||||
|
||||
const DOCUMENTATION_NOTE = ` ${_chalk().default.bold(
|
||||
'CLI Options Documentation:'
|
||||
)}
|
||||
https://jestjs.io/docs/en/cli.html
|
||||
`;
|
||||
exports.DOCUMENTATION_NOTE = DOCUMENTATION_NOTE;
|
||||
|
||||
const createCLIValidationError = (unrecognizedOptions, allowedOptions) => {
|
||||
let title = `${BULLET} Unrecognized CLI Parameter`;
|
||||
let message;
|
||||
const comment =
|
||||
` ${_chalk().default.bold('CLI Options Documentation')}:\n` +
|
||||
` https://jestjs.io/docs/en/cli.html\n`;
|
||||
|
||||
if (unrecognizedOptions.length === 1) {
|
||||
const unrecognized = unrecognizedOptions[0];
|
||||
const didYouMeanMessage = (0, _utils.createDidYouMeanMessage)(
|
||||
unrecognized,
|
||||
Array.from(allowedOptions)
|
||||
);
|
||||
message =
|
||||
` Unrecognized option ${_chalk().default.bold(
|
||||
(0, _utils.format)(unrecognized)
|
||||
)}.` + (didYouMeanMessage ? ` ${didYouMeanMessage}` : '');
|
||||
} else {
|
||||
title += 's';
|
||||
message =
|
||||
` Following options were not recognized:\n` +
|
||||
` ${_chalk().default.bold((0, _utils.format)(unrecognizedOptions))}`;
|
||||
}
|
||||
|
||||
return new _utils.ValidationError(title, message, comment);
|
||||
};
|
||||
|
||||
const logDeprecatedOptions = (deprecatedOptions, deprecationEntries, argv) => {
|
||||
deprecatedOptions.forEach(opt => {
|
||||
(0, _deprecated.deprecationWarning)(argv, opt, deprecationEntries, {
|
||||
..._defaultConfig.default,
|
||||
comment: DOCUMENTATION_NOTE
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function validateCLIOptions(argv, options, rawArgv = []) {
|
||||
const yargsSpecialOptions = ['$0', '_', 'help', 'h'];
|
||||
const deprecationEntries = options.deprecationEntries || {};
|
||||
const allowedOptions = Object.keys(options).reduce(
|
||||
(acc, option) => acc.add(option).add(options[option].alias || option),
|
||||
new Set(yargsSpecialOptions)
|
||||
);
|
||||
const unrecognizedOptions = Object.keys(argv).filter(
|
||||
arg =>
|
||||
!allowedOptions.has((0, _camelcase().default)(arg)) &&
|
||||
(!rawArgv.length || rawArgv.includes(arg)),
|
||||
[]
|
||||
);
|
||||
|
||||
if (unrecognizedOptions.length) {
|
||||
throw createCLIValidationError(unrecognizedOptions, allowedOptions);
|
||||
}
|
||||
|
||||
const CLIDeprecations = Object.keys(deprecationEntries).reduce(
|
||||
(acc, entry) => {
|
||||
if (options[entry]) {
|
||||
acc[entry] = deprecationEntries[entry];
|
||||
const alias = options[entry].alias;
|
||||
|
||||
if (alias) {
|
||||
acc[alias] = deprecationEntries[entry];
|
||||
}
|
||||
}
|
||||
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
const deprecations = new Set(Object.keys(CLIDeprecations));
|
||||
const deprecatedOptions = Object.keys(argv).filter(
|
||||
arg => deprecations.has(arg) && argv[arg] != null
|
||||
);
|
||||
|
||||
if (deprecatedOptions.length) {
|
||||
logDeprecatedOptions(deprecatedOptions, CLIDeprecations, argv);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
8
node_modules/jest-validate/build/warnings.d.ts
generated
vendored
Normal file
8
node_modules/jest-validate/build/warnings.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { ValidationOptions } from './types';
|
||||
export declare const unknownOptionWarning: (config: Record<string, any>, exampleConfig: Record<string, any>, option: string, options: ValidationOptions, path?: string[] | undefined) => void;
|
48
node_modules/jest-validate/build/warnings.js
generated
vendored
Normal file
48
node_modules/jest-validate/build/warnings.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.unknownOptionWarning = void 0;
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _utils = require('./utils');
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const unknownOptionWarning = (config, exampleConfig, option, options, path) => {
|
||||
const didYouMean = (0, _utils.createDidYouMeanMessage)(
|
||||
option,
|
||||
Object.keys(exampleConfig)
|
||||
);
|
||||
const message =
|
||||
` Unknown option ${_chalk().default.bold(
|
||||
`"${path && path.length > 0 ? path.join('.') + '.' : ''}${option}"`
|
||||
)} with value ${_chalk().default.bold(
|
||||
(0, _utils.format)(config[option])
|
||||
)} was found.` +
|
||||
(didYouMean && ` ${didYouMean}`) +
|
||||
`\n This is probably a typing mistake. Fixing it will remove this message.`;
|
||||
const comment = options.comment;
|
||||
const name = (options.title && options.title.warning) || _utils.WARNING;
|
||||
(0, _utils.logValidationWarning)(name, message, comment);
|
||||
};
|
||||
|
||||
exports.unknownOptionWarning = unknownOptionWarning;
|
345
node_modules/jest-validate/node_modules/ansi-styles/index.d.ts
generated
vendored
Normal file
345
node_modules/jest-validate/node_modules/ansi-styles/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,345 @@
|
||||
declare type CSSColor =
|
||||
| 'aliceblue'
|
||||
| 'antiquewhite'
|
||||
| 'aqua'
|
||||
| 'aquamarine'
|
||||
| 'azure'
|
||||
| 'beige'
|
||||
| 'bisque'
|
||||
| 'black'
|
||||
| 'blanchedalmond'
|
||||
| 'blue'
|
||||
| 'blueviolet'
|
||||
| 'brown'
|
||||
| 'burlywood'
|
||||
| 'cadetblue'
|
||||
| 'chartreuse'
|
||||
| 'chocolate'
|
||||
| 'coral'
|
||||
| 'cornflowerblue'
|
||||
| 'cornsilk'
|
||||
| 'crimson'
|
||||
| 'cyan'
|
||||
| 'darkblue'
|
||||
| 'darkcyan'
|
||||
| 'darkgoldenrod'
|
||||
| 'darkgray'
|
||||
| 'darkgreen'
|
||||
| 'darkgrey'
|
||||
| 'darkkhaki'
|
||||
| 'darkmagenta'
|
||||
| 'darkolivegreen'
|
||||
| 'darkorange'
|
||||
| 'darkorchid'
|
||||
| 'darkred'
|
||||
| 'darksalmon'
|
||||
| 'darkseagreen'
|
||||
| 'darkslateblue'
|
||||
| 'darkslategray'
|
||||
| 'darkslategrey'
|
||||
| 'darkturquoise'
|
||||
| 'darkviolet'
|
||||
| 'deeppink'
|
||||
| 'deepskyblue'
|
||||
| 'dimgray'
|
||||
| 'dimgrey'
|
||||
| 'dodgerblue'
|
||||
| 'firebrick'
|
||||
| 'floralwhite'
|
||||
| 'forestgreen'
|
||||
| 'fuchsia'
|
||||
| 'gainsboro'
|
||||
| 'ghostwhite'
|
||||
| 'gold'
|
||||
| 'goldenrod'
|
||||
| 'gray'
|
||||
| 'green'
|
||||
| 'greenyellow'
|
||||
| 'grey'
|
||||
| 'honeydew'
|
||||
| 'hotpink'
|
||||
| 'indianred'
|
||||
| 'indigo'
|
||||
| 'ivory'
|
||||
| 'khaki'
|
||||
| 'lavender'
|
||||
| 'lavenderblush'
|
||||
| 'lawngreen'
|
||||
| 'lemonchiffon'
|
||||
| 'lightblue'
|
||||
| 'lightcoral'
|
||||
| 'lightcyan'
|
||||
| 'lightgoldenrodyellow'
|
||||
| 'lightgray'
|
||||
| 'lightgreen'
|
||||
| 'lightgrey'
|
||||
| 'lightpink'
|
||||
| 'lightsalmon'
|
||||
| 'lightseagreen'
|
||||
| 'lightskyblue'
|
||||
| 'lightslategray'
|
||||
| 'lightslategrey'
|
||||
| 'lightsteelblue'
|
||||
| 'lightyellow'
|
||||
| 'lime'
|
||||
| 'limegreen'
|
||||
| 'linen'
|
||||
| 'magenta'
|
||||
| 'maroon'
|
||||
| 'mediumaquamarine'
|
||||
| 'mediumblue'
|
||||
| 'mediumorchid'
|
||||
| 'mediumpurple'
|
||||
| 'mediumseagreen'
|
||||
| 'mediumslateblue'
|
||||
| 'mediumspringgreen'
|
||||
| 'mediumturquoise'
|
||||
| 'mediumvioletred'
|
||||
| 'midnightblue'
|
||||
| 'mintcream'
|
||||
| 'mistyrose'
|
||||
| 'moccasin'
|
||||
| 'navajowhite'
|
||||
| 'navy'
|
||||
| 'oldlace'
|
||||
| 'olive'
|
||||
| 'olivedrab'
|
||||
| 'orange'
|
||||
| 'orangered'
|
||||
| 'orchid'
|
||||
| 'palegoldenrod'
|
||||
| 'palegreen'
|
||||
| 'paleturquoise'
|
||||
| 'palevioletred'
|
||||
| 'papayawhip'
|
||||
| 'peachpuff'
|
||||
| 'peru'
|
||||
| 'pink'
|
||||
| 'plum'
|
||||
| 'powderblue'
|
||||
| 'purple'
|
||||
| 'rebeccapurple'
|
||||
| 'red'
|
||||
| 'rosybrown'
|
||||
| 'royalblue'
|
||||
| 'saddlebrown'
|
||||
| 'salmon'
|
||||
| 'sandybrown'
|
||||
| 'seagreen'
|
||||
| 'seashell'
|
||||
| 'sienna'
|
||||
| 'silver'
|
||||
| 'skyblue'
|
||||
| 'slateblue'
|
||||
| 'slategray'
|
||||
| 'slategrey'
|
||||
| 'snow'
|
||||
| 'springgreen'
|
||||
| 'steelblue'
|
||||
| 'tan'
|
||||
| 'teal'
|
||||
| 'thistle'
|
||||
| 'tomato'
|
||||
| 'turquoise'
|
||||
| 'violet'
|
||||
| 'wheat'
|
||||
| 'white'
|
||||
| 'whitesmoke'
|
||||
| 'yellow'
|
||||
| 'yellowgreen';
|
||||
|
||||
declare namespace ansiStyles {
|
||||
interface ColorConvert {
|
||||
/**
|
||||
The RGB color space.
|
||||
|
||||
@param red - (`0`-`255`)
|
||||
@param green - (`0`-`255`)
|
||||
@param blue - (`0`-`255`)
|
||||
*/
|
||||
rgb(red: number, green: number, blue: number): string;
|
||||
|
||||
/**
|
||||
The RGB HEX color space.
|
||||
|
||||
@param hex - A hexadecimal string containing RGB data.
|
||||
*/
|
||||
hex(hex: string): string;
|
||||
|
||||
/**
|
||||
@param keyword - A CSS color name.
|
||||
*/
|
||||
keyword(keyword: CSSColor): string;
|
||||
|
||||
/**
|
||||
The HSL color space.
|
||||
|
||||
@param hue - (`0`-`360`)
|
||||
@param saturation - (`0`-`100`)
|
||||
@param lightness - (`0`-`100`)
|
||||
*/
|
||||
hsl(hue: number, saturation: number, lightness: number): string;
|
||||
|
||||
/**
|
||||
The HSV color space.
|
||||
|
||||
@param hue - (`0`-`360`)
|
||||
@param saturation - (`0`-`100`)
|
||||
@param value - (`0`-`100`)
|
||||
*/
|
||||
hsv(hue: number, saturation: number, value: number): string;
|
||||
|
||||
/**
|
||||
The HSV color space.
|
||||
|
||||
@param hue - (`0`-`360`)
|
||||
@param whiteness - (`0`-`100`)
|
||||
@param blackness - (`0`-`100`)
|
||||
*/
|
||||
hwb(hue: number, whiteness: number, blackness: number): string;
|
||||
|
||||
/**
|
||||
Use a [4-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4-bit) to set text color.
|
||||
*/
|
||||
ansi(ansi: number): string;
|
||||
|
||||
/**
|
||||
Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
||||
*/
|
||||
ansi256(ansi: number): string;
|
||||
}
|
||||
|
||||
interface CSPair {
|
||||
/**
|
||||
The ANSI terminal control sequence for starting this style.
|
||||
*/
|
||||
readonly open: string;
|
||||
|
||||
/**
|
||||
The ANSI terminal control sequence for ending this style.
|
||||
*/
|
||||
readonly close: string;
|
||||
}
|
||||
|
||||
interface ColorBase {
|
||||
readonly ansi: ColorConvert;
|
||||
readonly ansi256: ColorConvert;
|
||||
readonly ansi16m: ColorConvert;
|
||||
|
||||
/**
|
||||
The ANSI terminal control sequence for ending this color.
|
||||
*/
|
||||
readonly close: string;
|
||||
}
|
||||
|
||||
interface Modifier {
|
||||
/**
|
||||
Resets the current color chain.
|
||||
*/
|
||||
readonly reset: CSPair;
|
||||
|
||||
/**
|
||||
Make text bold.
|
||||
*/
|
||||
readonly bold: CSPair;
|
||||
|
||||
/**
|
||||
Emitting only a small amount of light.
|
||||
*/
|
||||
readonly dim: CSPair;
|
||||
|
||||
/**
|
||||
Make text italic. (Not widely supported)
|
||||
*/
|
||||
readonly italic: CSPair;
|
||||
|
||||
/**
|
||||
Make text underline. (Not widely supported)
|
||||
*/
|
||||
readonly underline: CSPair;
|
||||
|
||||
/**
|
||||
Inverse background and foreground colors.
|
||||
*/
|
||||
readonly inverse: CSPair;
|
||||
|
||||
/**
|
||||
Prints the text, but makes it invisible.
|
||||
*/
|
||||
readonly hidden: CSPair;
|
||||
|
||||
/**
|
||||
Puts a horizontal line through the center of the text. (Not widely supported)
|
||||
*/
|
||||
readonly strikethrough: CSPair;
|
||||
}
|
||||
|
||||
interface ForegroundColor {
|
||||
readonly black: CSPair;
|
||||
readonly red: CSPair;
|
||||
readonly green: CSPair;
|
||||
readonly yellow: CSPair;
|
||||
readonly blue: CSPair;
|
||||
readonly cyan: CSPair;
|
||||
readonly magenta: CSPair;
|
||||
readonly white: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly gray: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly grey: CSPair;
|
||||
|
||||
readonly blackBright: CSPair;
|
||||
readonly redBright: CSPair;
|
||||
readonly greenBright: CSPair;
|
||||
readonly yellowBright: CSPair;
|
||||
readonly blueBright: CSPair;
|
||||
readonly cyanBright: CSPair;
|
||||
readonly magentaBright: CSPair;
|
||||
readonly whiteBright: CSPair;
|
||||
}
|
||||
|
||||
interface BackgroundColor {
|
||||
readonly bgBlack: CSPair;
|
||||
readonly bgRed: CSPair;
|
||||
readonly bgGreen: CSPair;
|
||||
readonly bgYellow: CSPair;
|
||||
readonly bgBlue: CSPair;
|
||||
readonly bgCyan: CSPair;
|
||||
readonly bgMagenta: CSPair;
|
||||
readonly bgWhite: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGray: CSPair;
|
||||
|
||||
/**
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGrey: CSPair;
|
||||
|
||||
readonly bgBlackBright: CSPair;
|
||||
readonly bgRedBright: CSPair;
|
||||
readonly bgGreenBright: CSPair;
|
||||
readonly bgYellowBright: CSPair;
|
||||
readonly bgBlueBright: CSPair;
|
||||
readonly bgCyanBright: CSPair;
|
||||
readonly bgMagentaBright: CSPair;
|
||||
readonly bgWhiteBright: CSPair;
|
||||
}
|
||||
}
|
||||
|
||||
declare const ansiStyles: {
|
||||
readonly modifier: ansiStyles.Modifier;
|
||||
readonly color: ansiStyles.ForegroundColor & ansiStyles.ColorBase;
|
||||
readonly bgColor: ansiStyles.BackgroundColor & ansiStyles.ColorBase;
|
||||
readonly codes: ReadonlyMap<number, number>;
|
||||
} & ansiStyles.BackgroundColor & ansiStyles.ForegroundColor & ansiStyles.Modifier;
|
||||
|
||||
export = ansiStyles;
|
163
node_modules/jest-validate/node_modules/ansi-styles/index.js
generated
vendored
Normal file
163
node_modules/jest-validate/node_modules/ansi-styles/index.js
generated
vendored
Normal file
@ -0,0 +1,163 @@
|
||||
'use strict';
|
||||
|
||||
const wrapAnsi16 = (fn, offset) => (...args) => {
|
||||
const code = fn(...args);
|
||||
return `\u001B[${code + offset}m`;
|
||||
};
|
||||
|
||||
const wrapAnsi256 = (fn, offset) => (...args) => {
|
||||
const code = fn(...args);
|
||||
return `\u001B[${38 + offset};5;${code}m`;
|
||||
};
|
||||
|
||||
const wrapAnsi16m = (fn, offset) => (...args) => {
|
||||
const rgb = fn(...args);
|
||||
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
||||
};
|
||||
|
||||
const ansi2ansi = n => n;
|
||||
const rgb2rgb = (r, g, b) => [r, g, b];
|
||||
|
||||
const setLazyProperty = (object, property, get) => {
|
||||
Object.defineProperty(object, property, {
|
||||
get: () => {
|
||||
const value = get();
|
||||
|
||||
Object.defineProperty(object, property, {
|
||||
value,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
return value;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
};
|
||||
|
||||
/** @type {typeof import('color-convert')} */
|
||||
let colorConvert;
|
||||
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
||||
if (colorConvert === undefined) {
|
||||
colorConvert = require('color-convert');
|
||||
}
|
||||
|
||||
const offset = isBackground ? 10 : 0;
|
||||
const styles = {};
|
||||
|
||||
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
||||
const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
|
||||
if (sourceSpace === targetSpace) {
|
||||
styles[name] = wrap(identity, offset);
|
||||
} else if (typeof suite === 'object') {
|
||||
styles[name] = wrap(suite[targetSpace], offset);
|
||||
}
|
||||
}
|
||||
|
||||
return styles;
|
||||
};
|
||||
|
||||
function assembleStyles() {
|
||||
const codes = new Map();
|
||||
const styles = {
|
||||
modifier: {
|
||||
reset: [0, 0],
|
||||
// 21 isn't widely supported and 22 does the same thing
|
||||
bold: [1, 22],
|
||||
dim: [2, 22],
|
||||
italic: [3, 23],
|
||||
underline: [4, 24],
|
||||
inverse: [7, 27],
|
||||
hidden: [8, 28],
|
||||
strikethrough: [9, 29]
|
||||
},
|
||||
color: {
|
||||
black: [30, 39],
|
||||
red: [31, 39],
|
||||
green: [32, 39],
|
||||
yellow: [33, 39],
|
||||
blue: [34, 39],
|
||||
magenta: [35, 39],
|
||||
cyan: [36, 39],
|
||||
white: [37, 39],
|
||||
|
||||
// Bright color
|
||||
blackBright: [90, 39],
|
||||
redBright: [91, 39],
|
||||
greenBright: [92, 39],
|
||||
yellowBright: [93, 39],
|
||||
blueBright: [94, 39],
|
||||
magentaBright: [95, 39],
|
||||
cyanBright: [96, 39],
|
||||
whiteBright: [97, 39]
|
||||
},
|
||||
bgColor: {
|
||||
bgBlack: [40, 49],
|
||||
bgRed: [41, 49],
|
||||
bgGreen: [42, 49],
|
||||
bgYellow: [43, 49],
|
||||
bgBlue: [44, 49],
|
||||
bgMagenta: [45, 49],
|
||||
bgCyan: [46, 49],
|
||||
bgWhite: [47, 49],
|
||||
|
||||
// Bright color
|
||||
bgBlackBright: [100, 49],
|
||||
bgRedBright: [101, 49],
|
||||
bgGreenBright: [102, 49],
|
||||
bgYellowBright: [103, 49],
|
||||
bgBlueBright: [104, 49],
|
||||
bgMagentaBright: [105, 49],
|
||||
bgCyanBright: [106, 49],
|
||||
bgWhiteBright: [107, 49]
|
||||
}
|
||||
};
|
||||
|
||||
// Alias bright black as gray (and grey)
|
||||
styles.color.gray = styles.color.blackBright;
|
||||
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
||||
styles.color.grey = styles.color.blackBright;
|
||||
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
||||
|
||||
for (const [groupName, group] of Object.entries(styles)) {
|
||||
for (const [styleName, style] of Object.entries(group)) {
|
||||
styles[styleName] = {
|
||||
open: `\u001B[${style[0]}m`,
|
||||
close: `\u001B[${style[1]}m`
|
||||
};
|
||||
|
||||
group[styleName] = styles[styleName];
|
||||
|
||||
codes.set(style[0], style[1]);
|
||||
}
|
||||
|
||||
Object.defineProperty(styles, groupName, {
|
||||
value: group,
|
||||
enumerable: false
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(styles, 'codes', {
|
||||
value: codes,
|
||||
enumerable: false
|
||||
});
|
||||
|
||||
styles.color.close = '\u001B[39m';
|
||||
styles.bgColor.close = '\u001B[49m';
|
||||
|
||||
setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
|
||||
setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
|
||||
setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
|
||||
setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
|
||||
setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
|
||||
setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
|
||||
|
||||
return styles;
|
||||
}
|
||||
|
||||
// Make the export immutable
|
||||
Object.defineProperty(module, 'exports', {
|
||||
enumerable: true,
|
||||
get: assembleStyles
|
||||
});
|
9
node_modules/jest-validate/node_modules/ansi-styles/license
generated
vendored
Normal file
9
node_modules/jest-validate/node_modules/ansi-styles/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
56
node_modules/jest-validate/node_modules/ansi-styles/package.json
generated
vendored
Normal file
56
node_modules/jest-validate/node_modules/ansi-styles/package.json
generated
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
"name": "ansi-styles",
|
||||
"version": "4.3.0",
|
||||
"description": "ANSI escape codes for styling strings in the terminal",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/ansi-styles",
|
||||
"funding": "https://github.com/chalk/ansi-styles?sponsor=1",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd",
|
||||
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"ansi",
|
||||
"styles",
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"tty",
|
||||
"escape",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/color-convert": "^1.9.0",
|
||||
"ava": "^2.3.0",
|
||||
"svg-term-cli": "^2.1.1",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.25.3"
|
||||
}
|
||||
}
|
152
node_modules/jest-validate/node_modules/ansi-styles/readme.md
generated
vendored
Normal file
152
node_modules/jest-validate/node_modules/ansi-styles/readme.md
generated
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
# ansi-styles [](https://travis-ci.org/chalk/ansi-styles)
|
||||
|
||||
> [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
|
||||
|
||||
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
|
||||
|
||||
<img src="screenshot.svg" width="900">
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install ansi-styles
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const style = require('ansi-styles');
|
||||
|
||||
console.log(`${style.green.open}Hello world!${style.green.close}`);
|
||||
|
||||
|
||||
// Color conversion between 16/256/truecolor
|
||||
// NOTE: If conversion goes to 16 colors or 256 colors, the original color
|
||||
// may be degraded to fit that color palette. This means terminals
|
||||
// that do not support 16 million colors will best-match the
|
||||
// original color.
|
||||
console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
|
||||
console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
|
||||
console.log(style.color.ansi16m.hex('#abcdef') + 'Hello world!' + style.color.close);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
Each style has an `open` and `close` property.
|
||||
|
||||
## Styles
|
||||
|
||||
### Modifiers
|
||||
|
||||
- `reset`
|
||||
- `bold`
|
||||
- `dim`
|
||||
- `italic` *(Not widely supported)*
|
||||
- `underline`
|
||||
- `inverse`
|
||||
- `hidden`
|
||||
- `strikethrough` *(Not widely supported)*
|
||||
|
||||
### Colors
|
||||
|
||||
- `black`
|
||||
- `red`
|
||||
- `green`
|
||||
- `yellow`
|
||||
- `blue`
|
||||
- `magenta`
|
||||
- `cyan`
|
||||
- `white`
|
||||
- `blackBright` (alias: `gray`, `grey`)
|
||||
- `redBright`
|
||||
- `greenBright`
|
||||
- `yellowBright`
|
||||
- `blueBright`
|
||||
- `magentaBright`
|
||||
- `cyanBright`
|
||||
- `whiteBright`
|
||||
|
||||
### Background colors
|
||||
|
||||
- `bgBlack`
|
||||
- `bgRed`
|
||||
- `bgGreen`
|
||||
- `bgYellow`
|
||||
- `bgBlue`
|
||||
- `bgMagenta`
|
||||
- `bgCyan`
|
||||
- `bgWhite`
|
||||
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
||||
- `bgRedBright`
|
||||
- `bgGreenBright`
|
||||
- `bgYellowBright`
|
||||
- `bgBlueBright`
|
||||
- `bgMagentaBright`
|
||||
- `bgCyanBright`
|
||||
- `bgWhiteBright`
|
||||
|
||||
## Advanced usage
|
||||
|
||||
By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
|
||||
|
||||
- `style.modifier`
|
||||
- `style.color`
|
||||
- `style.bgColor`
|
||||
|
||||
###### Example
|
||||
|
||||
```js
|
||||
console.log(style.color.green.open);
|
||||
```
|
||||
|
||||
Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
|
||||
|
||||
###### Example
|
||||
|
||||
```js
|
||||
console.log(style.codes.get(36));
|
||||
//=> 39
|
||||
```
|
||||
|
||||
## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
|
||||
|
||||
`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
|
||||
|
||||
The following color spaces from `color-convert` are supported:
|
||||
|
||||
- `rgb`
|
||||
- `hex`
|
||||
- `keyword`
|
||||
- `hsl`
|
||||
- `hsv`
|
||||
- `hwb`
|
||||
- `ansi`
|
||||
- `ansi256`
|
||||
|
||||
To use these, call the associated conversion function with the intended output, for example:
|
||||
|
||||
```js
|
||||
style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code
|
||||
style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code
|
||||
|
||||
style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
|
||||
style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code
|
||||
|
||||
style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code
|
||||
style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
## For enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
411
node_modules/jest-validate/node_modules/chalk/index.d.ts
generated
vendored
Normal file
411
node_modules/jest-validate/node_modules/chalk/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,411 @@
|
||||
declare const enum LevelEnum {
|
||||
/**
|
||||
All colors disabled.
|
||||
*/
|
||||
None = 0,
|
||||
|
||||
/**
|
||||
Basic 16 colors support.
|
||||
*/
|
||||
Basic = 1,
|
||||
|
||||
/**
|
||||
ANSI 256 colors support.
|
||||
*/
|
||||
Ansi256 = 2,
|
||||
|
||||
/**
|
||||
Truecolor 16 million colors support.
|
||||
*/
|
||||
TrueColor = 3
|
||||
}
|
||||
|
||||
/**
|
||||
Basic foreground colors.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
declare type ForegroundColor =
|
||||
| 'black'
|
||||
| 'red'
|
||||
| 'green'
|
||||
| 'yellow'
|
||||
| 'blue'
|
||||
| 'magenta'
|
||||
| 'cyan'
|
||||
| 'white'
|
||||
| 'gray'
|
||||
| 'grey'
|
||||
| 'blackBright'
|
||||
| 'redBright'
|
||||
| 'greenBright'
|
||||
| 'yellowBright'
|
||||
| 'blueBright'
|
||||
| 'magentaBright'
|
||||
| 'cyanBright'
|
||||
| 'whiteBright';
|
||||
|
||||
/**
|
||||
Basic background colors.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
declare type BackgroundColor =
|
||||
| 'bgBlack'
|
||||
| 'bgRed'
|
||||
| 'bgGreen'
|
||||
| 'bgYellow'
|
||||
| 'bgBlue'
|
||||
| 'bgMagenta'
|
||||
| 'bgCyan'
|
||||
| 'bgWhite'
|
||||
| 'bgGray'
|
||||
| 'bgGrey'
|
||||
| 'bgBlackBright'
|
||||
| 'bgRedBright'
|
||||
| 'bgGreenBright'
|
||||
| 'bgYellowBright'
|
||||
| 'bgBlueBright'
|
||||
| 'bgMagentaBright'
|
||||
| 'bgCyanBright'
|
||||
| 'bgWhiteBright';
|
||||
|
||||
/**
|
||||
Basic colors.
|
||||
|
||||
[More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
|
||||
*/
|
||||
declare type Color = ForegroundColor | BackgroundColor;
|
||||
|
||||
declare type Modifiers =
|
||||
| 'reset'
|
||||
| 'bold'
|
||||
| 'dim'
|
||||
| 'italic'
|
||||
| 'underline'
|
||||
| 'inverse'
|
||||
| 'hidden'
|
||||
| 'strikethrough'
|
||||
| 'visible';
|
||||
|
||||
declare namespace chalk {
|
||||
type Level = LevelEnum;
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
Specify the color support for Chalk.
|
||||
By default, color support is automatically detected based on the environment.
|
||||
*/
|
||||
level?: Level;
|
||||
}
|
||||
|
||||
interface Instance {
|
||||
/**
|
||||
Return a new Chalk instance.
|
||||
*/
|
||||
new (options?: Options): Chalk;
|
||||
}
|
||||
|
||||
/**
|
||||
Detect whether the terminal supports color.
|
||||
*/
|
||||
interface ColorSupport {
|
||||
/**
|
||||
The color level used by Chalk.
|
||||
*/
|
||||
level: Level;
|
||||
|
||||
/**
|
||||
Return whether Chalk supports basic 16 colors.
|
||||
*/
|
||||
hasBasic: boolean;
|
||||
|
||||
/**
|
||||
Return whether Chalk supports ANSI 256 colors.
|
||||
*/
|
||||
has256: boolean;
|
||||
|
||||
/**
|
||||
Return whether Chalk supports Truecolor 16 million colors.
|
||||
*/
|
||||
has16m: boolean;
|
||||
}
|
||||
|
||||
interface ChalkFunction {
|
||||
/**
|
||||
Use a template string.
|
||||
|
||||
@remarks Template literals are unsupported for nested calls (see [issue #341](https://github.com/chalk/chalk/issues/341))
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk = require('chalk');
|
||||
|
||||
log(chalk`
|
||||
CPU: {red ${cpu.totalPercent}%}
|
||||
RAM: {green ${ram.used / ram.total * 100}%}
|
||||
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
||||
`);
|
||||
```
|
||||
*/
|
||||
(text: TemplateStringsArray, ...placeholders: unknown[]): string;
|
||||
|
||||
(...text: unknown[]): string;
|
||||
}
|
||||
|
||||
interface Chalk extends ChalkFunction {
|
||||
/**
|
||||
Return a new Chalk instance.
|
||||
*/
|
||||
Instance: Instance;
|
||||
|
||||
/**
|
||||
The color support for Chalk.
|
||||
By default, color support is automatically detected based on the environment.
|
||||
*/
|
||||
level: Level;
|
||||
|
||||
/**
|
||||
Use HEX value to set text color.
|
||||
|
||||
@param color - Hexadecimal value representing the desired color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk = require('chalk');
|
||||
|
||||
chalk.hex('#DEADED');
|
||||
```
|
||||
*/
|
||||
hex(color: string): Chalk;
|
||||
|
||||
/**
|
||||
Use keyword color value to set text color.
|
||||
|
||||
@param color - Keyword value representing the desired color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk = require('chalk');
|
||||
|
||||
chalk.keyword('orange');
|
||||
```
|
||||
*/
|
||||
keyword(color: string): Chalk;
|
||||
|
||||
/**
|
||||
Use RGB values to set text color.
|
||||
*/
|
||||
rgb(red: number, green: number, blue: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HSL values to set text color.
|
||||
*/
|
||||
hsl(hue: number, saturation: number, lightness: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HSV values to set text color.
|
||||
*/
|
||||
hsv(hue: number, saturation: number, value: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HWB values to set text color.
|
||||
*/
|
||||
hwb(hue: number, whiteness: number, blackness: number): Chalk;
|
||||
|
||||
/**
|
||||
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.
|
||||
|
||||
30 <= code && code < 38 || 90 <= code && code < 98
|
||||
For example, 31 for red, 91 for redBright.
|
||||
*/
|
||||
ansi(code: number): Chalk;
|
||||
|
||||
/**
|
||||
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
||||
*/
|
||||
ansi256(index: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HEX value to set background color.
|
||||
|
||||
@param color - Hexadecimal value representing the desired color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk = require('chalk');
|
||||
|
||||
chalk.bgHex('#DEADED');
|
||||
```
|
||||
*/
|
||||
bgHex(color: string): Chalk;
|
||||
|
||||
/**
|
||||
Use keyword color value to set background color.
|
||||
|
||||
@param color - Keyword value representing the desired color.
|
||||
|
||||
@example
|
||||
```
|
||||
import chalk = require('chalk');
|
||||
|
||||
chalk.bgKeyword('orange');
|
||||
```
|
||||
*/
|
||||
bgKeyword(color: string): Chalk;
|
||||
|
||||
/**
|
||||
Use RGB values to set background color.
|
||||
*/
|
||||
bgRgb(red: number, green: number, blue: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HSL values to set background color.
|
||||
*/
|
||||
bgHsl(hue: number, saturation: number, lightness: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HSV values to set background color.
|
||||
*/
|
||||
bgHsv(hue: number, saturation: number, value: number): Chalk;
|
||||
|
||||
/**
|
||||
Use HWB values to set background color.
|
||||
*/
|
||||
bgHwb(hue: number, whiteness: number, blackness: number): Chalk;
|
||||
|
||||
/**
|
||||
Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.
|
||||
|
||||
30 <= code && code < 38 || 90 <= code && code < 98
|
||||
For example, 31 for red, 91 for redBright.
|
||||
Use the foreground code, not the background code (for example, not 41, nor 101).
|
||||
*/
|
||||
bgAnsi(code: number): Chalk;
|
||||
|
||||
/**
|
||||
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
|
||||
*/
|
||||
bgAnsi256(index: number): Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Resets the current color chain.
|
||||
*/
|
||||
readonly reset: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Make text bold.
|
||||
*/
|
||||
readonly bold: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Emitting only a small amount of light.
|
||||
*/
|
||||
readonly dim: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Make text italic. (Not widely supported)
|
||||
*/
|
||||
readonly italic: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Make text underline. (Not widely supported)
|
||||
*/
|
||||
readonly underline: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Inverse background and foreground colors.
|
||||
*/
|
||||
readonly inverse: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Prints the text, but makes it invisible.
|
||||
*/
|
||||
readonly hidden: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Puts a horizontal line through the center of the text. (Not widely supported)
|
||||
*/
|
||||
readonly strikethrough: Chalk;
|
||||
|
||||
/**
|
||||
Modifier: Prints the text only when Chalk has a color support level > 0.
|
||||
Can be useful for things that are purely cosmetic.
|
||||
*/
|
||||
readonly visible: Chalk;
|
||||
|
||||
readonly black: Chalk;
|
||||
readonly red: Chalk;
|
||||
readonly green: Chalk;
|
||||
readonly yellow: Chalk;
|
||||
readonly blue: Chalk;
|
||||
readonly magenta: Chalk;
|
||||
readonly cyan: Chalk;
|
||||
readonly white: Chalk;
|
||||
|
||||
/*
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly gray: Chalk;
|
||||
|
||||
/*
|
||||
Alias for `blackBright`.
|
||||
*/
|
||||
readonly grey: Chalk;
|
||||
|
||||
readonly blackBright: Chalk;
|
||||
readonly redBright: Chalk;
|
||||
readonly greenBright: Chalk;
|
||||
readonly yellowBright: Chalk;
|
||||
readonly blueBright: Chalk;
|
||||
readonly magentaBright: Chalk;
|
||||
readonly cyanBright: Chalk;
|
||||
readonly whiteBright: Chalk;
|
||||
|
||||
readonly bgBlack: Chalk;
|
||||
readonly bgRed: Chalk;
|
||||
readonly bgGreen: Chalk;
|
||||
readonly bgYellow: Chalk;
|
||||
readonly bgBlue: Chalk;
|
||||
readonly bgMagenta: Chalk;
|
||||
readonly bgCyan: Chalk;
|
||||
readonly bgWhite: Chalk;
|
||||
|
||||
/*
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGray: Chalk;
|
||||
|
||||
/*
|
||||
Alias for `bgBlackBright`.
|
||||
*/
|
||||
readonly bgGrey: Chalk;
|
||||
|
||||
readonly bgBlackBright: Chalk;
|
||||
readonly bgRedBright: Chalk;
|
||||
readonly bgGreenBright: Chalk;
|
||||
readonly bgYellowBright: Chalk;
|
||||
readonly bgBlueBright: Chalk;
|
||||
readonly bgMagentaBright: Chalk;
|
||||
readonly bgCyanBright: Chalk;
|
||||
readonly bgWhiteBright: Chalk;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Main Chalk object that allows to chain styles together.
|
||||
Call the last one as a method with a string argument.
|
||||
Order doesn't matter, and later styles take precedent in case of a conflict.
|
||||
This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
||||
*/
|
||||
declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
|
||||
supportsColor: chalk.ColorSupport | false;
|
||||
Level: typeof LevelEnum;
|
||||
Color: Color;
|
||||
ForegroundColor: ForegroundColor;
|
||||
BackgroundColor: BackgroundColor;
|
||||
Modifiers: Modifiers;
|
||||
stderr: chalk.Chalk & {supportsColor: chalk.ColorSupport | false};
|
||||
};
|
||||
|
||||
export = chalk;
|
9
node_modules/jest-validate/node_modules/chalk/license
generated
vendored
Normal file
9
node_modules/jest-validate/node_modules/chalk/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
63
node_modules/jest-validate/node_modules/chalk/package.json
generated
vendored
Normal file
63
node_modules/jest-validate/node_modules/chalk/package.json
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "chalk",
|
||||
"version": "3.0.0",
|
||||
"description": "Terminal string styling done right",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/chalk",
|
||||
"main": "source",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && nyc ava && tsd",
|
||||
"bench": "matcha benchmark.js"
|
||||
},
|
||||
"files": [
|
||||
"source",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"str",
|
||||
"ansi",
|
||||
"style",
|
||||
"styles",
|
||||
"tty",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^2.4.0",
|
||||
"coveralls": "^3.0.7",
|
||||
"execa": "^3.2.0",
|
||||
"import-fresh": "^3.1.0",
|
||||
"matcha": "^0.7.0",
|
||||
"nyc": "^14.1.1",
|
||||
"resolve-from": "^5.0.0",
|
||||
"tsd": "^0.7.4",
|
||||
"xo": "^0.25.3"
|
||||
},
|
||||
"xo": {
|
||||
"rules": {
|
||||
"unicorn/prefer-string-slice": "off",
|
||||
"unicorn/prefer-includes": "off"
|
||||
}
|
||||
}
|
||||
}
|
304
node_modules/jest-validate/node_modules/chalk/readme.md
generated
vendored
Normal file
304
node_modules/jest-validate/node_modules/chalk/readme.md
generated
vendored
Normal file
@ -0,0 +1,304 @@
|
||||
<h1 align="center">
|
||||
<br>
|
||||
<br>
|
||||
<img width="320" src="media/logo.svg" alt="Chalk">
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
</h1>
|
||||
|
||||
> Terminal string styling done right
|
||||
|
||||
[](https://travis-ci.org/chalk/chalk) [](https://coveralls.io/github/chalk/chalk?branch=master) [](https://www.npmjs.com/package/chalk?activeTab=dependents) [](https://www.npmjs.com/package/chalk) [](https://www.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/xojs/xo) 
|
||||
|
||||
<img src="https://cdn.jsdelivr.net/gh/chalk/ansi-styles@8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" width="900">
|
||||
|
||||
|
||||
## Highlights
|
||||
|
||||
- Expressive API
|
||||
- Highly performant
|
||||
- Ability to nest styles
|
||||
- [256/Truecolor color support](#256-and-truecolor-color-support)
|
||||
- Auto-detects color support
|
||||
- Doesn't extend `String.prototype`
|
||||
- Clean and focused
|
||||
- Actively maintained
|
||||
- [Used by ~46,000 packages](https://www.npmjs.com/browse/depended/chalk) as of October 1, 2019
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```console
|
||||
$ npm install chalk
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
|
||||
console.log(chalk.blue('Hello world!'));
|
||||
```
|
||||
|
||||
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
const log = console.log;
|
||||
|
||||
// Combine styled and normal strings
|
||||
log(chalk.blue('Hello') + ' World' + chalk.red('!'));
|
||||
|
||||
// Compose multiple styles using the chainable API
|
||||
log(chalk.blue.bgRed.bold('Hello world!'));
|
||||
|
||||
// Pass in multiple arguments
|
||||
log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
|
||||
|
||||
// Nest styles
|
||||
log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
|
||||
|
||||
// Nest styles of the same type even (color, underline, background)
|
||||
log(chalk.green(
|
||||
'I am a green line ' +
|
||||
chalk.blue.underline.bold('with a blue substring') +
|
||||
' that becomes green again!'
|
||||
));
|
||||
|
||||
// ES2015 template literal
|
||||
log(`
|
||||
CPU: ${chalk.red('90%')}
|
||||
RAM: ${chalk.green('40%')}
|
||||
DISK: ${chalk.yellow('70%')}
|
||||
`);
|
||||
|
||||
// ES2015 tagged template literal
|
||||
log(chalk`
|
||||
CPU: {red ${cpu.totalPercent}%}
|
||||
RAM: {green ${ram.used / ram.total * 100}%}
|
||||
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
||||
`);
|
||||
|
||||
// Use RGB colors in terminal emulators that support it.
|
||||
log(chalk.keyword('orange')('Yay for orange colored text!'));
|
||||
log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
|
||||
log(chalk.hex('#DEADED').bold('Bold gray!'));
|
||||
```
|
||||
|
||||
Easily define your own themes:
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
|
||||
const error = chalk.bold.red;
|
||||
const warning = chalk.keyword('orange');
|
||||
|
||||
console.log(error('Error!'));
|
||||
console.log(warning('Warning!'));
|
||||
```
|
||||
|
||||
Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
|
||||
|
||||
```js
|
||||
const name = 'Sindre';
|
||||
console.log(chalk.green('Hello %s'), name);
|
||||
//=> 'Hello Sindre'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### chalk.`<style>[.<style>...](string, [string...])`
|
||||
|
||||
Example: `chalk.red.bold.underline('Hello', 'world');`
|
||||
|
||||
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
||||
|
||||
Multiple arguments will be separated by space.
|
||||
|
||||
### chalk.level
|
||||
|
||||
Specifies the level of color support.
|
||||
|
||||
Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
|
||||
|
||||
If you need to change this in a reusable module, create a new instance:
|
||||
|
||||
```js
|
||||
const ctx = new chalk.Instance({level: 0});
|
||||
```
|
||||
|
||||
| Level | Description |
|
||||
| :---: | :--- |
|
||||
| `0` | All colors disabled |
|
||||
| `1` | Basic color support (16 colors) |
|
||||
| `2` | 256 color support |
|
||||
| `3` | Truecolor support (16 million colors) |
|
||||
|
||||
### chalk.supportsColor
|
||||
|
||||
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
|
||||
|
||||
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
||||
|
||||
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
||||
|
||||
### chalk.stderr and chalk.stderr.supportsColor
|
||||
|
||||
`chalk.stderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `chalk.supportsColor` apply to this too. `chalk.stderr.supportsColor` is exposed for convenience.
|
||||
|
||||
|
||||
## Styles
|
||||
|
||||
### Modifiers
|
||||
|
||||
- `reset` - Resets the current color chain.
|
||||
- `bold` - Make text bold.
|
||||
- `dim` - Emitting only a small amount of light.
|
||||
- `italic` - Make text italic. *(Not widely supported)*
|
||||
- `underline` - Make text underline. *(Not widely supported)*
|
||||
- `inverse`- Inverse background and foreground colors.
|
||||
- `hidden` - Prints the text, but makes it invisible.
|
||||
- `strikethrough` - Puts a horizontal line through the center of the text. *(Not widely supported)*
|
||||
- `visible`- Prints the text only when Chalk has a color level > 0. Can be useful for things that are purely cosmetic.
|
||||
|
||||
### Colors
|
||||
|
||||
- `black`
|
||||
- `red`
|
||||
- `green`
|
||||
- `yellow`
|
||||
- `blue`
|
||||
- `magenta`
|
||||
- `cyan`
|
||||
- `white`
|
||||
- `blackBright` (alias: `gray`, `grey`)
|
||||
- `redBright`
|
||||
- `greenBright`
|
||||
- `yellowBright`
|
||||
- `blueBright`
|
||||
- `magentaBright`
|
||||
- `cyanBright`
|
||||
- `whiteBright`
|
||||
|
||||
### Background colors
|
||||
|
||||
- `bgBlack`
|
||||
- `bgRed`
|
||||
- `bgGreen`
|
||||
- `bgYellow`
|
||||
- `bgBlue`
|
||||
- `bgMagenta`
|
||||
- `bgCyan`
|
||||
- `bgWhite`
|
||||
- `bgBlackBright` (alias: `bgGray`, `bgGrey`)
|
||||
- `bgRedBright`
|
||||
- `bgGreenBright`
|
||||
- `bgYellowBright`
|
||||
- `bgBlueBright`
|
||||
- `bgMagentaBright`
|
||||
- `bgCyanBright`
|
||||
- `bgWhiteBright`
|
||||
|
||||
|
||||
## Tagged template literal
|
||||
|
||||
Chalk can be used as a [tagged template literal](http://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
|
||||
const miles = 18;
|
||||
const calculateFeet = miles => miles * 5280;
|
||||
|
||||
console.log(chalk`
|
||||
There are {bold 5280 feet} in a mile.
|
||||
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
|
||||
`);
|
||||
```
|
||||
|
||||
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
|
||||
|
||||
Template styles are chained exactly like normal Chalk styles. The following two statements are equivalent:
|
||||
|
||||
```js
|
||||
console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
|
||||
console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
|
||||
```
|
||||
|
||||
Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain spaces between parameters.
|
||||
|
||||
All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
|
||||
|
||||
|
||||
## 256 and Truecolor color support
|
||||
|
||||
Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
|
||||
|
||||
Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
|
||||
|
||||
Examples:
|
||||
|
||||
- `chalk.hex('#DEADED').underline('Hello, world!')`
|
||||
- `chalk.keyword('orange')('Some orange text')`
|
||||
- `chalk.rgb(15, 100, 204).inverse('Hello!')`
|
||||
|
||||
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `keyword` for foreground colors and `bgKeyword` for background colors).
|
||||
|
||||
- `chalk.bgHex('#DEADED').underline('Hello, world!')`
|
||||
- `chalk.bgKeyword('orange')('Some orange text')`
|
||||
- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
|
||||
|
||||
The following color models can be used:
|
||||
|
||||
- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
|
||||
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
|
||||
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
|
||||
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
|
||||
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
|
||||
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
|
||||
- [`ansi`](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) - Example: `chalk.ansi(31).bgAnsi(93)('red on yellowBright')`
|
||||
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`
|
||||
|
||||
|
||||
## Windows
|
||||
|
||||
If you're on Windows, do yourself a favor and use [Windows Terminal](https://github.com/microsoft/terminal) instead of `cmd.exe`.
|
||||
|
||||
|
||||
## Origin story
|
||||
|
||||
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
|
||||
|
||||
|
||||
## chalk for enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
The maintainers of chalk and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-chalk?utm_source=npm-chalk&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
|
||||
- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
|
||||
- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
|
||||
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
|
||||
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream
|
||||
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
|
||||
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
|
||||
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
|
||||
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
||||
- [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models
|
||||
- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
|
||||
- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
|
||||
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
||||
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
233
node_modules/jest-validate/node_modules/chalk/source/index.js
generated
vendored
Normal file
233
node_modules/jest-validate/node_modules/chalk/source/index.js
generated
vendored
Normal file
@ -0,0 +1,233 @@
|
||||
'use strict';
|
||||
const ansiStyles = require('ansi-styles');
|
||||
const {stdout: stdoutColor, stderr: stderrColor} = require('supports-color');
|
||||
const {
|
||||
stringReplaceAll,
|
||||
stringEncaseCRLFWithFirstIndex
|
||||
} = require('./util');
|
||||
|
||||
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
||||
const levelMapping = [
|
||||
'ansi',
|
||||
'ansi',
|
||||
'ansi256',
|
||||
'ansi16m'
|
||||
];
|
||||
|
||||
const styles = Object.create(null);
|
||||
|
||||
const applyOptions = (object, options = {}) => {
|
||||
if (options.level > 3 || options.level < 0) {
|
||||
throw new Error('The `level` option should be an integer from 0 to 3');
|
||||
}
|
||||
|
||||
// Detect level if not set manually
|
||||
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
||||
object.level = options.level === undefined ? colorLevel : options.level;
|
||||
};
|
||||
|
||||
class ChalkClass {
|
||||
constructor(options) {
|
||||
return chalkFactory(options);
|
||||
}
|
||||
}
|
||||
|
||||
const chalkFactory = options => {
|
||||
const chalk = {};
|
||||
applyOptions(chalk, options);
|
||||
|
||||
chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
|
||||
|
||||
Object.setPrototypeOf(chalk, Chalk.prototype);
|
||||
Object.setPrototypeOf(chalk.template, chalk);
|
||||
|
||||
chalk.template.constructor = () => {
|
||||
throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
|
||||
};
|
||||
|
||||
chalk.template.Instance = ChalkClass;
|
||||
|
||||
return chalk.template;
|
||||
};
|
||||
|
||||
function Chalk(options) {
|
||||
return chalkFactory(options);
|
||||
}
|
||||
|
||||
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
||||
styles[styleName] = {
|
||||
get() {
|
||||
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
||||
Object.defineProperty(this, styleName, {value: builder});
|
||||
return builder;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
styles.visible = {
|
||||
get() {
|
||||
const builder = createBuilder(this, this._styler, true);
|
||||
Object.defineProperty(this, 'visible', {value: builder});
|
||||
return builder;
|
||||
}
|
||||
};
|
||||
|
||||
const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
|
||||
|
||||
for (const model of usedModels) {
|
||||
styles[model] = {
|
||||
get() {
|
||||
const {level} = this;
|
||||
return function (...arguments_) {
|
||||
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
||||
return createBuilder(this, styler, this._isEmpty);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
for (const model of usedModels) {
|
||||
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
||||
styles[bgModel] = {
|
||||
get() {
|
||||
const {level} = this;
|
||||
return function (...arguments_) {
|
||||
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
||||
return createBuilder(this, styler, this._isEmpty);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const proto = Object.defineProperties(() => {}, {
|
||||
...styles,
|
||||
level: {
|
||||
enumerable: true,
|
||||
get() {
|
||||
return this._generator.level;
|
||||
},
|
||||
set(level) {
|
||||
this._generator.level = level;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const createStyler = (open, close, parent) => {
|
||||
let openAll;
|
||||
let closeAll;
|
||||
if (parent === undefined) {
|
||||
openAll = open;
|
||||
closeAll = close;
|
||||
} else {
|
||||
openAll = parent.openAll + open;
|
||||
closeAll = close + parent.closeAll;
|
||||
}
|
||||
|
||||
return {
|
||||
open,
|
||||
close,
|
||||
openAll,
|
||||
closeAll,
|
||||
parent
|
||||
};
|
||||
};
|
||||
|
||||
const createBuilder = (self, _styler, _isEmpty) => {
|
||||
const builder = (...arguments_) => {
|
||||
// Single argument is hot path, implicit coercion is faster than anything
|
||||
// eslint-disable-next-line no-implicit-coercion
|
||||
return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
||||
};
|
||||
|
||||
// `__proto__` is used because we must return a function, but there is
|
||||
// no way to create a function with a different prototype
|
||||
builder.__proto__ = proto; // eslint-disable-line no-proto
|
||||
|
||||
builder._generator = self;
|
||||
builder._styler = _styler;
|
||||
builder._isEmpty = _isEmpty;
|
||||
|
||||
return builder;
|
||||
};
|
||||
|
||||
const applyStyle = (self, string) => {
|
||||
if (self.level <= 0 || !string) {
|
||||
return self._isEmpty ? '' : string;
|
||||
}
|
||||
|
||||
let styler = self._styler;
|
||||
|
||||
if (styler === undefined) {
|
||||
return string;
|
||||
}
|
||||
|
||||
const {openAll, closeAll} = styler;
|
||||
if (string.indexOf('\u001B') !== -1) {
|
||||
while (styler !== undefined) {
|
||||
// Replace any instances already present with a re-opening code
|
||||
// otherwise only the part of the string until said closing code
|
||||
// will be colored, and the rest will simply be 'plain'.
|
||||
string = stringReplaceAll(string, styler.close, styler.open);
|
||||
|
||||
styler = styler.parent;
|
||||
}
|
||||
}
|
||||
|
||||
// We can move both next actions out of loop, because remaining actions in loop won't have
|
||||
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
||||
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
||||
const lfIndex = string.indexOf('\n');
|
||||
if (lfIndex !== -1) {
|
||||
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
||||
}
|
||||
|
||||
return openAll + string + closeAll;
|
||||
};
|
||||
|
||||
let template;
|
||||
const chalkTag = (chalk, ...strings) => {
|
||||
const [firstString] = strings;
|
||||
|
||||
if (!Array.isArray(firstString)) {
|
||||
// If chalk() was called by itself or with a string,
|
||||
// return the string itself as a string.
|
||||
return strings.join(' ');
|
||||
}
|
||||
|
||||
const arguments_ = strings.slice(1);
|
||||
const parts = [firstString.raw[0]];
|
||||
|
||||
for (let i = 1; i < firstString.length; i++) {
|
||||
parts.push(
|
||||
String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
|
||||
String(firstString.raw[i])
|
||||
);
|
||||
}
|
||||
|
||||
if (template === undefined) {
|
||||
template = require('./templates');
|
||||
}
|
||||
|
||||
return template(chalk, parts.join(''));
|
||||
};
|
||||
|
||||
Object.defineProperties(Chalk.prototype, styles);
|
||||
|
||||
const chalk = Chalk(); // eslint-disable-line new-cap
|
||||
chalk.supportsColor = stdoutColor;
|
||||
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
|
||||
chalk.stderr.supportsColor = stderrColor;
|
||||
|
||||
// For TypeScript
|
||||
chalk.Level = {
|
||||
None: 0,
|
||||
Basic: 1,
|
||||
Ansi256: 2,
|
||||
TrueColor: 3,
|
||||
0: 'None',
|
||||
1: 'Basic',
|
||||
2: 'Ansi256',
|
||||
3: 'TrueColor'
|
||||
};
|
||||
|
||||
module.exports = chalk;
|
134
node_modules/jest-validate/node_modules/chalk/source/templates.js
generated
vendored
Normal file
134
node_modules/jest-validate/node_modules/chalk/source/templates.js
generated
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
'use strict';
|
||||
const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
||||
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
||||
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
||||
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi;
|
||||
|
||||
const ESCAPES = new Map([
|
||||
['n', '\n'],
|
||||
['r', '\r'],
|
||||
['t', '\t'],
|
||||
['b', '\b'],
|
||||
['f', '\f'],
|
||||
['v', '\v'],
|
||||
['0', '\0'],
|
||||
['\\', '\\'],
|
||||
['e', '\u001B'],
|
||||
['a', '\u0007']
|
||||
]);
|
||||
|
||||
function unescape(c) {
|
||||
const u = c[0] === 'u';
|
||||
const bracket = c[1] === '{';
|
||||
|
||||
if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
|
||||
return String.fromCharCode(parseInt(c.slice(1), 16));
|
||||
}
|
||||
|
||||
if (u && bracket) {
|
||||
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
||||
}
|
||||
|
||||
return ESCAPES.get(c) || c;
|
||||
}
|
||||
|
||||
function parseArguments(name, arguments_) {
|
||||
const results = [];
|
||||
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
||||
let matches;
|
||||
|
||||
for (const chunk of chunks) {
|
||||
const number = Number(chunk);
|
||||
if (!Number.isNaN(number)) {
|
||||
results.push(number);
|
||||
} else if ((matches = chunk.match(STRING_REGEX))) {
|
||||
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
||||
} else {
|
||||
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function parseStyle(style) {
|
||||
STYLE_REGEX.lastIndex = 0;
|
||||
|
||||
const results = [];
|
||||
let matches;
|
||||
|
||||
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
||||
const name = matches[1];
|
||||
|
||||
if (matches[2]) {
|
||||
const args = parseArguments(name, matches[2]);
|
||||
results.push([name].concat(args));
|
||||
} else {
|
||||
results.push([name]);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function buildStyle(chalk, styles) {
|
||||
const enabled = {};
|
||||
|
||||
for (const layer of styles) {
|
||||
for (const style of layer.styles) {
|
||||
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
let current = chalk;
|
||||
for (const [styleName, styles] of Object.entries(enabled)) {
|
||||
if (!Array.isArray(styles)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(styleName in current)) {
|
||||
throw new Error(`Unknown Chalk style: ${styleName}`);
|
||||
}
|
||||
|
||||
current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
module.exports = (chalk, temporary) => {
|
||||
const styles = [];
|
||||
const chunks = [];
|
||||
let chunk = [];
|
||||
|
||||
// eslint-disable-next-line max-params
|
||||
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
||||
if (escapeCharacter) {
|
||||
chunk.push(unescape(escapeCharacter));
|
||||
} else if (style) {
|
||||
const string = chunk.join('');
|
||||
chunk = [];
|
||||
chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
|
||||
styles.push({inverse, styles: parseStyle(style)});
|
||||
} else if (close) {
|
||||
if (styles.length === 0) {
|
||||
throw new Error('Found extraneous } in Chalk template literal');
|
||||
}
|
||||
|
||||
chunks.push(buildStyle(chalk, styles)(chunk.join('')));
|
||||
chunk = [];
|
||||
styles.pop();
|
||||
} else {
|
||||
chunk.push(character);
|
||||
}
|
||||
});
|
||||
|
||||
chunks.push(chunk.join(''));
|
||||
|
||||
if (styles.length > 0) {
|
||||
const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
return chunks.join('');
|
||||
};
|
39
node_modules/jest-validate/node_modules/chalk/source/util.js
generated
vendored
Normal file
39
node_modules/jest-validate/node_modules/chalk/source/util.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
const stringReplaceAll = (string, substring, replacer) => {
|
||||
let index = string.indexOf(substring);
|
||||
if (index === -1) {
|
||||
return string;
|
||||
}
|
||||
|
||||
const substringLength = substring.length;
|
||||
let endIndex = 0;
|
||||
let returnValue = '';
|
||||
do {
|
||||
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
||||
endIndex = index + substringLength;
|
||||
index = string.indexOf(substring, endIndex);
|
||||
} while (index !== -1);
|
||||
|
||||
returnValue += string.substr(endIndex);
|
||||
return returnValue;
|
||||
};
|
||||
|
||||
const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
|
||||
let endIndex = 0;
|
||||
let returnValue = '';
|
||||
do {
|
||||
const gotCR = string[index - 1] === '\r';
|
||||
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
|
||||
endIndex = index + 1;
|
||||
index = string.indexOf('\n', endIndex);
|
||||
} while (index !== -1);
|
||||
|
||||
returnValue += string.substr(endIndex);
|
||||
return returnValue;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
stringReplaceAll,
|
||||
stringEncaseCRLFWithFirstIndex
|
||||
};
|
54
node_modules/jest-validate/node_modules/color-convert/CHANGELOG.md
generated
vendored
Normal file
54
node_modules/jest-validate/node_modules/color-convert/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
# 1.0.0 - 2016-01-07
|
||||
|
||||
- Removed: unused speed test
|
||||
- Added: Automatic routing between previously unsupported conversions
|
||||
([#27](https://github.com/Qix-/color-convert/pull/27))
|
||||
- Removed: `xxx2xxx()` and `xxx2xxxRaw()` functions
|
||||
([#27](https://github.com/Qix-/color-convert/pull/27))
|
||||
- Removed: `convert()` class
|
||||
([#27](https://github.com/Qix-/color-convert/pull/27))
|
||||
- Changed: all functions to lookup dictionary
|
||||
([#27](https://github.com/Qix-/color-convert/pull/27))
|
||||
- Changed: `ansi` to `ansi256`
|
||||
([#27](https://github.com/Qix-/color-convert/pull/27))
|
||||
- Fixed: argument grouping for functions requiring only one argument
|
||||
([#27](https://github.com/Qix-/color-convert/pull/27))
|
||||
|
||||
# 0.6.0 - 2015-07-23
|
||||
|
||||
- Added: methods to handle
|
||||
[ANSI](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) 16/256 colors:
|
||||
- rgb2ansi16
|
||||
- rgb2ansi
|
||||
- hsl2ansi16
|
||||
- hsl2ansi
|
||||
- hsv2ansi16
|
||||
- hsv2ansi
|
||||
- hwb2ansi16
|
||||
- hwb2ansi
|
||||
- cmyk2ansi16
|
||||
- cmyk2ansi
|
||||
- keyword2ansi16
|
||||
- keyword2ansi
|
||||
- ansi162rgb
|
||||
- ansi162hsl
|
||||
- ansi162hsv
|
||||
- ansi162hwb
|
||||
- ansi162cmyk
|
||||
- ansi162keyword
|
||||
- ansi2rgb
|
||||
- ansi2hsl
|
||||
- ansi2hsv
|
||||
- ansi2hwb
|
||||
- ansi2cmyk
|
||||
- ansi2keyword
|
||||
([#18](https://github.com/harthur/color-convert/pull/18))
|
||||
|
||||
# 0.5.3 - 2015-06-02
|
||||
|
||||
- Fixed: hsl2hsv does not return `NaN` anymore when using `[0,0,0]`
|
||||
([#15](https://github.com/harthur/color-convert/issues/15))
|
||||
|
||||
---
|
||||
|
||||
Check out commit logs for older releases
|
21
node_modules/jest-validate/node_modules/color-convert/LICENSE
generated
vendored
Normal file
21
node_modules/jest-validate/node_modules/color-convert/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
Copyright (c) 2011-2016 Heather Arthur <fayearthur@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
68
node_modules/jest-validate/node_modules/color-convert/README.md
generated
vendored
Normal file
68
node_modules/jest-validate/node_modules/color-convert/README.md
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
# color-convert
|
||||
|
||||
[](https://travis-ci.org/Qix-/color-convert)
|
||||
|
||||
Color-convert is a color conversion library for JavaScript and node.
|
||||
It converts all ways between `rgb`, `hsl`, `hsv`, `hwb`, `cmyk`, `ansi`, `ansi16`, `hex` strings, and CSS `keyword`s (will round to closest):
|
||||
|
||||
```js
|
||||
var convert = require('color-convert');
|
||||
|
||||
convert.rgb.hsl(140, 200, 100); // [96, 48, 59]
|
||||
convert.keyword.rgb('blue'); // [0, 0, 255]
|
||||
|
||||
var rgbChannels = convert.rgb.channels; // 3
|
||||
var cmykChannels = convert.cmyk.channels; // 4
|
||||
var ansiChannels = convert.ansi16.channels; // 1
|
||||
```
|
||||
|
||||
# Install
|
||||
|
||||
```console
|
||||
$ npm install color-convert
|
||||
```
|
||||
|
||||
# API
|
||||
|
||||
Simply get the property of the _from_ and _to_ conversion that you're looking for.
|
||||
|
||||
All functions have a rounded and unrounded variant. By default, return values are rounded. To get the unrounded (raw) results, simply tack on `.raw` to the function.
|
||||
|
||||
All 'from' functions have a hidden property called `.channels` that indicates the number of channels the function expects (not including alpha).
|
||||
|
||||
```js
|
||||
var convert = require('color-convert');
|
||||
|
||||
// Hex to LAB
|
||||
convert.hex.lab('DEADBF'); // [ 76, 21, -2 ]
|
||||
convert.hex.lab.raw('DEADBF'); // [ 75.56213190997677, 20.653827952644754, -2.290532499330533 ]
|
||||
|
||||
// RGB to CMYK
|
||||
convert.rgb.cmyk(167, 255, 4); // [ 35, 0, 98, 0 ]
|
||||
convert.rgb.cmyk.raw(167, 255, 4); // [ 34.509803921568626, 0, 98.43137254901961, 0 ]
|
||||
```
|
||||
|
||||
### Arrays
|
||||
All functions that accept multiple arguments also support passing an array.
|
||||
|
||||
Note that this does **not** apply to functions that convert from a color that only requires one value (e.g. `keyword`, `ansi256`, `hex`, etc.)
|
||||
|
||||
```js
|
||||
var convert = require('color-convert');
|
||||
|
||||
convert.rgb.hex(123, 45, 67); // '7B2D43'
|
||||
convert.rgb.hex([123, 45, 67]); // '7B2D43'
|
||||
```
|
||||
|
||||
## Routing
|
||||
|
||||
Conversions that don't have an _explicitly_ defined conversion (in [conversions.js](conversions.js)), but can be converted by means of sub-conversions (e.g. XYZ -> **RGB** -> CMYK), are automatically routed together. This allows just about any color model supported by `color-convert` to be converted to any other model, so long as a sub-conversion path exists. This is also true for conversions requiring more than one step in between (e.g. LCH -> **LAB** -> **XYZ** -> **RGB** -> Hex).
|
||||
|
||||
Keep in mind that extensive conversions _may_ result in a loss of precision, and exist only to be complete. For a list of "direct" (single-step) conversions, see [conversions.js](conversions.js).
|
||||
|
||||
# Contribute
|
||||
|
||||
If there is a new model you would like to support, or want to add a direct conversion between two existing models, please send us a pull request.
|
||||
|
||||
# License
|
||||
Copyright © 2011-2016, Heather Arthur and Josh Junon. Licensed under the [MIT License](LICENSE).
|
839
node_modules/jest-validate/node_modules/color-convert/conversions.js
generated
vendored
Normal file
839
node_modules/jest-validate/node_modules/color-convert/conversions.js
generated
vendored
Normal file
@ -0,0 +1,839 @@
|
||||
/* MIT license */
|
||||
/* eslint-disable no-mixed-operators */
|
||||
const cssKeywords = require('color-name');
|
||||
|
||||
// NOTE: conversions should only return primitive values (i.e. arrays, or
|
||||
// values that give correct `typeof` results).
|
||||
// do not use box values types (i.e. Number(), String(), etc.)
|
||||
|
||||
const reverseKeywords = {};
|
||||
for (const key of Object.keys(cssKeywords)) {
|
||||
reverseKeywords[cssKeywords[key]] = key;
|
||||
}
|
||||
|
||||
const convert = {
|
||||
rgb: {channels: 3, labels: 'rgb'},
|
||||
hsl: {channels: 3, labels: 'hsl'},
|
||||
hsv: {channels: 3, labels: 'hsv'},
|
||||
hwb: {channels: 3, labels: 'hwb'},
|
||||
cmyk: {channels: 4, labels: 'cmyk'},
|
||||
xyz: {channels: 3, labels: 'xyz'},
|
||||
lab: {channels: 3, labels: 'lab'},
|
||||
lch: {channels: 3, labels: 'lch'},
|
||||
hex: {channels: 1, labels: ['hex']},
|
||||
keyword: {channels: 1, labels: ['keyword']},
|
||||
ansi16: {channels: 1, labels: ['ansi16']},
|
||||
ansi256: {channels: 1, labels: ['ansi256']},
|
||||
hcg: {channels: 3, labels: ['h', 'c', 'g']},
|
||||
apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
|
||||
gray: {channels: 1, labels: ['gray']}
|
||||
};
|
||||
|
||||
module.exports = convert;
|
||||
|
||||
// Hide .channels and .labels properties
|
||||
for (const model of Object.keys(convert)) {
|
||||
if (!('channels' in convert[model])) {
|
||||
throw new Error('missing channels property: ' + model);
|
||||
}
|
||||
|
||||
if (!('labels' in convert[model])) {
|
||||
throw new Error('missing channel labels property: ' + model);
|
||||
}
|
||||
|
||||
if (convert[model].labels.length !== convert[model].channels) {
|
||||
throw new Error('channel and label counts mismatch: ' + model);
|
||||
}
|
||||
|
||||
const {channels, labels} = convert[model];
|
||||
delete convert[model].channels;
|
||||
delete convert[model].labels;
|
||||
Object.defineProperty(convert[model], 'channels', {value: channels});
|
||||
Object.defineProperty(convert[model], 'labels', {value: labels});
|
||||
}
|
||||
|
||||
convert.rgb.hsl = function (rgb) {
|
||||
const r = rgb[0] / 255;
|
||||
const g = rgb[1] / 255;
|
||||
const b = rgb[2] / 255;
|
||||
const min = Math.min(r, g, b);
|
||||
const max = Math.max(r, g, b);
|
||||
const delta = max - min;
|
||||
let h;
|
||||
let s;
|
||||
|
||||
if (max === min) {
|
||||
h = 0;
|
||||
} else if (r === max) {
|
||||
h = (g - b) / delta;
|
||||
} else if (g === max) {
|
||||
h = 2 + (b - r) / delta;
|
||||
} else if (b === max) {
|
||||
h = 4 + (r - g) / delta;
|
||||
}
|
||||
|
||||
h = Math.min(h * 60, 360);
|
||||
|
||||
if (h < 0) {
|
||||
h += 360;
|
||||
}
|
||||
|
||||
const l = (min + max) / 2;
|
||||
|
||||
if (max === min) {
|
||||
s = 0;
|
||||
} else if (l <= 0.5) {
|
||||
s = delta / (max + min);
|
||||
} else {
|
||||
s = delta / (2 - max - min);
|
||||
}
|
||||
|
||||
return [h, s * 100, l * 100];
|
||||
};
|
||||
|
||||
convert.rgb.hsv = function (rgb) {
|
||||
let rdif;
|
||||
let gdif;
|
||||
let bdif;
|
||||
let h;
|
||||
let s;
|
||||
|
||||
const r = rgb[0] / 255;
|
||||
const g = rgb[1] / 255;
|
||||
const b = rgb[2] / 255;
|
||||
const v = Math.max(r, g, b);
|
||||
const diff = v - Math.min(r, g, b);
|
||||
const diffc = function (c) {
|
||||
return (v - c) / 6 / diff + 1 / 2;
|
||||
};
|
||||
|
||||
if (diff === 0) {
|
||||
h = 0;
|
||||
s = 0;
|
||||
} else {
|
||||
s = diff / v;
|
||||
rdif = diffc(r);
|
||||
gdif = diffc(g);
|
||||
bdif = diffc(b);
|
||||
|
||||
if (r === v) {
|
||||
h = bdif - gdif;
|
||||
} else if (g === v) {
|
||||
h = (1 / 3) + rdif - bdif;
|
||||
} else if (b === v) {
|
||||
h = (2 / 3) + gdif - rdif;
|
||||
}
|
||||
|
||||
if (h < 0) {
|
||||
h += 1;
|
||||
} else if (h > 1) {
|
||||
h -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
h * 360,
|
||||
s * 100,
|
||||
v * 100
|
||||
];
|
||||
};
|
||||
|
||||
convert.rgb.hwb = function (rgb) {
|
||||
const r = rgb[0];
|
||||
const g = rgb[1];
|
||||
let b = rgb[2];
|
||||
const h = convert.rgb.hsl(rgb)[0];
|
||||
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
||||
|
||||
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
||||
|
||||
return [h, w * 100, b * 100];
|
||||
};
|
||||
|
||||
convert.rgb.cmyk = function (rgb) {
|
||||
const r = rgb[0] / 255;
|
||||
const g = rgb[1] / 255;
|
||||
const b = rgb[2] / 255;
|
||||
|
||||
const k = Math.min(1 - r, 1 - g, 1 - b);
|
||||
const c = (1 - r - k) / (1 - k) || 0;
|
||||
const m = (1 - g - k) / (1 - k) || 0;
|
||||
const y = (1 - b - k) / (1 - k) || 0;
|
||||
|
||||
return [c * 100, m * 100, y * 100, k * 100];
|
||||
};
|
||||
|
||||
function comparativeDistance(x, y) {
|
||||
/*
|
||||
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
||||
*/
|
||||
return (
|
||||
((x[0] - y[0]) ** 2) +
|
||||
((x[1] - y[1]) ** 2) +
|
||||
((x[2] - y[2]) ** 2)
|
||||
);
|
||||
}
|
||||
|
||||
convert.rgb.keyword = function (rgb) {
|
||||
const reversed = reverseKeywords[rgb];
|
||||
if (reversed) {
|
||||
return reversed;
|
||||
}
|
||||
|
||||
let currentClosestDistance = Infinity;
|
||||
let currentClosestKeyword;
|
||||
|
||||
for (const keyword of Object.keys(cssKeywords)) {
|
||||
const value = cssKeywords[keyword];
|
||||
|
||||
// Compute comparative distance
|
||||
const distance = comparativeDistance(rgb, value);
|
||||
|
||||
// Check if its less, if so set as closest
|
||||
if (distance < currentClosestDistance) {
|
||||
currentClosestDistance = distance;
|
||||
currentClosestKeyword = keyword;
|
||||
}
|
||||
}
|
||||
|
||||
return currentClosestKeyword;
|
||||
};
|
||||
|
||||
convert.keyword.rgb = function (keyword) {
|
||||
return cssKeywords[keyword];
|
||||
};
|
||||
|
||||
convert.rgb.xyz = function (rgb) {
|
||||
let r = rgb[0] / 255;
|
||||
let g = rgb[1] / 255;
|
||||
let b = rgb[2] / 255;
|
||||
|
||||
// Assume sRGB
|
||||
r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
|
||||
g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
|
||||
b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
|
||||
|
||||
const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
|
||||
const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
|
||||
const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
|
||||
|
||||
return [x * 100, y * 100, z * 100];
|
||||
};
|
||||
|
||||
convert.rgb.lab = function (rgb) {
|
||||
const xyz = convert.rgb.xyz(rgb);
|
||||
let x = xyz[0];
|
||||
let y = xyz[1];
|
||||
let z = xyz[2];
|
||||
|
||||
x /= 95.047;
|
||||
y /= 100;
|
||||
z /= 108.883;
|
||||
|
||||
x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
|
||||
y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
|
||||
z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
|
||||
|
||||
const l = (116 * y) - 16;
|
||||
const a = 500 * (x - y);
|
||||
const b = 200 * (y - z);
|
||||
|
||||
return [l, a, b];
|
||||
};
|
||||
|
||||
convert.hsl.rgb = function (hsl) {
|
||||
const h = hsl[0] / 360;
|
||||
const s = hsl[1] / 100;
|
||||
const l = hsl[2] / 100;
|
||||
let t2;
|
||||
let t3;
|
||||
let val;
|
||||
|
||||
if (s === 0) {
|
||||
val = l * 255;
|
||||
return [val, val, val];
|
||||
}
|
||||
|
||||
if (l < 0.5) {
|
||||
t2 = l * (1 + s);
|
||||
} else {
|
||||
t2 = l + s - l * s;
|
||||
}
|
||||
|
||||
const t1 = 2 * l - t2;
|
||||
|
||||
const rgb = [0, 0, 0];
|
||||
for (let i = 0; i < 3; i++) {
|
||||
t3 = h + 1 / 3 * -(i - 1);
|
||||
if (t3 < 0) {
|
||||
t3++;
|
||||
}
|
||||
|
||||
if (t3 > 1) {
|
||||
t3--;
|
||||
}
|
||||
|
||||
if (6 * t3 < 1) {
|
||||
val = t1 + (t2 - t1) * 6 * t3;
|
||||
} else if (2 * t3 < 1) {
|
||||
val = t2;
|
||||
} else if (3 * t3 < 2) {
|
||||
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
||||
} else {
|
||||
val = t1;
|
||||
}
|
||||
|
||||
rgb[i] = val * 255;
|
||||
}
|
||||
|
||||
return rgb;
|
||||
};
|
||||
|
||||
convert.hsl.hsv = function (hsl) {
|
||||
const h = hsl[0];
|
||||
let s = hsl[1] / 100;
|
||||
let l = hsl[2] / 100;
|
||||
let smin = s;
|
||||
const lmin = Math.max(l, 0.01);
|
||||
|
||||
l *= 2;
|
||||
s *= (l <= 1) ? l : 2 - l;
|
||||
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
||||
const v = (l + s) / 2;
|
||||
const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
|
||||
|
||||
return [h, sv * 100, v * 100];
|
||||
};
|
||||
|
||||
convert.hsv.rgb = function (hsv) {
|
||||
const h = hsv[0] / 60;
|
||||
const s = hsv[1] / 100;
|
||||
let v = hsv[2] / 100;
|
||||
const hi = Math.floor(h) % 6;
|
||||
|
||||
const f = h - Math.floor(h);
|
||||
const p = 255 * v * (1 - s);
|
||||
const q = 255 * v * (1 - (s * f));
|
||||
const t = 255 * v * (1 - (s * (1 - f)));
|
||||
v *= 255;
|
||||
|
||||
switch (hi) {
|
||||
case 0:
|
||||
return [v, t, p];
|
||||
case 1:
|
||||
return [q, v, p];
|
||||
case 2:
|
||||
return [p, v, t];
|
||||
case 3:
|
||||
return [p, q, v];
|
||||
case 4:
|
||||
return [t, p, v];
|
||||
case 5:
|
||||
return [v, p, q];
|
||||
}
|
||||
};
|
||||
|
||||
convert.hsv.hsl = function (hsv) {
|
||||
const h = hsv[0];
|
||||
const s = hsv[1] / 100;
|
||||
const v = hsv[2] / 100;
|
||||
const vmin = Math.max(v, 0.01);
|
||||
let sl;
|
||||
let l;
|
||||
|
||||
l = (2 - s) * v;
|
||||
const lmin = (2 - s) * vmin;
|
||||
sl = s * vmin;
|
||||
sl /= (lmin <= 1) ? lmin : 2 - lmin;
|
||||
sl = sl || 0;
|
||||
l /= 2;
|
||||
|
||||
return [h, sl * 100, l * 100];
|
||||
};
|
||||
|
||||
// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
|
||||
convert.hwb.rgb = function (hwb) {
|
||||
const h = hwb[0] / 360;
|
||||
let wh = hwb[1] / 100;
|
||||
let bl = hwb[2] / 100;
|
||||
const ratio = wh + bl;
|
||||
let f;
|
||||
|
||||
// Wh + bl cant be > 1
|
||||
if (ratio > 1) {
|
||||
wh /= ratio;
|
||||
bl /= ratio;
|
||||
}
|
||||
|
||||
const i = Math.floor(6 * h);
|
||||
const v = 1 - bl;
|
||||
f = 6 * h - i;
|
||||
|
||||
if ((i & 0x01) !== 0) {
|
||||
f = 1 - f;
|
||||
}
|
||||
|
||||
const n = wh + f * (v - wh); // Linear interpolation
|
||||
|
||||
let r;
|
||||
let g;
|
||||
let b;
|
||||
/* eslint-disable max-statements-per-line,no-multi-spaces */
|
||||
switch (i) {
|
||||
default:
|
||||
case 6:
|
||||
case 0: r = v; g = n; b = wh; break;
|
||||
case 1: r = n; g = v; b = wh; break;
|
||||
case 2: r = wh; g = v; b = n; break;
|
||||
case 3: r = wh; g = n; b = v; break;
|
||||
case 4: r = n; g = wh; b = v; break;
|
||||
case 5: r = v; g = wh; b = n; break;
|
||||
}
|
||||
/* eslint-enable max-statements-per-line,no-multi-spaces */
|
||||
|
||||
return [r * 255, g * 255, b * 255];
|
||||
};
|
||||
|
||||
convert.cmyk.rgb = function (cmyk) {
|
||||
const c = cmyk[0] / 100;
|
||||
const m = cmyk[1] / 100;
|
||||
const y = cmyk[2] / 100;
|
||||
const k = cmyk[3] / 100;
|
||||
|
||||
const r = 1 - Math.min(1, c * (1 - k) + k);
|
||||
const g = 1 - Math.min(1, m * (1 - k) + k);
|
||||
const b = 1 - Math.min(1, y * (1 - k) + k);
|
||||
|
||||
return [r * 255, g * 255, b * 255];
|
||||
};
|
||||
|
||||
convert.xyz.rgb = function (xyz) {
|
||||
const x = xyz[0] / 100;
|
||||
const y = xyz[1] / 100;
|
||||
const z = xyz[2] / 100;
|
||||
let r;
|
||||
let g;
|
||||
let b;
|
||||
|
||||
r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
|
||||
g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
|
||||
b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
|
||||
|
||||
// Assume sRGB
|
||||
r = r > 0.0031308
|
||||
? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
|
||||
: r * 12.92;
|
||||
|
||||
g = g > 0.0031308
|
||||
? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
|
||||
: g * 12.92;
|
||||
|
||||
b = b > 0.0031308
|
||||
? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
|
||||
: b * 12.92;
|
||||
|
||||
r = Math.min(Math.max(0, r), 1);
|
||||
g = Math.min(Math.max(0, g), 1);
|
||||
b = Math.min(Math.max(0, b), 1);
|
||||
|
||||
return [r * 255, g * 255, b * 255];
|
||||
};
|
||||
|
||||
convert.xyz.lab = function (xyz) {
|
||||
let x = xyz[0];
|
||||
let y = xyz[1];
|
||||
let z = xyz[2];
|
||||
|
||||
x /= 95.047;
|
||||
y /= 100;
|
||||
z /= 108.883;
|
||||
|
||||
x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
|
||||
y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
|
||||
z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
|
||||
|
||||
const l = (116 * y) - 16;
|
||||
const a = 500 * (x - y);
|
||||
const b = 200 * (y - z);
|
||||
|
||||
return [l, a, b];
|
||||
};
|
||||
|
||||
convert.lab.xyz = function (lab) {
|
||||
const l = lab[0];
|
||||
const a = lab[1];
|
||||
const b = lab[2];
|
||||
let x;
|
||||
let y;
|
||||
let z;
|
||||
|
||||
y = (l + 16) / 116;
|
||||
x = a / 500 + y;
|
||||
z = y - b / 200;
|
||||
|
||||
const y2 = y ** 3;
|
||||
const x2 = x ** 3;
|
||||
const z2 = z ** 3;
|
||||
y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
||||
x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
||||
z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
||||
|
||||
x *= 95.047;
|
||||
y *= 100;
|
||||
z *= 108.883;
|
||||
|
||||
return [x, y, z];
|
||||
};
|
||||
|
||||
convert.lab.lch = function (lab) {
|
||||
const l = lab[0];
|
||||
const a = lab[1];
|
||||
const b = lab[2];
|
||||
let h;
|
||||
|
||||
const hr = Math.atan2(b, a);
|
||||
h = hr * 360 / 2 / Math.PI;
|
||||
|
||||
if (h < 0) {
|
||||
h += 360;
|
||||
}
|
||||
|
||||
const c = Math.sqrt(a * a + b * b);
|
||||
|
||||
return [l, c, h];
|
||||
};
|
||||
|
||||
convert.lch.lab = function (lch) {
|
||||
const l = lch[0];
|
||||
const c = lch[1];
|
||||
const h = lch[2];
|
||||
|
||||
const hr = h / 360 * 2 * Math.PI;
|
||||
const a = c * Math.cos(hr);
|
||||
const b = c * Math.sin(hr);
|
||||
|
||||
return [l, a, b];
|
||||
};
|
||||
|
||||
convert.rgb.ansi16 = function (args, saturation = null) {
|
||||
const [r, g, b] = args;
|
||||
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
|
||||
|
||||
value = Math.round(value / 50);
|
||||
|
||||
if (value === 0) {
|
||||
return 30;
|
||||
}
|
||||
|
||||
let ansi = 30
|
||||
+ ((Math.round(b / 255) << 2)
|
||||
| (Math.round(g / 255) << 1)
|
||||
| Math.round(r / 255));
|
||||
|
||||
if (value === 2) {
|
||||
ansi += 60;
|
||||
}
|
||||
|
||||
return ansi;
|
||||
};
|
||||
|
||||
convert.hsv.ansi16 = function (args) {
|
||||
// Optimization here; we already know the value and don't need to get
|
||||
// it converted for us.
|
||||
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
||||
};
|
||||
|
||||
convert.rgb.ansi256 = function (args) {
|
||||
const r = args[0];
|
||||
const g = args[1];
|
||||
const b = args[2];
|
||||
|
||||
// We use the extended greyscale palette here, with the exception of
|
||||
// black and white. normal palette only has 4 greyscale shades.
|
||||
if (r === g && g === b) {
|
||||
if (r < 8) {
|
||||
return 16;
|
||||
}
|
||||
|
||||
if (r > 248) {
|
||||
return 231;
|
||||
}
|
||||
|
||||
return Math.round(((r - 8) / 247) * 24) + 232;
|
||||
}
|
||||
|
||||
const ansi = 16
|
||||
+ (36 * Math.round(r / 255 * 5))
|
||||
+ (6 * Math.round(g / 255 * 5))
|
||||
+ Math.round(b / 255 * 5);
|
||||
|
||||
return ansi;
|
||||
};
|
||||
|
||||
convert.ansi16.rgb = function (args) {
|
||||
let color = args % 10;
|
||||
|
||||
// Handle greyscale
|
||||
if (color === 0 || color === 7) {
|
||||
if (args > 50) {
|
||||
color += 3.5;
|
||||
}
|
||||
|
||||
color = color / 10.5 * 255;
|
||||
|
||||
return [color, color, color];
|
||||
}
|
||||
|
||||
const mult = (~~(args > 50) + 1) * 0.5;
|
||||
const r = ((color & 1) * mult) * 255;
|
||||
const g = (((color >> 1) & 1) * mult) * 255;
|
||||
const b = (((color >> 2) & 1) * mult) * 255;
|
||||
|
||||
return [r, g, b];
|
||||
};
|
||||
|
||||
convert.ansi256.rgb = function (args) {
|
||||
// Handle greyscale
|
||||
if (args >= 232) {
|
||||
const c = (args - 232) * 10 + 8;
|
||||
return [c, c, c];
|
||||
}
|
||||
|
||||
args -= 16;
|
||||
|
||||
let rem;
|
||||
const r = Math.floor(args / 36) / 5 * 255;
|
||||
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
||||
const b = (rem % 6) / 5 * 255;
|
||||
|
||||
return [r, g, b];
|
||||
};
|
||||
|
||||
convert.rgb.hex = function (args) {
|
||||
const integer = ((Math.round(args[0]) & 0xFF) << 16)
|
||||
+ ((Math.round(args[1]) & 0xFF) << 8)
|
||||
+ (Math.round(args[2]) & 0xFF);
|
||||
|
||||
const string = integer.toString(16).toUpperCase();
|
||||
return '000000'.substring(string.length) + string;
|
||||
};
|
||||
|
||||
convert.hex.rgb = function (args) {
|
||||
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
||||
if (!match) {
|
||||
return [0, 0, 0];
|
||||
}
|
||||
|
||||
let colorString = match[0];
|
||||
|
||||
if (match[0].length === 3) {
|
||||
colorString = colorString.split('').map(char => {
|
||||
return char + char;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
const integer = parseInt(colorString, 16);
|
||||
const r = (integer >> 16) & 0xFF;
|
||||
const g = (integer >> 8) & 0xFF;
|
||||
const b = integer & 0xFF;
|
||||
|
||||
return [r, g, b];
|
||||
};
|
||||
|
||||
convert.rgb.hcg = function (rgb) {
|
||||
const r = rgb[0] / 255;
|
||||
const g = rgb[1] / 255;
|
||||
const b = rgb[2] / 255;
|
||||
const max = Math.max(Math.max(r, g), b);
|
||||
const min = Math.min(Math.min(r, g), b);
|
||||
const chroma = (max - min);
|
||||
let grayscale;
|
||||
let hue;
|
||||
|
||||
if (chroma < 1) {
|
||||
grayscale = min / (1 - chroma);
|
||||
} else {
|
||||
grayscale = 0;
|
||||
}
|
||||
|
||||
if (chroma <= 0) {
|
||||
hue = 0;
|
||||
} else
|
||||
if (max === r) {
|
||||
hue = ((g - b) / chroma) % 6;
|
||||
} else
|
||||
if (max === g) {
|
||||
hue = 2 + (b - r) / chroma;
|
||||
} else {
|
||||
hue = 4 + (r - g) / chroma;
|
||||
}
|
||||
|
||||
hue /= 6;
|
||||
hue %= 1;
|
||||
|
||||
return [hue * 360, chroma * 100, grayscale * 100];
|
||||
};
|
||||
|
||||
convert.hsl.hcg = function (hsl) {
|
||||
const s = hsl[1] / 100;
|
||||
const l = hsl[2] / 100;
|
||||
|
||||
const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
|
||||
|
||||
let f = 0;
|
||||
if (c < 1.0) {
|
||||
f = (l - 0.5 * c) / (1.0 - c);
|
||||
}
|
||||
|
||||
return [hsl[0], c * 100, f * 100];
|
||||
};
|
||||
|
||||
convert.hsv.hcg = function (hsv) {
|
||||
const s = hsv[1] / 100;
|
||||
const v = hsv[2] / 100;
|
||||
|
||||
const c = s * v;
|
||||
let f = 0;
|
||||
|
||||
if (c < 1.0) {
|
||||
f = (v - c) / (1 - c);
|
||||
}
|
||||
|
||||
return [hsv[0], c * 100, f * 100];
|
||||
};
|
||||
|
||||
convert.hcg.rgb = function (hcg) {
|
||||
const h = hcg[0] / 360;
|
||||
const c = hcg[1] / 100;
|
||||
const g = hcg[2] / 100;
|
||||
|
||||
if (c === 0.0) {
|
||||
return [g * 255, g * 255, g * 255];
|
||||
}
|
||||
|
||||
const pure = [0, 0, 0];
|
||||
const hi = (h % 1) * 6;
|
||||
const v = hi % 1;
|
||||
const w = 1 - v;
|
||||
let mg = 0;
|
||||
|
||||
/* eslint-disable max-statements-per-line */
|
||||
switch (Math.floor(hi)) {
|
||||
case 0:
|
||||
pure[0] = 1; pure[1] = v; pure[2] = 0; break;
|
||||
case 1:
|
||||
pure[0] = w; pure[1] = 1; pure[2] = 0; break;
|
||||
case 2:
|
||||
pure[0] = 0; pure[1] = 1; pure[2] = v; break;
|
||||
case 3:
|
||||
pure[0] = 0; pure[1] = w; pure[2] = 1; break;
|
||||
case 4:
|
||||
pure[0] = v; pure[1] = 0; pure[2] = 1; break;
|
||||
default:
|
||||
pure[0] = 1; pure[1] = 0; pure[2] = w;
|
||||
}
|
||||
/* eslint-enable max-statements-per-line */
|
||||
|
||||
mg = (1.0 - c) * g;
|
||||
|
||||
return [
|
||||
(c * pure[0] + mg) * 255,
|
||||
(c * pure[1] + mg) * 255,
|
||||
(c * pure[2] + mg) * 255
|
||||
];
|
||||
};
|
||||
|
||||
convert.hcg.hsv = function (hcg) {
|
||||
const c = hcg[1] / 100;
|
||||
const g = hcg[2] / 100;
|
||||
|
||||
const v = c + g * (1.0 - c);
|
||||
let f = 0;
|
||||
|
||||
if (v > 0.0) {
|
||||
f = c / v;
|
||||
}
|
||||
|
||||
return [hcg[0], f * 100, v * 100];
|
||||
};
|
||||
|
||||
convert.hcg.hsl = function (hcg) {
|
||||
const c = hcg[1] / 100;
|
||||
const g = hcg[2] / 100;
|
||||
|
||||
const l = g * (1.0 - c) + 0.5 * c;
|
||||
let s = 0;
|
||||
|
||||
if (l > 0.0 && l < 0.5) {
|
||||
s = c / (2 * l);
|
||||
} else
|
||||
if (l >= 0.5 && l < 1.0) {
|
||||
s = c / (2 * (1 - l));
|
||||
}
|
||||
|
||||
return [hcg[0], s * 100, l * 100];
|
||||
};
|
||||
|
||||
convert.hcg.hwb = function (hcg) {
|
||||
const c = hcg[1] / 100;
|
||||
const g = hcg[2] / 100;
|
||||
const v = c + g * (1.0 - c);
|
||||
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
||||
};
|
||||
|
||||
convert.hwb.hcg = function (hwb) {
|
||||
const w = hwb[1] / 100;
|
||||
const b = hwb[2] / 100;
|
||||
const v = 1 - b;
|
||||
const c = v - w;
|
||||
let g = 0;
|
||||
|
||||
if (c < 1) {
|
||||
g = (v - c) / (1 - c);
|
||||
}
|
||||
|
||||
return [hwb[0], c * 100, g * 100];
|
||||
};
|
||||
|
||||
convert.apple.rgb = function (apple) {
|
||||
return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
|
||||
};
|
||||
|
||||
convert.rgb.apple = function (rgb) {
|
||||
return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
|
||||
};
|
||||
|
||||
convert.gray.rgb = function (args) {
|
||||
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
||||
};
|
||||
|
||||
convert.gray.hsl = function (args) {
|
||||
return [0, 0, args[0]];
|
||||
};
|
||||
|
||||
convert.gray.hsv = convert.gray.hsl;
|
||||
|
||||
convert.gray.hwb = function (gray) {
|
||||
return [0, 100, gray[0]];
|
||||
};
|
||||
|
||||
convert.gray.cmyk = function (gray) {
|
||||
return [0, 0, 0, gray[0]];
|
||||
};
|
||||
|
||||
convert.gray.lab = function (gray) {
|
||||
return [gray[0], 0, 0];
|
||||
};
|
||||
|
||||
convert.gray.hex = function (gray) {
|
||||
const val = Math.round(gray[0] / 100 * 255) & 0xFF;
|
||||
const integer = (val << 16) + (val << 8) + val;
|
||||
|
||||
const string = integer.toString(16).toUpperCase();
|
||||
return '000000'.substring(string.length) + string;
|
||||
};
|
||||
|
||||
convert.rgb.gray = function (rgb) {
|
||||
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
||||
return [val / 255 * 100];
|
||||
};
|
81
node_modules/jest-validate/node_modules/color-convert/index.js
generated
vendored
Normal file
81
node_modules/jest-validate/node_modules/color-convert/index.js
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
const conversions = require('./conversions');
|
||||
const route = require('./route');
|
||||
|
||||
const convert = {};
|
||||
|
||||
const models = Object.keys(conversions);
|
||||
|
||||
function wrapRaw(fn) {
|
||||
const wrappedFn = function (...args) {
|
||||
const arg0 = args[0];
|
||||
if (arg0 === undefined || arg0 === null) {
|
||||
return arg0;
|
||||
}
|
||||
|
||||
if (arg0.length > 1) {
|
||||
args = arg0;
|
||||
}
|
||||
|
||||
return fn(args);
|
||||
};
|
||||
|
||||
// Preserve .conversion property if there is one
|
||||
if ('conversion' in fn) {
|
||||
wrappedFn.conversion = fn.conversion;
|
||||
}
|
||||
|
||||
return wrappedFn;
|
||||
}
|
||||
|
||||
function wrapRounded(fn) {
|
||||
const wrappedFn = function (...args) {
|
||||
const arg0 = args[0];
|
||||
|
||||
if (arg0 === undefined || arg0 === null) {
|
||||
return arg0;
|
||||
}
|
||||
|
||||
if (arg0.length > 1) {
|
||||
args = arg0;
|
||||
}
|
||||
|
||||
const result = fn(args);
|
||||
|
||||
// We're assuming the result is an array here.
|
||||
// see notice in conversions.js; don't use box types
|
||||
// in conversion functions.
|
||||
if (typeof result === 'object') {
|
||||
for (let len = result.length, i = 0; i < len; i++) {
|
||||
result[i] = Math.round(result[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// Preserve .conversion property if there is one
|
||||
if ('conversion' in fn) {
|
||||
wrappedFn.conversion = fn.conversion;
|
||||
}
|
||||
|
||||
return wrappedFn;
|
||||
}
|
||||
|
||||
models.forEach(fromModel => {
|
||||
convert[fromModel] = {};
|
||||
|
||||
Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
|
||||
Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
|
||||
|
||||
const routes = route(fromModel);
|
||||
const routeModels = Object.keys(routes);
|
||||
|
||||
routeModels.forEach(toModel => {
|
||||
const fn = routes[toModel];
|
||||
|
||||
convert[fromModel][toModel] = wrapRounded(fn);
|
||||
convert[fromModel][toModel].raw = wrapRaw(fn);
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = convert;
|
48
node_modules/jest-validate/node_modules/color-convert/package.json
generated
vendored
Normal file
48
node_modules/jest-validate/node_modules/color-convert/package.json
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "color-convert",
|
||||
"description": "Plain color conversion functions",
|
||||
"version": "2.0.1",
|
||||
"author": "Heather Arthur <fayearthur@gmail.com>",
|
||||
"license": "MIT",
|
||||
"repository": "Qix-/color-convert",
|
||||
"scripts": {
|
||||
"pretest": "xo",
|
||||
"test": "node test/basic.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=7.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"color",
|
||||
"colour",
|
||||
"convert",
|
||||
"converter",
|
||||
"conversion",
|
||||
"rgb",
|
||||
"hsl",
|
||||
"hsv",
|
||||
"hwb",
|
||||
"cmyk",
|
||||
"ansi",
|
||||
"ansi16"
|
||||
],
|
||||
"files": [
|
||||
"index.js",
|
||||
"conversions.js",
|
||||
"route.js"
|
||||
],
|
||||
"xo": {
|
||||
"rules": {
|
||||
"default-case": 0,
|
||||
"no-inline-comments": 0,
|
||||
"operator-linebreak": 0
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"chalk": "^2.4.2",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"color-name": "~1.1.4"
|
||||
}
|
||||
}
|
97
node_modules/jest-validate/node_modules/color-convert/route.js
generated
vendored
Normal file
97
node_modules/jest-validate/node_modules/color-convert/route.js
generated
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
const conversions = require('./conversions');
|
||||
|
||||
/*
|
||||
This function routes a model to all other models.
|
||||
|
||||
all functions that are routed have a property `.conversion` attached
|
||||
to the returned synthetic function. This property is an array
|
||||
of strings, each with the steps in between the 'from' and 'to'
|
||||
color models (inclusive).
|
||||
|
||||
conversions that are not possible simply are not included.
|
||||
*/
|
||||
|
||||
function buildGraph() {
|
||||
const graph = {};
|
||||
// https://jsperf.com/object-keys-vs-for-in-with-closure/3
|
||||
const models = Object.keys(conversions);
|
||||
|
||||
for (let len = models.length, i = 0; i < len; i++) {
|
||||
graph[models[i]] = {
|
||||
// http://jsperf.com/1-vs-infinity
|
||||
// micro-opt, but this is simple.
|
||||
distance: -1,
|
||||
parent: null
|
||||
};
|
||||
}
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
// https://en.wikipedia.org/wiki/Breadth-first_search
|
||||
function deriveBFS(fromModel) {
|
||||
const graph = buildGraph();
|
||||
const queue = [fromModel]; // Unshift -> queue -> pop
|
||||
|
||||
graph[fromModel].distance = 0;
|
||||
|
||||
while (queue.length) {
|
||||
const current = queue.pop();
|
||||
const adjacents = Object.keys(conversions[current]);
|
||||
|
||||
for (let len = adjacents.length, i = 0; i < len; i++) {
|
||||
const adjacent = adjacents[i];
|
||||
const node = graph[adjacent];
|
||||
|
||||
if (node.distance === -1) {
|
||||
node.distance = graph[current].distance + 1;
|
||||
node.parent = current;
|
||||
queue.unshift(adjacent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return graph;
|
||||
}
|
||||
|
||||
function link(from, to) {
|
||||
return function (args) {
|
||||
return to(from(args));
|
||||
};
|
||||
}
|
||||
|
||||
function wrapConversion(toModel, graph) {
|
||||
const path = [graph[toModel].parent, toModel];
|
||||
let fn = conversions[graph[toModel].parent][toModel];
|
||||
|
||||
let cur = graph[toModel].parent;
|
||||
while (graph[cur].parent) {
|
||||
path.unshift(graph[cur].parent);
|
||||
fn = link(conversions[graph[cur].parent][cur], fn);
|
||||
cur = graph[cur].parent;
|
||||
}
|
||||
|
||||
fn.conversion = path;
|
||||
return fn;
|
||||
}
|
||||
|
||||
module.exports = function (fromModel) {
|
||||
const graph = deriveBFS(fromModel);
|
||||
const conversion = {};
|
||||
|
||||
const models = Object.keys(graph);
|
||||
for (let len = models.length, i = 0; i < len; i++) {
|
||||
const toModel = models[i];
|
||||
const node = graph[toModel];
|
||||
|
||||
if (node.parent === null) {
|
||||
// No possible conversion, or this node is the source model.
|
||||
continue;
|
||||
}
|
||||
|
||||
conversion[toModel] = wrapConversion(toModel, graph);
|
||||
}
|
||||
|
||||
return conversion;
|
||||
};
|
||||
|
8
node_modules/jest-validate/node_modules/color-name/LICENSE
generated
vendored
Normal file
8
node_modules/jest-validate/node_modules/color-name/LICENSE
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2015 Dmitry Ivanov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
11
node_modules/jest-validate/node_modules/color-name/README.md
generated
vendored
Normal file
11
node_modules/jest-validate/node_modules/color-name/README.md
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
A JSON with color names and its values. Based on http://dev.w3.org/csswg/css-color/#named-colors.
|
||||
|
||||
[](https://nodei.co/npm/color-name/)
|
||||
|
||||
|
||||
```js
|
||||
var colors = require('color-name');
|
||||
colors.red //[255,0,0]
|
||||
```
|
||||
|
||||
<a href="LICENSE"><img src="https://upload.wikimedia.org/wikipedia/commons/0/0c/MIT_logo.svg" width="120"/></a>
|
152
node_modules/jest-validate/node_modules/color-name/index.js
generated
vendored
Normal file
152
node_modules/jest-validate/node_modules/color-name/index.js
generated
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
"aliceblue": [240, 248, 255],
|
||||
"antiquewhite": [250, 235, 215],
|
||||
"aqua": [0, 255, 255],
|
||||
"aquamarine": [127, 255, 212],
|
||||
"azure": [240, 255, 255],
|
||||
"beige": [245, 245, 220],
|
||||
"bisque": [255, 228, 196],
|
||||
"black": [0, 0, 0],
|
||||
"blanchedalmond": [255, 235, 205],
|
||||
"blue": [0, 0, 255],
|
||||
"blueviolet": [138, 43, 226],
|
||||
"brown": [165, 42, 42],
|
||||
"burlywood": [222, 184, 135],
|
||||
"cadetblue": [95, 158, 160],
|
||||
"chartreuse": [127, 255, 0],
|
||||
"chocolate": [210, 105, 30],
|
||||
"coral": [255, 127, 80],
|
||||
"cornflowerblue": [100, 149, 237],
|
||||
"cornsilk": [255, 248, 220],
|
||||
"crimson": [220, 20, 60],
|
||||
"cyan": [0, 255, 255],
|
||||
"darkblue": [0, 0, 139],
|
||||
"darkcyan": [0, 139, 139],
|
||||
"darkgoldenrod": [184, 134, 11],
|
||||
"darkgray": [169, 169, 169],
|
||||
"darkgreen": [0, 100, 0],
|
||||
"darkgrey": [169, 169, 169],
|
||||
"darkkhaki": [189, 183, 107],
|
||||
"darkmagenta": [139, 0, 139],
|
||||
"darkolivegreen": [85, 107, 47],
|
||||
"darkorange": [255, 140, 0],
|
||||
"darkorchid": [153, 50, 204],
|
||||
"darkred": [139, 0, 0],
|
||||
"darksalmon": [233, 150, 122],
|
||||
"darkseagreen": [143, 188, 143],
|
||||
"darkslateblue": [72, 61, 139],
|
||||
"darkslategray": [47, 79, 79],
|
||||
"darkslategrey": [47, 79, 79],
|
||||
"darkturquoise": [0, 206, 209],
|
||||
"darkviolet": [148, 0, 211],
|
||||
"deeppink": [255, 20, 147],
|
||||
"deepskyblue": [0, 191, 255],
|
||||
"dimgray": [105, 105, 105],
|
||||
"dimgrey": [105, 105, 105],
|
||||
"dodgerblue": [30, 144, 255],
|
||||
"firebrick": [178, 34, 34],
|
||||
"floralwhite": [255, 250, 240],
|
||||
"forestgreen": [34, 139, 34],
|
||||
"fuchsia": [255, 0, 255],
|
||||
"gainsboro": [220, 220, 220],
|
||||
"ghostwhite": [248, 248, 255],
|
||||
"gold": [255, 215, 0],
|
||||
"goldenrod": [218, 165, 32],
|
||||
"gray": [128, 128, 128],
|
||||
"green": [0, 128, 0],
|
||||
"greenyellow": [173, 255, 47],
|
||||
"grey": [128, 128, 128],
|
||||
"honeydew": [240, 255, 240],
|
||||
"hotpink": [255, 105, 180],
|
||||
"indianred": [205, 92, 92],
|
||||
"indigo": [75, 0, 130],
|
||||
"ivory": [255, 255, 240],
|
||||
"khaki": [240, 230, 140],
|
||||
"lavender": [230, 230, 250],
|
||||
"lavenderblush": [255, 240, 245],
|
||||
"lawngreen": [124, 252, 0],
|
||||
"lemonchiffon": [255, 250, 205],
|
||||
"lightblue": [173, 216, 230],
|
||||
"lightcoral": [240, 128, 128],
|
||||
"lightcyan": [224, 255, 255],
|
||||
"lightgoldenrodyellow": [250, 250, 210],
|
||||
"lightgray": [211, 211, 211],
|
||||
"lightgreen": [144, 238, 144],
|
||||
"lightgrey": [211, 211, 211],
|
||||
"lightpink": [255, 182, 193],
|
||||
"lightsalmon": [255, 160, 122],
|
||||
"lightseagreen": [32, 178, 170],
|
||||
"lightskyblue": [135, 206, 250],
|
||||
"lightslategray": [119, 136, 153],
|
||||
"lightslategrey": [119, 136, 153],
|
||||
"lightsteelblue": [176, 196, 222],
|
||||
"lightyellow": [255, 255, 224],
|
||||
"lime": [0, 255, 0],
|
||||
"limegreen": [50, 205, 50],
|
||||
"linen": [250, 240, 230],
|
||||
"magenta": [255, 0, 255],
|
||||
"maroon": [128, 0, 0],
|
||||
"mediumaquamarine": [102, 205, 170],
|
||||
"mediumblue": [0, 0, 205],
|
||||
"mediumorchid": [186, 85, 211],
|
||||
"mediumpurple": [147, 112, 219],
|
||||
"mediumseagreen": [60, 179, 113],
|
||||
"mediumslateblue": [123, 104, 238],
|
||||
"mediumspringgreen": [0, 250, 154],
|
||||
"mediumturquoise": [72, 209, 204],
|
||||
"mediumvioletred": [199, 21, 133],
|
||||
"midnightblue": [25, 25, 112],
|
||||
"mintcream": [245, 255, 250],
|
||||
"mistyrose": [255, 228, 225],
|
||||
"moccasin": [255, 228, 181],
|
||||
"navajowhite": [255, 222, 173],
|
||||
"navy": [0, 0, 128],
|
||||
"oldlace": [253, 245, 230],
|
||||
"olive": [128, 128, 0],
|
||||
"olivedrab": [107, 142, 35],
|
||||
"orange": [255, 165, 0],
|
||||
"orangered": [255, 69, 0],
|
||||
"orchid": [218, 112, 214],
|
||||
"palegoldenrod": [238, 232, 170],
|
||||
"palegreen": [152, 251, 152],
|
||||
"paleturquoise": [175, 238, 238],
|
||||
"palevioletred": [219, 112, 147],
|
||||
"papayawhip": [255, 239, 213],
|
||||
"peachpuff": [255, 218, 185],
|
||||
"peru": [205, 133, 63],
|
||||
"pink": [255, 192, 203],
|
||||
"plum": [221, 160, 221],
|
||||
"powderblue": [176, 224, 230],
|
||||
"purple": [128, 0, 128],
|
||||
"rebeccapurple": [102, 51, 153],
|
||||
"red": [255, 0, 0],
|
||||
"rosybrown": [188, 143, 143],
|
||||
"royalblue": [65, 105, 225],
|
||||
"saddlebrown": [139, 69, 19],
|
||||
"salmon": [250, 128, 114],
|
||||
"sandybrown": [244, 164, 96],
|
||||
"seagreen": [46, 139, 87],
|
||||
"seashell": [255, 245, 238],
|
||||
"sienna": [160, 82, 45],
|
||||
"silver": [192, 192, 192],
|
||||
"skyblue": [135, 206, 235],
|
||||
"slateblue": [106, 90, 205],
|
||||
"slategray": [112, 128, 144],
|
||||
"slategrey": [112, 128, 144],
|
||||
"snow": [255, 250, 250],
|
||||
"springgreen": [0, 255, 127],
|
||||
"steelblue": [70, 130, 180],
|
||||
"tan": [210, 180, 140],
|
||||
"teal": [0, 128, 128],
|
||||
"thistle": [216, 191, 216],
|
||||
"tomato": [255, 99, 71],
|
||||
"turquoise": [64, 224, 208],
|
||||
"violet": [238, 130, 238],
|
||||
"wheat": [245, 222, 179],
|
||||
"white": [255, 255, 255],
|
||||
"whitesmoke": [245, 245, 245],
|
||||
"yellow": [255, 255, 0],
|
||||
"yellowgreen": [154, 205, 50]
|
||||
};
|
28
node_modules/jest-validate/node_modules/color-name/package.json
generated
vendored
Normal file
28
node_modules/jest-validate/node_modules/color-name/package.json
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "color-name",
|
||||
"version": "1.1.4",
|
||||
"description": "A list of color names and its values",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "node test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:colorjs/color-name.git"
|
||||
},
|
||||
"keywords": [
|
||||
"color-name",
|
||||
"color",
|
||||
"color-keyword",
|
||||
"keyword"
|
||||
],
|
||||
"author": "DY <dfcreative@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/colorjs/color-name/issues"
|
||||
},
|
||||
"homepage": "https://github.com/colorjs/color-name"
|
||||
}
|
39
node_modules/jest-validate/node_modules/has-flag/index.d.ts
generated
vendored
Normal file
39
node_modules/jest-validate/node_modules/has-flag/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag.
|
||||
|
||||
@param flag - CLI flag to look for. The `--` prefix is optional.
|
||||
@param argv - CLI arguments. Default: `process.argv`.
|
||||
@returns Whether the flag exists.
|
||||
|
||||
@example
|
||||
```
|
||||
// $ ts-node foo.ts -f --unicorn --foo=bar -- --rainbow
|
||||
|
||||
// foo.ts
|
||||
import hasFlag = require('has-flag');
|
||||
|
||||
hasFlag('unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('--unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('f');
|
||||
//=> true
|
||||
|
||||
hasFlag('-f');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo=bar');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo');
|
||||
//=> false
|
||||
|
||||
hasFlag('rainbow');
|
||||
//=> false
|
||||
```
|
||||
*/
|
||||
declare function hasFlag(flag: string, argv?: string[]): boolean;
|
||||
|
||||
export = hasFlag;
|
8
node_modules/jest-validate/node_modules/has-flag/index.js
generated
vendored
Normal file
8
node_modules/jest-validate/node_modules/has-flag/index.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = (flag, argv = process.argv) => {
|
||||
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
||||
const position = argv.indexOf(prefix + flag);
|
||||
const terminatorPosition = argv.indexOf('--');
|
||||
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
||||
};
|
9
node_modules/jest-validate/node_modules/has-flag/license
generated
vendored
Normal file
9
node_modules/jest-validate/node_modules/has-flag/license
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
46
node_modules/jest-validate/node_modules/has-flag/package.json
generated
vendored
Normal file
46
node_modules/jest-validate/node_modules/has-flag/package.json
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "has-flag",
|
||||
"version": "4.0.0",
|
||||
"description": "Check if argv has a specific flag",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/has-flag",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"has",
|
||||
"check",
|
||||
"detect",
|
||||
"contains",
|
||||
"find",
|
||||
"flag",
|
||||
"cli",
|
||||
"command-line",
|
||||
"argv",
|
||||
"process",
|
||||
"arg",
|
||||
"args",
|
||||
"argument",
|
||||
"arguments",
|
||||
"getopt",
|
||||
"minimist",
|
||||
"optimist"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
89
node_modules/jest-validate/node_modules/has-flag/readme.md
generated
vendored
Normal file
89
node_modules/jest-validate/node_modules/has-flag/readme.md
generated
vendored
Normal file
@ -0,0 +1,89 @@
|
||||
# has-flag [](https://travis-ci.org/sindresorhus/has-flag)
|
||||
|
||||
> Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag
|
||||
|
||||
Correctly stops looking after an `--` argument terminator.
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-has-flag?utm_source=npm-has-flag&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install has-flag
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// foo.js
|
||||
const hasFlag = require('has-flag');
|
||||
|
||||
hasFlag('unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('--unicorn');
|
||||
//=> true
|
||||
|
||||
hasFlag('f');
|
||||
//=> true
|
||||
|
||||
hasFlag('-f');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo=bar');
|
||||
//=> true
|
||||
|
||||
hasFlag('foo');
|
||||
//=> false
|
||||
|
||||
hasFlag('rainbow');
|
||||
//=> false
|
||||
```
|
||||
|
||||
```
|
||||
$ node foo.js -f --unicorn --foo=bar -- --rainbow
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### hasFlag(flag, [argv])
|
||||
|
||||
Returns a boolean for whether the flag exists.
|
||||
|
||||
#### flag
|
||||
|
||||
Type: `string`
|
||||
|
||||
CLI flag to look for. The `--` prefix is optional.
|
||||
|
||||
#### argv
|
||||
|
||||
Type: `string[]`<br>
|
||||
Default: `process.argv`
|
||||
|
||||
CLI arguments.
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
21
node_modules/jest-validate/node_modules/pretty-format/LICENSE
generated
vendored
Normal file
21
node_modules/jest-validate/node_modules/pretty-format/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Facebook, Inc. and its affiliates.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
456
node_modules/jest-validate/node_modules/pretty-format/README.md
generated
vendored
Executable file
456
node_modules/jest-validate/node_modules/pretty-format/README.md
generated
vendored
Executable file
@ -0,0 +1,456 @@
|
||||
# pretty-format
|
||||
|
||||
Stringify any JavaScript value.
|
||||
|
||||
- Serialize built-in JavaScript types.
|
||||
- Serialize application-specific data types with built-in or user-defined plugins.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ yarn add pretty-format
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const prettyFormat = require('pretty-format'); // CommonJS
|
||||
```
|
||||
|
||||
```js
|
||||
import prettyFormat from 'pretty-format'; // ES2015 modules
|
||||
```
|
||||
|
||||
```js
|
||||
const val = {object: {}};
|
||||
val.circularReference = val;
|
||||
val[Symbol('foo')] = 'foo';
|
||||
val.map = new Map([['prop', 'value']]);
|
||||
val.array = [-0, Infinity, NaN];
|
||||
|
||||
console.log(prettyFormat(val));
|
||||
/*
|
||||
Object {
|
||||
"array": Array [
|
||||
-0,
|
||||
Infinity,
|
||||
NaN,
|
||||
],
|
||||
"circularReference": [Circular],
|
||||
"map": Map {
|
||||
"prop" => "value",
|
||||
},
|
||||
"object": Object {},
|
||||
Symbol(foo): "foo",
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
## Usage with options
|
||||
|
||||
```js
|
||||
function onClick() {}
|
||||
|
||||
console.log(prettyFormat(onClick));
|
||||
/*
|
||||
[Function onClick]
|
||||
*/
|
||||
|
||||
const options = {
|
||||
printFunctionName: false,
|
||||
};
|
||||
console.log(prettyFormat(onClick, options));
|
||||
/*
|
||||
[Function]
|
||||
*/
|
||||
```
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
| key | type | default | description |
|
||||
| :------------------ | :-------- | :--------- | :------------------------------------------------------ |
|
||||
| `callToJSON` | `boolean` | `true` | call `toJSON` method (if it exists) on objects |
|
||||
| `escapeRegex` | `boolean` | `false` | escape special characters in regular expressions |
|
||||
| `escapeString` | `boolean` | `true` | escape special characters in strings |
|
||||
| `highlight` | `boolean` | `false` | highlight syntax with colors in terminal (some plugins) |
|
||||
| `indent` | `number` | `2` | spaces in each level of indentation |
|
||||
| `maxDepth` | `number` | `Infinity` | levels to print in arrays, objects, elements, and so on |
|
||||
| `min` | `boolean` | `false` | minimize added space: no indentation nor line breaks |
|
||||
| `plugins` | `array` | `[]` | plugins to serialize application-specific data types |
|
||||
| `printFunctionName` | `boolean` | `true` | include or omit the name of a function |
|
||||
| `theme` | `object` | | colors to highlight syntax in terminal |
|
||||
|
||||
Property values of `theme` are from [ansi-styles colors](https://github.com/chalk/ansi-styles#colors)
|
||||
|
||||
```js
|
||||
const DEFAULT_THEME = {
|
||||
comment: 'gray',
|
||||
content: 'reset',
|
||||
prop: 'yellow',
|
||||
tag: 'cyan',
|
||||
value: 'green',
|
||||
};
|
||||
```
|
||||
|
||||
## Usage with plugins
|
||||
|
||||
The `pretty-format` package provides some built-in plugins, including:
|
||||
|
||||
- `ReactElement` for elements from `react`
|
||||
- `ReactTestComponent` for test objects from `react-test-renderer`
|
||||
|
||||
```js
|
||||
// CommonJS
|
||||
const prettyFormat = require('pretty-format');
|
||||
const ReactElement = prettyFormat.plugins.ReactElement;
|
||||
const ReactTestComponent = prettyFormat.plugins.ReactTestComponent;
|
||||
|
||||
const React = require('react');
|
||||
const renderer = require('react-test-renderer');
|
||||
```
|
||||
|
||||
```js
|
||||
// ES2015 modules and destructuring assignment
|
||||
import prettyFormat from 'pretty-format';
|
||||
const {ReactElement, ReactTestComponent} = prettyFormat.plugins;
|
||||
|
||||
import React from 'react';
|
||||
import renderer from 'react-test-renderer';
|
||||
```
|
||||
|
||||
```js
|
||||
const onClick = () => {};
|
||||
const element = React.createElement('button', {onClick}, 'Hello World');
|
||||
|
||||
const formatted1 = prettyFormat(element, {
|
||||
plugins: [ReactElement],
|
||||
printFunctionName: false,
|
||||
});
|
||||
const formatted2 = prettyFormat(renderer.create(element).toJSON(), {
|
||||
plugins: [ReactTestComponent],
|
||||
printFunctionName: false,
|
||||
});
|
||||
/*
|
||||
<button
|
||||
onClick=[Function]
|
||||
>
|
||||
Hello World
|
||||
</button>
|
||||
*/
|
||||
```
|
||||
|
||||
## Usage in Jest
|
||||
|
||||
For snapshot tests, Jest uses `pretty-format` with options that include some of its built-in plugins. For this purpose, plugins are also known as **snapshot serializers**.
|
||||
|
||||
To serialize application-specific data types, you can add modules to `devDependencies` of a project, and then:
|
||||
|
||||
In an **individual** test file, you can add a module as follows. It precedes any modules from Jest configuration.
|
||||
|
||||
```js
|
||||
import serializer from 'my-serializer-module';
|
||||
expect.addSnapshotSerializer(serializer);
|
||||
|
||||
// tests which have `expect(value).toMatchSnapshot()` assertions
|
||||
```
|
||||
|
||||
For **all** test files, you can specify modules in Jest configuration. They precede built-in plugins for React, HTML, and Immutable.js data types. For example, in a `package.json` file:
|
||||
|
||||
```json
|
||||
{
|
||||
"jest": {
|
||||
"snapshotSerializers": ["my-serializer-module"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Writing plugins
|
||||
|
||||
A plugin is a JavaScript object.
|
||||
|
||||
If `options` has a `plugins` array: for the first plugin whose `test(val)` method returns a truthy value, then `prettyFormat(val, options)` returns the result from either:
|
||||
|
||||
- `serialize(val, …)` method of the **improved** interface (available in **version 21** or later)
|
||||
- `print(val, …)` method of the **original** interface (if plugin does not have `serialize` method)
|
||||
|
||||
### test
|
||||
|
||||
Write `test` so it can receive `val` argument of any type. To serialize **objects** which have certain properties, then a guarded expression like `val != null && …` or more concise `val && …` prevents the following errors:
|
||||
|
||||
- `TypeError: Cannot read property 'whatever' of null`
|
||||
- `TypeError: Cannot read property 'whatever' of undefined`
|
||||
|
||||
For example, `test` method of built-in `ReactElement` plugin:
|
||||
|
||||
```js
|
||||
const elementSymbol = Symbol.for('react.element');
|
||||
const test = val => val && val.$$typeof === elementSymbol;
|
||||
```
|
||||
|
||||
Pay attention to efficiency in `test` because `pretty-format` calls it often.
|
||||
|
||||
### serialize
|
||||
|
||||
The **improved** interface is available in **version 21** or later.
|
||||
|
||||
Write `serialize` to return a string, given the arguments:
|
||||
|
||||
- `val` which “passed the test”
|
||||
- unchanging `config` object: derived from `options`
|
||||
- current `indentation` string: concatenate to `indent` from `config`
|
||||
- current `depth` number: compare to `maxDepth` from `config`
|
||||
- current `refs` array: find circular references in objects
|
||||
- `printer` callback function: serialize children
|
||||
|
||||
### config
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
| key | type | description |
|
||||
| :------------------ | :-------- | :------------------------------------------------------ |
|
||||
| `callToJSON` | `boolean` | call `toJSON` method (if it exists) on objects |
|
||||
| `colors` | `Object` | escape codes for colors to highlight syntax |
|
||||
| `escapeRegex` | `boolean` | escape special characters in regular expressions |
|
||||
| `escapeString` | `boolean` | escape special characters in strings |
|
||||
| `indent` | `string` | spaces in each level of indentation |
|
||||
| `maxDepth` | `number` | levels to print in arrays, objects, elements, and so on |
|
||||
| `min` | `boolean` | minimize added space: no indentation nor line breaks |
|
||||
| `plugins` | `array` | plugins to serialize application-specific data types |
|
||||
| `printFunctionName` | `boolean` | include or omit the name of a function |
|
||||
| `spacingInner` | `strong` | spacing to separate items in a list |
|
||||
| `spacingOuter` | `strong` | spacing to enclose a list of items |
|
||||
|
||||
Each property of `colors` in `config` corresponds to a property of `theme` in `options`:
|
||||
|
||||
- the key is the same (for example, `tag`)
|
||||
- the value in `colors` is a object with `open` and `close` properties whose values are escape codes from [ansi-styles](https://github.com/chalk/ansi-styles) for the color value in `theme` (for example, `'cyan'`)
|
||||
|
||||
Some properties in `config` are derived from `min` in `options`:
|
||||
|
||||
- `spacingInner` and `spacingOuter` are **newline** if `min` is `false`
|
||||
- `spacingInner` is **space** and `spacingOuter` is **empty string** if `min` is `true`
|
||||
|
||||
### Example of serialize and test
|
||||
|
||||
This plugin is a pattern you can apply to serialize composite data types. Side note: `pretty-format` does not need a plugin to serialize arrays.
|
||||
|
||||
```js
|
||||
// We reused more code when we factored out a function for child items
|
||||
// that is independent of depth, name, and enclosing punctuation (see below).
|
||||
const SEPARATOR = ',';
|
||||
function serializeItems(items, config, indentation, depth, refs, printer) {
|
||||
if (items.length === 0) {
|
||||
return '';
|
||||
}
|
||||
const indentationItems = indentation + config.indent;
|
||||
return (
|
||||
config.spacingOuter +
|
||||
items
|
||||
.map(
|
||||
item =>
|
||||
indentationItems +
|
||||
printer(item, config, indentationItems, depth, refs), // callback
|
||||
)
|
||||
.join(SEPARATOR + config.spacingInner) +
|
||||
(config.min ? '' : SEPARATOR) + // following the last item
|
||||
config.spacingOuter +
|
||||
indentation
|
||||
);
|
||||
}
|
||||
|
||||
const plugin = {
|
||||
test(val) {
|
||||
return Array.isArray(val);
|
||||
},
|
||||
serialize(array, config, indentation, depth, refs, printer) {
|
||||
const name = array.constructor.name;
|
||||
return ++depth > config.maxDepth
|
||||
? '[' + name + ']'
|
||||
: (config.min ? '' : name + ' ') +
|
||||
'[' +
|
||||
serializeItems(array, config, indentation, depth, refs, printer) +
|
||||
']';
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
```js
|
||||
const val = {
|
||||
filter: 'completed',
|
||||
items: [
|
||||
{
|
||||
text: 'Write test',
|
||||
completed: true,
|
||||
},
|
||||
{
|
||||
text: 'Write serialize',
|
||||
completed: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
```js
|
||||
console.log(
|
||||
prettyFormat(val, {
|
||||
plugins: [plugin],
|
||||
}),
|
||||
);
|
||||
/*
|
||||
Object {
|
||||
"filter": "completed",
|
||||
"items": Array [
|
||||
Object {
|
||||
"completed": true,
|
||||
"text": "Write test",
|
||||
},
|
||||
Object {
|
||||
"completed": true,
|
||||
"text": "Write serialize",
|
||||
},
|
||||
],
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
```js
|
||||
console.log(
|
||||
prettyFormat(val, {
|
||||
indent: 4,
|
||||
plugins: [plugin],
|
||||
}),
|
||||
);
|
||||
/*
|
||||
Object {
|
||||
"filter": "completed",
|
||||
"items": Array [
|
||||
Object {
|
||||
"completed": true,
|
||||
"text": "Write test",
|
||||
},
|
||||
Object {
|
||||
"completed": true,
|
||||
"text": "Write serialize",
|
||||
},
|
||||
],
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
```js
|
||||
console.log(
|
||||
prettyFormat(val, {
|
||||
maxDepth: 1,
|
||||
plugins: [plugin],
|
||||
}),
|
||||
);
|
||||
/*
|
||||
Object {
|
||||
"filter": "completed",
|
||||
"items": [Array],
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
```js
|
||||
console.log(
|
||||
prettyFormat(val, {
|
||||
min: true,
|
||||
plugins: [plugin],
|
||||
}),
|
||||
);
|
||||
/*
|
||||
{"filter": "completed", "items": [{"completed": true, "text": "Write test"}, {"completed": true, "text": "Write serialize"}]}
|
||||
*/
|
||||
```
|
||||
|
||||
### print
|
||||
|
||||
The **original** interface is adequate for plugins:
|
||||
|
||||
- that **do not** depend on options other than `highlight` or `min`
|
||||
- that **do not** depend on `depth` or `refs` in recursive traversal, and
|
||||
- if values either
|
||||
- do **not** require indentation, or
|
||||
- do **not** occur as children of JavaScript data structures (for example, array)
|
||||
|
||||
Write `print` to return a string, given the arguments:
|
||||
|
||||
- `val` which “passed the test”
|
||||
- current `printer(valChild)` callback function: serialize children
|
||||
- current `indenter(lines)` callback function: indent lines at the next level
|
||||
- unchanging `config` object: derived from `options`
|
||||
- unchanging `colors` object: derived from `options`
|
||||
|
||||
The 3 properties of `config` are `min` in `options` and:
|
||||
|
||||
- `spacing` and `edgeSpacing` are **newline** if `min` is `false`
|
||||
- `spacing` is **space** and `edgeSpacing` is **empty string** if `min` is `true`
|
||||
|
||||
Each property of `colors` corresponds to a property of `theme` in `options`:
|
||||
|
||||
- the key is the same (for example, `tag`)
|
||||
- the value in `colors` is a object with `open` and `close` properties whose values are escape codes from [ansi-styles](https://github.com/chalk/ansi-styles) for the color value in `theme` (for example, `'cyan'`)
|
||||
|
||||
### Example of print and test
|
||||
|
||||
This plugin prints functions with the **number of named arguments** excluding rest argument.
|
||||
|
||||
```js
|
||||
const plugin = {
|
||||
print(val) {
|
||||
return `[Function ${val.name || 'anonymous'} ${val.length}]`;
|
||||
},
|
||||
test(val) {
|
||||
return typeof val === 'function';
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
```js
|
||||
const val = {
|
||||
onClick(event) {},
|
||||
render() {},
|
||||
};
|
||||
|
||||
prettyFormat(val, {
|
||||
plugins: [plugin],
|
||||
});
|
||||
/*
|
||||
Object {
|
||||
"onClick": [Function onClick 1],
|
||||
"render": [Function render 0],
|
||||
}
|
||||
*/
|
||||
|
||||
prettyFormat(val);
|
||||
/*
|
||||
Object {
|
||||
"onClick": [Function onClick],
|
||||
"render": [Function render],
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
This plugin **ignores** the `printFunctionName` option. That limitation of the original `print` interface is a reason to use the improved `serialize` interface, described above.
|
||||
|
||||
```js
|
||||
prettyFormat(val, {
|
||||
plugins: [pluginOld],
|
||||
printFunctionName: false,
|
||||
});
|
||||
/*
|
||||
Object {
|
||||
"onClick": [Function onClick 1],
|
||||
"render": [Function render 0],
|
||||
}
|
||||
*/
|
||||
|
||||
prettyFormat(val, {
|
||||
printFunctionName: false,
|
||||
});
|
||||
/*
|
||||
Object {
|
||||
"onClick": [Function],
|
||||
"render": [Function],
|
||||
}
|
||||
*/
|
||||
```
|
3252
node_modules/jest-validate/node_modules/pretty-format/build-es5/index.js
generated
vendored
Normal file
3252
node_modules/jest-validate/node_modules/pretty-format/build-es5/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/jest-validate/node_modules/pretty-format/build-es5/index.js.map
generated
vendored
Normal file
1
node_modules/jest-validate/node_modules/pretty-format/build-es5/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
32
node_modules/jest-validate/node_modules/pretty-format/build/collections.d.ts
generated
vendored
Normal file
32
node_modules/jest-validate/node_modules/pretty-format/build/collections.d.ts
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
import type { Config, Printer, Refs } from './types';
|
||||
/**
|
||||
* Return entries (for example, of a map)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, braces)
|
||||
*/
|
||||
export declare function printIteratorEntries(iterator: Iterator<[unknown, unknown]>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer, separator?: string): string;
|
||||
/**
|
||||
* Return values (for example, of a set)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (braces or brackets)
|
||||
*/
|
||||
export declare function printIteratorValues(iterator: Iterator<unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string;
|
||||
/**
|
||||
* Return items (for example, of an array)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, brackets)
|
||||
**/
|
||||
export declare function printListItems(list: ArrayLike<unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string;
|
||||
/**
|
||||
* Return properties of an object
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, braces)
|
||||
*/
|
||||
export declare function printObjectProperties(val: Record<string, unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string;
|
185
node_modules/jest-validate/node_modules/pretty-format/build/collections.js
generated
vendored
Normal file
185
node_modules/jest-validate/node_modules/pretty-format/build/collections.js
generated
vendored
Normal file
@ -0,0 +1,185 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.printIteratorEntries = printIteratorEntries;
|
||||
exports.printIteratorValues = printIteratorValues;
|
||||
exports.printListItems = printListItems;
|
||||
exports.printObjectProperties = printObjectProperties;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
const getKeysOfEnumerableProperties = object => {
|
||||
const keys = Object.keys(object).sort();
|
||||
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
Object.getOwnPropertySymbols(object).forEach(symbol => {
|
||||
if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
|
||||
keys.push(symbol);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return keys;
|
||||
};
|
||||
/**
|
||||
* Return entries (for example, of a map)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, braces)
|
||||
*/
|
||||
|
||||
function printIteratorEntries(
|
||||
iterator,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer, // Too bad, so sad that separator for ECMAScript Map has been ' => '
|
||||
// What a distracting diff if you change a data structure to/from
|
||||
// ECMAScript Object or Immutable.Map/OrderedMap which use the default.
|
||||
separator = ': '
|
||||
) {
|
||||
let result = '';
|
||||
let current = iterator.next();
|
||||
|
||||
if (!current.done) {
|
||||
result += config.spacingOuter;
|
||||
const indentationNext = indentation + config.indent;
|
||||
|
||||
while (!current.done) {
|
||||
const name = printer(
|
||||
current.value[0],
|
||||
config,
|
||||
indentationNext,
|
||||
depth,
|
||||
refs
|
||||
);
|
||||
const value = printer(
|
||||
current.value[1],
|
||||
config,
|
||||
indentationNext,
|
||||
depth,
|
||||
refs
|
||||
);
|
||||
result += indentationNext + name + separator + value;
|
||||
current = iterator.next();
|
||||
|
||||
if (!current.done) {
|
||||
result += ',' + config.spacingInner;
|
||||
} else if (!config.min) {
|
||||
result += ',';
|
||||
}
|
||||
}
|
||||
|
||||
result += config.spacingOuter + indentation;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Return values (for example, of a set)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (braces or brackets)
|
||||
*/
|
||||
|
||||
function printIteratorValues(
|
||||
iterator,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) {
|
||||
let result = '';
|
||||
let current = iterator.next();
|
||||
|
||||
if (!current.done) {
|
||||
result += config.spacingOuter;
|
||||
const indentationNext = indentation + config.indent;
|
||||
|
||||
while (!current.done) {
|
||||
result +=
|
||||
indentationNext +
|
||||
printer(current.value, config, indentationNext, depth, refs);
|
||||
current = iterator.next();
|
||||
|
||||
if (!current.done) {
|
||||
result += ',' + config.spacingInner;
|
||||
} else if (!config.min) {
|
||||
result += ',';
|
||||
}
|
||||
}
|
||||
|
||||
result += config.spacingOuter + indentation;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Return items (for example, of an array)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, brackets)
|
||||
**/
|
||||
|
||||
function printListItems(list, config, indentation, depth, refs, printer) {
|
||||
let result = '';
|
||||
|
||||
if (list.length) {
|
||||
result += config.spacingOuter;
|
||||
const indentationNext = indentation + config.indent;
|
||||
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
result +=
|
||||
indentationNext +
|
||||
printer(list[i], config, indentationNext, depth, refs);
|
||||
|
||||
if (i < list.length - 1) {
|
||||
result += ',' + config.spacingInner;
|
||||
} else if (!config.min) {
|
||||
result += ',';
|
||||
}
|
||||
}
|
||||
|
||||
result += config.spacingOuter + indentation;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Return properties of an object
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, braces)
|
||||
*/
|
||||
|
||||
function printObjectProperties(val, config, indentation, depth, refs, printer) {
|
||||
let result = '';
|
||||
const keys = getKeysOfEnumerableProperties(val);
|
||||
|
||||
if (keys.length) {
|
||||
result += config.spacingOuter;
|
||||
const indentationNext = indentation + config.indent;
|
||||
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const name = printer(key, config, indentationNext, depth, refs);
|
||||
const value = printer(val[key], config, indentationNext, depth, refs);
|
||||
result += indentationNext + name + ': ' + value;
|
||||
|
||||
if (i < keys.length - 1) {
|
||||
result += ',' + config.spacingInner;
|
||||
} else if (!config.min) {
|
||||
result += ',';
|
||||
}
|
||||
}
|
||||
|
||||
result += config.spacingOuter + indentation;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
37
node_modules/jest-validate/node_modules/pretty-format/build/index.d.ts
generated
vendored
Normal file
37
node_modules/jest-validate/node_modules/pretty-format/build/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type * as PrettyFormat from './types';
|
||||
/**
|
||||
* Returns a presentation string of your `val` object
|
||||
* @param val any potential JavaScript object
|
||||
* @param options Custom settings
|
||||
*/
|
||||
declare function prettyFormat(val: unknown, options?: PrettyFormat.OptionsReceived): string;
|
||||
declare namespace prettyFormat {
|
||||
var plugins: {
|
||||
AsymmetricMatcher: PrettyFormat.NewPlugin;
|
||||
ConvertAnsi: PrettyFormat.NewPlugin;
|
||||
DOMCollection: PrettyFormat.NewPlugin;
|
||||
DOMElement: PrettyFormat.NewPlugin;
|
||||
Immutable: PrettyFormat.NewPlugin;
|
||||
ReactElement: PrettyFormat.NewPlugin;
|
||||
ReactTestComponent: PrettyFormat.NewPlugin;
|
||||
};
|
||||
}
|
||||
declare namespace prettyFormat {
|
||||
type Colors = PrettyFormat.Colors;
|
||||
type Config = PrettyFormat.Config;
|
||||
type Options = PrettyFormat.Options;
|
||||
type OptionsReceived = PrettyFormat.OptionsReceived;
|
||||
type OldPlugin = PrettyFormat.OldPlugin;
|
||||
type NewPlugin = PrettyFormat.NewPlugin;
|
||||
type Plugin = PrettyFormat.Plugin;
|
||||
type Plugins = PrettyFormat.Plugins;
|
||||
type Refs = PrettyFormat.Refs;
|
||||
type Theme = PrettyFormat.Theme;
|
||||
}
|
||||
export = prettyFormat;
|
559
node_modules/jest-validate/node_modules/pretty-format/build/index.js
generated
vendored
Normal file
559
node_modules/jest-validate/node_modules/pretty-format/build/index.js
generated
vendored
Normal file
@ -0,0 +1,559 @@
|
||||
'use strict';
|
||||
|
||||
var _ansiStyles = _interopRequireDefault(require('ansi-styles'));
|
||||
|
||||
var _collections = require('./collections');
|
||||
|
||||
var _AsymmetricMatcher = _interopRequireDefault(
|
||||
require('./plugins/AsymmetricMatcher')
|
||||
);
|
||||
|
||||
var _ConvertAnsi = _interopRequireDefault(require('./plugins/ConvertAnsi'));
|
||||
|
||||
var _DOMCollection = _interopRequireDefault(require('./plugins/DOMCollection'));
|
||||
|
||||
var _DOMElement = _interopRequireDefault(require('./plugins/DOMElement'));
|
||||
|
||||
var _Immutable = _interopRequireDefault(require('./plugins/Immutable'));
|
||||
|
||||
var _ReactElement = _interopRequireDefault(require('./plugins/ReactElement'));
|
||||
|
||||
var _ReactTestComponent = _interopRequireDefault(
|
||||
require('./plugins/ReactTestComponent')
|
||||
);
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const toString = Object.prototype.toString;
|
||||
const toISOString = Date.prototype.toISOString;
|
||||
const errorToString = Error.prototype.toString;
|
||||
const regExpToString = RegExp.prototype.toString;
|
||||
/**
|
||||
* Explicitly comparing typeof constructor to function avoids undefined as name
|
||||
* when mock identity-obj-proxy returns the key as the value for any key.
|
||||
*/
|
||||
|
||||
const getConstructorName = val =>
|
||||
(typeof val.constructor === 'function' && val.constructor.name) || 'Object';
|
||||
/* global window */
|
||||
|
||||
/** Is val is equal to global window object? Works even if it does not exist :) */
|
||||
|
||||
const isWindow = val => typeof window !== 'undefined' && val === window;
|
||||
|
||||
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
|
||||
const NEWLINE_REGEXP = /\n/gi;
|
||||
|
||||
class PrettyFormatPluginError extends Error {
|
||||
constructor(message, stack) {
|
||||
super(message);
|
||||
this.stack = stack;
|
||||
this.name = this.constructor.name;
|
||||
}
|
||||
}
|
||||
|
||||
function isToStringedArrayType(toStringed) {
|
||||
return (
|
||||
toStringed === '[object Array]' ||
|
||||
toStringed === '[object ArrayBuffer]' ||
|
||||
toStringed === '[object DataView]' ||
|
||||
toStringed === '[object Float32Array]' ||
|
||||
toStringed === '[object Float64Array]' ||
|
||||
toStringed === '[object Int8Array]' ||
|
||||
toStringed === '[object Int16Array]' ||
|
||||
toStringed === '[object Int32Array]' ||
|
||||
toStringed === '[object Uint8Array]' ||
|
||||
toStringed === '[object Uint8ClampedArray]' ||
|
||||
toStringed === '[object Uint16Array]' ||
|
||||
toStringed === '[object Uint32Array]'
|
||||
);
|
||||
}
|
||||
|
||||
function printNumber(val) {
|
||||
return Object.is(val, -0) ? '-0' : String(val);
|
||||
}
|
||||
|
||||
function printBigInt(val) {
|
||||
return String(`${val}n`);
|
||||
}
|
||||
|
||||
function printFunction(val, printFunctionName) {
|
||||
if (!printFunctionName) {
|
||||
return '[Function]';
|
||||
}
|
||||
|
||||
return '[Function ' + (val.name || 'anonymous') + ']';
|
||||
}
|
||||
|
||||
function printSymbol(val) {
|
||||
return String(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
|
||||
}
|
||||
|
||||
function printError(val) {
|
||||
return '[' + errorToString.call(val) + ']';
|
||||
}
|
||||
/**
|
||||
* The first port of call for printing an object, handles most of the
|
||||
* data-types in JS.
|
||||
*/
|
||||
|
||||
function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
|
||||
if (val === true || val === false) {
|
||||
return '' + val;
|
||||
}
|
||||
|
||||
if (val === undefined) {
|
||||
return 'undefined';
|
||||
}
|
||||
|
||||
if (val === null) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
const typeOf = typeof val;
|
||||
|
||||
if (typeOf === 'number') {
|
||||
return printNumber(val);
|
||||
}
|
||||
|
||||
if (typeOf === 'bigint') {
|
||||
return printBigInt(val);
|
||||
}
|
||||
|
||||
if (typeOf === 'string') {
|
||||
if (escapeString) {
|
||||
return '"' + val.replace(/"|\\/g, '\\$&') + '"';
|
||||
}
|
||||
|
||||
return '"' + val + '"';
|
||||
}
|
||||
|
||||
if (typeOf === 'function') {
|
||||
return printFunction(val, printFunctionName);
|
||||
}
|
||||
|
||||
if (typeOf === 'symbol') {
|
||||
return printSymbol(val);
|
||||
}
|
||||
|
||||
const toStringed = toString.call(val);
|
||||
|
||||
if (toStringed === '[object WeakMap]') {
|
||||
return 'WeakMap {}';
|
||||
}
|
||||
|
||||
if (toStringed === '[object WeakSet]') {
|
||||
return 'WeakSet {}';
|
||||
}
|
||||
|
||||
if (
|
||||
toStringed === '[object Function]' ||
|
||||
toStringed === '[object GeneratorFunction]'
|
||||
) {
|
||||
return printFunction(val, printFunctionName);
|
||||
}
|
||||
|
||||
if (toStringed === '[object Symbol]') {
|
||||
return printSymbol(val);
|
||||
}
|
||||
|
||||
if (toStringed === '[object Date]') {
|
||||
return isNaN(+val) ? 'Date { NaN }' : toISOString.call(val);
|
||||
}
|
||||
|
||||
if (toStringed === '[object Error]') {
|
||||
return printError(val);
|
||||
}
|
||||
|
||||
if (toStringed === '[object RegExp]') {
|
||||
if (escapeRegex) {
|
||||
// https://github.com/benjamingr/RegExp.escape/blob/master/polyfill.js
|
||||
return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||
}
|
||||
|
||||
return regExpToString.call(val);
|
||||
}
|
||||
|
||||
if (val instanceof Error) {
|
||||
return printError(val);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Handles more complex objects ( such as objects with circular references.
|
||||
* maps and sets etc )
|
||||
*/
|
||||
|
||||
function printComplexValue(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
hasCalledToJSON
|
||||
) {
|
||||
if (refs.indexOf(val) !== -1) {
|
||||
return '[Circular]';
|
||||
}
|
||||
|
||||
refs = refs.slice();
|
||||
refs.push(val);
|
||||
const hitMaxDepth = ++depth > config.maxDepth;
|
||||
const min = config.min;
|
||||
|
||||
if (
|
||||
config.callToJSON &&
|
||||
!hitMaxDepth &&
|
||||
val.toJSON &&
|
||||
typeof val.toJSON === 'function' &&
|
||||
!hasCalledToJSON
|
||||
) {
|
||||
return printer(val.toJSON(), config, indentation, depth, refs, true);
|
||||
}
|
||||
|
||||
const toStringed = toString.call(val);
|
||||
|
||||
if (toStringed === '[object Arguments]') {
|
||||
return hitMaxDepth
|
||||
? '[Arguments]'
|
||||
: (min ? '' : 'Arguments ') +
|
||||
'[' +
|
||||
(0, _collections.printListItems)(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
']';
|
||||
}
|
||||
|
||||
if (isToStringedArrayType(toStringed)) {
|
||||
return hitMaxDepth
|
||||
? '[' + val.constructor.name + ']'
|
||||
: (min ? '' : val.constructor.name + ' ') +
|
||||
'[' +
|
||||
(0, _collections.printListItems)(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
']';
|
||||
}
|
||||
|
||||
if (toStringed === '[object Map]') {
|
||||
return hitMaxDepth
|
||||
? '[Map]'
|
||||
: 'Map {' +
|
||||
(0, _collections.printIteratorEntries)(
|
||||
val.entries(),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
' => '
|
||||
) +
|
||||
'}';
|
||||
}
|
||||
|
||||
if (toStringed === '[object Set]') {
|
||||
return hitMaxDepth
|
||||
? '[Set]'
|
||||
: 'Set {' +
|
||||
(0, _collections.printIteratorValues)(
|
||||
val.values(),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
'}';
|
||||
} // Avoid failure to serialize global window object in jsdom test environment.
|
||||
// For example, not even relevant if window is prop of React element.
|
||||
|
||||
return hitMaxDepth || isWindow(val)
|
||||
? '[' + getConstructorName(val) + ']'
|
||||
: (min ? '' : getConstructorName(val) + ' ') +
|
||||
'{' +
|
||||
(0, _collections.printObjectProperties)(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
'}';
|
||||
}
|
||||
|
||||
function isNewPlugin(plugin) {
|
||||
return plugin.serialize != null;
|
||||
}
|
||||
|
||||
function printPlugin(plugin, val, config, indentation, depth, refs) {
|
||||
let printed;
|
||||
|
||||
try {
|
||||
printed = isNewPlugin(plugin)
|
||||
? plugin.serialize(val, config, indentation, depth, refs, printer)
|
||||
: plugin.print(
|
||||
val,
|
||||
valChild => printer(valChild, config, indentation, depth, refs),
|
||||
str => {
|
||||
const indentationNext = indentation + config.indent;
|
||||
return (
|
||||
indentationNext +
|
||||
str.replace(NEWLINE_REGEXP, '\n' + indentationNext)
|
||||
);
|
||||
},
|
||||
{
|
||||
edgeSpacing: config.spacingOuter,
|
||||
min: config.min,
|
||||
spacing: config.spacingInner
|
||||
},
|
||||
config.colors
|
||||
);
|
||||
} catch (error) {
|
||||
throw new PrettyFormatPluginError(error.message, error.stack);
|
||||
}
|
||||
|
||||
if (typeof printed !== 'string') {
|
||||
throw new Error(
|
||||
`pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`
|
||||
);
|
||||
}
|
||||
|
||||
return printed;
|
||||
}
|
||||
|
||||
function findPlugin(plugins, val) {
|
||||
for (let p = 0; p < plugins.length; p++) {
|
||||
try {
|
||||
if (plugins[p].test(val)) {
|
||||
return plugins[p];
|
||||
}
|
||||
} catch (error) {
|
||||
throw new PrettyFormatPluginError(error.message, error.stack);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
|
||||
const plugin = findPlugin(config.plugins, val);
|
||||
|
||||
if (plugin !== null) {
|
||||
return printPlugin(plugin, val, config, indentation, depth, refs);
|
||||
}
|
||||
|
||||
const basicResult = printBasicValue(
|
||||
val,
|
||||
config.printFunctionName,
|
||||
config.escapeRegex,
|
||||
config.escapeString
|
||||
);
|
||||
|
||||
if (basicResult !== null) {
|
||||
return basicResult;
|
||||
}
|
||||
|
||||
return printComplexValue(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
hasCalledToJSON
|
||||
);
|
||||
}
|
||||
|
||||
const DEFAULT_THEME = {
|
||||
comment: 'gray',
|
||||
content: 'reset',
|
||||
prop: 'yellow',
|
||||
tag: 'cyan',
|
||||
value: 'green'
|
||||
};
|
||||
const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
|
||||
const DEFAULT_OPTIONS = {
|
||||
callToJSON: true,
|
||||
escapeRegex: false,
|
||||
escapeString: true,
|
||||
highlight: false,
|
||||
indent: 2,
|
||||
maxDepth: Infinity,
|
||||
min: false,
|
||||
plugins: [],
|
||||
printFunctionName: true,
|
||||
theme: DEFAULT_THEME
|
||||
};
|
||||
|
||||
function validateOptions(options) {
|
||||
Object.keys(options).forEach(key => {
|
||||
if (!DEFAULT_OPTIONS.hasOwnProperty(key)) {
|
||||
throw new Error(`pretty-format: Unknown option "${key}".`);
|
||||
}
|
||||
});
|
||||
|
||||
if (options.min && options.indent !== undefined && options.indent !== 0) {
|
||||
throw new Error(
|
||||
'pretty-format: Options "min" and "indent" cannot be used together.'
|
||||
);
|
||||
}
|
||||
|
||||
if (options.theme !== undefined) {
|
||||
if (options.theme === null) {
|
||||
throw new Error(`pretty-format: Option "theme" must not be null.`);
|
||||
}
|
||||
|
||||
if (typeof options.theme !== 'object') {
|
||||
throw new Error(
|
||||
`pretty-format: Option "theme" must be of type "object" but instead received "${typeof options.theme}".`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getColorsHighlight = options =>
|
||||
DEFAULT_THEME_KEYS.reduce((colors, key) => {
|
||||
const value =
|
||||
options.theme && options.theme[key] !== undefined
|
||||
? options.theme[key]
|
||||
: DEFAULT_THEME[key];
|
||||
const color = value && _ansiStyles.default[value];
|
||||
|
||||
if (
|
||||
color &&
|
||||
typeof color.close === 'string' &&
|
||||
typeof color.open === 'string'
|
||||
) {
|
||||
colors[key] = color;
|
||||
} else {
|
||||
throw new Error(
|
||||
`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`
|
||||
);
|
||||
}
|
||||
|
||||
return colors;
|
||||
}, Object.create(null));
|
||||
|
||||
const getColorsEmpty = () =>
|
||||
DEFAULT_THEME_KEYS.reduce((colors, key) => {
|
||||
colors[key] = {
|
||||
close: '',
|
||||
open: ''
|
||||
};
|
||||
return colors;
|
||||
}, Object.create(null));
|
||||
|
||||
const getPrintFunctionName = options =>
|
||||
options && options.printFunctionName !== undefined
|
||||
? options.printFunctionName
|
||||
: DEFAULT_OPTIONS.printFunctionName;
|
||||
|
||||
const getEscapeRegex = options =>
|
||||
options && options.escapeRegex !== undefined
|
||||
? options.escapeRegex
|
||||
: DEFAULT_OPTIONS.escapeRegex;
|
||||
|
||||
const getEscapeString = options =>
|
||||
options && options.escapeString !== undefined
|
||||
? options.escapeString
|
||||
: DEFAULT_OPTIONS.escapeString;
|
||||
|
||||
const getConfig = options => ({
|
||||
callToJSON:
|
||||
options && options.callToJSON !== undefined
|
||||
? options.callToJSON
|
||||
: DEFAULT_OPTIONS.callToJSON,
|
||||
colors:
|
||||
options && options.highlight
|
||||
? getColorsHighlight(options)
|
||||
: getColorsEmpty(),
|
||||
escapeRegex: getEscapeRegex(options),
|
||||
escapeString: getEscapeString(options),
|
||||
indent:
|
||||
options && options.min
|
||||
? ''
|
||||
: createIndent(
|
||||
options && options.indent !== undefined
|
||||
? options.indent
|
||||
: DEFAULT_OPTIONS.indent
|
||||
),
|
||||
maxDepth:
|
||||
options && options.maxDepth !== undefined
|
||||
? options.maxDepth
|
||||
: DEFAULT_OPTIONS.maxDepth,
|
||||
min: options && options.min !== undefined ? options.min : DEFAULT_OPTIONS.min,
|
||||
plugins:
|
||||
options && options.plugins !== undefined
|
||||
? options.plugins
|
||||
: DEFAULT_OPTIONS.plugins,
|
||||
printFunctionName: getPrintFunctionName(options),
|
||||
spacingInner: options && options.min ? ' ' : '\n',
|
||||
spacingOuter: options && options.min ? '' : '\n'
|
||||
});
|
||||
|
||||
function createIndent(indent) {
|
||||
return new Array(indent + 1).join(' ');
|
||||
}
|
||||
/**
|
||||
* Returns a presentation string of your `val` object
|
||||
* @param val any potential JavaScript object
|
||||
* @param options Custom settings
|
||||
*/
|
||||
|
||||
function prettyFormat(val, options) {
|
||||
if (options) {
|
||||
validateOptions(options);
|
||||
|
||||
if (options.plugins) {
|
||||
const plugin = findPlugin(options.plugins, val);
|
||||
|
||||
if (plugin !== null) {
|
||||
return printPlugin(plugin, val, getConfig(options), '', 0, []);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const basicResult = printBasicValue(
|
||||
val,
|
||||
getPrintFunctionName(options),
|
||||
getEscapeRegex(options),
|
||||
getEscapeString(options)
|
||||
);
|
||||
|
||||
if (basicResult !== null) {
|
||||
return basicResult;
|
||||
}
|
||||
|
||||
return printComplexValue(val, getConfig(options), '', 0, []);
|
||||
}
|
||||
|
||||
prettyFormat.plugins = {
|
||||
AsymmetricMatcher: _AsymmetricMatcher.default,
|
||||
ConvertAnsi: _ConvertAnsi.default,
|
||||
DOMCollection: _DOMCollection.default,
|
||||
DOMElement: _DOMElement.default,
|
||||
Immutable: _Immutable.default,
|
||||
ReactElement: _ReactElement.default,
|
||||
ReactTestComponent: _ReactTestComponent.default
|
||||
}; // eslint-disable-next-line no-redeclare
|
||||
|
||||
module.exports = prettyFormat;
|
11
node_modules/jest-validate/node_modules/pretty-format/build/plugins/AsymmetricMatcher.d.ts
generated
vendored
Normal file
11
node_modules/jest-validate/node_modules/pretty-format/build/plugins/AsymmetricMatcher.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
export declare const test: NewPlugin['test'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
103
node_modules/jest-validate/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js
generated
vendored
Normal file
103
node_modules/jest-validate/node_modules/pretty-format/build/plugins/AsymmetricMatcher.js
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.test = exports.serialize = void 0;
|
||||
|
||||
var _collections = require('../collections');
|
||||
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
const asymmetricMatcher =
|
||||
typeof Symbol === 'function' && Symbol.for
|
||||
? Symbol.for('jest.asymmetricMatcher')
|
||||
: 0x1357a5;
|
||||
const SPACE = ' ';
|
||||
|
||||
const serialize = (val, config, indentation, depth, refs, printer) => {
|
||||
const stringedValue = val.toString();
|
||||
|
||||
if (
|
||||
stringedValue === 'ArrayContaining' ||
|
||||
stringedValue === 'ArrayNotContaining'
|
||||
) {
|
||||
if (++depth > config.maxDepth) {
|
||||
return '[' + stringedValue + ']';
|
||||
}
|
||||
|
||||
return (
|
||||
stringedValue +
|
||||
SPACE +
|
||||
'[' +
|
||||
(0, _collections.printListItems)(
|
||||
val.sample,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
']'
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
stringedValue === 'ObjectContaining' ||
|
||||
stringedValue === 'ObjectNotContaining'
|
||||
) {
|
||||
if (++depth > config.maxDepth) {
|
||||
return '[' + stringedValue + ']';
|
||||
}
|
||||
|
||||
return (
|
||||
stringedValue +
|
||||
SPACE +
|
||||
'{' +
|
||||
(0, _collections.printObjectProperties)(
|
||||
val.sample,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
'}'
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
stringedValue === 'StringMatching' ||
|
||||
stringedValue === 'StringNotMatching'
|
||||
) {
|
||||
return (
|
||||
stringedValue +
|
||||
SPACE +
|
||||
printer(val.sample, config, indentation, depth, refs)
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
stringedValue === 'StringContaining' ||
|
||||
stringedValue === 'StringNotContaining'
|
||||
) {
|
||||
return (
|
||||
stringedValue +
|
||||
SPACE +
|
||||
printer(val.sample, config, indentation, depth, refs)
|
||||
);
|
||||
}
|
||||
|
||||
return val.toAsymmetricMatcher();
|
||||
};
|
||||
|
||||
exports.serialize = serialize;
|
||||
|
||||
const test = val => val && val.$$typeof === asymmetricMatcher;
|
||||
|
||||
exports.test = test;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
11
node_modules/jest-validate/node_modules/pretty-format/build/plugins/ConvertAnsi.d.ts
generated
vendored
Normal file
11
node_modules/jest-validate/node_modules/pretty-format/build/plugins/ConvertAnsi.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare const test: NewPlugin['test'];
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
96
node_modules/jest-validate/node_modules/pretty-format/build/plugins/ConvertAnsi.js
generated
vendored
Normal file
96
node_modules/jest-validate/node_modules/pretty-format/build/plugins/ConvertAnsi.js
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.serialize = exports.test = void 0;
|
||||
|
||||
var _ansiRegex = _interopRequireDefault(require('ansi-regex'));
|
||||
|
||||
var _ansiStyles = _interopRequireDefault(require('ansi-styles'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const toHumanReadableAnsi = text =>
|
||||
text.replace((0, _ansiRegex.default)(), match => {
|
||||
switch (match) {
|
||||
case _ansiStyles.default.red.close:
|
||||
case _ansiStyles.default.green.close:
|
||||
case _ansiStyles.default.cyan.close:
|
||||
case _ansiStyles.default.gray.close:
|
||||
case _ansiStyles.default.white.close:
|
||||
case _ansiStyles.default.yellow.close:
|
||||
case _ansiStyles.default.bgRed.close:
|
||||
case _ansiStyles.default.bgGreen.close:
|
||||
case _ansiStyles.default.bgYellow.close:
|
||||
case _ansiStyles.default.inverse.close:
|
||||
case _ansiStyles.default.dim.close:
|
||||
case _ansiStyles.default.bold.close:
|
||||
case _ansiStyles.default.reset.open:
|
||||
case _ansiStyles.default.reset.close:
|
||||
return '</>';
|
||||
|
||||
case _ansiStyles.default.red.open:
|
||||
return '<red>';
|
||||
|
||||
case _ansiStyles.default.green.open:
|
||||
return '<green>';
|
||||
|
||||
case _ansiStyles.default.cyan.open:
|
||||
return '<cyan>';
|
||||
|
||||
case _ansiStyles.default.gray.open:
|
||||
return '<gray>';
|
||||
|
||||
case _ansiStyles.default.white.open:
|
||||
return '<white>';
|
||||
|
||||
case _ansiStyles.default.yellow.open:
|
||||
return '<yellow>';
|
||||
|
||||
case _ansiStyles.default.bgRed.open:
|
||||
return '<bgRed>';
|
||||
|
||||
case _ansiStyles.default.bgGreen.open:
|
||||
return '<bgGreen>';
|
||||
|
||||
case _ansiStyles.default.bgYellow.open:
|
||||
return '<bgYellow>';
|
||||
|
||||
case _ansiStyles.default.inverse.open:
|
||||
return '<inverse>';
|
||||
|
||||
case _ansiStyles.default.dim.open:
|
||||
return '<dim>';
|
||||
|
||||
case _ansiStyles.default.bold.open:
|
||||
return '<bold>';
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
});
|
||||
|
||||
const test = val =>
|
||||
typeof val === 'string' && !!val.match((0, _ansiRegex.default)());
|
||||
|
||||
exports.test = test;
|
||||
|
||||
const serialize = (val, config, indentation, depth, refs, printer) =>
|
||||
printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
|
||||
|
||||
exports.serialize = serialize;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
11
node_modules/jest-validate/node_modules/pretty-format/build/plugins/DOMCollection.d.ts
generated
vendored
Normal file
11
node_modules/jest-validate/node_modules/pretty-format/build/plugins/DOMCollection.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare const test: NewPlugin['test'];
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
78
node_modules/jest-validate/node_modules/pretty-format/build/plugins/DOMCollection.js
generated
vendored
Normal file
78
node_modules/jest-validate/node_modules/pretty-format/build/plugins/DOMCollection.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.serialize = exports.test = void 0;
|
||||
|
||||
var _collections = require('../collections');
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const SPACE = ' ';
|
||||
const OBJECT_NAMES = ['DOMStringMap', 'NamedNodeMap'];
|
||||
const ARRAY_REGEXP = /^(HTML\w*Collection|NodeList)$/;
|
||||
|
||||
const testName = name =>
|
||||
OBJECT_NAMES.indexOf(name) !== -1 || ARRAY_REGEXP.test(name);
|
||||
|
||||
const test = val =>
|
||||
val &&
|
||||
val.constructor &&
|
||||
!!val.constructor.name &&
|
||||
testName(val.constructor.name);
|
||||
|
||||
exports.test = test;
|
||||
|
||||
const isNamedNodeMap = collection =>
|
||||
collection.constructor.name === 'NamedNodeMap';
|
||||
|
||||
const serialize = (collection, config, indentation, depth, refs, printer) => {
|
||||
const name = collection.constructor.name;
|
||||
|
||||
if (++depth > config.maxDepth) {
|
||||
return '[' + name + ']';
|
||||
}
|
||||
|
||||
return (
|
||||
(config.min ? '' : name + SPACE) +
|
||||
(OBJECT_NAMES.indexOf(name) !== -1
|
||||
? '{' +
|
||||
(0, _collections.printObjectProperties)(
|
||||
isNamedNodeMap(collection)
|
||||
? Array.from(collection).reduce((props, attribute) => {
|
||||
props[attribute.name] = attribute.value;
|
||||
return props;
|
||||
}, {})
|
||||
: {...collection},
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
'}'
|
||||
: '[' +
|
||||
(0, _collections.printListItems)(
|
||||
Array.from(collection),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
']')
|
||||
);
|
||||
};
|
||||
|
||||
exports.serialize = serialize;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
11
node_modules/jest-validate/node_modules/pretty-format/build/plugins/DOMElement.d.ts
generated
vendored
Normal file
11
node_modules/jest-validate/node_modules/pretty-format/build/plugins/DOMElement.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare const test: NewPlugin['test'];
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
104
node_modules/jest-validate/node_modules/pretty-format/build/plugins/DOMElement.js
generated
vendored
Normal file
104
node_modules/jest-validate/node_modules/pretty-format/build/plugins/DOMElement.js
generated
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.serialize = exports.test = void 0;
|
||||
|
||||
var _markup = require('./lib/markup');
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const ELEMENT_NODE = 1;
|
||||
const TEXT_NODE = 3;
|
||||
const COMMENT_NODE = 8;
|
||||
const FRAGMENT_NODE = 11;
|
||||
const ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/;
|
||||
|
||||
const testNode = (nodeType, name) =>
|
||||
(nodeType === ELEMENT_NODE && ELEMENT_REGEXP.test(name)) ||
|
||||
(nodeType === TEXT_NODE && name === 'Text') ||
|
||||
(nodeType === COMMENT_NODE && name === 'Comment') ||
|
||||
(nodeType === FRAGMENT_NODE && name === 'DocumentFragment');
|
||||
|
||||
const test = val =>
|
||||
val &&
|
||||
val.constructor &&
|
||||
val.constructor.name &&
|
||||
testNode(val.nodeType, val.constructor.name);
|
||||
|
||||
exports.test = test;
|
||||
|
||||
function nodeIsText(node) {
|
||||
return node.nodeType === TEXT_NODE;
|
||||
}
|
||||
|
||||
function nodeIsComment(node) {
|
||||
return node.nodeType === COMMENT_NODE;
|
||||
}
|
||||
|
||||
function nodeIsFragment(node) {
|
||||
return node.nodeType === FRAGMENT_NODE;
|
||||
}
|
||||
|
||||
const serialize = (node, config, indentation, depth, refs, printer) => {
|
||||
if (nodeIsText(node)) {
|
||||
return (0, _markup.printText)(node.data, config);
|
||||
}
|
||||
|
||||
if (nodeIsComment(node)) {
|
||||
return (0, _markup.printComment)(node.data, config);
|
||||
}
|
||||
|
||||
const type = nodeIsFragment(node)
|
||||
? `DocumentFragment`
|
||||
: node.tagName.toLowerCase();
|
||||
|
||||
if (++depth > config.maxDepth) {
|
||||
return (0, _markup.printElementAsLeaf)(type, config);
|
||||
}
|
||||
|
||||
return (0, _markup.printElement)(
|
||||
type,
|
||||
(0, _markup.printProps)(
|
||||
nodeIsFragment(node)
|
||||
? []
|
||||
: Array.from(node.attributes)
|
||||
.map(attr => attr.name)
|
||||
.sort(),
|
||||
nodeIsFragment(node)
|
||||
? {}
|
||||
: Array.from(node.attributes).reduce((props, attribute) => {
|
||||
props[attribute.name] = attribute.value;
|
||||
return props;
|
||||
}, {}),
|
||||
config,
|
||||
indentation + config.indent,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
),
|
||||
(0, _markup.printChildren)(
|
||||
Array.prototype.slice.call(node.childNodes || node.children),
|
||||
config,
|
||||
indentation + config.indent,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
),
|
||||
config,
|
||||
indentation
|
||||
);
|
||||
};
|
||||
|
||||
exports.serialize = serialize;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
11
node_modules/jest-validate/node_modules/pretty-format/build/plugins/Immutable.d.ts
generated
vendored
Normal file
11
node_modules/jest-validate/node_modules/pretty-format/build/plugins/Immutable.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
export declare const test: NewPlugin['test'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
247
node_modules/jest-validate/node_modules/pretty-format/build/plugins/Immutable.js
generated
vendored
Normal file
247
node_modules/jest-validate/node_modules/pretty-format/build/plugins/Immutable.js
generated
vendored
Normal file
@ -0,0 +1,247 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.test = exports.serialize = void 0;
|
||||
|
||||
var _collections = require('../collections');
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// SENTINEL constants are from https://github.com/facebook/immutable-js
|
||||
const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
|
||||
const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
|
||||
const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
|
||||
const IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
|
||||
const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
|
||||
const IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
|
||||
|
||||
const IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
|
||||
const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
|
||||
const IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
|
||||
|
||||
const getImmutableName = name => 'Immutable.' + name;
|
||||
|
||||
const printAsLeaf = name => '[' + name + ']';
|
||||
|
||||
const SPACE = ' ';
|
||||
const LAZY = '…'; // Seq is lazy if it calls a method like filter
|
||||
|
||||
const printImmutableEntries = (
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
type
|
||||
) =>
|
||||
++depth > config.maxDepth
|
||||
? printAsLeaf(getImmutableName(type))
|
||||
: getImmutableName(type) +
|
||||
SPACE +
|
||||
'{' +
|
||||
(0, _collections.printIteratorEntries)(
|
||||
val.entries(),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
'}'; // Record has an entries method because it is a collection in immutable v3.
|
||||
// Return an iterator for Immutable Record from version v3 or v4.
|
||||
|
||||
function getRecordEntries(val) {
|
||||
let i = 0;
|
||||
return {
|
||||
next() {
|
||||
if (i < val._keys.length) {
|
||||
const key = val._keys[i++];
|
||||
return {
|
||||
done: false,
|
||||
value: [key, val.get(key)]
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
done: true,
|
||||
value: undefined
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const printImmutableRecord = (
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) => {
|
||||
// _name property is defined only for an Immutable Record instance
|
||||
// which was constructed with a second optional descriptive name arg
|
||||
const name = getImmutableName(val._name || 'Record');
|
||||
return ++depth > config.maxDepth
|
||||
? printAsLeaf(name)
|
||||
: name +
|
||||
SPACE +
|
||||
'{' +
|
||||
(0, _collections.printIteratorEntries)(
|
||||
getRecordEntries(val),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
'}';
|
||||
};
|
||||
|
||||
const printImmutableSeq = (val, config, indentation, depth, refs, printer) => {
|
||||
const name = getImmutableName('Seq');
|
||||
|
||||
if (++depth > config.maxDepth) {
|
||||
return printAsLeaf(name);
|
||||
}
|
||||
|
||||
if (val[IS_KEYED_SENTINEL]) {
|
||||
return (
|
||||
name +
|
||||
SPACE +
|
||||
'{' + // from Immutable collection of entries or from ECMAScript object
|
||||
(val._iter || val._object
|
||||
? (0, _collections.printIteratorEntries)(
|
||||
val.entries(),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
)
|
||||
: LAZY) +
|
||||
'}'
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
name +
|
||||
SPACE +
|
||||
'[' +
|
||||
(val._iter || // from Immutable collection of values
|
||||
val._array || // from ECMAScript array
|
||||
val._collection || // from ECMAScript collection in immutable v4
|
||||
val._iterable // from ECMAScript collection in immutable v3
|
||||
? (0, _collections.printIteratorValues)(
|
||||
val.values(),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
)
|
||||
: LAZY) +
|
||||
']'
|
||||
);
|
||||
};
|
||||
|
||||
const printImmutableValues = (
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
type
|
||||
) =>
|
||||
++depth > config.maxDepth
|
||||
? printAsLeaf(getImmutableName(type))
|
||||
: getImmutableName(type) +
|
||||
SPACE +
|
||||
'[' +
|
||||
(0, _collections.printIteratorValues)(
|
||||
val.values(),
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
) +
|
||||
']';
|
||||
|
||||
const serialize = (val, config, indentation, depth, refs, printer) => {
|
||||
if (val[IS_MAP_SENTINEL]) {
|
||||
return printImmutableEntries(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map'
|
||||
);
|
||||
}
|
||||
|
||||
if (val[IS_LIST_SENTINEL]) {
|
||||
return printImmutableValues(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
'List'
|
||||
);
|
||||
}
|
||||
|
||||
if (val[IS_SET_SENTINEL]) {
|
||||
return printImmutableValues(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set'
|
||||
);
|
||||
}
|
||||
|
||||
if (val[IS_STACK_SENTINEL]) {
|
||||
return printImmutableValues(
|
||||
val,
|
||||
config,
|
||||
indentation,
|
||||
depth,
|
||||
refs,
|
||||
printer,
|
||||
'Stack'
|
||||
);
|
||||
}
|
||||
|
||||
if (val[IS_SEQ_SENTINEL]) {
|
||||
return printImmutableSeq(val, config, indentation, depth, refs, printer);
|
||||
} // For compatibility with immutable v3 and v4, let record be the default.
|
||||
|
||||
return printImmutableRecord(val, config, indentation, depth, refs, printer);
|
||||
}; // Explicitly comparing sentinel properties to true avoids false positive
|
||||
// when mock identity-obj-proxy returns the key as the value for any key.
|
||||
|
||||
exports.serialize = serialize;
|
||||
|
||||
const test = val =>
|
||||
val &&
|
||||
(val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
|
||||
|
||||
exports.test = test;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
11
node_modules/jest-validate/node_modules/pretty-format/build/plugins/ReactElement.d.ts
generated
vendored
Normal file
11
node_modules/jest-validate/node_modules/pretty-format/build/plugins/ReactElement.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
export declare const test: NewPlugin['test'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
166
node_modules/jest-validate/node_modules/pretty-format/build/plugins/ReactElement.js
generated
vendored
Normal file
166
node_modules/jest-validate/node_modules/pretty-format/build/plugins/ReactElement.js
generated
vendored
Normal file
@ -0,0 +1,166 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.test = exports.serialize = void 0;
|
||||
|
||||
var ReactIs = _interopRequireWildcard(require('react-is'));
|
||||
|
||||
var _markup = require('./lib/markup');
|
||||
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// Given element.props.children, or subtree during recursive traversal,
|
||||
// return flattened array of children.
|
||||
const getChildren = (arg, children = []) => {
|
||||
if (Array.isArray(arg)) {
|
||||
arg.forEach(item => {
|
||||
getChildren(item, children);
|
||||
});
|
||||
} else if (arg != null && arg !== false) {
|
||||
children.push(arg);
|
||||
}
|
||||
|
||||
return children;
|
||||
};
|
||||
|
||||
const getType = element => {
|
||||
const type = element.type;
|
||||
|
||||
if (typeof type === 'string') {
|
||||
return type;
|
||||
}
|
||||
|
||||
if (typeof type === 'function') {
|
||||
return type.displayName || type.name || 'Unknown';
|
||||
}
|
||||
|
||||
if (ReactIs.isFragment(element)) {
|
||||
return 'React.Fragment';
|
||||
}
|
||||
|
||||
if (ReactIs.isSuspense(element)) {
|
||||
return 'React.Suspense';
|
||||
}
|
||||
|
||||
if (typeof type === 'object' && type !== null) {
|
||||
if (ReactIs.isContextProvider(element)) {
|
||||
return 'Context.Provider';
|
||||
}
|
||||
|
||||
if (ReactIs.isContextConsumer(element)) {
|
||||
return 'Context.Consumer';
|
||||
}
|
||||
|
||||
if (ReactIs.isForwardRef(element)) {
|
||||
if (type.displayName) {
|
||||
return type.displayName;
|
||||
}
|
||||
|
||||
const functionName = type.render.displayName || type.render.name || '';
|
||||
return functionName !== ''
|
||||
? 'ForwardRef(' + functionName + ')'
|
||||
: 'ForwardRef';
|
||||
}
|
||||
|
||||
if (ReactIs.isMemo(element)) {
|
||||
const functionName =
|
||||
type.displayName || type.type.displayName || type.type.name || '';
|
||||
return functionName !== '' ? 'Memo(' + functionName + ')' : 'Memo';
|
||||
}
|
||||
}
|
||||
|
||||
return 'UNDEFINED';
|
||||
};
|
||||
|
||||
const getPropKeys = element => {
|
||||
const {props} = element;
|
||||
return Object.keys(props)
|
||||
.filter(key => key !== 'children' && props[key] !== undefined)
|
||||
.sort();
|
||||
};
|
||||
|
||||
const serialize = (element, config, indentation, depth, refs, printer) =>
|
||||
++depth > config.maxDepth
|
||||
? (0, _markup.printElementAsLeaf)(getType(element), config)
|
||||
: (0, _markup.printElement)(
|
||||
getType(element),
|
||||
(0, _markup.printProps)(
|
||||
getPropKeys(element),
|
||||
element.props,
|
||||
config,
|
||||
indentation + config.indent,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
),
|
||||
(0, _markup.printChildren)(
|
||||
getChildren(element.props.children),
|
||||
config,
|
||||
indentation + config.indent,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
),
|
||||
config,
|
||||
indentation
|
||||
);
|
||||
|
||||
exports.serialize = serialize;
|
||||
|
||||
const test = val => val && ReactIs.isElement(val);
|
||||
|
||||
exports.test = test;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
18
node_modules/jest-validate/node_modules/pretty-format/build/plugins/ReactTestComponent.d.ts
generated
vendored
Normal file
18
node_modules/jest-validate/node_modules/pretty-format/build/plugins/ReactTestComponent.d.ts
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { NewPlugin } from '../types';
|
||||
export declare type ReactTestObject = {
|
||||
$$typeof: symbol;
|
||||
type: string;
|
||||
props?: Record<string, unknown>;
|
||||
children?: null | Array<ReactTestChild>;
|
||||
};
|
||||
declare type ReactTestChild = ReactTestObject | string | number;
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
export declare const test: NewPlugin['test'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
65
node_modules/jest-validate/node_modules/pretty-format/build/plugins/ReactTestComponent.js
generated
vendored
Normal file
65
node_modules/jest-validate/node_modules/pretty-format/build/plugins/ReactTestComponent.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.test = exports.serialize = void 0;
|
||||
|
||||
var _markup = require('./lib/markup');
|
||||
|
||||
var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
||||
const testSymbol =
|
||||
typeof Symbol === 'function' && Symbol.for
|
||||
? Symbol.for('react.test.json')
|
||||
: 0xea71357;
|
||||
|
||||
const getPropKeys = object => {
|
||||
const {props} = object;
|
||||
return props
|
||||
? Object.keys(props)
|
||||
.filter(key => props[key] !== undefined)
|
||||
.sort()
|
||||
: [];
|
||||
};
|
||||
|
||||
const serialize = (object, config, indentation, depth, refs, printer) =>
|
||||
++depth > config.maxDepth
|
||||
? (0, _markup.printElementAsLeaf)(object.type, config)
|
||||
: (0, _markup.printElement)(
|
||||
object.type,
|
||||
object.props
|
||||
? (0, _markup.printProps)(
|
||||
getPropKeys(object),
|
||||
object.props,
|
||||
config,
|
||||
indentation + config.indent,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
)
|
||||
: '',
|
||||
object.children
|
||||
? (0, _markup.printChildren)(
|
||||
object.children,
|
||||
config,
|
||||
indentation + config.indent,
|
||||
depth,
|
||||
refs,
|
||||
printer
|
||||
)
|
||||
: '',
|
||||
config,
|
||||
indentation
|
||||
);
|
||||
|
||||
exports.serialize = serialize;
|
||||
|
||||
const test = val => val && val.$$typeof === testSymbol;
|
||||
|
||||
exports.test = test;
|
||||
const plugin = {
|
||||
serialize,
|
||||
test
|
||||
};
|
||||
var _default = plugin;
|
||||
exports.default = _default;
|
7
node_modules/jest-validate/node_modules/pretty-format/build/plugins/lib/escapeHTML.d.ts
generated
vendored
Normal file
7
node_modules/jest-validate/node_modules/pretty-format/build/plugins/lib/escapeHTML.d.ts
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export default function escapeHTML(str: string): string;
|
16
node_modules/jest-validate/node_modules/pretty-format/build/plugins/lib/escapeHTML.js
generated
vendored
Normal file
16
node_modules/jest-validate/node_modules/pretty-format/build/plugins/lib/escapeHTML.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = escapeHTML;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
function escapeHTML(str) {
|
||||
return str.replace(/</g, '<').replace(/>/g, '>');
|
||||
}
|
13
node_modules/jest-validate/node_modules/pretty-format/build/plugins/lib/markup.d.ts
generated
vendored
Normal file
13
node_modules/jest-validate/node_modules/pretty-format/build/plugins/lib/markup.d.ts
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { Config, Printer, Refs } from '../../types';
|
||||
export declare const printProps: (keys: string[], props: Record<string, unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
||||
export declare const printChildren: (children: any[], config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
||||
export declare const printText: (text: string, config: Config) => string;
|
||||
export declare const printComment: (comment: string, config: Config) => string;
|
||||
export declare const printElement: (type: string, printedProps: string, printedChildren: string, config: Config, indentation: string) => string;
|
||||
export declare const printElementAsLeaf: (type: string, config: Config) => string;
|
147
node_modules/jest-validate/node_modules/pretty-format/build/plugins/lib/markup.js
generated
vendored
Normal file
147
node_modules/jest-validate/node_modules/pretty-format/build/plugins/lib/markup.js
generated
vendored
Normal file
@ -0,0 +1,147 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.printElementAsLeaf = exports.printElement = exports.printComment = exports.printText = exports.printChildren = exports.printProps = void 0;
|
||||
|
||||
var _escapeHTML = _interopRequireDefault(require('./escapeHTML'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
// Return empty string if keys is empty.
|
||||
const printProps = (keys, props, config, indentation, depth, refs, printer) => {
|
||||
const indentationNext = indentation + config.indent;
|
||||
const colors = config.colors;
|
||||
return keys
|
||||
.map(key => {
|
||||
const value = props[key];
|
||||
let printed = printer(value, config, indentationNext, depth, refs);
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
if (printed.indexOf('\n') !== -1) {
|
||||
printed =
|
||||
config.spacingOuter +
|
||||
indentationNext +
|
||||
printed +
|
||||
config.spacingOuter +
|
||||
indentation;
|
||||
}
|
||||
|
||||
printed = '{' + printed + '}';
|
||||
}
|
||||
|
||||
return (
|
||||
config.spacingInner +
|
||||
indentation +
|
||||
colors.prop.open +
|
||||
key +
|
||||
colors.prop.close +
|
||||
'=' +
|
||||
colors.value.open +
|
||||
printed +
|
||||
colors.value.close
|
||||
);
|
||||
})
|
||||
.join('');
|
||||
}; // Return empty string if children is empty.
|
||||
|
||||
exports.printProps = printProps;
|
||||
|
||||
const printChildren = (children, config, indentation, depth, refs, printer) =>
|
||||
children
|
||||
.map(
|
||||
child =>
|
||||
config.spacingOuter +
|
||||
indentation +
|
||||
(typeof child === 'string'
|
||||
? printText(child, config)
|
||||
: printer(child, config, indentation, depth, refs))
|
||||
)
|
||||
.join('');
|
||||
|
||||
exports.printChildren = printChildren;
|
||||
|
||||
const printText = (text, config) => {
|
||||
const contentColor = config.colors.content;
|
||||
return (
|
||||
contentColor.open + (0, _escapeHTML.default)(text) + contentColor.close
|
||||
);
|
||||
};
|
||||
|
||||
exports.printText = printText;
|
||||
|
||||
const printComment = (comment, config) => {
|
||||
const commentColor = config.colors.comment;
|
||||
return (
|
||||
commentColor.open +
|
||||
'<!--' +
|
||||
(0, _escapeHTML.default)(comment) +
|
||||
'-->' +
|
||||
commentColor.close
|
||||
);
|
||||
}; // Separate the functions to format props, children, and element,
|
||||
// so a plugin could override a particular function, if needed.
|
||||
// Too bad, so sad: the traditional (but unnecessary) space
|
||||
// in a self-closing tagColor requires a second test of printedProps.
|
||||
|
||||
exports.printComment = printComment;
|
||||
|
||||
const printElement = (
|
||||
type,
|
||||
printedProps,
|
||||
printedChildren,
|
||||
config,
|
||||
indentation
|
||||
) => {
|
||||
const tagColor = config.colors.tag;
|
||||
return (
|
||||
tagColor.open +
|
||||
'<' +
|
||||
type +
|
||||
(printedProps &&
|
||||
tagColor.close +
|
||||
printedProps +
|
||||
config.spacingOuter +
|
||||
indentation +
|
||||
tagColor.open) +
|
||||
(printedChildren
|
||||
? '>' +
|
||||
tagColor.close +
|
||||
printedChildren +
|
||||
config.spacingOuter +
|
||||
indentation +
|
||||
tagColor.open +
|
||||
'</' +
|
||||
type
|
||||
: (printedProps && !config.min ? '' : ' ') + '/') +
|
||||
'>' +
|
||||
tagColor.close
|
||||
);
|
||||
};
|
||||
|
||||
exports.printElement = printElement;
|
||||
|
||||
const printElementAsLeaf = (type, config) => {
|
||||
const tagColor = config.colors.tag;
|
||||
return (
|
||||
tagColor.open +
|
||||
'<' +
|
||||
type +
|
||||
tagColor.close +
|
||||
' …' +
|
||||
tagColor.open +
|
||||
' />' +
|
||||
tagColor.close
|
||||
);
|
||||
};
|
||||
|
||||
exports.printElementAsLeaf = printElementAsLeaf;
|
32
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/collections.d.ts
generated
vendored
Normal file
32
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/collections.d.ts
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
import { Config, Printer, Refs } from './types';
|
||||
/**
|
||||
* Return entries (for example, of a map)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, braces)
|
||||
*/
|
||||
export declare function printIteratorEntries(iterator: Iterator<[unknown, unknown]>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer, separator?: string): string;
|
||||
/**
|
||||
* Return values (for example, of a set)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (braces or brackets)
|
||||
*/
|
||||
export declare function printIteratorValues(iterator: Iterator<unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string;
|
||||
/**
|
||||
* Return items (for example, of an array)
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, brackets)
|
||||
**/
|
||||
export declare function printListItems(list: ArrayLike<unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string;
|
||||
/**
|
||||
* Return properties of an object
|
||||
* with spacing, indentation, and comma
|
||||
* without surrounding punctuation (for example, braces)
|
||||
*/
|
||||
export declare function printObjectProperties(val: Record<string, unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer): string;
|
37
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/index.d.ts
generated
vendored
Normal file
37
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import * as PrettyFormat from './types';
|
||||
/**
|
||||
* Returns a presentation string of your `val` object
|
||||
* @param val any potential JavaScript object
|
||||
* @param options Custom settings
|
||||
*/
|
||||
declare function prettyFormat(val: unknown, options?: PrettyFormat.OptionsReceived): string;
|
||||
declare namespace prettyFormat {
|
||||
var plugins: {
|
||||
AsymmetricMatcher: PrettyFormat.NewPlugin;
|
||||
ConvertAnsi: PrettyFormat.NewPlugin;
|
||||
DOMCollection: PrettyFormat.NewPlugin;
|
||||
DOMElement: PrettyFormat.NewPlugin;
|
||||
Immutable: PrettyFormat.NewPlugin;
|
||||
ReactElement: PrettyFormat.NewPlugin;
|
||||
ReactTestComponent: PrettyFormat.NewPlugin;
|
||||
};
|
||||
}
|
||||
declare namespace prettyFormat {
|
||||
type Colors = PrettyFormat.Colors;
|
||||
type Config = PrettyFormat.Config;
|
||||
type Options = PrettyFormat.Options;
|
||||
type OptionsReceived = PrettyFormat.OptionsReceived;
|
||||
type OldPlugin = PrettyFormat.OldPlugin;
|
||||
type NewPlugin = PrettyFormat.NewPlugin;
|
||||
type Plugin = PrettyFormat.Plugin;
|
||||
type Plugins = PrettyFormat.Plugins;
|
||||
type Refs = PrettyFormat.Refs;
|
||||
type Theme = PrettyFormat.Theme;
|
||||
}
|
||||
export = prettyFormat;
|
11
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/AsymmetricMatcher.d.ts
generated
vendored
Normal file
11
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/AsymmetricMatcher.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { NewPlugin } from '../types';
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
export declare const test: NewPlugin['test'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
11
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/ConvertAnsi.d.ts
generated
vendored
Normal file
11
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/ConvertAnsi.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { NewPlugin } from '../types';
|
||||
export declare const test: NewPlugin['test'];
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
11
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/DOMCollection.d.ts
generated
vendored
Normal file
11
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/DOMCollection.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { NewPlugin } from '../types';
|
||||
export declare const test: NewPlugin['test'];
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
11
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/DOMElement.d.ts
generated
vendored
Normal file
11
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/DOMElement.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { NewPlugin } from '../types';
|
||||
export declare const test: NewPlugin['test'];
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
11
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/Immutable.d.ts
generated
vendored
Normal file
11
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/Immutable.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { NewPlugin } from '../types';
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
export declare const test: NewPlugin['test'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
11
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/ReactElement.d.ts
generated
vendored
Normal file
11
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/ReactElement.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { NewPlugin } from '../types';
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
export declare const test: NewPlugin['test'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
18
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/ReactTestComponent.d.ts
generated
vendored
Normal file
18
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/ReactTestComponent.d.ts
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { NewPlugin } from '../types';
|
||||
export declare type ReactTestObject = {
|
||||
$$typeof: symbol;
|
||||
type: string;
|
||||
props?: Record<string, unknown>;
|
||||
children?: null | Array<ReactTestChild>;
|
||||
};
|
||||
declare type ReactTestChild = ReactTestObject | string | number;
|
||||
export declare const serialize: NewPlugin['serialize'];
|
||||
export declare const test: NewPlugin['test'];
|
||||
declare const plugin: NewPlugin;
|
||||
export default plugin;
|
7
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/lib/escapeHTML.d.ts
generated
vendored
Normal file
7
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/lib/escapeHTML.d.ts
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export default function escapeHTML(str: string): string;
|
13
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/lib/markup.d.ts
generated
vendored
Normal file
13
node_modules/jest-validate/node_modules/pretty-format/build/ts3.4/plugins/lib/markup.d.ts
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { Config, Printer, Refs } from '../../types';
|
||||
export declare const printProps: (keys: string[], props: Record<string, unknown>, config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
||||
export declare const printChildren: (children: any[], config: Config, indentation: string, depth: number, refs: Refs, printer: Printer) => string;
|
||||
export declare const printText: (text: string, config: Config) => string;
|
||||
export declare const printComment: (comment: string, config: Config) => string;
|
||||
export declare const printElement: (type: string, printedProps: string, printedChildren: string, config: Config, indentation: string) => string;
|
||||
export declare const printElementAsLeaf: (type: string, config: Config) => string;
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user