mirror of
https://github.com/github/codeql-action.git
synced 2025-12-24 08:10:06 +08:00
Update checked-in dependencies
This commit is contained in:
1124
node_modules/.package-lock.json
generated
vendored
1124
node_modules/.package-lock.json
generated
vendored
File diff suppressed because it is too large
Load Diff
2
node_modules/@eslint/js/package.json
generated
vendored
2
node_modules/@eslint/js/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@eslint/js",
|
||||
"version": "9.9.1",
|
||||
"version": "9.10.0",
|
||||
"description": "ESLint JavaScript language implementation",
|
||||
"main": "./src/index.js",
|
||||
"scripts": {},
|
||||
|
||||
130
node_modules/@humanwhocodes/config-array/api.js
generated
vendored
130
node_modules/@humanwhocodes/config-array/api.js
generated
vendored
@@ -154,8 +154,82 @@ const MINIMATCH_OPTIONS = {
|
||||
|
||||
const CONFIG_TYPES = new Set(['array', 'function']);
|
||||
|
||||
/**
|
||||
* Fields that are considered metadata and not part of the config object.
|
||||
*/
|
||||
const META_FIELDS = new Set(['name']);
|
||||
|
||||
const FILES_AND_IGNORES_SCHEMA = new objectSchema.ObjectSchema(filesAndIgnoresSchema);
|
||||
|
||||
/**
|
||||
* Wrapper error for config validation errors that adds a name to the front of the
|
||||
* error message.
|
||||
*/
|
||||
class ConfigError extends Error {
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {string} name The config object name causing the error.
|
||||
* @param {number} index The index of the config object in the array.
|
||||
* @param {Error} source The source error.
|
||||
*/
|
||||
constructor(name, index, { cause, message }) {
|
||||
|
||||
|
||||
const finalMessage = message || cause.message;
|
||||
|
||||
super(`Config ${name}: ${finalMessage}`, { cause });
|
||||
|
||||
// copy over custom properties that aren't represented
|
||||
if (cause) {
|
||||
for (const key of Object.keys(cause)) {
|
||||
if (!(key in this)) {
|
||||
this[key] = cause[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the error.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
this.name = 'ConfigError';
|
||||
|
||||
/**
|
||||
* The index of the config object in the array.
|
||||
* @type {number}
|
||||
* @readonly
|
||||
*/
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of a config object.
|
||||
* @param {object} config The config object to get the name of.
|
||||
* @returns {string} The name of the config object.
|
||||
*/
|
||||
function getConfigName(config) {
|
||||
if (config && typeof config.name === 'string' && config.name) {
|
||||
return `"${config.name}"`;
|
||||
}
|
||||
|
||||
return '(unnamed)';
|
||||
}
|
||||
|
||||
/**
|
||||
* Rethrows a config error with additional information about the config object.
|
||||
* @param {object} config The config object to get the name of.
|
||||
* @param {number} index The index of the config object in the array.
|
||||
* @param {Error} error The error to rethrow.
|
||||
* @throws {ConfigError} When the error is rethrown for a config.
|
||||
*/
|
||||
function rethrowConfigError(config, index, error) {
|
||||
const configName = getConfigName(config);
|
||||
throw new ConfigError(configName, index, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorthand for checking if a value is a string.
|
||||
* @param {any} value The value to check.
|
||||
@@ -166,23 +240,43 @@ function isString(value) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the files and ignores keys of a config object are valid as per base schema.
|
||||
* @param {object} config The config object to check.
|
||||
* Creates a function that asserts that the config is valid
|
||||
* during normalization. This checks that the config is not nullish
|
||||
* and that files and ignores keys of a config object are valid as per base schema.
|
||||
* @param {Object} config The config object to check.
|
||||
* @param {number} index The index of the config object in the array.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the files and ignores keys of a config object are not valid.
|
||||
* @throws {ConfigError} If the files and ignores keys of a config object are not valid.
|
||||
*/
|
||||
function assertValidFilesAndIgnores(config) {
|
||||
if (!config || typeof config !== 'object') {
|
||||
return;
|
||||
function assertValidBaseConfig(config, index) {
|
||||
|
||||
if (config === null) {
|
||||
throw new ConfigError(getConfigName(config), index, { message: 'Unexpected null config.' });
|
||||
}
|
||||
|
||||
if (config === undefined) {
|
||||
throw new ConfigError(getConfigName(config), index, { message: 'Unexpected undefined config.' });
|
||||
}
|
||||
|
||||
if (typeof config !== 'object') {
|
||||
throw new ConfigError(getConfigName(config), index, { message: 'Unexpected non-object config.' });
|
||||
}
|
||||
|
||||
const validateConfig = { };
|
||||
|
||||
if ('files' in config) {
|
||||
validateConfig.files = config.files;
|
||||
}
|
||||
|
||||
if ('ignores' in config) {
|
||||
validateConfig.ignores = config.ignores;
|
||||
}
|
||||
FILES_AND_IGNORES_SCHEMA.validate(validateConfig);
|
||||
|
||||
try {
|
||||
FILES_AND_IGNORES_SCHEMA.validate(validateConfig);
|
||||
} catch (validationError) {
|
||||
rethrowConfigError(config, index, { cause: validationError });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -377,7 +471,7 @@ function pathMatchesIgnores(filePath, basePath, config) {
|
||||
*/
|
||||
const relativeFilePath = path.relative(basePath, filePath);
|
||||
|
||||
return Object.keys(config).length > 1 &&
|
||||
return Object.keys(config).filter(key => !META_FIELDS.has(key)).length > 1 &&
|
||||
!shouldIgnorePath(config.ignores, filePath, relativeFilePath);
|
||||
}
|
||||
|
||||
@@ -511,7 +605,7 @@ class ConfigArray extends Array {
|
||||
/**
|
||||
* Tracks if the array has been normalized.
|
||||
* @property isNormalized
|
||||
* @type boolean
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
this[ConfigArraySymbol.isNormalized] = normalized;
|
||||
@@ -530,7 +624,7 @@ class ConfigArray extends Array {
|
||||
* The path of the config file that this array was loaded from.
|
||||
* This is used to calculate filename matches.
|
||||
* @property basePath
|
||||
* @type string
|
||||
* @type {string}
|
||||
*/
|
||||
this.basePath = basePath;
|
||||
|
||||
@@ -539,14 +633,14 @@ class ConfigArray extends Array {
|
||||
/**
|
||||
* The supported config types.
|
||||
* @property configTypes
|
||||
* @type Array<string>
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
this.extraConfigTypes = Object.freeze([...extraConfigTypes]);
|
||||
|
||||
/**
|
||||
* A cache to store calculated configs for faster repeat lookup.
|
||||
* @property configCache
|
||||
* @type Map
|
||||
* @type {Map<string, Object>}
|
||||
* @private
|
||||
*/
|
||||
this[ConfigArraySymbol.configCache] = new Map();
|
||||
@@ -645,7 +739,7 @@ class ConfigArray extends Array {
|
||||
* In this case, it acts list a globally ignored pattern. If there
|
||||
* are additional keys, then ignores act like exclusions.
|
||||
*/
|
||||
if (config.ignores && Object.keys(config).length === 1) {
|
||||
if (config.ignores && Object.keys(config).filter(key => !META_FIELDS.has(key)).length === 1) {
|
||||
result.push(...config.ignores);
|
||||
}
|
||||
}
|
||||
@@ -677,7 +771,7 @@ class ConfigArray extends Array {
|
||||
const normalizedConfigs = await normalize(this, context, this.extraConfigTypes);
|
||||
this.length = 0;
|
||||
this.push(...normalizedConfigs.map(this[ConfigArraySymbol.preprocessConfig].bind(this)));
|
||||
this.forEach(assertValidFilesAndIgnores);
|
||||
this.forEach(assertValidBaseConfig);
|
||||
this[ConfigArraySymbol.isNormalized] = true;
|
||||
|
||||
// prevent further changes
|
||||
@@ -699,7 +793,7 @@ class ConfigArray extends Array {
|
||||
const normalizedConfigs = normalizeSync(this, context, this.extraConfigTypes);
|
||||
this.length = 0;
|
||||
this.push(...normalizedConfigs.map(this[ConfigArraySymbol.preprocessConfig].bind(this)));
|
||||
this.forEach(assertValidFilesAndIgnores);
|
||||
this.forEach(assertValidBaseConfig);
|
||||
this[ConfigArraySymbol.isNormalized] = true;
|
||||
|
||||
// prevent further changes
|
||||
@@ -932,7 +1026,11 @@ class ConfigArray extends Array {
|
||||
// otherwise construct the config
|
||||
|
||||
finalConfig = matchingConfigIndices.reduce((result, index) => {
|
||||
return this[ConfigArraySymbol.schema].merge(result, this[index]);
|
||||
try {
|
||||
return this[ConfigArraySymbol.schema].merge(result, this[index]);
|
||||
} catch (validationError) {
|
||||
rethrowConfigError(this[index], index, { cause: validationError});
|
||||
}
|
||||
}, {}, this);
|
||||
|
||||
finalConfig = this[ConfigArraySymbol.finalizeConfig](finalConfig);
|
||||
|
||||
8
node_modules/@humanwhocodes/config-array/package.json
generated
vendored
8
node_modules/@humanwhocodes/config-array/package.json
generated
vendored
@@ -1,11 +1,13 @@
|
||||
{
|
||||
"name": "@humanwhocodes/config-array",
|
||||
"version": "0.11.14",
|
||||
"version": "0.13.0",
|
||||
"description": "Glob-based configuration matching.",
|
||||
"author": "Nicholas C. Zakas",
|
||||
"main": "api.js",
|
||||
"files": [
|
||||
"api.js"
|
||||
"api.js",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -42,7 +44,7 @@
|
||||
"node": ">=10.10.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@humanwhocodes/object-schema": "^2.0.2",
|
||||
"@humanwhocodes/object-schema": "^2.0.3",
|
||||
"debug": "^4.3.1",
|
||||
"minimatch": "^3.0.5"
|
||||
},
|
||||
|
||||
29
node_modules/@humanwhocodes/object-schema/.eslintrc.js
generated
vendored
29
node_modules/@humanwhocodes/object-schema/.eslintrc.js
generated
vendored
@@ -1,29 +0,0 @@
|
||||
module.exports = {
|
||||
"env": {
|
||||
"commonjs": true,
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018
|
||||
},
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
4
|
||||
],
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"unix"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"double"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
]
|
||||
}
|
||||
};
|
||||
27
node_modules/@humanwhocodes/object-schema/.github/workflows/nodejs-test.yml
generated
vendored
27
node_modules/@humanwhocodes/object-schema/.github/workflows/nodejs-test.yml
generated
vendored
@@ -1,27 +0,0 @@
|
||||
name: Node CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, macOS-latest, ubuntu-latest]
|
||||
node: [18.x, 19.x, 20.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: npm install, build, and test
|
||||
run: |
|
||||
npm install
|
||||
npm run build --if-present
|
||||
npm test
|
||||
env:
|
||||
CI: true
|
||||
39
node_modules/@humanwhocodes/object-schema/.github/workflows/release-please.yml
generated
vendored
39
node_modules/@humanwhocodes/object-schema/.github/workflows/release-please.yml
generated
vendored
@@ -1,39 +0,0 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
name: release-please
|
||||
jobs:
|
||||
release-please:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: GoogleCloudPlatform/release-please-action@v3
|
||||
id: release
|
||||
with:
|
||||
release-type: node
|
||||
package-name: object-schema
|
||||
# The logic below handles the npm publication:
|
||||
- uses: actions/checkout@v4
|
||||
# these if statements ensure that a publication only occurs when
|
||||
# a new release is created:
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 12
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
- run: npm ci
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
- run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
|
||||
# Tweets out release announcement
|
||||
- run: 'npx @humanwhocodes/tweet "Object Schema v${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }} has been released!\n\n${{ github.event.release.html_url }}"'
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
env:
|
||||
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
|
||||
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
|
||||
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
|
||||
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
|
||||
7
node_modules/@humanwhocodes/object-schema/CHANGELOG.md
generated
vendored
7
node_modules/@humanwhocodes/object-schema/CHANGELOG.md
generated
vendored
@@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## [2.0.3](https://github.com/humanwhocodes/object-schema/compare/v2.0.2...v2.0.3) (2024-04-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Ensure test files are not including in package ([6eeb32c](https://github.com/humanwhocodes/object-schema/commit/6eeb32cc76a3e37d76b2990bd603d72061c816e0)), closes [#19](https://github.com/humanwhocodes/object-schema/issues/19)
|
||||
|
||||
## [2.0.2](https://github.com/humanwhocodes/object-schema/compare/v2.0.1...v2.0.2) (2024-01-10)
|
||||
|
||||
|
||||
|
||||
7
node_modules/@humanwhocodes/object-schema/package.json
generated
vendored
7
node_modules/@humanwhocodes/object-schema/package.json
generated
vendored
@@ -1,8 +1,13 @@
|
||||
{
|
||||
"name": "@humanwhocodes/object-schema",
|
||||
"version": "2.0.2",
|
||||
"version": "2.0.3",
|
||||
"description": "An object schema merger/validator",
|
||||
"main": "src/index.js",
|
||||
"files": [
|
||||
"src",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
|
||||
66
node_modules/@humanwhocodes/object-schema/tests/merge-strategy.js
generated
vendored
66
node_modules/@humanwhocodes/object-schema/tests/merge-strategy.js
generated
vendored
@@ -1,66 +0,0 @@
|
||||
/**
|
||||
* @filedescription Merge Strategy Tests
|
||||
*/
|
||||
/* global it, describe, beforeEach */
|
||||
|
||||
"use strict";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const assert = require("chai").assert;
|
||||
const { MergeStrategy } = require("../src/");
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
describe("MergeStrategy", () => {
|
||||
|
||||
|
||||
describe("overwrite()", () => {
|
||||
|
||||
it("should overwrite the first value with the second when the second is defined", () => {
|
||||
const result = MergeStrategy.overwrite(1, 2);
|
||||
assert.strictEqual(result, 2);
|
||||
});
|
||||
|
||||
it("should overwrite the first value with the second when the second is undefined", () => {
|
||||
const result = MergeStrategy.overwrite(1, undefined);
|
||||
assert.strictEqual(result, undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("replace()", () => {
|
||||
|
||||
it("should overwrite the first value with the second when the second is defined", () => {
|
||||
const result = MergeStrategy.replace(1, 2);
|
||||
assert.strictEqual(result, 2);
|
||||
});
|
||||
|
||||
it("should return the first value when the second is undefined", () => {
|
||||
const result = MergeStrategy.replace(1, undefined);
|
||||
assert.strictEqual(result, 1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("assign()", () => {
|
||||
|
||||
it("should merge properties from two objects when called", () => {
|
||||
|
||||
const object1 = { foo: 1, bar: 3 };
|
||||
const object2 = { foo: 2 };
|
||||
|
||||
const result = MergeStrategy.assign(object1, object2);
|
||||
assert.deepStrictEqual(result, {
|
||||
foo: 2,
|
||||
bar: 3
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
659
node_modules/@humanwhocodes/object-schema/tests/object-schema.js
generated
vendored
659
node_modules/@humanwhocodes/object-schema/tests/object-schema.js
generated
vendored
@@ -1,659 +0,0 @@
|
||||
/**
|
||||
* @filedescription Object Schema Tests
|
||||
*/
|
||||
/* global it, describe, beforeEach */
|
||||
|
||||
"use strict";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const assert = require("chai").assert;
|
||||
const { ObjectSchema } = require("../src/");
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
describe("ObjectSchema", () => {
|
||||
|
||||
let schema;
|
||||
|
||||
describe("new ObjectSchema()", () => {
|
||||
|
||||
it("should add a new key when a strategy is passed", () => {
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {},
|
||||
validate() {}
|
||||
}
|
||||
});
|
||||
|
||||
assert.isTrue(schema.hasKey("foo"));
|
||||
});
|
||||
|
||||
it("should throw an error when a strategy is missing a merge() method", () => {
|
||||
assert.throws(() => {
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
validate() { }
|
||||
}
|
||||
});
|
||||
}, /Definition for key "foo" must have a merge property/);
|
||||
});
|
||||
|
||||
it("should throw an error when a strategy is missing a merge() method", () => {
|
||||
assert.throws(() => {
|
||||
schema = new ObjectSchema();
|
||||
}, /Schema definitions missing/);
|
||||
});
|
||||
|
||||
it("should throw an error when a strategy is missing a validate() method", () => {
|
||||
assert.throws(() => {
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() { },
|
||||
}
|
||||
});
|
||||
}, /Definition for key "foo" must have a validate\(\) method/);
|
||||
});
|
||||
|
||||
it("should throw an error when merge is an invalid string", () => {
|
||||
assert.throws(() => {
|
||||
new ObjectSchema({
|
||||
foo: {
|
||||
merge: "bar",
|
||||
validate() { }
|
||||
}
|
||||
});
|
||||
}, /key "foo" missing valid merge strategy/);
|
||||
});
|
||||
|
||||
it("should throw an error when validate is an invalid string", () => {
|
||||
assert.throws(() => {
|
||||
new ObjectSchema({
|
||||
foo: {
|
||||
merge: "assign",
|
||||
validate: "s"
|
||||
}
|
||||
});
|
||||
}, /key "foo" missing valid validation strategy/);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe("merge()", () => {
|
||||
|
||||
it("should throw an error when an unexpected key is found", () => {
|
||||
let schema = new ObjectSchema({});
|
||||
|
||||
assert.throws(() => {
|
||||
schema.merge({ foo: true }, { foo: true });
|
||||
}, /Unexpected key "foo"/);
|
||||
});
|
||||
|
||||
it("should throw an error when merge() throws an error", () => {
|
||||
let schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
throw new Error("Boom!");
|
||||
},
|
||||
validate() {}
|
||||
}
|
||||
});
|
||||
|
||||
assert.throws(() => {
|
||||
schema.merge({ foo: true }, { foo: true });
|
||||
}, /Key "foo": Boom!/);
|
||||
|
||||
});
|
||||
|
||||
it("should throw an error when merge() throws an error with a readonly message", () => {
|
||||
let schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
throw {
|
||||
get message() {
|
||||
return "Boom!";
|
||||
}
|
||||
};
|
||||
},
|
||||
validate() {}
|
||||
}
|
||||
});
|
||||
|
||||
assert.throws(() => {
|
||||
schema.merge({ foo: true }, { foo: true });
|
||||
}, /Key "foo": Boom!/);
|
||||
|
||||
});
|
||||
|
||||
it("should throw an error with custom properties when merge() throws an error with custom properties", () => {
|
||||
let schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
throw {
|
||||
get message() {
|
||||
return "Boom!";
|
||||
},
|
||||
booya: true
|
||||
};
|
||||
},
|
||||
validate() {}
|
||||
}
|
||||
});
|
||||
|
||||
let errorThrown = false;
|
||||
|
||||
try {
|
||||
schema.merge({ foo: true }, { foo: true });
|
||||
} catch (ex) {
|
||||
errorThrown = true;
|
||||
assert.isTrue(ex.booya);
|
||||
}
|
||||
|
||||
assert.isTrue(errorThrown);
|
||||
|
||||
});
|
||||
|
||||
it("should call the merge() strategy for one key when called", () => {
|
||||
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
return "bar";
|
||||
},
|
||||
validate() {}
|
||||
}
|
||||
});
|
||||
|
||||
const result = schema.merge({ foo: true }, { foo: false });
|
||||
assert.propertyVal(result, "foo", "bar");
|
||||
});
|
||||
|
||||
it("should not call the merge() strategy when both objects don't contain the key", () => {
|
||||
|
||||
let called = false;
|
||||
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
called = true;
|
||||
},
|
||||
validate() {}
|
||||
}
|
||||
});
|
||||
|
||||
schema.merge({}, {});
|
||||
assert.isFalse(called, "The merge() strategy should not have been called.");
|
||||
});
|
||||
|
||||
it("should omit returning the key when the merge() strategy returns undefined", () => {
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
return undefined;
|
||||
},
|
||||
validate() { }
|
||||
}
|
||||
});
|
||||
|
||||
const result = schema.merge({ foo: true }, { foo: false });
|
||||
assert.notProperty(result, "foo");
|
||||
});
|
||||
|
||||
it("should call the merge() strategy for two keys when called", () => {
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
return "bar";
|
||||
},
|
||||
validate() { }
|
||||
},
|
||||
bar: {
|
||||
merge() {
|
||||
return "baz";
|
||||
},
|
||||
validate() {}
|
||||
}
|
||||
});
|
||||
|
||||
const result = schema.merge({ foo: true, bar: 1 }, { foo: true, bar: 2 });
|
||||
assert.propertyVal(result, "foo", "bar");
|
||||
assert.propertyVal(result, "bar", "baz");
|
||||
});
|
||||
|
||||
it("should call the merge() strategy for two keys when called on three objects", () => {
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
return "bar";
|
||||
},
|
||||
validate() { }
|
||||
},
|
||||
bar: {
|
||||
merge() {
|
||||
return "baz";
|
||||
},
|
||||
validate() { }
|
||||
}
|
||||
});
|
||||
|
||||
const result = schema.merge(
|
||||
{ foo: true, bar: 1 },
|
||||
{ foo: true, bar: 3 },
|
||||
{ foo: false, bar: 2 }
|
||||
);
|
||||
assert.propertyVal(result, "foo", "bar");
|
||||
assert.propertyVal(result, "bar", "baz");
|
||||
});
|
||||
|
||||
it("should call the merge() strategy when defined as 'overwrite'", () => {
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge: "overwrite",
|
||||
validate() { }
|
||||
}
|
||||
});
|
||||
|
||||
const result = schema.merge(
|
||||
{ foo: true },
|
||||
{ foo: false }
|
||||
);
|
||||
assert.propertyVal(result, "foo", false);
|
||||
});
|
||||
|
||||
it("should call the merge() strategy when defined as 'assign'", () => {
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge: "assign",
|
||||
validate() { }
|
||||
}
|
||||
});
|
||||
|
||||
const result = schema.merge(
|
||||
{ foo: { bar: true } },
|
||||
{ foo: { baz: false } }
|
||||
);
|
||||
|
||||
assert.strictEqual(result.foo.bar, true);
|
||||
assert.strictEqual(result.foo.baz, false);
|
||||
});
|
||||
|
||||
it("should call the merge strategy when there's a subschema", () => {
|
||||
|
||||
schema = new ObjectSchema({
|
||||
name: {
|
||||
schema: {
|
||||
first: {
|
||||
merge: "replace",
|
||||
validate: "string"
|
||||
},
|
||||
last: {
|
||||
merge: "replace",
|
||||
validate: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const result = schema.merge({
|
||||
name: {
|
||||
first: "n",
|
||||
last: "z"
|
||||
}
|
||||
}, {
|
||||
name: {
|
||||
first: "g"
|
||||
}
|
||||
});
|
||||
|
||||
assert.strictEqual(result.name.first, "g");
|
||||
assert.strictEqual(result.name.last, "z");
|
||||
});
|
||||
|
||||
it("should return separate objects when using subschema", () => {
|
||||
|
||||
schema = new ObjectSchema({
|
||||
age: {
|
||||
merge: "replace",
|
||||
validate: "number"
|
||||
},
|
||||
address: {
|
||||
schema: {
|
||||
street: {
|
||||
schema: {
|
||||
number: {
|
||||
merge: "replace",
|
||||
validate: "number"
|
||||
},
|
||||
streetName: {
|
||||
merge: "replace",
|
||||
validate: "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
state: {
|
||||
merge: "replace",
|
||||
validate: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const baseObject = {
|
||||
address: {
|
||||
street: {
|
||||
number: 100,
|
||||
streetName: "Foo St"
|
||||
},
|
||||
state: "HA"
|
||||
}
|
||||
};
|
||||
|
||||
const result = schema.merge(baseObject, {
|
||||
age: 29
|
||||
});
|
||||
|
||||
assert.notStrictEqual(result.address.street, baseObject.address.street);
|
||||
assert.deepStrictEqual(result.address, baseObject.address);
|
||||
});
|
||||
|
||||
it("should not error when calling the merge strategy when there's a subschema and no matching key in second object", () => {
|
||||
|
||||
schema = new ObjectSchema({
|
||||
name: {
|
||||
schema: {
|
||||
first: {
|
||||
merge: "replace",
|
||||
validate: "string"
|
||||
},
|
||||
last: {
|
||||
merge: "replace",
|
||||
validate: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const result = schema.merge({
|
||||
name: {
|
||||
first: "n",
|
||||
last: "z"
|
||||
}
|
||||
}, {
|
||||
});
|
||||
|
||||
assert.strictEqual(result.name.first, "n");
|
||||
assert.strictEqual(result.name.last, "z");
|
||||
});
|
||||
|
||||
it("should not error when calling the merge strategy when there's multiple subschemas and no matching key in second object", () => {
|
||||
|
||||
schema = new ObjectSchema({
|
||||
user: {
|
||||
schema: {
|
||||
name: {
|
||||
schema: {
|
||||
first: {
|
||||
merge: "replace",
|
||||
validate: "string"
|
||||
},
|
||||
last: {
|
||||
merge: "replace",
|
||||
validate: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const result = schema.merge({
|
||||
user: {
|
||||
name: {
|
||||
first: "n",
|
||||
last: "z"
|
||||
}
|
||||
}
|
||||
}, {
|
||||
});
|
||||
|
||||
assert.strictEqual(result.user.name.first, "n");
|
||||
assert.strictEqual(result.user.name.last, "z");
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe("validate()", () => {
|
||||
|
||||
it("should throw an error when an unexpected key is found", () => {
|
||||
let schema = new ObjectSchema({});
|
||||
assert.throws(() => {
|
||||
schema.validate({ foo: true });
|
||||
}, /Unexpected key "foo"/);
|
||||
});
|
||||
|
||||
it("should not throw an error when an expected key is found", () => {
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
return "bar";
|
||||
},
|
||||
validate() {}
|
||||
}
|
||||
});
|
||||
|
||||
schema.validate({ foo: true });
|
||||
});
|
||||
|
||||
it("should pass the property value into validate() when key is found", () => {
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
return "bar";
|
||||
},
|
||||
validate(value) {
|
||||
assert.isTrue(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
schema.validate({ foo: true });
|
||||
});
|
||||
|
||||
it("should not throw an error when expected keys are found", () => {
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
return "bar";
|
||||
},
|
||||
validate() {}
|
||||
},
|
||||
bar: {
|
||||
merge() {
|
||||
return "baz";
|
||||
},
|
||||
validate() {}
|
||||
}
|
||||
});
|
||||
|
||||
schema.validate({ foo: true, bar: true });
|
||||
});
|
||||
|
||||
it("should not throw an error when expected keys are found with required keys", () => {
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
return "bar";
|
||||
},
|
||||
validate() { }
|
||||
},
|
||||
bar: {
|
||||
requires: ["foo"],
|
||||
merge() {
|
||||
return "baz";
|
||||
},
|
||||
validate() { }
|
||||
}
|
||||
});
|
||||
|
||||
schema.validate({ foo: true, bar: true });
|
||||
});
|
||||
|
||||
it("should throw an error when expected keys are found without required keys", () => {
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
return "bar";
|
||||
},
|
||||
validate() { }
|
||||
},
|
||||
baz: {
|
||||
merge() {
|
||||
return "baz";
|
||||
},
|
||||
validate() { }
|
||||
},
|
||||
bar: {
|
||||
name: "bar",
|
||||
requires: ["foo", "baz"],
|
||||
merge() { },
|
||||
validate() { }
|
||||
}
|
||||
});
|
||||
|
||||
assert.throws(() => {
|
||||
schema.validate({ bar: true });
|
||||
}, /Key "bar" requires keys "foo", "baz"./);
|
||||
});
|
||||
|
||||
|
||||
it("should throw an error when an expected key is found but is invalid", () => {
|
||||
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
return "bar";
|
||||
},
|
||||
validate() {
|
||||
throw new Error("Invalid key.");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
assert.throws(() => {
|
||||
schema.validate({ foo: true });
|
||||
}, /Key "foo": Invalid key/);
|
||||
});
|
||||
|
||||
it("should throw an error when an expected key is found but is invalid with a string validator", () => {
|
||||
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
return "bar";
|
||||
},
|
||||
validate: "string"
|
||||
}
|
||||
});
|
||||
|
||||
assert.throws(() => {
|
||||
schema.validate({ foo: true });
|
||||
}, /Key "foo": Expected a string/);
|
||||
});
|
||||
|
||||
it("should throw an error when an expected key is found but is invalid with a number validator", () => {
|
||||
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
merge() {
|
||||
return "bar";
|
||||
},
|
||||
validate: "number"
|
||||
}
|
||||
});
|
||||
|
||||
assert.throws(() => {
|
||||
schema.validate({ foo: true });
|
||||
}, /Key "foo": Expected a number/);
|
||||
});
|
||||
|
||||
it("should throw an error when a required key is missing", () => {
|
||||
|
||||
schema = new ObjectSchema({
|
||||
foo: {
|
||||
required: true,
|
||||
merge() {
|
||||
return "bar";
|
||||
},
|
||||
validate() {}
|
||||
}
|
||||
});
|
||||
|
||||
assert.throws(() => {
|
||||
schema.validate({});
|
||||
}, /Missing required key "foo"/);
|
||||
});
|
||||
|
||||
it("should throw an error when a subschema is provided and the value doesn't validate", () => {
|
||||
|
||||
schema = new ObjectSchema({
|
||||
name: {
|
||||
schema: {
|
||||
first: {
|
||||
merge: "replace",
|
||||
validate: "string"
|
||||
},
|
||||
last: {
|
||||
merge: "replace",
|
||||
validate: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
assert.throws(() => {
|
||||
schema.validate({
|
||||
name: {
|
||||
first: 123,
|
||||
last: "z"
|
||||
}
|
||||
});
|
||||
|
||||
}, /Key "name": Key "first": Expected a string/);
|
||||
});
|
||||
|
||||
it("should not throw an error when a subschema is provided and the value validates", () => {
|
||||
|
||||
schema = new ObjectSchema({
|
||||
name: {
|
||||
schema: {
|
||||
first: {
|
||||
merge: "replace",
|
||||
validate: "string"
|
||||
},
|
||||
last: {
|
||||
merge: "replace",
|
||||
validate: "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
schema.validate({
|
||||
name: {
|
||||
first: "n",
|
||||
last: "z"
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
186
node_modules/@humanwhocodes/object-schema/tests/validation-strategy.js
generated
vendored
186
node_modules/@humanwhocodes/object-schema/tests/validation-strategy.js
generated
vendored
@@ -1,186 +0,0 @@
|
||||
/**
|
||||
* @filedescription Merge Strategy Tests
|
||||
*/
|
||||
/* global it, describe, beforeEach */
|
||||
|
||||
"use strict";
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const assert = require("chai").assert;
|
||||
const { ValidationStrategy } = require("../src/");
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
describe("ValidationStrategy", () => {
|
||||
|
||||
describe("boolean", () => {
|
||||
it("should not throw an error when the value is a boolean", () => {
|
||||
ValidationStrategy.boolean(true);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is null", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.boolean(null);
|
||||
}, /Expected a Boolean/);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is a string", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.boolean("foo");
|
||||
}, /Expected a Boolean/);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is a number", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.boolean(123);
|
||||
}, /Expected a Boolean/);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is an object", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.boolean({});
|
||||
}, /Expected a Boolean/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("number", () => {
|
||||
it("should not throw an error when the value is a number", () => {
|
||||
ValidationStrategy.number(25);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is null", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.number(null);
|
||||
}, /Expected a number/);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is a string", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.number("foo");
|
||||
}, /Expected a number/);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is a boolean", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.number(true);
|
||||
}, /Expected a number/);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is an object", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.number({});
|
||||
}, /Expected a number/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("object", () => {
|
||||
it("should not throw an error when the value is an object", () => {
|
||||
ValidationStrategy.object({});
|
||||
});
|
||||
|
||||
it("should throw an error when the value is null", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.object(null);
|
||||
}, /Expected an object/);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is a string", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.object("");
|
||||
}, /Expected an object/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("array", () => {
|
||||
it("should not throw an error when the value is an array", () => {
|
||||
ValidationStrategy.array([]);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is null", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.array(null);
|
||||
}, /Expected an array/);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is a string", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.array("");
|
||||
}, /Expected an array/);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is an object", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.array({});
|
||||
}, /Expected an array/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("object?", () => {
|
||||
it("should not throw an error when the value is an object", () => {
|
||||
ValidationStrategy["object?"]({});
|
||||
});
|
||||
|
||||
it("should not throw an error when the value is null", () => {
|
||||
ValidationStrategy["object?"](null);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is a string", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy["object?"]("");
|
||||
}, /Expected an object/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("string", () => {
|
||||
it("should not throw an error when the value is a string", () => {
|
||||
ValidationStrategy.string("foo");
|
||||
});
|
||||
|
||||
it("should not throw an error when the value is an empty string", () => {
|
||||
ValidationStrategy.string("");
|
||||
});
|
||||
|
||||
it("should throw an error when the value is null", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.string(null);
|
||||
}, /Expected a string/);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is an object", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy.string({});
|
||||
}, /Expected a string/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("string!", () => {
|
||||
it("should not throw an error when the value is an string", () => {
|
||||
ValidationStrategy["string!"]("foo");
|
||||
});
|
||||
|
||||
it("should throw an error when the value is an empty string", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy["string!"]("");
|
||||
}, /Expected a non-empty string/);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is null", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy["string!"](null);
|
||||
}, /Expected a non-empty string/);
|
||||
});
|
||||
|
||||
it("should throw an error when the value is an object", () => {
|
||||
assert.throws(() => {
|
||||
ValidationStrategy["string!"]({});
|
||||
}, /Expected a non-empty string/);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
Copyright (c) 2019 Ryan Tsao
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
49
node_modules/@rtsao/scc/README.md
generated
vendored
Normal file
49
node_modules/@rtsao/scc/README.md
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
# `@rtsao/scc`
|
||||
|
||||
Find strongly connected components of a directed graph using [Tarjan's algorithm](https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm).
|
||||
|
||||
This algorithm efficiently yields both a topological order and list of any cycles.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
yarn add @rtsao/scc
|
||||
```
|
||||
|
||||
```
|
||||
npm install @rtsao/scc
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const scc = require("@rtsao/scc");
|
||||
|
||||
const digraph = new Map([
|
||||
["a", new Set(["c", "d"])],
|
||||
["b", new Set(["a"])],
|
||||
["c", new Set(["b"])],
|
||||
["d", new Set(["e"])],
|
||||
["e", new Set()]
|
||||
]);
|
||||
|
||||
const components = scc(digraph);
|
||||
// [ Set { 'e' }, Set { 'd' }, Set { 'b', 'c', 'a' } ]
|
||||
```
|
||||
|
||||
#### Illustration of example input digraph
|
||||
```
|
||||
┌───┐ ┌───┐
|
||||
│ d │ ◀── │ a │ ◀┐
|
||||
└───┘ └───┘ │
|
||||
│ │ │
|
||||
▼ ▼ │
|
||||
┌───┐ ┌───┐ │
|
||||
│ e │ │ c │ │
|
||||
└───┘ └───┘ │
|
||||
│ │
|
||||
▼ │
|
||||
┌───┐ │
|
||||
│ b │ ─┘
|
||||
└───┘
|
||||
```
|
||||
1
node_modules/@rtsao/scc/index.d.ts
generated
vendored
Normal file
1
node_modules/@rtsao/scc/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default function tarjan<T>(graph: Map<T, Set<T>>): Array<Set<T>>
|
||||
51
node_modules/@rtsao/scc/index.js
generated
vendored
Normal file
51
node_modules/@rtsao/scc/index.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = tarjan;
|
||||
|
||||
// Adapted from https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm#The_algorithm_in_pseudocode
|
||||
|
||||
function tarjan(graph) {
|
||||
const indices = new Map();
|
||||
const lowlinks = new Map();
|
||||
const onStack = new Set();
|
||||
const stack = [];
|
||||
const scc = [];
|
||||
let idx = 0;
|
||||
|
||||
function strongConnect(v) {
|
||||
indices.set(v, idx);
|
||||
lowlinks.set(v, idx);
|
||||
idx++;
|
||||
stack.push(v);
|
||||
onStack.add(v);
|
||||
|
||||
const deps = graph.get(v);
|
||||
for (const dep of deps) {
|
||||
if (!indices.has(dep)) {
|
||||
strongConnect(dep);
|
||||
lowlinks.set(v, Math.min(lowlinks.get(v), lowlinks.get(dep)));
|
||||
} else if (onStack.has(dep)) {
|
||||
lowlinks.set(v, Math.min(lowlinks.get(v), indices.get(dep)));
|
||||
}
|
||||
}
|
||||
|
||||
if (lowlinks.get(v) === indices.get(v)) {
|
||||
const vertices = new Set();
|
||||
let w = null;
|
||||
while (v !== w) {
|
||||
w = stack.pop();
|
||||
onStack.delete(w);
|
||||
vertices.add(w);
|
||||
}
|
||||
scc.push(vertices);
|
||||
}
|
||||
}
|
||||
|
||||
for (const v of graph.keys()) {
|
||||
if (!indices.has(v)) {
|
||||
strongConnect(v);
|
||||
}
|
||||
}
|
||||
|
||||
return scc;
|
||||
}
|
||||
5
node_modules/@rtsao/scc/index.js.flow
generated
vendored
Normal file
5
node_modules/@rtsao/scc/index.js.flow
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
// @flow
|
||||
|
||||
declare function tarjan<T>(graph: Map<T, Set<T>>): Array<Set<T>>;
|
||||
|
||||
declare module.exports: typeof tarjan;
|
||||
7
node_modules/@rtsao/scc/package.json
generated
vendored
Normal file
7
node_modules/@rtsao/scc/package.json
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "@rtsao/scc",
|
||||
"version": "1.1.0",
|
||||
"repository": "rtsao/scc",
|
||||
"main": "index.js",
|
||||
"license": "MIT"
|
||||
}
|
||||
85
node_modules/@sinonjs/fake-timers/README.md
generated
vendored
85
node_modules/@sinonjs/fake-timers/README.md
generated
vendored
@@ -3,19 +3,27 @@
|
||||
[](https://codecov.io/gh/sinonjs/fake-timers)
|
||||
<a href="CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg" alt="Contributor Covenant" /></a>
|
||||
|
||||
JavaScript implementation of the timer APIs; `setTimeout`, `clearTimeout`, `setImmediate`, `clearImmediate`, `setInterval`, `clearInterval`, `requestAnimationFrame`, `cancelAnimationFrame`, `requestIdleCallback`, and `cancelIdleCallback`, along with a clock instance that controls the flow of time. FakeTimers also provides a `Date` implementation that gets its time from the clock.
|
||||
JavaScript implementation of the timer
|
||||
APIs; `setTimeout`, `clearTimeout`, `setImmediate`, `clearImmediate`, `setInterval`, `clearInterval`, `requestAnimationFrame`, `cancelAnimationFrame`, `requestIdleCallback`,
|
||||
and `cancelIdleCallback`, along with a clock instance that controls the flow of time. FakeTimers also provides a `Date`
|
||||
implementation that gets its time from the clock.
|
||||
|
||||
In addition in browser environment `@sinonjs/fake-timers` provides a `performance` implementation that gets its time from the clock. In Node environments FakeTimers provides a `nextTick` implementation that is synchronized with the clock - and a `process.hrtime` shim that works with the clock.
|
||||
In addition in browser environment `@sinonjs/fake-timers` provides a `performance` implementation that gets its time
|
||||
from the clock. In Node environments FakeTimers provides a `nextTick` implementation that is synchronized with the
|
||||
clock - and a `process.hrtime` shim that works with the clock.
|
||||
|
||||
`@sinonjs/fake-timers` can be used to simulate passing time in automated tests and other
|
||||
situations where you want the scheduling semantics, but don't want to actually
|
||||
wait.
|
||||
|
||||
`@sinonjs/fake-timers` is extracted from [Sinon.JS](https://github.com/sinonjs/sinon.js) and targets the [same runtimes](https://sinonjs.org/releases/latest/#supported-runtimes).
|
||||
`@sinonjs/fake-timers` is extracted from [Sinon.JS](https://github.com/sinonjs/sinon.js) and targets
|
||||
the [same runtimes](https://sinonjs.org/releases/latest/#supported-runtimes).
|
||||
|
||||
## Autocomplete, IntelliSense and TypeScript definitions
|
||||
|
||||
Version 7 introduced JSDoc to the codebase. This should provide autocomplete and type suggestions in supporting IDEs. If you need more elaborate type support, TypeScript definitions for the Sinon projects are independently maintained by the Definitely Types community:
|
||||
Version 7 introduced JSDoc to the codebase. This should provide autocomplete and type suggestions in supporting IDEs. If
|
||||
you need more elaborate type support, TypeScript definitions for the Sinon projects are independently maintained by the
|
||||
Definitely Types community:
|
||||
|
||||
```
|
||||
npm install -D @types/sinonjs__fake-timers
|
||||
@@ -29,7 +37,8 @@ npm install -D @types/sinonjs__fake-timers
|
||||
npm install @sinonjs/fake-timers
|
||||
```
|
||||
|
||||
If you want to use `@sinonjs/fake-timers` in a browser you can either build your own bundle or use [Skypack](https://www.skypack.dev).
|
||||
If you want to use `@sinonjs/fake-timers` in a browser you can either build your own bundle or
|
||||
use [Skypack](https://www.skypack.dev).
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -54,7 +63,8 @@ clock.tick(15);
|
||||
|
||||
Upon executing the last line, an interesting fact about the
|
||||
[Poblano](https://en.wikipedia.org/wiki/Poblano) will be printed synchronously to
|
||||
the screen. If you want to simulate asynchronous behavior, please see the `async` function variants (eg `clock.tick(time)` vs `await clock.tickAsync(time)`).
|
||||
the screen. If you want to simulate asynchronous behavior, please see the `async` function variants (
|
||||
eg `clock.tick(time)` vs `await clock.tickAsync(time)`).
|
||||
|
||||
The `next`, `runAll`, `runToFrame`, and `runToLast` methods are available to advance the clock. See the
|
||||
API Reference for more details.
|
||||
@@ -67,7 +77,9 @@ clock instance, not the browser's internals.
|
||||
|
||||
Calling `install` with no arguments achieves this. You can call `uninstall`
|
||||
later to restore things as they were again.
|
||||
Note that in NodeJS also the [timers](https://nodejs.org/api/timers.html) module will receive fake timers when using global scope.
|
||||
Note that in NodeJS the [timers](https://nodejs.org/api/timers.html)
|
||||
and [timers/promises](https://nodejs.org/api/timers.html#timers-promises-api) modules will also receive fake timers when
|
||||
using global scope.
|
||||
|
||||
```js
|
||||
// In the browser distribution, a global `FakeTimers` is already available
|
||||
@@ -143,22 +155,26 @@ Creates a clock. The default
|
||||
|
||||
The `now` argument may be a number (in milliseconds) or a Date object.
|
||||
|
||||
The `loopLimit` argument sets the maximum number of timers that will be run when calling `runAll()` before assuming that we have an infinite loop and throwing an error. The default is `1000`.
|
||||
The `loopLimit` argument sets the maximum number of timers that will be run when calling `runAll()` before assuming that
|
||||
we have an infinite loop and throwing an error. The default is `1000`.
|
||||
|
||||
### `var clock = FakeTimers.install([config])`
|
||||
|
||||
Installs FakeTimers using the specified config (otherwise with epoch `0` on the global scope).
|
||||
Note that in NodeJS also the [timers](https://nodejs.org/api/timers.html) module will receive fake timers when using global scope.
|
||||
Note that in NodeJS the [timers](https://nodejs.org/api/timers.html)
|
||||
and [timers/promises](https://nodejs.org/api/timers.html#timers-promises-api) modules will also receive fake timers when
|
||||
using global scope.
|
||||
The following configuration options are available
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
| -------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `config.now` | Number/Date | 0 | installs FakeTimers with the specified unix epoch |
|
||||
| `config.toFake` | String[] | ["setTimeout", "clearTimeout", "setImmediate", "clearImmediate","setInterval", "clearInterval", "Date", "requestAnimationFrame", "cancelAnimationFrame", "requestIdleCallback", "cancelIdleCallback", "hrtime", "performance"] | an array with explicit function names (or objects, in the case of "performance") to hijack. _When not set, FakeTimers will automatically fake all methods **except** `nextTick`_ e.g., `FakeTimers.install({ toFake: ["setTimeout","nextTick"]})` will fake only `setTimeout` and `nextTick` |
|
||||
| `config.loopLimit` | Number | 1000 | the maximum number of timers that will be run when calling runAll() |
|
||||
| `config.shouldAdvanceTime` | Boolean | false | tells FakeTimers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by 20ms for every 20ms change in the real system time) |
|
||||
| `config.advanceTimeDelta` | Number | 20 | relevant only when using with `shouldAdvanceTime: true`. increment mocked time by `advanceTimeDelta` ms every `advanceTimeDelta` ms change in the real system time. |
|
||||
| `config.shouldClearNativeTimers` | Boolean | false | tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. |
|
||||
| Parameter | Type | Default | Description |
|
||||
| -------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `config.now` | Number/Date | 0 | installs FakeTimers with the specified unix epoch |
|
||||
| `config.toFake` | String[] | ["setTimeout", "clearTimeout", "setImmediate", "clearImmediate","setInterval", "clearInterval", "Date", "requestAnimationFrame", "cancelAnimationFrame", "requestIdleCallback", "cancelIdleCallback", "hrtime", "performance"] | an array with explicit function names (or objects, in the case of "performance") to hijack. \_When not set, FakeTimers will automatically fake all methods e.g., `FakeTimers.install({ toFake: ["setTimeout","nextTick"]})` will fake only `setTimeout` and `nextTick` |
|
||||
| `config.loopLimit` | Number | 1000 | the maximum number of timers that will be run when calling runAll() |
|
||||
| `config.shouldAdvanceTime` | Boolean | false | tells FakeTimers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by 20ms for every 20ms change in the real system time) |
|
||||
| `config.advanceTimeDelta` | Number | 20 | relevant only when using with `shouldAdvanceTime: true`. increment mocked time by `advanceTimeDelta` ms every `advanceTimeDelta` ms change in the real system time. |
|
||||
| `config.shouldClearNativeTimers` | Boolean | false | tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. |
|
||||
| `config.ignoreMissingTimers` | Boolean | false | tells FakeTimers to ignore missing timers that might not exist in the given environment |
|
||||
|
||||
### `var id = clock.setTimeout(callback, timeout)`
|
||||
|
||||
@@ -218,7 +234,9 @@ Cancels the callback scheduled by the provided id.
|
||||
|
||||
### `clock.requestIdleCallback(callback[, timeout])`
|
||||
|
||||
Queued the callback to be fired during idle periods to perform background and low priority work on the main event loop. Callbacks which have a timeout option will be fired no later than time in milliseconds. Returns an `id` which can be used to cancel the callback.
|
||||
Queued the callback to be fired during idle periods to perform background and low priority work on the main event loop.
|
||||
Callbacks which have a timeout option will be fired no later than time in milliseconds. Returns an `id` which can be
|
||||
used to cancel the callback.
|
||||
|
||||
### `clock.cancelIdleCallback(id)`
|
||||
|
||||
@@ -263,7 +281,8 @@ callbacks to execute _before_ running the timers.
|
||||
Advance the clock by jumping forward in time, firing callbacks at most once.
|
||||
`time` takes the same formats as [`clock.tick`](#clockticktime--await-clocktickasynctime).
|
||||
|
||||
This can be used to simulate the JS engine (such as a browser) being put to sleep and resumed later, skipping intermediary timers.
|
||||
This can be used to simulate the JS engine (such as a browser) being put to sleep and resumed later, skipping
|
||||
intermediary timers.
|
||||
|
||||
### `clock.reset()`
|
||||
|
||||
@@ -273,9 +292,11 @@ Useful to reset the state of the clock without having to `uninstall` and `instal
|
||||
|
||||
### `clock.runAll()` / `await clock.runAllAsync()`
|
||||
|
||||
This runs all pending timers until there are none remaining. If new timers are added while it is executing they will be run as well.
|
||||
This runs all pending timers until there are none remaining. If new timers are added while it is executing they will be
|
||||
run as well.
|
||||
|
||||
This makes it easier to run asynchronous tests to completion without worrying about the number of timers they use, or the delays in those timers.
|
||||
This makes it easier to run asynchronous tests to completion without worrying about the number of timers they use, or
|
||||
the delays in those timers.
|
||||
|
||||
It runs a maximum of `loopLimit` times after which it assumes there is an infinite loop of timers and throws an error.
|
||||
|
||||
@@ -284,7 +305,8 @@ callbacks to execute _before_ running the timers.
|
||||
|
||||
### `clock.runMicrotasks()`
|
||||
|
||||
This runs all pending microtasks scheduled with `nextTick` but none of the timers and is mostly useful for libraries using FakeTimers underneath and for running `nextTick` items without any timers.
|
||||
This runs all pending microtasks scheduled with `nextTick` but none of the timers and is mostly useful for libraries
|
||||
using FakeTimers underneath and for running `nextTick` items without any timers.
|
||||
|
||||
### `clock.runToFrame()`
|
||||
|
||||
@@ -323,11 +345,22 @@ Implements the `Date` object but using the clock to provide the correct time.
|
||||
|
||||
### `Performance`
|
||||
|
||||
Implements the `now` method of the [`Performance`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now) object but using the clock to provide the correct time. Only available in environments that support the Performance object (browsers mostly).
|
||||
Implements the `now` method of the [`Performance`](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now)
|
||||
object but using the clock to provide the correct time. Only available in environments that support the Performance
|
||||
object (browsers mostly).
|
||||
|
||||
### `FakeTimers.withGlobal`
|
||||
|
||||
In order to support creating clocks based on separate or sandboxed environments (such as JSDOM), FakeTimers exports a factory method which takes single argument `global`, which it inspects to figure out what to mock and what features to support. When invoking this function with a global, you will get back an object with `timers`, `createClock` and `install` - same as the regular FakeTimers exports only based on the passed in global instead of the global environment.
|
||||
In order to support creating clocks based on separate or sandboxed environments (such as JSDOM), FakeTimers exports a
|
||||
factory method which takes single argument `global`, which it inspects to figure out what to mock and what features to
|
||||
support. When invoking this function with a global, you will get back an object with `timers`, `createClock`
|
||||
and `install` - same as the regular FakeTimers exports only based on the passed in global instead of the global
|
||||
environment.
|
||||
|
||||
## Promises and fake time
|
||||
|
||||
If you use a Promise library like Bluebird, note that you should either call `clock.runMicrotasks()` or make sure to
|
||||
_not_ mock `nextTick`.
|
||||
|
||||
## Running tests
|
||||
|
||||
@@ -349,8 +382,8 @@ $(npm bin)/mocha ./test/fake-timers-test.js
|
||||
|
||||
### In the browser
|
||||
|
||||
[Mochify](https://github.com/mantoni/mochify.js) is used to run the tests in
|
||||
PhantomJS. Make sure you have `phantomjs` installed. Then:
|
||||
[Mochify](https://github.com/mochify-js) is used to run the tests in headless
|
||||
Chrome.
|
||||
|
||||
```sh
|
||||
npm test-headless
|
||||
|
||||
45
node_modules/@sinonjs/fake-timers/package.json
generated
vendored
45
node_modules/@sinonjs/fake-timers/package.json
generated
vendored
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@sinonjs/fake-timers",
|
||||
"description": "Fake JavaScript timers",
|
||||
"version": "11.2.2",
|
||||
"version": "13.0.2",
|
||||
"homepage": "https://github.com/sinonjs/fake-timers",
|
||||
"author": "Christian Johansen",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sinonjs/fake-timers.git"
|
||||
"url": "git+https://github.com/sinonjs/fake-timers.git"
|
||||
},
|
||||
"bugs": {
|
||||
"mail": "christian@cjohansen.no",
|
||||
@@ -16,39 +16,52 @@
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test-node": "mocha --timeout 200 test/ integration-test/ -R dot --check-leaks",
|
||||
"test-headless": "mochify --no-detect-globals --timeout=10000",
|
||||
"test-headless": "mochify --driver puppeteer",
|
||||
"test-check-coverage": "npm run test-coverage && nyc check-coverage",
|
||||
"test-cloud": "mochify --wd --no-detect-globals --timeout=10000",
|
||||
"test-coverage": "nyc --all --reporter text --reporter html --reporter lcovonly npm run test-node",
|
||||
"test-cloud": "npm run test-edge && npm run test-firefox && npm run test-safari",
|
||||
"test-edge": "BROWSER_NAME=MicrosoftEdge mochify --config mochify.webdriver.js",
|
||||
"test-firefox": "BROWSER_NAME=firefox mochify --config mochify.webdriver.js",
|
||||
"test-safari": "BROWSER_NAME=safari mochify --config mochify.webdriver.js",
|
||||
"test-coverage": "nyc -x mochify.webdriver.js -x coverage --all --reporter text --reporter html --reporter lcovonly npm run test-node",
|
||||
"test": "npm run test-node && npm run test-headless",
|
||||
"prettier:check": "prettier --check '**/*.{js,css,md}'",
|
||||
"prettier:write": "prettier --write '**/*.{js,css,md}'",
|
||||
"preversion": "./scripts/preversion.sh",
|
||||
"version": "./scripts/version.sh",
|
||||
"postversion": "./scripts/postversion.sh",
|
||||
"prepare": "husky install"
|
||||
"prepare": "husky"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,css,md}": "prettier --check",
|
||||
"*.js": "eslint"
|
||||
},
|
||||
"mochify": {
|
||||
"reporter": "dot",
|
||||
"timeout": 10000,
|
||||
"bundle": "esbuild --bundle --sourcemap=inline --define:process.env.NODE_DEBUG=\"\"",
|
||||
"bundle_stdin": "require",
|
||||
"spec": "test/**/*-test.js"
|
||||
},
|
||||
"files": [
|
||||
"src/"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@sinonjs/eslint-config": "^4.1.0",
|
||||
"@sinonjs/referee-sinon": "11.0.0",
|
||||
"husky": "^8.0.3",
|
||||
"jsdom": "22.1.0",
|
||||
"lint-staged": "15.0.1",
|
||||
"mocha": "10.2.0",
|
||||
"mochify": "9.2.0",
|
||||
"nyc": "15.1.0",
|
||||
"prettier": "3.0.3"
|
||||
"@mochify/cli": "^0.4.1",
|
||||
"@mochify/driver-puppeteer": "^0.4.0",
|
||||
"@mochify/driver-webdriver": "^0.2.1",
|
||||
"@sinonjs/eslint-config": "^5.0.3",
|
||||
"@sinonjs/referee-sinon": "12.0.0",
|
||||
"esbuild": "^0.23.1",
|
||||
"husky": "^9.1.5",
|
||||
"jsdom": "24.1.1",
|
||||
"lint-staged": "15.2.9",
|
||||
"mocha": "10.7.3",
|
||||
"nyc": "17.0.0",
|
||||
"prettier": "3.3.3"
|
||||
},
|
||||
"main": "./src/fake-timers-src.js",
|
||||
"dependencies": {
|
||||
"@sinonjs/commons": "^3.0.0"
|
||||
"@sinonjs/commons": "^3.0.1"
|
||||
},
|
||||
"nyc": {
|
||||
"branches": 85,
|
||||
|
||||
574
node_modules/@sinonjs/fake-timers/src/fake-timers-src.js
generated
vendored
574
node_modules/@sinonjs/fake-timers/src/fake-timers-src.js
generated
vendored
@@ -1,13 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
const globalObject = require("@sinonjs/commons").global;
|
||||
let timersModule;
|
||||
let timersModule, timersPromisesModule;
|
||||
if (typeof require === "function" && typeof module === "object") {
|
||||
try {
|
||||
timersModule = require("timers");
|
||||
} catch (e) {
|
||||
// ignored
|
||||
}
|
||||
try {
|
||||
timersPromisesModule = require("timers/promises");
|
||||
} catch (e) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,6 +99,8 @@ if (typeof require === "function" && typeof module === "object") {
|
||||
* @property {Function[]} methods - the methods that are faked
|
||||
* @property {boolean} [shouldClearNativeTimers] inherited from config
|
||||
* @property {{methodName:string, original:any}[] | undefined} timersModuleMethods
|
||||
* @property {{methodName:string, original:any}[] | undefined} timersPromisesModuleMethods
|
||||
* @property {Map<function(): void, AbortSignal>} abortListenerMap
|
||||
*/
|
||||
/* eslint-enable jsdoc/require-property-description */
|
||||
|
||||
@@ -107,6 +114,7 @@ if (typeof require === "function" && typeof module === "object") {
|
||||
* @property {boolean} [shouldAdvanceTime] tells FakeTimers to increment mocked time automatically (default false)
|
||||
* @property {number} [advanceTimeDelta] increment mocked time every <<advanceTimeDelta>> ms (default: 20ms)
|
||||
* @property {boolean} [shouldClearNativeTimers] forwards clear timer calls to native functions if they are not fakes (default: false)
|
||||
* @property {boolean} [ignoreMissingTimers] default is false, meaning asking to fake timers that are not present will throw an error
|
||||
*/
|
||||
|
||||
/* eslint-disable jsdoc/require-property-description */
|
||||
@@ -151,16 +159,26 @@ function withGlobal(_global) {
|
||||
const NOOP_ARRAY = function () {
|
||||
return [];
|
||||
};
|
||||
const timeoutResult = _global.setTimeout(NOOP, 0);
|
||||
const addTimerReturnsObject = typeof timeoutResult === "object";
|
||||
const hrtimePresent =
|
||||
const isPresent = {};
|
||||
let timeoutResult,
|
||||
addTimerReturnsObject = false;
|
||||
|
||||
if (_global.setTimeout) {
|
||||
isPresent.setTimeout = true;
|
||||
timeoutResult = _global.setTimeout(NOOP, 0);
|
||||
addTimerReturnsObject = typeof timeoutResult === "object";
|
||||
}
|
||||
isPresent.clearTimeout = Boolean(_global.clearTimeout);
|
||||
isPresent.setInterval = Boolean(_global.setInterval);
|
||||
isPresent.clearInterval = Boolean(_global.clearInterval);
|
||||
isPresent.hrtime =
|
||||
_global.process && typeof _global.process.hrtime === "function";
|
||||
const hrtimeBigintPresent =
|
||||
hrtimePresent && typeof _global.process.hrtime.bigint === "function";
|
||||
const nextTickPresent =
|
||||
isPresent.hrtimeBigint =
|
||||
isPresent.hrtime && typeof _global.process.hrtime.bigint === "function";
|
||||
isPresent.nextTick =
|
||||
_global.process && typeof _global.process.nextTick === "function";
|
||||
const utilPromisify = _global.process && require("util").promisify;
|
||||
const performancePresent =
|
||||
isPresent.performance =
|
||||
_global.performance && typeof _global.performance.now === "function";
|
||||
const hasPerformancePrototype =
|
||||
_global.Performance &&
|
||||
@@ -169,29 +187,60 @@ function withGlobal(_global) {
|
||||
_global.performance &&
|
||||
_global.performance.constructor &&
|
||||
_global.performance.constructor.prototype;
|
||||
const queueMicrotaskPresent = _global.hasOwnProperty("queueMicrotask");
|
||||
const requestAnimationFramePresent =
|
||||
isPresent.queueMicrotask = _global.hasOwnProperty("queueMicrotask");
|
||||
isPresent.requestAnimationFrame =
|
||||
_global.requestAnimationFrame &&
|
||||
typeof _global.requestAnimationFrame === "function";
|
||||
const cancelAnimationFramePresent =
|
||||
isPresent.cancelAnimationFrame =
|
||||
_global.cancelAnimationFrame &&
|
||||
typeof _global.cancelAnimationFrame === "function";
|
||||
const requestIdleCallbackPresent =
|
||||
isPresent.requestIdleCallback =
|
||||
_global.requestIdleCallback &&
|
||||
typeof _global.requestIdleCallback === "function";
|
||||
const cancelIdleCallbackPresent =
|
||||
isPresent.cancelIdleCallbackPresent =
|
||||
_global.cancelIdleCallback &&
|
||||
typeof _global.cancelIdleCallback === "function";
|
||||
const setImmediatePresent =
|
||||
isPresent.setImmediate =
|
||||
_global.setImmediate && typeof _global.setImmediate === "function";
|
||||
const intlPresent = _global.Intl && typeof _global.Intl === "object";
|
||||
isPresent.clearImmediate =
|
||||
_global.clearImmediate && typeof _global.clearImmediate === "function";
|
||||
isPresent.Intl = _global.Intl && typeof _global.Intl === "object";
|
||||
|
||||
_global.clearTimeout(timeoutResult);
|
||||
if (_global.clearTimeout) {
|
||||
_global.clearTimeout(timeoutResult);
|
||||
}
|
||||
|
||||
const NativeDate = _global.Date;
|
||||
const NativeIntl = _global.Intl;
|
||||
let uniqueTimerId = idCounterStart;
|
||||
|
||||
if (NativeDate === undefined) {
|
||||
throw new Error(
|
||||
"The global scope doesn't have a `Date` object" +
|
||||
" (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)",
|
||||
);
|
||||
}
|
||||
isPresent.Date = true;
|
||||
|
||||
/**
|
||||
* The PerformanceEntry object encapsulates a single performance metric
|
||||
* that is part of the browser's performance timeline.
|
||||
*
|
||||
* This is an object returned by the `mark` and `measure` methods on the Performance prototype
|
||||
*/
|
||||
class FakePerformanceEntry {
|
||||
constructor(name, entryType, startTime, duration) {
|
||||
this.name = name;
|
||||
this.entryType = entryType;
|
||||
this.startTime = startTime;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return JSON.stringify({ ...this });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} num
|
||||
* @returns {boolean}
|
||||
@@ -376,109 +425,76 @@ function withGlobal(_global) {
|
||||
return infiniteLoopError;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Date} target
|
||||
* @param {Date} source
|
||||
* @returns {Date} the target after modifications
|
||||
*/
|
||||
function mirrorDateProperties(target, source) {
|
||||
let prop;
|
||||
for (prop in source) {
|
||||
if (source.hasOwnProperty(prop)) {
|
||||
target[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
|
||||
// set special now implementation
|
||||
if (source.now) {
|
||||
target.now = function now() {
|
||||
return target.clock.now;
|
||||
};
|
||||
} else {
|
||||
delete target.now;
|
||||
}
|
||||
|
||||
// set special toSource implementation
|
||||
if (source.toSource) {
|
||||
target.toSource = function toSource() {
|
||||
return source.toSource();
|
||||
};
|
||||
} else {
|
||||
delete target.toSource;
|
||||
}
|
||||
|
||||
// set special toString implementation
|
||||
target.toString = function toString() {
|
||||
return source.toString();
|
||||
};
|
||||
|
||||
target.prototype = source.prototype;
|
||||
target.parse = source.parse;
|
||||
target.UTC = source.UTC;
|
||||
target.prototype.toUTCString = source.prototype.toUTCString;
|
||||
target.isFake = true;
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
//eslint-disable-next-line jsdoc/require-jsdoc
|
||||
function createDate() {
|
||||
/**
|
||||
* @param {number} year
|
||||
* @param {number} month
|
||||
* @param {number} date
|
||||
* @param {number} hour
|
||||
* @param {number} minute
|
||||
* @param {number} second
|
||||
* @param {number} ms
|
||||
* @returns {Date}
|
||||
*/
|
||||
function ClockDate(year, month, date, hour, minute, second, ms) {
|
||||
// the Date constructor called as a function, ref Ecma-262 Edition 5.1, section 15.9.2.
|
||||
// This remains so in the 10th edition of 2019 as well.
|
||||
if (!(this instanceof ClockDate)) {
|
||||
return new NativeDate(ClockDate.clock.now).toString();
|
||||
class ClockDate extends NativeDate {
|
||||
/**
|
||||
* @param {number} year
|
||||
* @param {number} month
|
||||
* @param {number} date
|
||||
* @param {number} hour
|
||||
* @param {number} minute
|
||||
* @param {number} second
|
||||
* @param {number} ms
|
||||
* @returns void
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
constructor(year, month, date, hour, minute, second, ms) {
|
||||
// Defensive and verbose to avoid potential harm in passing
|
||||
// explicit undefined when user does not pass argument
|
||||
if (arguments.length === 0) {
|
||||
super(ClockDate.clock.now);
|
||||
} else {
|
||||
super(...arguments);
|
||||
}
|
||||
}
|
||||
|
||||
// if Date is called as a constructor with 'new' keyword
|
||||
// Defensive and verbose to avoid potential harm in passing
|
||||
// explicit undefined when user does not pass argument
|
||||
switch (arguments.length) {
|
||||
case 0:
|
||||
return new NativeDate(ClockDate.clock.now);
|
||||
case 1:
|
||||
return new NativeDate(year);
|
||||
case 2:
|
||||
return new NativeDate(year, month);
|
||||
case 3:
|
||||
return new NativeDate(year, month, date);
|
||||
case 4:
|
||||
return new NativeDate(year, month, date, hour);
|
||||
case 5:
|
||||
return new NativeDate(year, month, date, hour, minute);
|
||||
case 6:
|
||||
return new NativeDate(
|
||||
year,
|
||||
month,
|
||||
date,
|
||||
hour,
|
||||
minute,
|
||||
second,
|
||||
);
|
||||
default:
|
||||
return new NativeDate(
|
||||
year,
|
||||
month,
|
||||
date,
|
||||
hour,
|
||||
minute,
|
||||
second,
|
||||
ms,
|
||||
);
|
||||
static [Symbol.hasInstance](instance) {
|
||||
return instance instanceof NativeDate;
|
||||
}
|
||||
}
|
||||
|
||||
return mirrorDateProperties(ClockDate, NativeDate);
|
||||
ClockDate.isFake = true;
|
||||
|
||||
if (NativeDate.now) {
|
||||
ClockDate.now = function now() {
|
||||
return ClockDate.clock.now;
|
||||
};
|
||||
}
|
||||
|
||||
if (NativeDate.toSource) {
|
||||
ClockDate.toSource = function toSource() {
|
||||
return NativeDate.toSource();
|
||||
};
|
||||
}
|
||||
|
||||
ClockDate.toString = function toString() {
|
||||
return NativeDate.toString();
|
||||
};
|
||||
|
||||
// noinspection UnnecessaryLocalVariableJS
|
||||
/**
|
||||
* A normal Class constructor cannot be called without `new`, but Date can, so we need
|
||||
* to wrap it in a Proxy in order to ensure this functionality of Date is kept intact
|
||||
*
|
||||
* @type {ClockDate}
|
||||
*/
|
||||
const ClockDateProxy = new Proxy(ClockDate, {
|
||||
// handler for [[Call]] invocations (i.e. not using `new`)
|
||||
apply() {
|
||||
// the Date constructor called as a function, ref Ecma-262 Edition 5.1, section 15.9.2.
|
||||
// This remains so in the 10th edition of 2019 as well.
|
||||
if (this instanceof ClockDate) {
|
||||
throw new TypeError(
|
||||
"A Proxy should only capture `new` calls with the `construct` handler. This is not supposed to be possible, so check the logic.",
|
||||
);
|
||||
}
|
||||
|
||||
return new NativeDate(ClockDate.clock.now).toString();
|
||||
},
|
||||
});
|
||||
|
||||
return ClockDateProxy;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -931,6 +947,16 @@ function withGlobal(_global) {
|
||||
timersModule[entry.methodName] = entry.original;
|
||||
}
|
||||
}
|
||||
if (clock.timersPromisesModuleMethods !== undefined) {
|
||||
for (
|
||||
let j = 0;
|
||||
j < clock.timersPromisesModuleMethods.length;
|
||||
j++
|
||||
) {
|
||||
const entry = clock.timersPromisesModuleMethods[j];
|
||||
timersPromisesModule[entry.methodName] = entry.original;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (config.shouldAdvanceTime === true) {
|
||||
@@ -940,6 +966,11 @@ function withGlobal(_global) {
|
||||
// Prevent multiple executions which will completely remove these props
|
||||
clock.methods = [];
|
||||
|
||||
for (const [listener, signal] of clock.abortListenerMap.entries()) {
|
||||
signal.removeEventListener("abort", listener);
|
||||
clock.abortListenerMap.delete(listener);
|
||||
}
|
||||
|
||||
// return pending timers, to enable checking what timers remained on uninstall
|
||||
if (!clock.timers) {
|
||||
return [];
|
||||
@@ -962,8 +993,7 @@ function withGlobal(_global) {
|
||||
clock[`_${method}`] = target[method];
|
||||
|
||||
if (method === "Date") {
|
||||
const date = mirrorDateProperties(clock[method], target[method]);
|
||||
target[method] = date;
|
||||
target[method] = clock[method];
|
||||
} else if (method === "Intl") {
|
||||
target[method] = clock[method];
|
||||
} else if (method === "performance") {
|
||||
@@ -1042,44 +1072,47 @@ function withGlobal(_global) {
|
||||
Date: _global.Date,
|
||||
};
|
||||
|
||||
if (setImmediatePresent) {
|
||||
if (isPresent.setImmediate) {
|
||||
timers.setImmediate = _global.setImmediate;
|
||||
}
|
||||
|
||||
if (isPresent.clearImmediate) {
|
||||
timers.clearImmediate = _global.clearImmediate;
|
||||
}
|
||||
|
||||
if (hrtimePresent) {
|
||||
if (isPresent.hrtime) {
|
||||
timers.hrtime = _global.process.hrtime;
|
||||
}
|
||||
|
||||
if (nextTickPresent) {
|
||||
if (isPresent.nextTick) {
|
||||
timers.nextTick = _global.process.nextTick;
|
||||
}
|
||||
|
||||
if (performancePresent) {
|
||||
if (isPresent.performance) {
|
||||
timers.performance = _global.performance;
|
||||
}
|
||||
|
||||
if (requestAnimationFramePresent) {
|
||||
if (isPresent.requestAnimationFrame) {
|
||||
timers.requestAnimationFrame = _global.requestAnimationFrame;
|
||||
}
|
||||
|
||||
if (queueMicrotaskPresent) {
|
||||
timers.queueMicrotask = true;
|
||||
if (isPresent.queueMicrotask) {
|
||||
timers.queueMicrotask = _global.queueMicrotask;
|
||||
}
|
||||
|
||||
if (cancelAnimationFramePresent) {
|
||||
if (isPresent.cancelAnimationFrame) {
|
||||
timers.cancelAnimationFrame = _global.cancelAnimationFrame;
|
||||
}
|
||||
|
||||
if (requestIdleCallbackPresent) {
|
||||
if (isPresent.requestIdleCallback) {
|
||||
timers.requestIdleCallback = _global.requestIdleCallback;
|
||||
}
|
||||
|
||||
if (cancelIdleCallbackPresent) {
|
||||
if (isPresent.cancelIdleCallback) {
|
||||
timers.cancelIdleCallback = _global.cancelIdleCallback;
|
||||
}
|
||||
|
||||
if (intlPresent) {
|
||||
if (isPresent.Intl) {
|
||||
timers.Intl = _global.Intl;
|
||||
}
|
||||
|
||||
@@ -1098,13 +1131,6 @@ function withGlobal(_global) {
|
||||
let nanos = 0;
|
||||
const adjustedSystemTime = [0, 0]; // [millis, nanoremainder]
|
||||
|
||||
if (NativeDate === undefined) {
|
||||
throw new Error(
|
||||
"The global scope doesn't have a `Date` object" +
|
||||
" (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)",
|
||||
);
|
||||
}
|
||||
|
||||
const clock = {
|
||||
now: start,
|
||||
Date: createDate(),
|
||||
@@ -1165,14 +1191,14 @@ function withGlobal(_global) {
|
||||
return millis;
|
||||
}
|
||||
|
||||
if (hrtimeBigintPresent) {
|
||||
if (isPresent.hrtimeBigint) {
|
||||
hrtime.bigint = function () {
|
||||
const parts = hrtime();
|
||||
return BigInt(parts[0]) * BigInt(1e9) + BigInt(parts[1]); // eslint-disable-line
|
||||
};
|
||||
}
|
||||
|
||||
if (intlPresent) {
|
||||
if (isPresent.Intl) {
|
||||
clock.Intl = createIntl();
|
||||
clock.Intl.clock = clock;
|
||||
}
|
||||
@@ -1257,7 +1283,7 @@ function withGlobal(_global) {
|
||||
return clearTimer(clock, timerId, "Interval");
|
||||
};
|
||||
|
||||
if (setImmediatePresent) {
|
||||
if (isPresent.setImmediate) {
|
||||
clock.setImmediate = function setImmediate(func) {
|
||||
return addTimer(clock, {
|
||||
func: func,
|
||||
@@ -1696,12 +1722,12 @@ function withGlobal(_global) {
|
||||
clock.tick(ms);
|
||||
};
|
||||
|
||||
if (performancePresent) {
|
||||
if (isPresent.performance) {
|
||||
clock.performance = Object.create(null);
|
||||
clock.performance.now = fakePerformanceNow;
|
||||
}
|
||||
|
||||
if (hrtimePresent) {
|
||||
if (isPresent.hrtime) {
|
||||
clock.hrtime = hrtime;
|
||||
}
|
||||
|
||||
@@ -1749,6 +1775,20 @@ function withGlobal(_global) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} timer/object the name of the thing that is not present
|
||||
* @param timer
|
||||
*/
|
||||
function handleMissingTimer(timer) {
|
||||
if (config.ignoreMissingTimers) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new ReferenceError(
|
||||
`non-existent timers and/or objects cannot be faked: '${timer}'`,
|
||||
);
|
||||
}
|
||||
|
||||
let i, l;
|
||||
const clock = createClock(config.now, config.loopLimit);
|
||||
clock.shouldClearNativeTimers = config.shouldClearNativeTimers;
|
||||
@@ -1757,13 +1797,12 @@ function withGlobal(_global) {
|
||||
return uninstall(clock, config);
|
||||
};
|
||||
|
||||
clock.abortListenerMap = new Map();
|
||||
|
||||
clock.methods = config.toFake || [];
|
||||
|
||||
if (clock.methods.length === 0) {
|
||||
// do not fake nextTick by default - GitHub#126
|
||||
clock.methods = Object.keys(timers).filter(function (key) {
|
||||
return key !== "nextTick" && key !== "queueMicrotask";
|
||||
});
|
||||
clock.methods = Object.keys(timers);
|
||||
}
|
||||
|
||||
if (config.shouldAdvanceTime === true) {
|
||||
@@ -1797,18 +1836,30 @@ function withGlobal(_global) {
|
||||
: NOOP;
|
||||
}
|
||||
});
|
||||
// ensure `mark` returns a value that is valid
|
||||
clock.performance.mark = (name) =>
|
||||
new FakePerformanceEntry(name, "mark", 0, 0);
|
||||
clock.performance.measure = (name) =>
|
||||
new FakePerformanceEntry(name, "measure", 0, 100);
|
||||
} else if ((config.toFake || []).includes("performance")) {
|
||||
// user explicitly tried to fake performance when not present
|
||||
throw new ReferenceError(
|
||||
"non-existent performance object cannot be faked",
|
||||
);
|
||||
return handleMissingTimer("performance");
|
||||
}
|
||||
}
|
||||
if (_global === globalObject && timersModule) {
|
||||
clock.timersModuleMethods = [];
|
||||
}
|
||||
if (_global === globalObject && timersPromisesModule) {
|
||||
clock.timersPromisesModuleMethods = [];
|
||||
}
|
||||
for (i = 0, l = clock.methods.length; i < l; i++) {
|
||||
const nameOfMethodToReplace = clock.methods[i];
|
||||
|
||||
if (!isPresent[nameOfMethodToReplace]) {
|
||||
handleMissingTimer(nameOfMethodToReplace);
|
||||
// eslint-disable-next-line
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nameOfMethodToReplace === "hrtime") {
|
||||
if (
|
||||
_global.process &&
|
||||
@@ -1838,6 +1889,239 @@ function withGlobal(_global) {
|
||||
timersModule[nameOfMethodToReplace] =
|
||||
_global[nameOfMethodToReplace];
|
||||
}
|
||||
if (clock.timersPromisesModuleMethods !== undefined) {
|
||||
if (nameOfMethodToReplace === "setTimeout") {
|
||||
clock.timersPromisesModuleMethods.push({
|
||||
methodName: "setTimeout",
|
||||
original: timersPromisesModule.setTimeout,
|
||||
});
|
||||
|
||||
timersPromisesModule.setTimeout = (
|
||||
delay,
|
||||
value,
|
||||
options = {},
|
||||
) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const abort = () => {
|
||||
options.signal.removeEventListener(
|
||||
"abort",
|
||||
abort,
|
||||
);
|
||||
clock.abortListenerMap.delete(abort);
|
||||
|
||||
// This is safe, there is no code path that leads to this function
|
||||
// being invoked before handle has been assigned.
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
clock.clearTimeout(handle);
|
||||
reject(options.signal.reason);
|
||||
};
|
||||
|
||||
const handle = clock.setTimeout(() => {
|
||||
if (options.signal) {
|
||||
options.signal.removeEventListener(
|
||||
"abort",
|
||||
abort,
|
||||
);
|
||||
clock.abortListenerMap.delete(abort);
|
||||
}
|
||||
|
||||
resolve(value);
|
||||
}, delay);
|
||||
|
||||
if (options.signal) {
|
||||
if (options.signal.aborted) {
|
||||
abort();
|
||||
} else {
|
||||
options.signal.addEventListener(
|
||||
"abort",
|
||||
abort,
|
||||
);
|
||||
clock.abortListenerMap.set(
|
||||
abort,
|
||||
options.signal,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (nameOfMethodToReplace === "setImmediate") {
|
||||
clock.timersPromisesModuleMethods.push({
|
||||
methodName: "setImmediate",
|
||||
original: timersPromisesModule.setImmediate,
|
||||
});
|
||||
|
||||
timersPromisesModule.setImmediate = (value, options = {}) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const abort = () => {
|
||||
options.signal.removeEventListener(
|
||||
"abort",
|
||||
abort,
|
||||
);
|
||||
clock.abortListenerMap.delete(abort);
|
||||
|
||||
// This is safe, there is no code path that leads to this function
|
||||
// being invoked before handle has been assigned.
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
clock.clearImmediate(handle);
|
||||
reject(options.signal.reason);
|
||||
};
|
||||
|
||||
const handle = clock.setImmediate(() => {
|
||||
if (options.signal) {
|
||||
options.signal.removeEventListener(
|
||||
"abort",
|
||||
abort,
|
||||
);
|
||||
clock.abortListenerMap.delete(abort);
|
||||
}
|
||||
|
||||
resolve(value);
|
||||
});
|
||||
|
||||
if (options.signal) {
|
||||
if (options.signal.aborted) {
|
||||
abort();
|
||||
} else {
|
||||
options.signal.addEventListener(
|
||||
"abort",
|
||||
abort,
|
||||
);
|
||||
clock.abortListenerMap.set(
|
||||
abort,
|
||||
options.signal,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (nameOfMethodToReplace === "setInterval") {
|
||||
clock.timersPromisesModuleMethods.push({
|
||||
methodName: "setInterval",
|
||||
original: timersPromisesModule.setInterval,
|
||||
});
|
||||
|
||||
timersPromisesModule.setInterval = (
|
||||
delay,
|
||||
value,
|
||||
options = {},
|
||||
) => ({
|
||||
[Symbol.asyncIterator]: () => {
|
||||
const createResolvable = () => {
|
||||
let resolve, reject;
|
||||
const promise = new Promise((res, rej) => {
|
||||
resolve = res;
|
||||
reject = rej;
|
||||
});
|
||||
promise.resolve = resolve;
|
||||
promise.reject = reject;
|
||||
return promise;
|
||||
};
|
||||
|
||||
let done = false;
|
||||
let hasThrown = false;
|
||||
let returnCall;
|
||||
let nextAvailable = 0;
|
||||
const nextQueue = [];
|
||||
|
||||
const handle = clock.setInterval(() => {
|
||||
if (nextQueue.length > 0) {
|
||||
nextQueue.shift().resolve();
|
||||
} else {
|
||||
nextAvailable++;
|
||||
}
|
||||
}, delay);
|
||||
|
||||
const abort = () => {
|
||||
options.signal.removeEventListener(
|
||||
"abort",
|
||||
abort,
|
||||
);
|
||||
clock.abortListenerMap.delete(abort);
|
||||
|
||||
clock.clearInterval(handle);
|
||||
done = true;
|
||||
for (const resolvable of nextQueue) {
|
||||
resolvable.resolve();
|
||||
}
|
||||
};
|
||||
|
||||
if (options.signal) {
|
||||
if (options.signal.aborted) {
|
||||
done = true;
|
||||
} else {
|
||||
options.signal.addEventListener(
|
||||
"abort",
|
||||
abort,
|
||||
);
|
||||
clock.abortListenerMap.set(
|
||||
abort,
|
||||
options.signal,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
next: async () => {
|
||||
if (options.signal?.aborted && !hasThrown) {
|
||||
hasThrown = true;
|
||||
throw options.signal.reason;
|
||||
}
|
||||
|
||||
if (done) {
|
||||
return { done: true, value: undefined };
|
||||
}
|
||||
|
||||
if (nextAvailable > 0) {
|
||||
nextAvailable--;
|
||||
return { done: false, value: value };
|
||||
}
|
||||
|
||||
const resolvable = createResolvable();
|
||||
nextQueue.push(resolvable);
|
||||
|
||||
await resolvable;
|
||||
|
||||
if (returnCall && nextQueue.length === 0) {
|
||||
returnCall.resolve();
|
||||
}
|
||||
|
||||
if (options.signal?.aborted && !hasThrown) {
|
||||
hasThrown = true;
|
||||
throw options.signal.reason;
|
||||
}
|
||||
|
||||
if (done) {
|
||||
return { done: true, value: undefined };
|
||||
}
|
||||
|
||||
return { done: false, value: value };
|
||||
},
|
||||
return: async () => {
|
||||
if (done) {
|
||||
return { done: true, value: undefined };
|
||||
}
|
||||
|
||||
if (nextQueue.length > 0) {
|
||||
returnCall = createResolvable();
|
||||
await returnCall;
|
||||
}
|
||||
|
||||
clock.clearInterval(handle);
|
||||
done = true;
|
||||
|
||||
if (options.signal) {
|
||||
options.signal.removeEventListener(
|
||||
"abort",
|
||||
abort,
|
||||
);
|
||||
clock.abortListenerMap.delete(abort);
|
||||
}
|
||||
|
||||
return { done: true, value: undefined };
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return clock;
|
||||
|
||||
10
node_modules/@sinonjs/samsam/docs/index.md
generated
vendored
10
node_modules/@sinonjs/samsam/docs/index.md
generated
vendored
@@ -249,7 +249,7 @@ samsam.match(
|
||||
return "yeah";
|
||||
},
|
||||
},
|
||||
"Yeah!"
|
||||
"Yeah!",
|
||||
); // true
|
||||
```
|
||||
|
||||
@@ -278,7 +278,7 @@ samsam.match(
|
||||
return "yeah!";
|
||||
},
|
||||
},
|
||||
/yeah/
|
||||
/yeah/,
|
||||
); // true
|
||||
samsam.match(234, /[a-z]/); // false
|
||||
```
|
||||
@@ -296,7 +296,7 @@ samsam.match(
|
||||
return "42";
|
||||
},
|
||||
},
|
||||
42
|
||||
42,
|
||||
); // true
|
||||
samsam.match(234, 1234); // false
|
||||
```
|
||||
@@ -328,7 +328,7 @@ samsam.match(
|
||||
},
|
||||
function () {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// false
|
||||
@@ -367,7 +367,7 @@ samsam.match(
|
||||
},
|
||||
{
|
||||
name: "Chris",
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// false
|
||||
|
||||
219
node_modules/@sinonjs/samsam/lib/create-matcher.js
generated
vendored
219
node_modules/@sinonjs/samsam/lib/create-matcher.js
generated
vendored
@@ -44,7 +44,7 @@ function createMatcher(expectation, message) {
|
||||
|
||||
if (arguments.length > 2) {
|
||||
throw new TypeError(
|
||||
`Expected 1 or 2 arguments, received ${arguments.length}`
|
||||
`Expected 1 or 2 arguments, received ${arguments.length}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -89,9 +89,12 @@ createMatcher.falsy = createMatcher(function (actual) {
|
||||
}, "falsy");
|
||||
|
||||
createMatcher.same = function (expectation) {
|
||||
return createMatcher(function (actual) {
|
||||
return expectation === actual;
|
||||
}, `same(${valueToString(expectation)})`);
|
||||
return createMatcher(
|
||||
function (actual) {
|
||||
return expectation === actual;
|
||||
},
|
||||
`same(${valueToString(expectation)})`,
|
||||
);
|
||||
};
|
||||
|
||||
createMatcher.in = function (arrayOfExpectations) {
|
||||
@@ -99,11 +102,14 @@ createMatcher.in = function (arrayOfExpectations) {
|
||||
throw new TypeError("array expected");
|
||||
}
|
||||
|
||||
return createMatcher(function (actual) {
|
||||
return some(arrayOfExpectations, function (expectation) {
|
||||
return expectation === actual;
|
||||
});
|
||||
}, `in(${valueToString(arrayOfExpectations)})`);
|
||||
return createMatcher(
|
||||
function (actual) {
|
||||
return some(arrayOfExpectations, function (expectation) {
|
||||
return expectation === actual;
|
||||
});
|
||||
},
|
||||
`in(${valueToString(arrayOfExpectations)})`,
|
||||
);
|
||||
};
|
||||
|
||||
createMatcher.typeOf = function (type) {
|
||||
@@ -125,12 +131,15 @@ createMatcher.instanceOf = function (type) {
|
||||
type,
|
||||
Symbol.hasInstance,
|
||||
"type",
|
||||
"[Symbol.hasInstance]"
|
||||
"[Symbol.hasInstance]",
|
||||
);
|
||||
}
|
||||
return createMatcher(function (actual) {
|
||||
return actual instanceof type;
|
||||
}, `instanceOf(${functionName(type) || objectToString(type)})`);
|
||||
return createMatcher(
|
||||
function (actual) {
|
||||
return actual instanceof type;
|
||||
},
|
||||
`instanceOf(${functionName(type) || objectToString(type)})`,
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -259,111 +268,137 @@ createMatcher.some = function (predicate) {
|
||||
createMatcher.array = createMatcher.typeOf("array");
|
||||
|
||||
createMatcher.array.deepEquals = function (expectation) {
|
||||
return createMatcher(function (actual) {
|
||||
// Comparing lengths is the fastest way to spot a difference before iterating through every item
|
||||
var sameLength = actual.length === expectation.length;
|
||||
return (
|
||||
typeOf(actual) === "array" &&
|
||||
sameLength &&
|
||||
every(actual, function (element, index) {
|
||||
var expected = expectation[index];
|
||||
return typeOf(expected) === "array" &&
|
||||
typeOf(element) === "array"
|
||||
? createMatcher.array.deepEquals(expected).test(element)
|
||||
: deepEqual(expected, element);
|
||||
})
|
||||
);
|
||||
}, `deepEquals([${iterableToString(expectation)}])`);
|
||||
return createMatcher(
|
||||
function (actual) {
|
||||
// Comparing lengths is the fastest way to spot a difference before iterating through every item
|
||||
var sameLength = actual.length === expectation.length;
|
||||
return (
|
||||
typeOf(actual) === "array" &&
|
||||
sameLength &&
|
||||
every(actual, function (element, index) {
|
||||
var expected = expectation[index];
|
||||
return typeOf(expected) === "array" &&
|
||||
typeOf(element) === "array"
|
||||
? createMatcher.array.deepEquals(expected).test(element)
|
||||
: deepEqual(expected, element);
|
||||
})
|
||||
);
|
||||
},
|
||||
`deepEquals([${iterableToString(expectation)}])`,
|
||||
);
|
||||
};
|
||||
|
||||
createMatcher.array.startsWith = function (expectation) {
|
||||
return createMatcher(function (actual) {
|
||||
return (
|
||||
typeOf(actual) === "array" &&
|
||||
every(expectation, function (expectedElement, index) {
|
||||
return actual[index] === expectedElement;
|
||||
})
|
||||
);
|
||||
}, `startsWith([${iterableToString(expectation)}])`);
|
||||
return createMatcher(
|
||||
function (actual) {
|
||||
return (
|
||||
typeOf(actual) === "array" &&
|
||||
every(expectation, function (expectedElement, index) {
|
||||
return actual[index] === expectedElement;
|
||||
})
|
||||
);
|
||||
},
|
||||
`startsWith([${iterableToString(expectation)}])`,
|
||||
);
|
||||
};
|
||||
|
||||
createMatcher.array.endsWith = function (expectation) {
|
||||
return createMatcher(function (actual) {
|
||||
// This indicates the index in which we should start matching
|
||||
var offset = actual.length - expectation.length;
|
||||
return createMatcher(
|
||||
function (actual) {
|
||||
// This indicates the index in which we should start matching
|
||||
var offset = actual.length - expectation.length;
|
||||
|
||||
return (
|
||||
typeOf(actual) === "array" &&
|
||||
every(expectation, function (expectedElement, index) {
|
||||
return actual[offset + index] === expectedElement;
|
||||
})
|
||||
);
|
||||
}, `endsWith([${iterableToString(expectation)}])`);
|
||||
return (
|
||||
typeOf(actual) === "array" &&
|
||||
every(expectation, function (expectedElement, index) {
|
||||
return actual[offset + index] === expectedElement;
|
||||
})
|
||||
);
|
||||
},
|
||||
`endsWith([${iterableToString(expectation)}])`,
|
||||
);
|
||||
};
|
||||
|
||||
createMatcher.array.contains = function (expectation) {
|
||||
return createMatcher(function (actual) {
|
||||
return (
|
||||
typeOf(actual) === "array" &&
|
||||
every(expectation, function (expectedElement) {
|
||||
return arrayIndexOf(actual, expectedElement) !== -1;
|
||||
})
|
||||
);
|
||||
}, `contains([${iterableToString(expectation)}])`);
|
||||
return createMatcher(
|
||||
function (actual) {
|
||||
return (
|
||||
typeOf(actual) === "array" &&
|
||||
every(expectation, function (expectedElement) {
|
||||
return arrayIndexOf(actual, expectedElement) !== -1;
|
||||
})
|
||||
);
|
||||
},
|
||||
`contains([${iterableToString(expectation)}])`,
|
||||
);
|
||||
};
|
||||
|
||||
createMatcher.map = createMatcher.typeOf("map");
|
||||
|
||||
createMatcher.map.deepEquals = function mapDeepEquals(expectation) {
|
||||
return createMatcher(function (actual) {
|
||||
// Comparing lengths is the fastest way to spot a difference before iterating through every item
|
||||
var sameLength = actual.size === expectation.size;
|
||||
return (
|
||||
typeOf(actual) === "map" &&
|
||||
sameLength &&
|
||||
every(actual, function (element, key) {
|
||||
return expectation.has(key) && expectation.get(key) === element;
|
||||
})
|
||||
);
|
||||
}, `deepEquals(Map[${iterableToString(expectation)}])`);
|
||||
return createMatcher(
|
||||
function (actual) {
|
||||
// Comparing lengths is the fastest way to spot a difference before iterating through every item
|
||||
var sameLength = actual.size === expectation.size;
|
||||
return (
|
||||
typeOf(actual) === "map" &&
|
||||
sameLength &&
|
||||
every(actual, function (element, key) {
|
||||
return (
|
||||
expectation.has(key) && expectation.get(key) === element
|
||||
);
|
||||
})
|
||||
);
|
||||
},
|
||||
`deepEquals(Map[${iterableToString(expectation)}])`,
|
||||
);
|
||||
};
|
||||
|
||||
createMatcher.map.contains = function mapContains(expectation) {
|
||||
return createMatcher(function (actual) {
|
||||
return (
|
||||
typeOf(actual) === "map" &&
|
||||
every(expectation, function (element, key) {
|
||||
return actual.has(key) && actual.get(key) === element;
|
||||
})
|
||||
);
|
||||
}, `contains(Map[${iterableToString(expectation)}])`);
|
||||
return createMatcher(
|
||||
function (actual) {
|
||||
return (
|
||||
typeOf(actual) === "map" &&
|
||||
every(expectation, function (element, key) {
|
||||
return actual.has(key) && actual.get(key) === element;
|
||||
})
|
||||
);
|
||||
},
|
||||
`contains(Map[${iterableToString(expectation)}])`,
|
||||
);
|
||||
};
|
||||
|
||||
createMatcher.set = createMatcher.typeOf("set");
|
||||
|
||||
createMatcher.set.deepEquals = function setDeepEquals(expectation) {
|
||||
return createMatcher(function (actual) {
|
||||
// Comparing lengths is the fastest way to spot a difference before iterating through every item
|
||||
var sameLength = actual.size === expectation.size;
|
||||
return (
|
||||
typeOf(actual) === "set" &&
|
||||
sameLength &&
|
||||
every(actual, function (element) {
|
||||
return expectation.has(element);
|
||||
})
|
||||
);
|
||||
}, `deepEquals(Set[${iterableToString(expectation)}])`);
|
||||
return createMatcher(
|
||||
function (actual) {
|
||||
// Comparing lengths is the fastest way to spot a difference before iterating through every item
|
||||
var sameLength = actual.size === expectation.size;
|
||||
return (
|
||||
typeOf(actual) === "set" &&
|
||||
sameLength &&
|
||||
every(actual, function (element) {
|
||||
return expectation.has(element);
|
||||
})
|
||||
);
|
||||
},
|
||||
`deepEquals(Set[${iterableToString(expectation)}])`,
|
||||
);
|
||||
};
|
||||
|
||||
createMatcher.set.contains = function setContains(expectation) {
|
||||
return createMatcher(function (actual) {
|
||||
return (
|
||||
typeOf(actual) === "set" &&
|
||||
every(expectation, function (element) {
|
||||
return actual.has(element);
|
||||
})
|
||||
);
|
||||
}, `contains(Set[${iterableToString(expectation)}])`);
|
||||
return createMatcher(
|
||||
function (actual) {
|
||||
return (
|
||||
typeOf(actual) === "set" &&
|
||||
every(expectation, function (element) {
|
||||
return actual.has(element);
|
||||
})
|
||||
);
|
||||
},
|
||||
`contains(Set[${iterableToString(expectation)}])`,
|
||||
);
|
||||
};
|
||||
|
||||
createMatcher.bool = createMatcher.typeOf("boolean");
|
||||
|
||||
2
node_modules/@sinonjs/samsam/lib/create-matcher/assert-type.js
generated
vendored
2
node_modules/@sinonjs/samsam/lib/create-matcher/assert-type.js
generated
vendored
@@ -16,7 +16,7 @@ function assertType(value, type, name) {
|
||||
var actual = typeOf(value);
|
||||
if (actual !== type) {
|
||||
throw new TypeError(
|
||||
`Expected type of ${name} to be ${type}, but was ${actual}`
|
||||
`Expected type of ${name} to be ${type}, but was ${actual}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
4
node_modules/@sinonjs/samsam/lib/create-matcher/match-object.js
generated
vendored
4
node_modules/@sinonjs/samsam/lib/create-matcher/match-object.js
generated
vendored
@@ -6,6 +6,7 @@ var typeOf = require("@sinonjs/commons").typeOf;
|
||||
|
||||
var deepEqualFactory = require("../deep-equal").use;
|
||||
|
||||
var identical = require("../identical");
|
||||
var isMatcher = require("./is-matcher");
|
||||
|
||||
var keys = Object.keys;
|
||||
@@ -41,6 +42,9 @@ function matchObject(actual, expectation, matcher) {
|
||||
return false;
|
||||
}
|
||||
} else if (typeOf(exp) === "object") {
|
||||
if (identical(exp, act)) {
|
||||
return true;
|
||||
}
|
||||
if (!matchObject(act, exp, matcher)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
2
node_modules/@sinonjs/samsam/lib/create-set.js
generated
vendored
2
node_modules/@sinonjs/samsam/lib/create-set.js
generated
vendored
@@ -17,7 +17,7 @@ var forEach = require("@sinonjs/commons").prototypes.array.forEach;
|
||||
function createSet(array) {
|
||||
if (arguments.length > 0 && !Array.isArray(array)) {
|
||||
throw new TypeError(
|
||||
"createSet can be called with either no arguments or an Array"
|
||||
"createSet can be called with either no arguments or an Array",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
6
node_modules/@sinonjs/samsam/lib/deep-equal.js
generated
vendored
6
node_modules/@sinonjs/samsam/lib/deep-equal.js
generated
vendored
@@ -67,7 +67,7 @@ function deepEqualCyclic(actual, expectation, match) {
|
||||
actualObj,
|
||||
expectationObj,
|
||||
actualPath,
|
||||
expectationPath
|
||||
expectationPath,
|
||||
) {
|
||||
// If both are matchers they must be the same instance in order to be
|
||||
// considered equal If we didn't do that we would end up running one
|
||||
@@ -140,7 +140,7 @@ function deepEqualCyclic(actual, expectation, match) {
|
||||
[];
|
||||
var expectationKeysAndSymbols = concat(
|
||||
expectationKeys,
|
||||
expectationSymbols
|
||||
expectationSymbols,
|
||||
);
|
||||
|
||||
if (isArguments(actualObj) || isArguments(expectationObj)) {
|
||||
@@ -289,7 +289,7 @@ function deepEqualCyclic(actual, expectation, match) {
|
||||
actualValue,
|
||||
expectationValue,
|
||||
newActualPath,
|
||||
newExpectationPath
|
||||
newExpectationPath,
|
||||
);
|
||||
});
|
||||
})(actual, expectation, "$1", "$2");
|
||||
|
||||
6
node_modules/@sinonjs/samsam/lib/match.js
generated
vendored
6
node_modules/@sinonjs/samsam/lib/match.js
generated
vendored
@@ -70,7 +70,7 @@ function match(object, matcherOrValue) {
|
||||
notNull &&
|
||||
indexOf(
|
||||
valueToString(object).toLowerCase(),
|
||||
matcherOrValue.toLowerCase()
|
||||
matcherOrValue.toLowerCase(),
|
||||
) >= 0
|
||||
);
|
||||
case "null":
|
||||
@@ -102,7 +102,7 @@ function match(object, matcherOrValue) {
|
||||
/* istanbul ignore next: this is covered by a test, that is only run in IE, but we collect coverage information in node*/
|
||||
if (!engineCanCompareMaps) {
|
||||
throw new Error(
|
||||
"The JavaScript engine does not support Array.from and cannot reliably do value comparison of Map instances"
|
||||
"The JavaScript engine does not support Array.from and cannot reliably do value comparison of Map instances",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ function match(object, matcherOrValue) {
|
||||
arrayContains(
|
||||
Array.from(object),
|
||||
Array.from(matcherOrValue),
|
||||
match
|
||||
match,
|
||||
)
|
||||
);
|
||||
default:
|
||||
|
||||
29
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/LICENSE
generated
vendored
29
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/LICENSE
generated
vendored
@@ -1,29 +0,0 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2018, Sinon.JS
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
16
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/README.md
generated
vendored
16
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/README.md
generated
vendored
@@ -1,16 +0,0 @@
|
||||
# commons
|
||||
|
||||
[](https://circleci.com/gh/sinonjs/commons)
|
||||
[](https://codecov.io/gh/sinonjs/commons)
|
||||
<a href="CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg" alt="Contributor Covenant" /></a>
|
||||
|
||||
Simple functions shared among the sinon end user libraries
|
||||
|
||||
## Rules
|
||||
|
||||
- Follows the [Sinon.JS compatibility](https://github.com/sinonjs/sinon/blob/master/CONTRIBUTING.md#compatibility)
|
||||
- 100% test coverage
|
||||
- Code formatted using [Prettier](https://prettier.io)
|
||||
- No side effects welcome! (only pure functions)
|
||||
- No platform specific functions
|
||||
- One export per file (any bundler can do tree shaking)
|
||||
57
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/called-in-order.js
generated
vendored
57
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/called-in-order.js
generated
vendored
@@ -1,57 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var every = require("./prototypes/array").every;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
function hasCallsLeft(callMap, spy) {
|
||||
if (callMap[spy.id] === undefined) {
|
||||
callMap[spy.id] = 0;
|
||||
}
|
||||
|
||||
return callMap[spy.id] < spy.callCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
function checkAdjacentCalls(callMap, spy, index, spies) {
|
||||
var calledBeforeNext = true;
|
||||
|
||||
if (index !== spies.length - 1) {
|
||||
calledBeforeNext = spy.calledBefore(spies[index + 1]);
|
||||
}
|
||||
|
||||
if (hasCallsLeft(callMap, spy) && calledBeforeNext) {
|
||||
callMap[spy.id] += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Sinon proxy object (fake, spy, stub)
|
||||
*
|
||||
* @typedef {object} SinonProxy
|
||||
* @property {Function} calledBefore - A method that determines if this proxy was called before another one
|
||||
* @property {string} id - Some id
|
||||
* @property {number} callCount - Number of times this proxy has been called
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns true when the spies have been called in the order they were supplied in
|
||||
*
|
||||
* @param {SinonProxy[] | SinonProxy} spies An array of proxies, or several proxies as arguments
|
||||
* @returns {boolean} true when spies are called in order, false otherwise
|
||||
*/
|
||||
function calledInOrder(spies) {
|
||||
var callMap = {};
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
var _spies = arguments.length > 1 ? arguments : spies;
|
||||
|
||||
return every(_spies, checkAdjacentCalls.bind(null, callMap));
|
||||
}
|
||||
|
||||
module.exports = calledInOrder;
|
||||
121
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/called-in-order.test.js
generated
vendored
121
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/called-in-order.test.js
generated
vendored
@@ -1,121 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var assert = require("@sinonjs/referee-sinon").assert;
|
||||
var calledInOrder = require("./called-in-order");
|
||||
var sinon = require("@sinonjs/referee-sinon").sinon;
|
||||
|
||||
var testObject1 = {
|
||||
someFunction: function () {
|
||||
return;
|
||||
},
|
||||
};
|
||||
var testObject2 = {
|
||||
otherFunction: function () {
|
||||
return;
|
||||
},
|
||||
};
|
||||
var testObject3 = {
|
||||
thirdFunction: function () {
|
||||
return;
|
||||
},
|
||||
};
|
||||
|
||||
function testMethod() {
|
||||
testObject1.someFunction();
|
||||
testObject2.otherFunction();
|
||||
testObject2.otherFunction();
|
||||
testObject2.otherFunction();
|
||||
testObject3.thirdFunction();
|
||||
}
|
||||
|
||||
describe("calledInOrder", function () {
|
||||
beforeEach(function () {
|
||||
sinon.stub(testObject1, "someFunction");
|
||||
sinon.stub(testObject2, "otherFunction");
|
||||
sinon.stub(testObject3, "thirdFunction");
|
||||
testMethod();
|
||||
});
|
||||
afterEach(function () {
|
||||
testObject1.someFunction.restore();
|
||||
testObject2.otherFunction.restore();
|
||||
testObject3.thirdFunction.restore();
|
||||
});
|
||||
|
||||
describe("given single array argument", function () {
|
||||
describe("when stubs were called in expected order", function () {
|
||||
it("returns true", function () {
|
||||
assert.isTrue(
|
||||
calledInOrder([
|
||||
testObject1.someFunction,
|
||||
testObject2.otherFunction,
|
||||
])
|
||||
);
|
||||
assert.isTrue(
|
||||
calledInOrder([
|
||||
testObject1.someFunction,
|
||||
testObject2.otherFunction,
|
||||
testObject2.otherFunction,
|
||||
testObject3.thirdFunction,
|
||||
])
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when stubs were called in unexpected order", function () {
|
||||
it("returns false", function () {
|
||||
assert.isFalse(
|
||||
calledInOrder([
|
||||
testObject2.otherFunction,
|
||||
testObject1.someFunction,
|
||||
])
|
||||
);
|
||||
assert.isFalse(
|
||||
calledInOrder([
|
||||
testObject2.otherFunction,
|
||||
testObject1.someFunction,
|
||||
testObject1.someFunction,
|
||||
testObject3.thirdFunction,
|
||||
])
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("given multiple arguments", function () {
|
||||
describe("when stubs were called in expected order", function () {
|
||||
it("returns true", function () {
|
||||
assert.isTrue(
|
||||
calledInOrder(
|
||||
testObject1.someFunction,
|
||||
testObject2.otherFunction
|
||||
)
|
||||
);
|
||||
assert.isTrue(
|
||||
calledInOrder(
|
||||
testObject1.someFunction,
|
||||
testObject2.otherFunction,
|
||||
testObject3.thirdFunction
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when stubs were called in unexpected order", function () {
|
||||
it("returns false", function () {
|
||||
assert.isFalse(
|
||||
calledInOrder(
|
||||
testObject2.otherFunction,
|
||||
testObject1.someFunction
|
||||
)
|
||||
);
|
||||
assert.isFalse(
|
||||
calledInOrder(
|
||||
testObject2.otherFunction,
|
||||
testObject1.someFunction,
|
||||
testObject3.thirdFunction
|
||||
)
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
27
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/class-name.js
generated
vendored
27
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/class-name.js
generated
vendored
@@ -1,27 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var functionName = require("./function-name");
|
||||
|
||||
/**
|
||||
* Returns a display name for a value from a constructor
|
||||
*
|
||||
* @param {object} value A value to examine
|
||||
* @returns {(string|null)} A string or null
|
||||
*/
|
||||
function className(value) {
|
||||
return (
|
||||
(value.constructor && value.constructor.name) ||
|
||||
// The next branch is for IE11 support only:
|
||||
// Because the name property is not set on the prototype
|
||||
// of the Function object, we finally try to grab the
|
||||
// name from its definition. This will never be reached
|
||||
// in node, so we are not able to test this properly.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
|
||||
(typeof value.constructor === "function" &&
|
||||
/* istanbul ignore next */
|
||||
functionName(value.constructor)) ||
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = className;
|
||||
37
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/class-name.test.js
generated
vendored
37
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/class-name.test.js
generated
vendored
@@ -1,37 +0,0 @@
|
||||
"use strict";
|
||||
/* eslint-disable no-empty-function */
|
||||
|
||||
var assert = require("@sinonjs/referee").assert;
|
||||
var className = require("./class-name");
|
||||
|
||||
describe("className", function () {
|
||||
it("returns the class name of an instance", function () {
|
||||
// Because eslint-config-sinon disables es6, we can't
|
||||
// use a class definition here
|
||||
// https://github.com/sinonjs/eslint-config-sinon/blob/master/index.js
|
||||
// var instance = new (class TestClass {})();
|
||||
var instance = new (function TestClass() {})();
|
||||
var name = className(instance);
|
||||
assert.equals(name, "TestClass");
|
||||
});
|
||||
|
||||
it("returns 'Object' for {}", function () {
|
||||
var name = className({});
|
||||
assert.equals(name, "Object");
|
||||
});
|
||||
|
||||
it("returns null for an object that has no prototype", function () {
|
||||
var obj = Object.create(null);
|
||||
var name = className(obj);
|
||||
assert.equals(name, null);
|
||||
});
|
||||
|
||||
it("returns null for an object whose prototype was mangled", function () {
|
||||
// This is what Node v6 and v7 do for objects returned by querystring.parse()
|
||||
function MangledObject() {}
|
||||
MangledObject.prototype = Object.create(null);
|
||||
var obj = new MangledObject();
|
||||
var name = className(obj);
|
||||
assert.equals(name, null);
|
||||
});
|
||||
});
|
||||
51
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/deprecated.js
generated
vendored
51
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/deprecated.js
generated
vendored
@@ -1,51 +0,0 @@
|
||||
/* eslint-disable no-console */
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Returns a function that will invoke the supplied function and print a
|
||||
* deprecation warning to the console each time it is called.
|
||||
*
|
||||
* @param {Function} func
|
||||
* @param {string} msg
|
||||
* @returns {Function}
|
||||
*/
|
||||
exports.wrap = function (func, msg) {
|
||||
var wrapped = function () {
|
||||
exports.printWarning(msg);
|
||||
return func.apply(this, arguments);
|
||||
};
|
||||
if (func.prototype) {
|
||||
wrapped.prototype = func.prototype;
|
||||
}
|
||||
return wrapped;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a string which can be supplied to `wrap()` to notify the user that a
|
||||
* particular part of the sinon API has been deprecated.
|
||||
*
|
||||
* @param {string} packageName
|
||||
* @param {string} funcName
|
||||
* @returns {string}
|
||||
*/
|
||||
exports.defaultMsg = function (packageName, funcName) {
|
||||
return `${packageName}.${funcName} is deprecated and will be removed from the public API in a future version of ${packageName}.`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Prints a warning on the console, when it exists
|
||||
*
|
||||
* @param {string} msg
|
||||
* @returns {undefined}
|
||||
*/
|
||||
exports.printWarning = function (msg) {
|
||||
/* istanbul ignore next */
|
||||
if (typeof process === "object" && process.emitWarning) {
|
||||
// Emit Warnings in Node
|
||||
process.emitWarning(msg);
|
||||
} else if (console.info) {
|
||||
console.info(msg);
|
||||
} else {
|
||||
console.log(msg);
|
||||
}
|
||||
};
|
||||
101
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/deprecated.test.js
generated
vendored
101
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/deprecated.test.js
generated
vendored
@@ -1,101 +0,0 @@
|
||||
/* eslint-disable no-console */
|
||||
"use strict";
|
||||
|
||||
var assert = require("@sinonjs/referee-sinon").assert;
|
||||
var sinon = require("@sinonjs/referee-sinon").sinon;
|
||||
|
||||
var deprecated = require("./deprecated");
|
||||
|
||||
var msg = "test";
|
||||
|
||||
describe("deprecated", function () {
|
||||
describe("defaultMsg", function () {
|
||||
it("should return a string", function () {
|
||||
assert.equals(
|
||||
deprecated.defaultMsg("sinon", "someFunc"),
|
||||
"sinon.someFunc is deprecated and will be removed from the public API in a future version of sinon."
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("printWarning", function () {
|
||||
beforeEach(function () {
|
||||
sinon.replace(process, "emitWarning", sinon.fake());
|
||||
});
|
||||
|
||||
afterEach(sinon.restore);
|
||||
|
||||
describe("when `process.emitWarning` is defined", function () {
|
||||
it("should call process.emitWarning with a msg", function () {
|
||||
deprecated.printWarning(msg);
|
||||
assert.calledOnceWith(process.emitWarning, msg);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when `process.emitWarning` is undefined", function () {
|
||||
beforeEach(function () {
|
||||
sinon.replace(console, "info", sinon.fake());
|
||||
sinon.replace(console, "log", sinon.fake());
|
||||
process.emitWarning = undefined;
|
||||
});
|
||||
|
||||
afterEach(sinon.restore);
|
||||
|
||||
describe("when `console.info` is defined", function () {
|
||||
it("should call `console.info` with a message", function () {
|
||||
deprecated.printWarning(msg);
|
||||
assert.calledOnceWith(console.info, msg);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when `console.info` is undefined", function () {
|
||||
it("should call `console.log` with a message", function () {
|
||||
console.info = undefined;
|
||||
deprecated.printWarning(msg);
|
||||
assert.calledOnceWith(console.log, msg);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("wrap", function () {
|
||||
// eslint-disable-next-line mocha/no-setup-in-describe
|
||||
var method = sinon.fake();
|
||||
var wrapped;
|
||||
|
||||
beforeEach(function () {
|
||||
wrapped = deprecated.wrap(method, msg);
|
||||
});
|
||||
|
||||
it("should return a wrapper function", function () {
|
||||
assert.match(wrapped, sinon.match.func);
|
||||
});
|
||||
|
||||
it("should assign the prototype of the passed method", function () {
|
||||
assert.equals(method.prototype, wrapped.prototype);
|
||||
});
|
||||
|
||||
context("when the passed method has falsy prototype", function () {
|
||||
it("should not be assigned to the wrapped method", function () {
|
||||
method.prototype = null;
|
||||
wrapped = deprecated.wrap(method, msg);
|
||||
assert.match(wrapped.prototype, sinon.match.object);
|
||||
});
|
||||
});
|
||||
|
||||
context("when invoking the wrapped function", function () {
|
||||
before(function () {
|
||||
sinon.replace(deprecated, "printWarning", sinon.fake());
|
||||
wrapped({});
|
||||
});
|
||||
|
||||
it("should call `printWarning` before invoking", function () {
|
||||
assert.calledOnceWith(deprecated.printWarning, msg);
|
||||
});
|
||||
|
||||
it("should invoke the passed method with the given arguments", function () {
|
||||
assert.calledOnceWith(method, {});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
27
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/every.js
generated
vendored
27
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/every.js
generated
vendored
@@ -1,27 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Returns true when fn returns true for all members of obj.
|
||||
* This is an every implementation that works for all iterables
|
||||
*
|
||||
* @param {object} obj
|
||||
* @param {Function} fn
|
||||
* @returns {boolean}
|
||||
*/
|
||||
module.exports = function every(obj, fn) {
|
||||
var pass = true;
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line @sinonjs/no-prototype-methods/no-prototype-methods
|
||||
obj.forEach(function () {
|
||||
if (!fn.apply(this, arguments)) {
|
||||
// Throwing an error is the only way to break `forEach`
|
||||
throw new Error();
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
pass = false;
|
||||
}
|
||||
|
||||
return pass;
|
||||
};
|
||||
41
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/every.test.js
generated
vendored
41
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/every.test.js
generated
vendored
@@ -1,41 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var assert = require("@sinonjs/referee-sinon").assert;
|
||||
var sinon = require("@sinonjs/referee-sinon").sinon;
|
||||
var every = require("./every");
|
||||
|
||||
describe("util/core/every", function () {
|
||||
it("returns true when the callback function returns true for every element in an iterable", function () {
|
||||
var obj = [true, true, true, true];
|
||||
var allTrue = every(obj, function (val) {
|
||||
return val;
|
||||
});
|
||||
|
||||
assert(allTrue);
|
||||
});
|
||||
|
||||
it("returns false when the callback function returns false for any element in an iterable", function () {
|
||||
var obj = [true, true, true, false];
|
||||
var result = every(obj, function (val) {
|
||||
return val;
|
||||
});
|
||||
|
||||
assert.isFalse(result);
|
||||
});
|
||||
|
||||
it("calls the given callback once for each item in an iterable until it returns false", function () {
|
||||
var iterableOne = [true, true, true, true];
|
||||
var iterableTwo = [true, true, false, true];
|
||||
var callback = sinon.spy(function (val) {
|
||||
return val;
|
||||
});
|
||||
|
||||
every(iterableOne, callback);
|
||||
assert.equals(callback.callCount, 4);
|
||||
|
||||
callback.resetHistory();
|
||||
|
||||
every(iterableTwo, callback);
|
||||
assert.equals(callback.callCount, 3);
|
||||
});
|
||||
});
|
||||
29
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/function-name.js
generated
vendored
29
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/function-name.js
generated
vendored
@@ -1,29 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Returns a display name for a function
|
||||
*
|
||||
* @param {Function} func
|
||||
* @returns {string}
|
||||
*/
|
||||
module.exports = function functionName(func) {
|
||||
if (!func) {
|
||||
return "";
|
||||
}
|
||||
|
||||
try {
|
||||
return (
|
||||
func.displayName ||
|
||||
func.name ||
|
||||
// Use function decomposition as a last resort to get function
|
||||
// name. Does not rely on function decomposition to work - if it
|
||||
// doesn't debugging will be slightly less informative
|
||||
// (i.e. toString will say 'spy' rather than 'myFunc').
|
||||
(String(func).match(/function ([^\s(]+)/) || [])[1]
|
||||
);
|
||||
} catch (e) {
|
||||
// Stringify may fail and we might get an exception, as a last-last
|
||||
// resort fall back to empty string.
|
||||
return "";
|
||||
}
|
||||
};
|
||||
76
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/function-name.test.js
generated
vendored
76
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/function-name.test.js
generated
vendored
@@ -1,76 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var jsc = require("jsverify");
|
||||
var refute = require("@sinonjs/referee-sinon").refute;
|
||||
|
||||
var functionName = require("./function-name");
|
||||
|
||||
describe("function-name", function () {
|
||||
it("should return empty string if func is falsy", function () {
|
||||
jsc.assertForall("falsy", function (fn) {
|
||||
return functionName(fn) === "";
|
||||
});
|
||||
});
|
||||
|
||||
it("should use displayName by default", function () {
|
||||
jsc.assertForall("nestring", function (displayName) {
|
||||
var fn = { displayName: displayName };
|
||||
|
||||
return functionName(fn) === fn.displayName;
|
||||
});
|
||||
});
|
||||
|
||||
it("should use name if displayName is not available", function () {
|
||||
jsc.assertForall("nestring", function (name) {
|
||||
var fn = { name: name };
|
||||
|
||||
return functionName(fn) === fn.name;
|
||||
});
|
||||
});
|
||||
|
||||
it("should fallback to string parsing", function () {
|
||||
jsc.assertForall("nat", function (naturalNumber) {
|
||||
var name = `fn${naturalNumber}`;
|
||||
var fn = {
|
||||
toString: function () {
|
||||
return `\nfunction ${name}`;
|
||||
},
|
||||
};
|
||||
|
||||
return functionName(fn) === name;
|
||||
});
|
||||
});
|
||||
|
||||
it("should not fail when a name cannot be found", function () {
|
||||
refute.exception(function () {
|
||||
var fn = {
|
||||
toString: function () {
|
||||
return "\nfunction (";
|
||||
},
|
||||
};
|
||||
|
||||
functionName(fn);
|
||||
});
|
||||
});
|
||||
|
||||
it("should not fail when toString is undefined", function () {
|
||||
refute.exception(function () {
|
||||
functionName(Object.create(null));
|
||||
});
|
||||
});
|
||||
|
||||
it("should not fail when toString throws", function () {
|
||||
refute.exception(function () {
|
||||
var fn;
|
||||
try {
|
||||
// eslint-disable-next-line no-eval
|
||||
fn = eval("(function*() {})")().constructor;
|
||||
} catch (e) {
|
||||
// env doesn't support generators
|
||||
return;
|
||||
}
|
||||
|
||||
functionName(fn);
|
||||
});
|
||||
});
|
||||
});
|
||||
22
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/global.js
generated
vendored
22
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/global.js
generated
vendored
@@ -1,22 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* A reference to the global object
|
||||
*
|
||||
* @type {object} globalObject
|
||||
*/
|
||||
var globalObject;
|
||||
|
||||
/* istanbul ignore else */
|
||||
if (typeof global !== "undefined") {
|
||||
// Node
|
||||
globalObject = global;
|
||||
} else if (typeof window !== "undefined") {
|
||||
// Browser
|
||||
globalObject = window;
|
||||
} else {
|
||||
// WebWorker
|
||||
globalObject = self;
|
||||
}
|
||||
|
||||
module.exports = globalObject;
|
||||
16
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/global.test.js
generated
vendored
16
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/global.test.js
generated
vendored
@@ -1,16 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var assert = require("@sinonjs/referee-sinon").assert;
|
||||
var globalObject = require("./global");
|
||||
|
||||
describe("global", function () {
|
||||
before(function () {
|
||||
if (typeof global === "undefined") {
|
||||
this.skip();
|
||||
}
|
||||
});
|
||||
|
||||
it("is same as global", function () {
|
||||
assert.same(globalObject, global);
|
||||
});
|
||||
});
|
||||
14
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/index.js
generated
vendored
14
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/index.js
generated
vendored
@@ -1,14 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
global: require("./global"),
|
||||
calledInOrder: require("./called-in-order"),
|
||||
className: require("./class-name"),
|
||||
deprecated: require("./deprecated"),
|
||||
every: require("./every"),
|
||||
functionName: require("./function-name"),
|
||||
orderByFirstCall: require("./order-by-first-call"),
|
||||
prototypes: require("./prototypes"),
|
||||
typeOf: require("./type-of"),
|
||||
valueToString: require("./value-to-string"),
|
||||
};
|
||||
31
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/index.test.js
generated
vendored
31
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/index.test.js
generated
vendored
@@ -1,31 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var assert = require("@sinonjs/referee-sinon").assert;
|
||||
var index = require("./index");
|
||||
|
||||
var expectedMethods = [
|
||||
"calledInOrder",
|
||||
"className",
|
||||
"every",
|
||||
"functionName",
|
||||
"orderByFirstCall",
|
||||
"typeOf",
|
||||
"valueToString",
|
||||
];
|
||||
var expectedObjectProperties = ["deprecated", "prototypes"];
|
||||
|
||||
describe("package", function () {
|
||||
// eslint-disable-next-line mocha/no-setup-in-describe
|
||||
expectedMethods.forEach(function (name) {
|
||||
it(`should export a method named ${name}`, function () {
|
||||
assert.isFunction(index[name]);
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line mocha/no-setup-in-describe
|
||||
expectedObjectProperties.forEach(function (name) {
|
||||
it(`should export an object property named ${name}`, function () {
|
||||
assert.isObject(index[name]);
|
||||
});
|
||||
});
|
||||
});
|
||||
36
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/order-by-first-call.js
generated
vendored
36
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/order-by-first-call.js
generated
vendored
@@ -1,36 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var sort = require("./prototypes/array").sort;
|
||||
var slice = require("./prototypes/array").slice;
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
function comparator(a, b) {
|
||||
// uuid, won't ever be equal
|
||||
var aCall = a.getCall(0);
|
||||
var bCall = b.getCall(0);
|
||||
var aId = (aCall && aCall.callId) || -1;
|
||||
var bId = (bCall && bCall.callId) || -1;
|
||||
|
||||
return aId < bId ? -1 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Sinon proxy object (fake, spy, stub)
|
||||
*
|
||||
* @typedef {object} SinonProxy
|
||||
* @property {Function} getCall - A method that can return the first call
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sorts an array of SinonProxy instances (fake, spy, stub) by their first call
|
||||
*
|
||||
* @param {SinonProxy[] | SinonProxy} spies
|
||||
* @returns {SinonProxy[]}
|
||||
*/
|
||||
function orderByFirstCall(spies) {
|
||||
return sort(slice(spies), comparator);
|
||||
}
|
||||
|
||||
module.exports = orderByFirstCall;
|
||||
@@ -1,52 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var assert = require("@sinonjs/referee-sinon").assert;
|
||||
var knuthShuffle = require("knuth-shuffle").knuthShuffle;
|
||||
var sinon = require("@sinonjs/referee-sinon").sinon;
|
||||
var orderByFirstCall = require("./order-by-first-call");
|
||||
|
||||
describe("orderByFirstCall", function () {
|
||||
it("should order an Array of spies by the callId of the first call, ascending", function () {
|
||||
// create an array of spies
|
||||
var spies = [
|
||||
sinon.spy(),
|
||||
sinon.spy(),
|
||||
sinon.spy(),
|
||||
sinon.spy(),
|
||||
sinon.spy(),
|
||||
sinon.spy(),
|
||||
];
|
||||
|
||||
// call all the spies
|
||||
spies.forEach(function (spy) {
|
||||
spy();
|
||||
});
|
||||
|
||||
// add a few uncalled spies
|
||||
spies.push(sinon.spy());
|
||||
spies.push(sinon.spy());
|
||||
|
||||
// randomise the order of the spies
|
||||
knuthShuffle(spies);
|
||||
|
||||
var sortedSpies = orderByFirstCall(spies);
|
||||
|
||||
assert.equals(sortedSpies.length, spies.length);
|
||||
|
||||
var orderedByFirstCall = sortedSpies.every(function (spy, index) {
|
||||
if (index + 1 === sortedSpies.length) {
|
||||
return true;
|
||||
}
|
||||
var nextSpy = sortedSpies[index + 1];
|
||||
|
||||
// uncalled spies should be ordered first
|
||||
if (!spy.called) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return spy.calledImmediatelyBefore(nextSpy);
|
||||
});
|
||||
|
||||
assert.isTrue(orderedByFirstCall);
|
||||
});
|
||||
});
|
||||
43
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/README.md
generated
vendored
43
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/README.md
generated
vendored
@@ -1,43 +0,0 @@
|
||||
# Prototypes
|
||||
|
||||
The functions in this folder are to be use for keeping cached references to the built-in prototypes, so that people can't inadvertently break the library by making mistakes in userland.
|
||||
|
||||
See https://github.com/sinonjs/sinon/pull/1523
|
||||
|
||||
## Without cached references
|
||||
|
||||
```js
|
||||
// in userland, the library user needs to replace the filter method on
|
||||
// Array.prototype
|
||||
var array = [1, 2, 3];
|
||||
sinon.replace(array, "filter", sinon.fake.returns(2));
|
||||
|
||||
// in a sinon module, the library author needs to use the filter method
|
||||
var someArray = ["a", "b", 42, "c"];
|
||||
var answer = filter(someArray, function (v) {
|
||||
return v === 42;
|
||||
});
|
||||
|
||||
console.log(answer);
|
||||
// => 2
|
||||
```
|
||||
|
||||
## With cached references
|
||||
|
||||
```js
|
||||
// in userland, the library user needs to replace the filter method on
|
||||
// Array.prototype
|
||||
var array = [1, 2, 3];
|
||||
sinon.replace(array, "filter", sinon.fake.returns(2));
|
||||
|
||||
// in a sinon module, the library author needs to use the filter method
|
||||
// get a reference to the original Array.prototype.filter
|
||||
var filter = require("@sinonjs/commons").prototypes.array.filter;
|
||||
var someArray = ["a", "b", 42, "c"];
|
||||
var answer = filter(someArray, function (v) {
|
||||
return v === 42;
|
||||
});
|
||||
|
||||
console.log(answer);
|
||||
// => 42
|
||||
```
|
||||
5
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/array.js
generated
vendored
5
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/array.js
generated
vendored
@@ -1,5 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var copyPrototype = require("./copy-prototype-methods");
|
||||
|
||||
module.exports = copyPrototype(Array.prototype);
|
||||
@@ -1,40 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var call = Function.call;
|
||||
var throwsOnProto = require("./throws-on-proto");
|
||||
|
||||
var disallowedProperties = [
|
||||
// ignore size because it throws from Map
|
||||
"size",
|
||||
"caller",
|
||||
"callee",
|
||||
"arguments",
|
||||
];
|
||||
|
||||
// This branch is covered when tests are run with `--disable-proto=throw`,
|
||||
// however we can test both branches at the same time, so this is ignored
|
||||
/* istanbul ignore next */
|
||||
if (throwsOnProto) {
|
||||
disallowedProperties.push("__proto__");
|
||||
}
|
||||
|
||||
module.exports = function copyPrototypeMethods(prototype) {
|
||||
// eslint-disable-next-line @sinonjs/no-prototype-methods/no-prototype-methods
|
||||
return Object.getOwnPropertyNames(prototype).reduce(function (
|
||||
result,
|
||||
name
|
||||
) {
|
||||
if (disallowedProperties.includes(name)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (typeof prototype[name] !== "function") {
|
||||
return result;
|
||||
}
|
||||
|
||||
result[name] = call.bind(prototype[name]);
|
||||
|
||||
return result;
|
||||
},
|
||||
Object.create(null));
|
||||
};
|
||||
@@ -1,12 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var refute = require("@sinonjs/referee-sinon").refute;
|
||||
var copyPrototypeMethods = require("./copy-prototype-methods");
|
||||
|
||||
describe("copyPrototypeMethods", function () {
|
||||
it("does not throw for Map", function () {
|
||||
refute.exception(function () {
|
||||
copyPrototypeMethods(Map.prototype);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var copyPrototype = require("./copy-prototype-methods");
|
||||
|
||||
module.exports = copyPrototype(Function.prototype);
|
||||
10
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/index.js
generated
vendored
10
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/index.js
generated
vendored
@@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
array: require("./array"),
|
||||
function: require("./function"),
|
||||
map: require("./map"),
|
||||
object: require("./object"),
|
||||
set: require("./set"),
|
||||
string: require("./string"),
|
||||
};
|
||||
61
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/index.test.js
generated
vendored
61
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/index.test.js
generated
vendored
@@ -1,61 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var assert = require("@sinonjs/referee-sinon").assert;
|
||||
|
||||
var arrayProto = require("./index").array;
|
||||
var functionProto = require("./index").function;
|
||||
var mapProto = require("./index").map;
|
||||
var objectProto = require("./index").object;
|
||||
var setProto = require("./index").set;
|
||||
var stringProto = require("./index").string;
|
||||
var throwsOnProto = require("./throws-on-proto");
|
||||
|
||||
describe("prototypes", function () {
|
||||
describe(".array", function () {
|
||||
// eslint-disable-next-line mocha/no-setup-in-describe
|
||||
verifyProperties(arrayProto, Array);
|
||||
});
|
||||
describe(".function", function () {
|
||||
// eslint-disable-next-line mocha/no-setup-in-describe
|
||||
verifyProperties(functionProto, Function);
|
||||
});
|
||||
describe(".map", function () {
|
||||
// eslint-disable-next-line mocha/no-setup-in-describe
|
||||
verifyProperties(mapProto, Map);
|
||||
});
|
||||
describe(".object", function () {
|
||||
// eslint-disable-next-line mocha/no-setup-in-describe
|
||||
verifyProperties(objectProto, Object);
|
||||
});
|
||||
describe(".set", function () {
|
||||
// eslint-disable-next-line mocha/no-setup-in-describe
|
||||
verifyProperties(setProto, Set);
|
||||
});
|
||||
describe(".string", function () {
|
||||
// eslint-disable-next-line mocha/no-setup-in-describe
|
||||
verifyProperties(stringProto, String);
|
||||
});
|
||||
});
|
||||
|
||||
function verifyProperties(p, origin) {
|
||||
var disallowedProperties = ["size", "caller", "callee", "arguments"];
|
||||
if (throwsOnProto) {
|
||||
disallowedProperties.push("__proto__");
|
||||
}
|
||||
|
||||
it("should have all the methods of the origin prototype", function () {
|
||||
var methodNames = Object.getOwnPropertyNames(origin.prototype).filter(
|
||||
function (name) {
|
||||
if (disallowedProperties.includes(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return typeof origin.prototype[name] === "function";
|
||||
}
|
||||
);
|
||||
|
||||
methodNames.forEach(function (name) {
|
||||
assert.isTrue(Object.prototype.hasOwnProperty.call(p, name), name);
|
||||
});
|
||||
});
|
||||
}
|
||||
5
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/map.js
generated
vendored
5
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/map.js
generated
vendored
@@ -1,5 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var copyPrototype = require("./copy-prototype-methods");
|
||||
|
||||
module.exports = copyPrototype(Map.prototype);
|
||||
5
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/object.js
generated
vendored
5
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/object.js
generated
vendored
@@ -1,5 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var copyPrototype = require("./copy-prototype-methods");
|
||||
|
||||
module.exports = copyPrototype(Object.prototype);
|
||||
5
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/set.js
generated
vendored
5
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/set.js
generated
vendored
@@ -1,5 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var copyPrototype = require("./copy-prototype-methods");
|
||||
|
||||
module.exports = copyPrototype(Set.prototype);
|
||||
5
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/string.js
generated
vendored
5
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/prototypes/string.js
generated
vendored
@@ -1,5 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var copyPrototype = require("./copy-prototype-methods");
|
||||
|
||||
module.exports = copyPrototype(String.prototype);
|
||||
@@ -1,26 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Is true when the environment causes an error to be thrown for accessing the
|
||||
* __proto__ property.
|
||||
*
|
||||
* This is necessary in order to support `node --disable-proto=throw`.
|
||||
*
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
let throwsOnProto;
|
||||
try {
|
||||
const object = {};
|
||||
// eslint-disable-next-line no-proto, no-unused-expressions
|
||||
object.__proto__;
|
||||
throwsOnProto = false;
|
||||
} catch (_) {
|
||||
// This branch is covered when tests are run with `--disable-proto=throw`,
|
||||
// however we can test both branches at the same time, so this is ignored
|
||||
/* istanbul ignore next */
|
||||
throwsOnProto = true;
|
||||
}
|
||||
|
||||
module.exports = throwsOnProto;
|
||||
13
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/type-of.js
generated
vendored
13
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/type-of.js
generated
vendored
@@ -1,13 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var type = require("type-detect");
|
||||
|
||||
/**
|
||||
* Returns the lower-case result of running type from type-detect on the value
|
||||
*
|
||||
* @param {*} value
|
||||
* @returns {string}
|
||||
*/
|
||||
module.exports = function typeOf(value) {
|
||||
return type(value).toLowerCase();
|
||||
};
|
||||
51
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/type-of.test.js
generated
vendored
51
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/type-of.test.js
generated
vendored
@@ -1,51 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var assert = require("@sinonjs/referee-sinon").assert;
|
||||
var typeOf = require("./type-of");
|
||||
|
||||
describe("typeOf", function () {
|
||||
it("returns boolean", function () {
|
||||
assert.equals(typeOf(false), "boolean");
|
||||
});
|
||||
|
||||
it("returns string", function () {
|
||||
assert.equals(typeOf("Sinon.JS"), "string");
|
||||
});
|
||||
|
||||
it("returns number", function () {
|
||||
assert.equals(typeOf(123), "number");
|
||||
});
|
||||
|
||||
it("returns object", function () {
|
||||
assert.equals(typeOf({}), "object");
|
||||
});
|
||||
|
||||
it("returns function", function () {
|
||||
assert.equals(
|
||||
typeOf(function () {
|
||||
return undefined;
|
||||
}),
|
||||
"function"
|
||||
);
|
||||
});
|
||||
|
||||
it("returns undefined", function () {
|
||||
assert.equals(typeOf(undefined), "undefined");
|
||||
});
|
||||
|
||||
it("returns null", function () {
|
||||
assert.equals(typeOf(null), "null");
|
||||
});
|
||||
|
||||
it("returns array", function () {
|
||||
assert.equals(typeOf([]), "array");
|
||||
});
|
||||
|
||||
it("returns regexp", function () {
|
||||
assert.equals(typeOf(/.*/), "regexp");
|
||||
});
|
||||
|
||||
it("returns date", function () {
|
||||
assert.equals(typeOf(new Date()), "date");
|
||||
});
|
||||
});
|
||||
17
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/value-to-string.js
generated
vendored
17
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/value-to-string.js
generated
vendored
@@ -1,17 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Returns a string representation of the value
|
||||
*
|
||||
* @param {*} value
|
||||
* @returns {string}
|
||||
*/
|
||||
function valueToString(value) {
|
||||
if (value && value.toString) {
|
||||
// eslint-disable-next-line @sinonjs/no-prototype-methods/no-prototype-methods
|
||||
return value.toString();
|
||||
}
|
||||
return String(value);
|
||||
}
|
||||
|
||||
module.exports = valueToString;
|
||||
20
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/value-to-string.test.js
generated
vendored
20
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/lib/value-to-string.test.js
generated
vendored
@@ -1,20 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var assert = require("@sinonjs/referee-sinon").assert;
|
||||
var valueToString = require("./value-to-string");
|
||||
|
||||
describe("util/core/valueToString", function () {
|
||||
it("returns string representation of an object", function () {
|
||||
var obj = {};
|
||||
|
||||
assert.equals(valueToString(obj), obj.toString());
|
||||
});
|
||||
|
||||
it("returns 'null' for literal null'", function () {
|
||||
assert.equals(valueToString(null), "null");
|
||||
});
|
||||
|
||||
it("returns 'undefined' for literal undefined", function () {
|
||||
assert.equals(valueToString(undefined), "undefined");
|
||||
});
|
||||
});
|
||||
57
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/package.json
generated
vendored
57
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/package.json
generated
vendored
@@ -1,57 +0,0 @@
|
||||
{
|
||||
"name": "@sinonjs/commons",
|
||||
"version": "2.0.0",
|
||||
"description": "Simple functions shared among the sinon end user libraries",
|
||||
"main": "lib/index.js",
|
||||
"types": "./types/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "rm -rf types && tsc",
|
||||
"lint": "eslint .",
|
||||
"precommit": "lint-staged",
|
||||
"test": "mocha --recursive -R dot \"lib/**/*.test.js\"",
|
||||
"test-check-coverage": "npm run test-coverage && nyc check-coverage --branches 100 --functions 100 --lines 100",
|
||||
"test-coverage": "nyc --reporter text --reporter html --reporter lcovonly npm run test",
|
||||
"prepublishOnly": "npm run build",
|
||||
"prettier:check": "prettier --check '**/*.{js,css,md}'",
|
||||
"prettier:write": "prettier --write '**/*.{js,css,md}'",
|
||||
"preversion": "npm run test-check-coverage",
|
||||
"version": "changes --commits --footer",
|
||||
"postversion": "git push --follow-tags && npm publish",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sinonjs/commons.git"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"types"
|
||||
],
|
||||
"author": "",
|
||||
"license": "BSD-3-Clause",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sinonjs/commons/issues"
|
||||
},
|
||||
"homepage": "https://github.com/sinonjs/commons#readme",
|
||||
"lint-staged": {
|
||||
"*.{js,css,md}": "prettier --check",
|
||||
"*.js": "eslint"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sinonjs/eslint-config": "^4.0.6",
|
||||
"@sinonjs/eslint-plugin-no-prototype-methods": "^0.1.0",
|
||||
"@sinonjs/referee-sinon": "^10.1.0",
|
||||
"@studio/changes": "^2.2.0",
|
||||
"husky": "^6.0.0",
|
||||
"jsverify": "0.8.4",
|
||||
"knuth-shuffle": "^1.0.8",
|
||||
"lint-staged": "^13.0.3",
|
||||
"mocha": "^10.1.0",
|
||||
"nyc": "^15.1.0",
|
||||
"prettier": "^2.7.1",
|
||||
"typescript": "^4.8.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"type-detect": "4.0.8"
|
||||
}
|
||||
}
|
||||
36
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/called-in-order.d.ts
generated
vendored
36
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/called-in-order.d.ts
generated
vendored
@@ -1,36 +0,0 @@
|
||||
export = calledInOrder;
|
||||
/**
|
||||
* A Sinon proxy object (fake, spy, stub)
|
||||
*
|
||||
* @typedef {object} SinonProxy
|
||||
* @property {Function} calledBefore - A method that determines if this proxy was called before another one
|
||||
* @property {string} id - Some id
|
||||
* @property {number} callCount - Number of times this proxy has been called
|
||||
*/
|
||||
/**
|
||||
* Returns true when the spies have been called in the order they were supplied in
|
||||
*
|
||||
* @param {SinonProxy[] | SinonProxy} spies An array of proxies, or several proxies as arguments
|
||||
* @returns {boolean} true when spies are called in order, false otherwise
|
||||
*/
|
||||
declare function calledInOrder(spies: SinonProxy[] | SinonProxy, ...args: any[]): boolean;
|
||||
declare namespace calledInOrder {
|
||||
export { SinonProxy };
|
||||
}
|
||||
/**
|
||||
* A Sinon proxy object (fake, spy, stub)
|
||||
*/
|
||||
type SinonProxy = {
|
||||
/**
|
||||
* - A method that determines if this proxy was called before another one
|
||||
*/
|
||||
calledBefore: Function;
|
||||
/**
|
||||
* - Some id
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* - Number of times this proxy has been called
|
||||
*/
|
||||
callCount: number;
|
||||
};
|
||||
8
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/class-name.d.ts
generated
vendored
8
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/class-name.d.ts
generated
vendored
@@ -1,8 +0,0 @@
|
||||
export = className;
|
||||
/**
|
||||
* Returns a display name for a value from a constructor
|
||||
*
|
||||
* @param {object} value A value to examine
|
||||
* @returns {(string|null)} A string or null
|
||||
*/
|
||||
declare function className(value: object): (string | null);
|
||||
3
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/deprecated.d.ts
generated
vendored
3
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/deprecated.d.ts
generated
vendored
@@ -1,3 +0,0 @@
|
||||
export function wrap(func: Function, msg: string): Function;
|
||||
export function defaultMsg(packageName: string, funcName: string): string;
|
||||
export function printWarning(msg: string): undefined;
|
||||
2
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/every.d.ts
generated
vendored
2
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/every.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare function _exports(obj: object, fn: Function): boolean;
|
||||
export = _exports;
|
||||
2
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/function-name.d.ts
generated
vendored
2
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/function-name.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare function _exports(func: Function): string;
|
||||
export = _exports;
|
||||
7
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/global.d.ts
generated
vendored
7
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/global.d.ts
generated
vendored
@@ -1,7 +0,0 @@
|
||||
export = globalObject;
|
||||
/**
|
||||
* A reference to the global object
|
||||
*
|
||||
* @type {object} globalObject
|
||||
*/
|
||||
declare var globalObject: object;
|
||||
17
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/index.d.ts
generated
vendored
17
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/index.d.ts
generated
vendored
@@ -1,17 +0,0 @@
|
||||
export const global: any;
|
||||
export const calledInOrder: typeof import("./called-in-order");
|
||||
export const className: typeof import("./class-name");
|
||||
export const deprecated: typeof import("./deprecated");
|
||||
export const every: (obj: any, fn: Function) => boolean;
|
||||
export const functionName: (func: Function) => string;
|
||||
export const orderByFirstCall: typeof import("./order-by-first-call");
|
||||
export const prototypes: {
|
||||
array: any;
|
||||
function: any;
|
||||
map: any;
|
||||
object: any;
|
||||
set: any;
|
||||
string: any;
|
||||
};
|
||||
export const typeOf: (value: any) => string;
|
||||
export const valueToString: typeof import("./value-to-string");
|
||||
@@ -1,26 +0,0 @@
|
||||
export = orderByFirstCall;
|
||||
/**
|
||||
* A Sinon proxy object (fake, spy, stub)
|
||||
*
|
||||
* @typedef {object} SinonProxy
|
||||
* @property {Function} getCall - A method that can return the first call
|
||||
*/
|
||||
/**
|
||||
* Sorts an array of SinonProxy instances (fake, spy, stub) by their first call
|
||||
*
|
||||
* @param {SinonProxy[] | SinonProxy} spies
|
||||
* @returns {SinonProxy[]}
|
||||
*/
|
||||
declare function orderByFirstCall(spies: SinonProxy[] | SinonProxy): SinonProxy[];
|
||||
declare namespace orderByFirstCall {
|
||||
export { SinonProxy };
|
||||
}
|
||||
/**
|
||||
* A Sinon proxy object (fake, spy, stub)
|
||||
*/
|
||||
type SinonProxy = {
|
||||
/**
|
||||
* - A method that can return the first call
|
||||
*/
|
||||
getCall: Function;
|
||||
};
|
||||
@@ -1,2 +0,0 @@
|
||||
declare const _exports: any;
|
||||
export = _exports;
|
||||
@@ -1,2 +0,0 @@
|
||||
declare function _exports(prototype: any): any;
|
||||
export = _exports;
|
||||
@@ -1,2 +0,0 @@
|
||||
declare const _exports: any;
|
||||
export = _exports;
|
||||
@@ -1,7 +0,0 @@
|
||||
export declare const array: any;
|
||||
declare const _function: any;
|
||||
export { _function as function };
|
||||
export declare const map: any;
|
||||
export declare const object: any;
|
||||
export declare const set: any;
|
||||
export declare const string: any;
|
||||
2
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/prototypes/map.d.ts
generated
vendored
2
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/prototypes/map.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare const _exports: any;
|
||||
export = _exports;
|
||||
@@ -1,2 +0,0 @@
|
||||
declare const _exports: any;
|
||||
export = _exports;
|
||||
2
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/prototypes/set.d.ts
generated
vendored
2
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/prototypes/set.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare const _exports: any;
|
||||
export = _exports;
|
||||
@@ -1,2 +0,0 @@
|
||||
declare const _exports: any;
|
||||
export = _exports;
|
||||
@@ -1,12 +0,0 @@
|
||||
export = throwsOnProto;
|
||||
/**
|
||||
* Is true when the environment causes an error to be thrown for accessing the
|
||||
* __proto__ property.
|
||||
*
|
||||
* This is necessary in order to support `node --disable-proto=throw`.
|
||||
*
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
declare let throwsOnProto: boolean;
|
||||
2
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/type-of.d.ts
generated
vendored
2
node_modules/@sinonjs/samsam/node_modules/@sinonjs/commons/types/type-of.d.ts
generated
vendored
@@ -1,2 +0,0 @@
|
||||
declare function _exports(value: any): string;
|
||||
export = _exports;
|
||||
@@ -1,8 +0,0 @@
|
||||
export = valueToString;
|
||||
/**
|
||||
* Returns a string representation of the value
|
||||
*
|
||||
* @param {*} value
|
||||
* @returns {string}
|
||||
*/
|
||||
declare function valueToString(value: any): string;
|
||||
@@ -1,6 +1,4 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 typescript-eslint and other contributors
|
||||
Copyright (c) 2013 Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.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
|
||||
@@ -9,13 +7,13 @@ 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 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.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
235
node_modules/@sinonjs/samsam/node_modules/type-detect/README.md
generated
vendored
Normal file
235
node_modules/@sinonjs/samsam/node_modules/type-detect/README.md
generated
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
<h1 align=center>
|
||||
<a href="http://chaijs.com" title="Chai Documentation">
|
||||
<img alt="type-detect" src="https://raw.githubusercontent.com/chaijs/type-detect/master/type-detect-logo.svg"/>
|
||||
</a>
|
||||
</h1>
|
||||
<br>
|
||||
<p align=center>
|
||||
Improved typeof detection for <a href="https://nodejs.org">node</a>, <a href="https://deno.land/">Deno</a>, and the browser.
|
||||
</p>
|
||||
|
||||
<p align=center>
|
||||
<a href="./LICENSE">
|
||||
<img
|
||||
alt="license:mit"
|
||||
src="https://img.shields.io/badge/license-mit-green.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/packages/type-detect">
|
||||
<img
|
||||
alt="npm:?"
|
||||
src="https://img.shields.io/npm/v/type-detect.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://github.com/chaijs/type-detect">
|
||||
<img
|
||||
alt="build:?"
|
||||
src="https://github.com/chaijs/type-detect/workflows/Build/badge.svg"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://coveralls.io/r/chaijs/type-detect">
|
||||
<img
|
||||
alt="coverage:?"
|
||||
src="https://img.shields.io/coveralls/chaijs/type-detect/master.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/packages/type-detect">
|
||||
<img
|
||||
alt="dependencies:?"
|
||||
src="https://img.shields.io/npm/dm/type-detect.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="">
|
||||
<img
|
||||
alt="devDependencies:?"
|
||||
src="https://img.shields.io/david/chaijs/type-detect.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<br>
|
||||
<a href="https://chai-slack.herokuapp.com/">
|
||||
<img
|
||||
alt="Join the Slack chat"
|
||||
src="https://img.shields.io/badge/slack-join%20chat-E2206F.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
<a href="https://gitter.im/chaijs/chai">
|
||||
<img
|
||||
alt="Join the Gitter chat"
|
||||
src="https://img.shields.io/badge/gitter-join%20chat-D0104D.svg?style=flat-square"
|
||||
/>
|
||||
</a>
|
||||
</p>
|
||||
<div align=center>
|
||||
<table width="100%">
|
||||
<tr><th colspan=6>Supported Browsers</th></tr> <tr>
|
||||
<th align=center><img src="https://camo.githubusercontent.com/ab586f11dfcb49bf5f2c2fa9adadc5e857de122a/687474703a2f2f73766773686172652e636f6d2f692f3278532e737667" alt=""> Chrome</th>
|
||||
<th align=center><img src="https://camo.githubusercontent.com/98cca3108c18dcfaa62667b42046540c6822cdac/687474703a2f2f73766773686172652e636f6d2f692f3279352e737667" alt=""> Edge</th>
|
||||
<th align=center><img src="https://camo.githubusercontent.com/acdcb09840a9e1442cbaf1b684f95ab3c3f41cf4/687474703a2f2f73766773686172652e636f6d2f692f3279462e737667" alt=""> Firefox</th>
|
||||
<th align=center><img src="https://camo.githubusercontent.com/728f8cb0bee9ed58ab85e39266f1152c53e0dffd/687474703a2f2f73766773686172652e636f6d2f692f3278342e737667" alt=""> Safari</th>
|
||||
<th align=center><img src="https://camo.githubusercontent.com/96a2317034dee0040d0a762e7a30c3c650c45aac/687474703a2f2f73766773686172652e636f6d2f692f3279532e737667" alt=""> IE</th>
|
||||
</tr><tr>
|
||||
<td align=center>✅</td>
|
||||
<td align=center>✅</td>
|
||||
<td align=center>✅</td>
|
||||
<td align=center>✅</td>
|
||||
<td align=center>9, 10, 11</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
## What is Type-Detect?
|
||||
|
||||
Type Detect is a module which you can use to detect the type of a given object. It returns a string representation of the object's type, either using [`typeof`](http://www.ecma-international.org/ecma-262/6.0/index.html#sec-typeof-operator) or [`@@toStringTag`](http://www.ecma-international.org/ecma-262/6.0/index.html#sec-symbol.tostringtag). It also normalizes some object names for consistency among browsers.
|
||||
|
||||
## Why?
|
||||
|
||||
The `typeof` operator will only specify primitive values; everything else is `"object"` (including `null`, arrays, regexps, etc). Many developers use `Object.prototype.toString()` - which is a fine alternative and returns many more types (null returns `[object Null]`, Arrays as `[object Array]`, regexps as `[object RegExp]` etc).
|
||||
|
||||
Sadly, `Object.prototype.toString` is slow, and buggy. By slow - we mean it is slower than `typeof`. By buggy - we mean that some values (like Promises, the global object, iterators, dataviews, a bunch of HTML elements) all report different things in different browsers.
|
||||
|
||||
`type-detect` fixes all of the shortcomings with `Object.prototype.toString`. We have extra code to speed up checks of JS and DOM objects, as much as 20-30x faster for some values. `type-detect` also fixes any consistencies with these objects.
|
||||
|
||||
## Installation
|
||||
|
||||
### Node.js
|
||||
|
||||
`type-detect` is available on [npm](http://npmjs.org). To install it, type:
|
||||
|
||||
$ npm install type-detect
|
||||
|
||||
### Deno
|
||||
|
||||
`type-detect` can be imported with the following line:
|
||||
|
||||
```js
|
||||
import type from 'https://deno.land/x/type_detect@v4.1.0/index.ts'
|
||||
```
|
||||
|
||||
### Browsers
|
||||
|
||||
You can also use it within the browser; install via npm and use the `type-detect.js` file found within the download. For example:
|
||||
|
||||
```html
|
||||
<script src="./node_modules/type-detect/type-detect.js"></script>
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The primary export of `type-detect` is function that can serve as a replacement for `typeof`. The results of this function will be more specific than that of native `typeof`.
|
||||
|
||||
```js
|
||||
var type = require('type-detect');
|
||||
```
|
||||
Or, in the browser use case, after the <script> tag,
|
||||
```js
|
||||
var type = typeDetect;
|
||||
```
|
||||
|
||||
#### array
|
||||
|
||||
```js
|
||||
assert(type([]) === 'Array');
|
||||
assert(type(new Array()) === 'Array');
|
||||
```
|
||||
|
||||
#### regexp
|
||||
|
||||
```js
|
||||
assert(type(/a-z/gi) === 'RegExp');
|
||||
assert(type(new RegExp('a-z')) === 'RegExp');
|
||||
```
|
||||
|
||||
#### function
|
||||
|
||||
```js
|
||||
assert(type(function () {}) === 'function');
|
||||
```
|
||||
|
||||
#### arguments
|
||||
|
||||
```js
|
||||
(function () {
|
||||
assert(type(arguments) === 'Arguments');
|
||||
})();
|
||||
```
|
||||
|
||||
#### date
|
||||
|
||||
```js
|
||||
assert(type(new Date) === 'Date');
|
||||
```
|
||||
|
||||
#### number
|
||||
|
||||
```js
|
||||
assert(type(1) === 'number');
|
||||
assert(type(1.234) === 'number');
|
||||
assert(type(-1) === 'number');
|
||||
assert(type(-1.234) === 'number');
|
||||
assert(type(Infinity) === 'number');
|
||||
assert(type(NaN) === 'number');
|
||||
assert(type(new Number(1)) === 'Number'); // note - the object version has a capital N
|
||||
```
|
||||
|
||||
#### string
|
||||
|
||||
```js
|
||||
assert(type('hello world') === 'string');
|
||||
assert(type(new String('hello')) === 'String'); // note - the object version has a capital S
|
||||
```
|
||||
|
||||
#### null
|
||||
|
||||
```js
|
||||
assert(type(null) === 'null');
|
||||
assert(type(undefined) !== 'null');
|
||||
```
|
||||
|
||||
#### undefined
|
||||
|
||||
```js
|
||||
assert(type(undefined) === 'undefined');
|
||||
assert(type(null) !== 'undefined');
|
||||
```
|
||||
|
||||
#### object
|
||||
|
||||
```js
|
||||
var Noop = function () {};
|
||||
assert(type({}) === 'Object');
|
||||
assert(type(Noop) !== 'Object');
|
||||
assert(type(new Noop) === 'Object');
|
||||
assert(type(new Object) === 'Object');
|
||||
```
|
||||
|
||||
#### ECMA6 Types
|
||||
|
||||
All new ECMAScript 2015 objects are also supported, such as Promises and Symbols:
|
||||
|
||||
```js
|
||||
assert(type(new Map() === 'Map');
|
||||
assert(type(new WeakMap()) === 'WeakMap');
|
||||
assert(type(new Set()) === 'Set');
|
||||
assert(type(new WeakSet()) === 'WeakSet');
|
||||
assert(type(Symbol()) === 'symbol');
|
||||
assert(type(new Promise(callback) === 'Promise');
|
||||
assert(type(new Int8Array()) === 'Int8Array');
|
||||
assert(type(new Uint8Array()) === 'Uint8Array');
|
||||
assert(type(new UInt8ClampedArray()) === 'Uint8ClampedArray');
|
||||
assert(type(new Int16Array()) === 'Int16Array');
|
||||
assert(type(new Uint16Array()) === 'Uint16Array');
|
||||
assert(type(new Int32Array()) === 'Int32Array');
|
||||
assert(type(new UInt32Array()) === 'Uint32Array');
|
||||
assert(type(new Float32Array()) === 'Float32Array');
|
||||
assert(type(new Float64Array()) === 'Float64Array');
|
||||
assert(type(new ArrayBuffer()) === 'ArrayBuffer');
|
||||
assert(type(new DataView(arrayBuffer)) === 'DataView');
|
||||
```
|
||||
|
||||
Also, if you use `Symbol.toStringTag` to change an Objects return value of the `toString()` Method, `type()` will return this value, e.g:
|
||||
|
||||
```js
|
||||
var myObject = {};
|
||||
myObject[Symbol.toStringTag] = 'myCustomType';
|
||||
assert(type(myObject) === 'myCustomType');
|
||||
```
|
||||
1
node_modules/@sinonjs/samsam/node_modules/type-detect/index.d.ts
generated
vendored
Normal file
1
node_modules/@sinonjs/samsam/node_modules/type-detect/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default function typeDetect(obj: unknown): string;
|
||||
129
node_modules/@sinonjs/samsam/node_modules/type-detect/index.js
generated
vendored
Normal file
129
node_modules/@sinonjs/samsam/node_modules/type-detect/index.js
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
const promiseExists = typeof Promise === 'function';
|
||||
const globalObject = ((Obj) => {
|
||||
if (typeof globalThis === 'object') {
|
||||
return globalThis;
|
||||
}
|
||||
Object.defineProperty(Obj, 'typeDetectGlobalObject', {
|
||||
get() {
|
||||
return this;
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
const global = typeDetectGlobalObject;
|
||||
delete Obj.typeDetectGlobalObject;
|
||||
return global;
|
||||
})(Object.prototype);
|
||||
const symbolExists = typeof Symbol !== 'undefined';
|
||||
const mapExists = typeof Map !== 'undefined';
|
||||
const setExists = typeof Set !== 'undefined';
|
||||
const weakMapExists = typeof WeakMap !== 'undefined';
|
||||
const weakSetExists = typeof WeakSet !== 'undefined';
|
||||
const dataViewExists = typeof DataView !== 'undefined';
|
||||
const symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined';
|
||||
const symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined';
|
||||
const setEntriesExists = setExists && typeof Set.prototype.entries === 'function';
|
||||
const mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function';
|
||||
const setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries());
|
||||
const mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries());
|
||||
const arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
|
||||
const arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
|
||||
const stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === 'function';
|
||||
const stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]());
|
||||
const toStringLeftSliceLength = 8;
|
||||
const toStringRightSliceLength = -1;
|
||||
export default function typeDetect(obj) {
|
||||
const typeofObj = typeof obj;
|
||||
if (typeofObj !== 'object') {
|
||||
return typeofObj;
|
||||
}
|
||||
if (obj === null) {
|
||||
return 'null';
|
||||
}
|
||||
if (obj === globalObject) {
|
||||
return 'global';
|
||||
}
|
||||
if (Array.isArray(obj) &&
|
||||
(symbolToStringTagExists === false || !(Symbol.toStringTag in obj))) {
|
||||
return 'Array';
|
||||
}
|
||||
if (typeof window === 'object' && window !== null) {
|
||||
if (typeof window.location === 'object' && obj === window.location) {
|
||||
return 'Location';
|
||||
}
|
||||
if (typeof window.document === 'object' && obj === window.document) {
|
||||
return 'Document';
|
||||
}
|
||||
if (typeof window.navigator === 'object') {
|
||||
if (typeof window.navigator.mimeTypes === 'object' &&
|
||||
obj === window.navigator.mimeTypes) {
|
||||
return 'MimeTypeArray';
|
||||
}
|
||||
if (typeof window.navigator.plugins === 'object' &&
|
||||
obj === window.navigator.plugins) {
|
||||
return 'PluginArray';
|
||||
}
|
||||
}
|
||||
if ((typeof window.HTMLElement === 'function' ||
|
||||
typeof window.HTMLElement === 'object') &&
|
||||
obj instanceof window.HTMLElement) {
|
||||
if (obj.tagName === 'BLOCKQUOTE') {
|
||||
return 'HTMLQuoteElement';
|
||||
}
|
||||
if (obj.tagName === 'TD') {
|
||||
return 'HTMLTableDataCellElement';
|
||||
}
|
||||
if (obj.tagName === 'TH') {
|
||||
return 'HTMLTableHeaderCellElement';
|
||||
}
|
||||
}
|
||||
}
|
||||
const stringTag = (symbolToStringTagExists && obj[Symbol.toStringTag]);
|
||||
if (typeof stringTag === 'string') {
|
||||
return stringTag;
|
||||
}
|
||||
const objPrototype = Object.getPrototypeOf(obj);
|
||||
if (objPrototype === RegExp.prototype) {
|
||||
return 'RegExp';
|
||||
}
|
||||
if (objPrototype === Date.prototype) {
|
||||
return 'Date';
|
||||
}
|
||||
if (promiseExists && objPrototype === Promise.prototype) {
|
||||
return 'Promise';
|
||||
}
|
||||
if (setExists && objPrototype === Set.prototype) {
|
||||
return 'Set';
|
||||
}
|
||||
if (mapExists && objPrototype === Map.prototype) {
|
||||
return 'Map';
|
||||
}
|
||||
if (weakSetExists && objPrototype === WeakSet.prototype) {
|
||||
return 'WeakSet';
|
||||
}
|
||||
if (weakMapExists && objPrototype === WeakMap.prototype) {
|
||||
return 'WeakMap';
|
||||
}
|
||||
if (dataViewExists && objPrototype === DataView.prototype) {
|
||||
return 'DataView';
|
||||
}
|
||||
if (mapExists && objPrototype === mapIteratorPrototype) {
|
||||
return 'Map Iterator';
|
||||
}
|
||||
if (setExists && objPrototype === setIteratorPrototype) {
|
||||
return 'Set Iterator';
|
||||
}
|
||||
if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
|
||||
return 'Array Iterator';
|
||||
}
|
||||
if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
|
||||
return 'String Iterator';
|
||||
}
|
||||
if (objPrototype === null) {
|
||||
return 'Object';
|
||||
}
|
||||
return Object
|
||||
.prototype
|
||||
.toString
|
||||
.call(obj)
|
||||
.slice(toStringLeftSliceLength, toStringRightSliceLength);
|
||||
}
|
||||
393
node_modules/@sinonjs/samsam/node_modules/type-detect/index.ts
generated
vendored
Normal file
393
node_modules/@sinonjs/samsam/node_modules/type-detect/index.ts
generated
vendored
Normal file
@@ -0,0 +1,393 @@
|
||||
/* !
|
||||
* type-detect
|
||||
* Copyright(c) 2013 jake luer <jake@alogicalparadox.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
const promiseExists = typeof Promise === 'function';
|
||||
|
||||
const globalObject = ((Obj) => {
|
||||
if (typeof globalThis === 'object') {
|
||||
return globalThis; // eslint-disable-line
|
||||
}
|
||||
Object.defineProperty(Obj, 'typeDetectGlobalObject', {
|
||||
get() {
|
||||
return this;
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
// @ts-ignore
|
||||
const global = typeDetectGlobalObject; // eslint-disable-line
|
||||
// @ts-ignore
|
||||
delete Obj.typeDetectGlobalObject;
|
||||
return global;
|
||||
})(Object.prototype);
|
||||
|
||||
const symbolExists = typeof Symbol !== 'undefined';
|
||||
const mapExists = typeof Map !== 'undefined';
|
||||
const setExists = typeof Set !== 'undefined';
|
||||
const weakMapExists = typeof WeakMap !== 'undefined';
|
||||
const weakSetExists = typeof WeakSet !== 'undefined';
|
||||
const dataViewExists = typeof DataView !== 'undefined';
|
||||
const symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined';
|
||||
const symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined';
|
||||
const setEntriesExists = setExists && typeof Set.prototype.entries === 'function';
|
||||
const mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function';
|
||||
const setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries());
|
||||
const mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries());
|
||||
const arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
|
||||
const arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
|
||||
const stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === 'function';
|
||||
const stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]());
|
||||
const toStringLeftSliceLength = 8;
|
||||
const toStringRightSliceLength = -1;
|
||||
|
||||
/**
|
||||
* ### typeOf (obj)
|
||||
*
|
||||
* Uses `Object.prototype.toString` to determine the type of an object,
|
||||
* normalising behaviour across engine versions & well optimised.
|
||||
*
|
||||
* @param {Mixed} object
|
||||
* @return {String} object type
|
||||
* @api public
|
||||
*/
|
||||
export default function typeDetect(obj: unknown): string {
|
||||
/* ! Speed optimisation
|
||||
* Pre:
|
||||
* string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled)
|
||||
* boolean literal x 1,424,138 ops/sec ±4.54% (75 runs sampled)
|
||||
* number literal x 1,653,153 ops/sec ±1.91% (82 runs sampled)
|
||||
* undefined x 9,978,660 ops/sec ±1.92% (75 runs sampled)
|
||||
* function x 2,556,769 ops/sec ±1.73% (77 runs sampled)
|
||||
* Post:
|
||||
* string literal x 38,564,796 ops/sec ±1.15% (79 runs sampled)
|
||||
* boolean literal x 31,148,940 ops/sec ±1.10% (79 runs sampled)
|
||||
* number literal x 32,679,330 ops/sec ±1.90% (78 runs sampled)
|
||||
* undefined x 32,363,368 ops/sec ±1.07% (82 runs sampled)
|
||||
* function x 31,296,870 ops/sec ±0.96% (83 runs sampled)
|
||||
*/
|
||||
const typeofObj = typeof obj;
|
||||
if (typeofObj !== 'object') {
|
||||
return typeofObj;
|
||||
}
|
||||
|
||||
/* ! Speed optimisation
|
||||
* Pre:
|
||||
* null x 28,645,765 ops/sec ±1.17% (82 runs sampled)
|
||||
* Post:
|
||||
* null x 36,428,962 ops/sec ±1.37% (84 runs sampled)
|
||||
*/
|
||||
if (obj === null) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
/* ! Spec Conformance
|
||||
* Test: `Object.prototype.toString.call(window)``
|
||||
* - Node === "[object global]"
|
||||
* - Chrome === "[object global]"
|
||||
* - Firefox === "[object Window]"
|
||||
* - PhantomJS === "[object Window]"
|
||||
* - Safari === "[object Window]"
|
||||
* - IE 11 === "[object Window]"
|
||||
* - IE Edge === "[object Window]"
|
||||
* Test: `Object.prototype.toString.call(this)``
|
||||
* - Chrome Worker === "[object global]"
|
||||
* - Firefox Worker === "[object DedicatedWorkerGlobalScope]"
|
||||
* - Safari Worker === "[object DedicatedWorkerGlobalScope]"
|
||||
* - IE 11 Worker === "[object WorkerGlobalScope]"
|
||||
* - IE Edge Worker === "[object WorkerGlobalScope]"
|
||||
*/
|
||||
if (obj === globalObject) {
|
||||
return 'global';
|
||||
}
|
||||
|
||||
/* ! Speed optimisation
|
||||
* Pre:
|
||||
* array literal x 2,888,352 ops/sec ±0.67% (82 runs sampled)
|
||||
* Post:
|
||||
* array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled)
|
||||
*/
|
||||
if (
|
||||
Array.isArray(obj) &&
|
||||
(symbolToStringTagExists === false || !(Symbol.toStringTag in obj))
|
||||
) {
|
||||
return 'Array';
|
||||
}
|
||||
|
||||
// Not caching existence of `window` and related properties due to potential
|
||||
// for `window` to be unset before tests in quasi-browser environments.
|
||||
if (typeof window === 'object' && window !== null) {
|
||||
/* ! Spec Conformance
|
||||
* (https://html.spec.whatwg.org/multipage/browsers.html#location)
|
||||
* WhatWG HTML$7.7.3 - The `Location` interface
|
||||
* Test: `Object.prototype.toString.call(window.location)``
|
||||
* - IE <=11 === "[object Object]"
|
||||
* - IE Edge <=13 === "[object Object]"
|
||||
*/
|
||||
if (typeof (window as any).location === 'object' && obj === (window as any).location) {
|
||||
return 'Location';
|
||||
}
|
||||
|
||||
/* ! Spec Conformance
|
||||
* (https://html.spec.whatwg.org/#document)
|
||||
* WhatWG HTML$3.1.1 - The `Document` object
|
||||
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
|
||||
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268)
|
||||
* which suggests that browsers should use HTMLTableCellElement for
|
||||
* both TD and TH elements. WhatWG separates these.
|
||||
* WhatWG HTML states:
|
||||
* > For historical reasons, Window objects must also have a
|
||||
* > writable, configurable, non-enumerable property named
|
||||
* > HTMLDocument whose value is the Document interface object.
|
||||
* Test: `Object.prototype.toString.call(document)``
|
||||
* - Chrome === "[object HTMLDocument]"
|
||||
* - Firefox === "[object HTMLDocument]"
|
||||
* - Safari === "[object HTMLDocument]"
|
||||
* - IE <=10 === "[object Document]"
|
||||
* - IE 11 === "[object HTMLDocument]"
|
||||
* - IE Edge <=13 === "[object HTMLDocument]"
|
||||
*/
|
||||
if (typeof (window as any).document === 'object' && obj === (window as any).document) {
|
||||
return 'Document';
|
||||
}
|
||||
|
||||
if (typeof (window as any).navigator === 'object') {
|
||||
/* ! Spec Conformance
|
||||
* (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray)
|
||||
* WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray
|
||||
* Test: `Object.prototype.toString.call(navigator.mimeTypes)``
|
||||
* - IE <=10 === "[object MSMimeTypesCollection]"
|
||||
*/
|
||||
if (typeof (window as any).navigator.mimeTypes === 'object' &&
|
||||
obj === (window as any).navigator.mimeTypes) {
|
||||
return 'MimeTypeArray';
|
||||
}
|
||||
|
||||
/* ! Spec Conformance
|
||||
* (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
|
||||
* WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray
|
||||
* Test: `Object.prototype.toString.call(navigator.plugins)``
|
||||
* - IE <=10 === "[object MSPluginsCollection]"
|
||||
*/
|
||||
if (typeof (window as any).navigator.plugins === 'object' &&
|
||||
obj === (window as any).navigator.plugins) {
|
||||
return 'PluginArray';
|
||||
}
|
||||
}
|
||||
|
||||
if ((typeof (window as any).HTMLElement === 'function' ||
|
||||
typeof (window as any).HTMLElement === 'object') &&
|
||||
obj instanceof (window as any).HTMLElement) {
|
||||
/* ! Spec Conformance
|
||||
* (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
|
||||
* WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement`
|
||||
* Test: `Object.prototype.toString.call(document.createElement('blockquote'))``
|
||||
* - IE <=10 === "[object HTMLBlockElement]"
|
||||
*/
|
||||
if ((obj as any).tagName === 'BLOCKQUOTE') {
|
||||
return 'HTMLQuoteElement';
|
||||
}
|
||||
|
||||
/* ! Spec Conformance
|
||||
* (https://html.spec.whatwg.org/#htmltabledatacellelement)
|
||||
* WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement`
|
||||
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
|
||||
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
|
||||
* which suggests that browsers should use HTMLTableCellElement for
|
||||
* both TD and TH elements. WhatWG separates these.
|
||||
* Test: Object.prototype.toString.call(document.createElement('td'))
|
||||
* - Chrome === "[object HTMLTableCellElement]"
|
||||
* - Firefox === "[object HTMLTableCellElement]"
|
||||
* - Safari === "[object HTMLTableCellElement]"
|
||||
*/
|
||||
if ((obj as any).tagName === 'TD') {
|
||||
return 'HTMLTableDataCellElement';
|
||||
}
|
||||
|
||||
/* ! Spec Conformance
|
||||
* (https://html.spec.whatwg.org/#htmltableheadercellelement)
|
||||
* WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement`
|
||||
* Note: Most browsers currently adher to the W3C DOM Level 2 spec
|
||||
* (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
|
||||
* which suggests that browsers should use HTMLTableCellElement for
|
||||
* both TD and TH elements. WhatWG separates these.
|
||||
* Test: Object.prototype.toString.call(document.createElement('th'))
|
||||
* - Chrome === "[object HTMLTableCellElement]"
|
||||
* - Firefox === "[object HTMLTableCellElement]"
|
||||
* - Safari === "[object HTMLTableCellElement]"
|
||||
*/
|
||||
if ((obj as any).tagName === 'TH') {
|
||||
return 'HTMLTableHeaderCellElement';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ! Speed optimisation
|
||||
* Pre:
|
||||
* Float64Array x 625,644 ops/sec ±1.58% (80 runs sampled)
|
||||
* Float32Array x 1,279,852 ops/sec ±2.91% (77 runs sampled)
|
||||
* Uint32Array x 1,178,185 ops/sec ±1.95% (83 runs sampled)
|
||||
* Uint16Array x 1,008,380 ops/sec ±2.25% (80 runs sampled)
|
||||
* Uint8Array x 1,128,040 ops/sec ±2.11% (81 runs sampled)
|
||||
* Int32Array x 1,170,119 ops/sec ±2.88% (80 runs sampled)
|
||||
* Int16Array x 1,176,348 ops/sec ±5.79% (86 runs sampled)
|
||||
* Int8Array x 1,058,707 ops/sec ±4.94% (77 runs sampled)
|
||||
* Uint8ClampedArray x 1,110,633 ops/sec ±4.20% (80 runs sampled)
|
||||
* Post:
|
||||
* Float64Array x 7,105,671 ops/sec ±13.47% (64 runs sampled)
|
||||
* Float32Array x 5,887,912 ops/sec ±1.46% (82 runs sampled)
|
||||
* Uint32Array x 6,491,661 ops/sec ±1.76% (79 runs sampled)
|
||||
* Uint16Array x 6,559,795 ops/sec ±1.67% (82 runs sampled)
|
||||
* Uint8Array x 6,463,966 ops/sec ±1.43% (85 runs sampled)
|
||||
* Int32Array x 5,641,841 ops/sec ±3.49% (81 runs sampled)
|
||||
* Int16Array x 6,583,511 ops/sec ±1.98% (80 runs sampled)
|
||||
* Int8Array x 6,606,078 ops/sec ±1.74% (81 runs sampled)
|
||||
* Uint8ClampedArray x 6,602,224 ops/sec ±1.77% (83 runs sampled)
|
||||
*/
|
||||
const stringTag = (symbolToStringTagExists && (obj as any)[Symbol.toStringTag]);
|
||||
if (typeof stringTag === 'string') {
|
||||
return stringTag;
|
||||
}
|
||||
|
||||
const objPrototype = Object.getPrototypeOf(obj);
|
||||
/* ! Speed optimisation
|
||||
* Pre:
|
||||
* regex literal x 1,772,385 ops/sec ±1.85% (77 runs sampled)
|
||||
* regex constructor x 2,143,634 ops/sec ±2.46% (78 runs sampled)
|
||||
* Post:
|
||||
* regex literal x 3,928,009 ops/sec ±0.65% (78 runs sampled)
|
||||
* regex constructor x 3,931,108 ops/sec ±0.58% (84 runs sampled)
|
||||
*/
|
||||
if (objPrototype === RegExp.prototype) {
|
||||
return 'RegExp';
|
||||
}
|
||||
|
||||
/* ! Speed optimisation
|
||||
* Pre:
|
||||
* date x 2,130,074 ops/sec ±4.42% (68 runs sampled)
|
||||
* Post:
|
||||
* date x 3,953,779 ops/sec ±1.35% (77 runs sampled)
|
||||
*/
|
||||
if (objPrototype === Date.prototype) {
|
||||
return 'Date';
|
||||
}
|
||||
|
||||
/* ! Spec Conformance
|
||||
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag)
|
||||
* ES6$25.4.5.4 - Promise.prototype[@@toStringTag] should be "Promise":
|
||||
* Test: `Object.prototype.toString.call(Promise.resolve())``
|
||||
* - Chrome <=47 === "[object Object]"
|
||||
* - Edge <=20 === "[object Object]"
|
||||
* - Firefox 29-Latest === "[object Promise]"
|
||||
* - Safari 7.1-Latest === "[object Promise]"
|
||||
*/
|
||||
if (promiseExists && objPrototype === Promise.prototype) {
|
||||
return 'Promise';
|
||||
}
|
||||
|
||||
/* ! Speed optimisation
|
||||
* Pre:
|
||||
* set x 2,222,186 ops/sec ±1.31% (82 runs sampled)
|
||||
* Post:
|
||||
* set x 4,545,879 ops/sec ±1.13% (83 runs sampled)
|
||||
*/
|
||||
if (setExists && objPrototype === Set.prototype) {
|
||||
return 'Set';
|
||||
}
|
||||
|
||||
/* ! Speed optimisation
|
||||
* Pre:
|
||||
* map x 2,396,842 ops/sec ±1.59% (81 runs sampled)
|
||||
* Post:
|
||||
* map x 4,183,945 ops/sec ±6.59% (82 runs sampled)
|
||||
*/
|
||||
if (mapExists && objPrototype === Map.prototype) {
|
||||
return 'Map';
|
||||
}
|
||||
|
||||
/* ! Speed optimisation
|
||||
* Pre:
|
||||
* weakset x 1,323,220 ops/sec ±2.17% (76 runs sampled)
|
||||
* Post:
|
||||
* weakset x 4,237,510 ops/sec ±2.01% (77 runs sampled)
|
||||
*/
|
||||
if (weakSetExists && objPrototype === WeakSet.prototype) {
|
||||
return 'WeakSet';
|
||||
}
|
||||
|
||||
/* ! Speed optimisation
|
||||
* Pre:
|
||||
* weakmap x 1,500,260 ops/sec ±2.02% (78 runs sampled)
|
||||
* Post:
|
||||
* weakmap x 3,881,384 ops/sec ±1.45% (82 runs sampled)
|
||||
*/
|
||||
if (weakMapExists && objPrototype === WeakMap.prototype) {
|
||||
return 'WeakMap';
|
||||
}
|
||||
|
||||
/* ! Spec Conformance
|
||||
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag)
|
||||
* ES6$24.2.4.21 - DataView.prototype[@@toStringTag] should be "DataView":
|
||||
* Test: `Object.prototype.toString.call(new DataView(new ArrayBuffer(1)))``
|
||||
* - Edge <=13 === "[object Object]"
|
||||
*/
|
||||
if (dataViewExists && objPrototype === DataView.prototype) {
|
||||
return 'DataView';
|
||||
}
|
||||
|
||||
/* ! Spec Conformance
|
||||
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag)
|
||||
* ES6$23.1.5.2.2 - %MapIteratorPrototype%[@@toStringTag] should be "Map Iterator":
|
||||
* Test: `Object.prototype.toString.call(new Map().entries())``
|
||||
* - Edge <=13 === "[object Object]"
|
||||
*/
|
||||
if (mapExists && objPrototype === mapIteratorPrototype) {
|
||||
return 'Map Iterator';
|
||||
}
|
||||
|
||||
/* ! Spec Conformance
|
||||
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag)
|
||||
* ES6$23.2.5.2.2 - %SetIteratorPrototype%[@@toStringTag] should be "Set Iterator":
|
||||
* Test: `Object.prototype.toString.call(new Set().entries())``
|
||||
* - Edge <=13 === "[object Object]"
|
||||
*/
|
||||
if (setExists && objPrototype === setIteratorPrototype) {
|
||||
return 'Set Iterator';
|
||||
}
|
||||
|
||||
/* ! Spec Conformance
|
||||
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag)
|
||||
* ES6$22.1.5.2.2 - %ArrayIteratorPrototype%[@@toStringTag] should be "Array Iterator":
|
||||
* Test: `Object.prototype.toString.call([][Symbol.iterator]())``
|
||||
* - Edge <=13 === "[object Object]"
|
||||
*/
|
||||
if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
|
||||
return 'Array Iterator';
|
||||
}
|
||||
|
||||
/* ! Spec Conformance
|
||||
* (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag)
|
||||
* ES6$21.1.5.2.2 - %StringIteratorPrototype%[@@toStringTag] should be "String Iterator":
|
||||
* Test: `Object.prototype.toString.call(''[Symbol.iterator]())``
|
||||
* - Edge <=13 === "[object Object]"
|
||||
*/
|
||||
if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
|
||||
return 'String Iterator';
|
||||
}
|
||||
|
||||
/* ! Speed optimisation
|
||||
* Pre:
|
||||
* object from null x 2,424,320 ops/sec ±1.67% (76 runs sampled)
|
||||
* Post:
|
||||
* object from null x 5,838,000 ops/sec ±0.99% (84 runs sampled)
|
||||
*/
|
||||
if (objPrototype === null) {
|
||||
return 'Object';
|
||||
}
|
||||
|
||||
return Object
|
||||
.prototype
|
||||
.toString
|
||||
.call(obj)
|
||||
.slice(toStringLeftSliceLength, toStringRightSliceLength);
|
||||
}
|
||||
113
node_modules/@sinonjs/samsam/node_modules/type-detect/package.json
generated
vendored
Normal file
113
node_modules/@sinonjs/samsam/node_modules/type-detect/package.json
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
{
|
||||
"name": "type-detect",
|
||||
"version": "4.1.0",
|
||||
"description": "Improved typeof detection for node.js and the browser.",
|
||||
"keywords": [
|
||||
"type",
|
||||
"typeof",
|
||||
"types"
|
||||
],
|
||||
"license": "MIT",
|
||||
"author": "Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.com)",
|
||||
"contributors": [
|
||||
"Keith Cirkel (https://github.com/keithamus)",
|
||||
"David Losert (https://github.com/davelosert)",
|
||||
"Aleksey Shvayka (https://github.com/shvaikalesh)",
|
||||
"Lucas Fernandes da Costa (https://github.com/lucasfcosta)",
|
||||
"Grant Snodgrass (https://github.com/meeber)",
|
||||
"Jeremy Tice (https://github.com/jetpacmonkey)",
|
||||
"Edward Betts (https://github.com/EdwardBetts)",
|
||||
"dvlsg (https://github.com/dvlsg)",
|
||||
"Amila Welihinda (https://github.com/amilajack)",
|
||||
"Jake Champion (https://github.com/JakeChampion)",
|
||||
"Miroslav Bajtoš (https://github.com/bajtos)"
|
||||
],
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.ts",
|
||||
"index.d.ts",
|
||||
"type-detect.js"
|
||||
],
|
||||
"main": "./type-detect.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/chaijs/type-detect.git"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "node bench",
|
||||
"build": "tsc && rollup -c rollup.conf.js",
|
||||
"commit-msg": "commitlint -x angular",
|
||||
"lint": "eslint --ignore-path .gitignore . --ext .js,.ts",
|
||||
"prepare": "cross-env NODE_ENV=production npm run build",
|
||||
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
|
||||
"pretest:node": "cross-env NODE_ENV=test npm run build",
|
||||
"pretest:browser": "cross-env NODE_ENV=test npm run build",
|
||||
"test": "npm run test:node && npm run test:browser",
|
||||
"test:browser": "karma start --singleRun=true",
|
||||
"test:node": "nyc mocha type-detect.test.js",
|
||||
"test:deno": "deno test test/deno-test.ts",
|
||||
"posttest:node": "nyc report --report-dir \"coverage/node-$(node --version)\" --reporter=lcovonly && npm run upload-coverage",
|
||||
"posttest:browser": "npm run upload-coverage",
|
||||
"upload-coverage": "codecov"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"env": {
|
||||
"es6": true
|
||||
},
|
||||
"extends": [
|
||||
"strict/es6"
|
||||
],
|
||||
"globals": {
|
||||
"HTMLElement": false,
|
||||
"window": false
|
||||
},
|
||||
"rules": {
|
||||
"complexity": 0,
|
||||
"max-statements": 0,
|
||||
"prefer-rest-params": 0
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^13.1.0",
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"@rollup/plugin-commonjs": "^20.0.0",
|
||||
"@rollup/plugin-node-resolve": "^13.0.5",
|
||||
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
||||
"@typescript-eslint/parser": "^4.31.2",
|
||||
"benchmark": "^2.1.4",
|
||||
"buble": "^0.20.0",
|
||||
"codecov": "^3.8.3",
|
||||
"commitlint-config-angular": "^13.1.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-strict": "^14.0.1",
|
||||
"eslint-plugin-filenames": "^1.3.2",
|
||||
"husky": "^7.0.2",
|
||||
"karma": "^6.3.4",
|
||||
"karma-chrome-launcher": "^3.1.0",
|
||||
"karma-coverage": "^2.0.3",
|
||||
"karma-detect-browsers": "^2.3.3",
|
||||
"karma-edge-launcher": "^0.4.2",
|
||||
"karma-firefox-launcher": "^2.1.1",
|
||||
"karma-ie-launcher": "^1.0.0",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-opera-launcher": "^1.0.0",
|
||||
"karma-safari-launcher": "^1.0.0",
|
||||
"karma-safaritechpreview-launcher": "^2.0.2",
|
||||
"karma-sauce-launcher": "^4.3.6",
|
||||
"mocha": "^9.1.1",
|
||||
"nyc": "^15.1.0",
|
||||
"rollup": "^2.57.0",
|
||||
"rollup-plugin-istanbul": "^3.0.0",
|
||||
"semantic-release": "^18.0.0",
|
||||
"simple-assert": "^1.0.0",
|
||||
"typescript": "^4.4.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
}
|
||||
139
node_modules/@sinonjs/samsam/node_modules/type-detect/type-detect.js
generated
vendored
Normal file
139
node_modules/@sinonjs/samsam/node_modules/type-detect/type-detect.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.typeDetect = factory());
|
||||
})(this, (function () { 'use strict';
|
||||
|
||||
var promiseExists = typeof Promise === 'function';
|
||||
var globalObject = (function (Obj) {
|
||||
if (typeof globalThis === 'object') {
|
||||
return globalThis;
|
||||
}
|
||||
Object.defineProperty(Obj, 'typeDetectGlobalObject', {
|
||||
get: function get() {
|
||||
return this;
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
var global = typeDetectGlobalObject;
|
||||
delete Obj.typeDetectGlobalObject;
|
||||
return global;
|
||||
})(Object.prototype);
|
||||
var symbolExists = typeof Symbol !== 'undefined';
|
||||
var mapExists = typeof Map !== 'undefined';
|
||||
var setExists = typeof Set !== 'undefined';
|
||||
var weakMapExists = typeof WeakMap !== 'undefined';
|
||||
var weakSetExists = typeof WeakSet !== 'undefined';
|
||||
var dataViewExists = typeof DataView !== 'undefined';
|
||||
var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined';
|
||||
var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined';
|
||||
var setEntriesExists = setExists && typeof Set.prototype.entries === 'function';
|
||||
var mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function';
|
||||
var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries());
|
||||
var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries());
|
||||
var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
|
||||
var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
|
||||
var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === 'function';
|
||||
var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]());
|
||||
var toStringLeftSliceLength = 8;
|
||||
var toStringRightSliceLength = -1;
|
||||
function typeDetect(obj) {
|
||||
var typeofObj = typeof obj;
|
||||
if (typeofObj !== 'object') {
|
||||
return typeofObj;
|
||||
}
|
||||
if (obj === null) {
|
||||
return 'null';
|
||||
}
|
||||
if (obj === globalObject) {
|
||||
return 'global';
|
||||
}
|
||||
if (Array.isArray(obj) &&
|
||||
(symbolToStringTagExists === false || !(Symbol.toStringTag in obj))) {
|
||||
return 'Array';
|
||||
}
|
||||
if (typeof window === 'object' && window !== null) {
|
||||
if (typeof window.location === 'object' && obj === window.location) {
|
||||
return 'Location';
|
||||
}
|
||||
if (typeof window.document === 'object' && obj === window.document) {
|
||||
return 'Document';
|
||||
}
|
||||
if (typeof window.navigator === 'object') {
|
||||
if (typeof window.navigator.mimeTypes === 'object' &&
|
||||
obj === window.navigator.mimeTypes) {
|
||||
return 'MimeTypeArray';
|
||||
}
|
||||
if (typeof window.navigator.plugins === 'object' &&
|
||||
obj === window.navigator.plugins) {
|
||||
return 'PluginArray';
|
||||
}
|
||||
}
|
||||
if ((typeof window.HTMLElement === 'function' ||
|
||||
typeof window.HTMLElement === 'object') &&
|
||||
obj instanceof window.HTMLElement) {
|
||||
if (obj.tagName === 'BLOCKQUOTE') {
|
||||
return 'HTMLQuoteElement';
|
||||
}
|
||||
if (obj.tagName === 'TD') {
|
||||
return 'HTMLTableDataCellElement';
|
||||
}
|
||||
if (obj.tagName === 'TH') {
|
||||
return 'HTMLTableHeaderCellElement';
|
||||
}
|
||||
}
|
||||
}
|
||||
var stringTag = (symbolToStringTagExists && obj[Symbol.toStringTag]);
|
||||
if (typeof stringTag === 'string') {
|
||||
return stringTag;
|
||||
}
|
||||
var objPrototype = Object.getPrototypeOf(obj);
|
||||
if (objPrototype === RegExp.prototype) {
|
||||
return 'RegExp';
|
||||
}
|
||||
if (objPrototype === Date.prototype) {
|
||||
return 'Date';
|
||||
}
|
||||
if (promiseExists && objPrototype === Promise.prototype) {
|
||||
return 'Promise';
|
||||
}
|
||||
if (setExists && objPrototype === Set.prototype) {
|
||||
return 'Set';
|
||||
}
|
||||
if (mapExists && objPrototype === Map.prototype) {
|
||||
return 'Map';
|
||||
}
|
||||
if (weakSetExists && objPrototype === WeakSet.prototype) {
|
||||
return 'WeakSet';
|
||||
}
|
||||
if (weakMapExists && objPrototype === WeakMap.prototype) {
|
||||
return 'WeakMap';
|
||||
}
|
||||
if (dataViewExists && objPrototype === DataView.prototype) {
|
||||
return 'DataView';
|
||||
}
|
||||
if (mapExists && objPrototype === mapIteratorPrototype) {
|
||||
return 'Map Iterator';
|
||||
}
|
||||
if (setExists && objPrototype === setIteratorPrototype) {
|
||||
return 'Set Iterator';
|
||||
}
|
||||
if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
|
||||
return 'Array Iterator';
|
||||
}
|
||||
if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
|
||||
return 'String Iterator';
|
||||
}
|
||||
if (objPrototype === null) {
|
||||
return 'Object';
|
||||
}
|
||||
return Object
|
||||
.prototype
|
||||
.toString
|
||||
.call(obj)
|
||||
.slice(toStringLeftSliceLength, toStringRightSliceLength);
|
||||
}
|
||||
|
||||
return typeDetect;
|
||||
|
||||
}));
|
||||
34
node_modules/@sinonjs/samsam/package.json
generated
vendored
34
node_modules/@sinonjs/samsam/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@sinonjs/samsam",
|
||||
"version": "8.0.0",
|
||||
"version": "8.0.2",
|
||||
"description": "Value identification and comparison functions",
|
||||
"homepage": "http://sinonjs.github.io/samsam/",
|
||||
"author": "Christian Johansen",
|
||||
@@ -44,31 +44,31 @@
|
||||
"types/"
|
||||
],
|
||||
"dependencies": {
|
||||
"@sinonjs/commons": "^2.0.0",
|
||||
"@sinonjs/commons": "^3.0.1",
|
||||
"lodash.get": "^4.4.2",
|
||||
"type-detect": "^4.0.8"
|
||||
"type-detect": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sinonjs/eslint-config": "^4.0.6",
|
||||
"@sinonjs/eslint-plugin-no-prototype-methods": "^0.1.0",
|
||||
"@sinonjs/referee": "^9.1.1",
|
||||
"@studio/changes": "^2.2.0",
|
||||
"@sinonjs/eslint-config": "^5.0.3",
|
||||
"@sinonjs/eslint-plugin-no-prototype-methods": "^0.1.1",
|
||||
"@sinonjs/referee": "^11.0.1",
|
||||
"@studio/changes": "^3.0.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"husky": "^8.0.0",
|
||||
"jquery": "^3.4.1",
|
||||
"jsdoc": "^3.6.11",
|
||||
"jsdom": "^16.2.0",
|
||||
"husky": "^9.1.6",
|
||||
"jquery": "^3.7.1",
|
||||
"jsdoc": "^4.0.3",
|
||||
"jsdom": "^25.0.0",
|
||||
"jsdom-global": "^3.0.2",
|
||||
"lint-staged": "^10.0.7",
|
||||
"lint-staged": "^15.2.10",
|
||||
"microtime": "^3.1.1",
|
||||
"mocha": "^10.1.0",
|
||||
"mocha": "^10.7.3",
|
||||
"mochify": "^9.2.0",
|
||||
"nyc": "^15.1.0",
|
||||
"prettier": "^2.7.1",
|
||||
"nyc": "^17.0.0",
|
||||
"prettier": "^3.3.3",
|
||||
"proxyquire": "^2.1.3",
|
||||
"proxyquire-universal": "^2.1.0",
|
||||
"proxyquire-universal": "^3.0.1",
|
||||
"proxyquireify": "^3.2.1",
|
||||
"typescript": "^4.8.4"
|
||||
"typescript": "^5.6.2"
|
||||
},
|
||||
"nyc": {
|
||||
"exclude": [
|
||||
|
||||
34
node_modules/@sinonjs/samsam/types/create-matcher.d.ts
generated
vendored
34
node_modules/@sinonjs/samsam/types/create-matcher.d.ts
generated
vendored
@@ -10,31 +10,31 @@ export = createMatcher;
|
||||
declare function createMatcher(expectation: any, message: string, ...args: any[]): object;
|
||||
declare namespace createMatcher {
|
||||
export { isMatcher };
|
||||
export const any: any;
|
||||
export const defined: any;
|
||||
export const truthy: any;
|
||||
export const falsy: any;
|
||||
export let any: any;
|
||||
export let defined: any;
|
||||
export let truthy: any;
|
||||
export let falsy: any;
|
||||
export function same(expectation: any): any;
|
||||
function _in(arrayOfExpectations: any): any;
|
||||
export { _in as in };
|
||||
export function typeOf(type: any): any;
|
||||
export function instanceOf(type: any): any;
|
||||
export const has: any;
|
||||
export const hasOwn: any;
|
||||
export let has: any;
|
||||
export let hasOwn: any;
|
||||
export function hasNested(property: any, value: any, ...args: any[]): any;
|
||||
export function json(value: any): any;
|
||||
export function every(predicate: any): any;
|
||||
export function some(predicate: any): any;
|
||||
export const array: any;
|
||||
export const map: any;
|
||||
export const set: any;
|
||||
export const bool: any;
|
||||
export const number: any;
|
||||
export const string: any;
|
||||
export const object: any;
|
||||
export const func: any;
|
||||
export const regexp: any;
|
||||
export const date: any;
|
||||
export const symbol: any;
|
||||
export let array: any;
|
||||
export let map: any;
|
||||
export let set: any;
|
||||
export let bool: any;
|
||||
export let number: any;
|
||||
export let string: any;
|
||||
export let object: any;
|
||||
export let func: any;
|
||||
export let regexp: any;
|
||||
export let date: any;
|
||||
export let symbol: any;
|
||||
}
|
||||
import isMatcher = require("./create-matcher/is-matcher");
|
||||
|
||||
5
node_modules/@sinonjs/text-encoding/package.json
generated
vendored
5
node_modules/@sinonjs/text-encoding/package.json
generated
vendored
@@ -1,5 +1,8 @@
|
||||
{
|
||||
"name": "@sinonjs/text-encoding",
|
||||
"scripts": {
|
||||
"postpublish": "git push --tags"
|
||||
},
|
||||
"author": "Joshua Bell <inexorabletash@gmail.com>",
|
||||
"contributors": [
|
||||
"Joshua Bell <inexorabletash@gmail.com>",
|
||||
@@ -12,7 +15,7 @@
|
||||
"Pierre Queinnec <pierre@queinnec.org>",
|
||||
"Zack Weinberg <zackw@panix.com>"
|
||||
],
|
||||
"version": "0.7.2",
|
||||
"version": "0.7.3",
|
||||
"description": "Polyfill for the Encoding Living Standard's API.",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
|
||||
20
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-literal-property-style.js
generated
vendored
20
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-literal-property-style.js
generated
vendored
@@ -40,9 +40,6 @@ exports.default = (0, util_1.createRule)({
|
||||
defaultOptions: ['fields'],
|
||||
create(context, [style]) {
|
||||
const propertiesInfoStack = [];
|
||||
function getStringValue(node) {
|
||||
return (0, util_1.getStaticStringValue)(node) ?? context.sourceCode.getText(node);
|
||||
}
|
||||
function enterClassBody() {
|
||||
propertiesInfoStack.push({
|
||||
properties: [],
|
||||
@@ -56,8 +53,8 @@ exports.default = (0, util_1.createRule)({
|
||||
if (!value || !isSupportedLiteral(value)) {
|
||||
return;
|
||||
}
|
||||
const name = getStringValue(node.key);
|
||||
if (excludeSet.has(name)) {
|
||||
const name = (0, util_1.getStaticMemberAccessValue)(node, context);
|
||||
if (name && excludeSet.has(name)) {
|
||||
return;
|
||||
}
|
||||
context.report({
|
||||
@@ -105,12 +102,13 @@ exports.default = (0, util_1.createRule)({
|
||||
if (!argument || !isSupportedLiteral(argument)) {
|
||||
return;
|
||||
}
|
||||
const name = getStringValue(node.key);
|
||||
const hasDuplicateKeySetter = node.parent.body.some(element => {
|
||||
return (element.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
|
||||
element.kind === 'set' &&
|
||||
getStringValue(element.key) === name);
|
||||
});
|
||||
const name = (0, util_1.getStaticMemberAccessValue)(node, context);
|
||||
const hasDuplicateKeySetter = name &&
|
||||
node.parent.body.some(element => {
|
||||
return (element.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
|
||||
element.kind === 'set' &&
|
||||
(0, util_1.isStaticMemberAccessOfValue)(element, context, name));
|
||||
});
|
||||
if (hasDuplicateKeySetter) {
|
||||
return;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-methods-use-this.js
generated
vendored
4
node_modules/@typescript-eslint/eslint-plugin/dist/rules/class-methods-use-this.js
generated
vendored
@@ -120,9 +120,7 @@ exports.default = (0, util_1.createRule)({
|
||||
return true;
|
||||
}
|
||||
const hashIfNeeded = node.key.type === utils_1.AST_NODE_TYPES.PrivateIdentifier ? '#' : '';
|
||||
const name = node.key.type === utils_1.AST_NODE_TYPES.Literal
|
||||
? (0, util_1.getStaticStringValue)(node.key)
|
||||
: node.key.name || '';
|
||||
const name = (0, util_1.getStaticMemberAccessValue)(node, context);
|
||||
return !exceptMethods.has(hashIfNeeded + (name ?? ''));
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"class-methods-use-this.js","sourceRoot":"","sources":["../../src/rules/class-methods-use-this.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAE1D,kCAKiB;AAYjB,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,2CAA2C;YACxD,eAAe,EAAE,IAAI;YACrB,oBAAoB,EAAE,KAAK;SAC5B;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,aAAa,EAAE;wBACb,IAAI,EAAE,OAAO;wBACb,WAAW,EACT,4DAA4D;wBAC9D,KAAK,EAAE;4BACL,IAAI,EAAE,QAAQ;yBACf;qBACF;oBACD,qBAAqB,EAAE;wBACrB,IAAI,EAAE,SAAS;wBACf,WAAW,EACT,4EAA4E;wBAC9E,OAAO,EAAE,IAAI;qBACd;oBACD,qBAAqB,EAAE;wBACrB,IAAI,EAAE,SAAS;wBACf,WAAW,EAAE,oDAAoD;qBAClE;oBACD,qCAAqC,EAAE;wBACrC,KAAK,EAAE;4BACL;gCACE,IAAI,EAAE,SAAS;gCACf,WAAW,EAAE,gDAAgD;6BAC9D;4BACD;gCACE,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,CAAC,eAAe,CAAC;gCACvB,WAAW,EACT,sEAAsE;6BACzE;yBACF;wBACD,WAAW,EACT,2DAA2D;qBAC9D;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,+CAA+C;SAC7D;KACF;IACD,cAAc,EAAE;QACd;YACE,qBAAqB,EAAE,IAAI;YAC3B,aAAa,EAAE,EAAE;YACjB,qCAAqC,EAAE,KAAK;YAC5C,qBAAqB,EAAE,KAAK;SAC7B;KACF;IACD,MAAM,CACJ,OAAO,EACP,CACE,EACE,qBAAqB,EACrB,aAAa,EAAE,gBAAgB,EAC/B,qCAAqC,EACrC,qBAAqB,GACtB,EACF;QAED,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAchD,IAAI,KAAwB,CAAC;QAE7B,SAAS,WAAW,CAClB,MAAgE;YAEhE,IAAI,MAAM,EAAE,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,SAAS,EAAE,CAAC;gBACrD,KAAK,GAAG;oBACN,MAAM;oBACN,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;oBAC3B,QAAQ,EAAE,KAAK;oBACf,MAAM,EAAE,KAAK;iBACd,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,KAAK,GAAG;oBACN,MAAM,EAAE,IAAI;oBACZ,KAAK,EAAE,IAAI;oBACX,QAAQ,EAAE,KAAK;oBACf,MAAM,EAAE,KAAK;iBACd,CAAC;YACJ,CAAC;QACH,CAAC;QAED,SAAS,aAAa,CACpB,IAAoE;YAEpE,IACE,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,gBAAgB;gBACpD,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,kBAAkB,EACtD,CAAC;gBACD,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3B,CAAC;iBAAM,CAAC;gBACN,WAAW,EAAE,CAAC;YAChB,CAAC;QACH,CAAC;QAED;;WAEG;QACH,SAAS,UAAU;YACjB,MAAM,QAAQ,GAAG,KAAK,CAAC;YACvB,KAAK,GAAG,KAAK,EAAE,MAAM,CAAC;YACtB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,SAAS,aAAa,CACpB,aAAiD;YAEjD,IAAI,CAAC,aAAa,IAAI,aAAa,KAAK,QAAQ,EAAE,CAAC;gBACjD,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;QAED;;WAEG;QACH,SAAS,wBAAwB,CAC/B,IAAkC;YAElC,IACE,IAAI,CAAC,MAAM;gBACX,CAAC,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,gBAAgB;oBAC5C,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC;gBAC9B,CAAC,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,kBAAkB;oBAC9C,CAAC,qBAAqB,CAAC,EACzB,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;YAED,IAAI,IAAI,CAAC,QAAQ,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;gBAC9C,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,YAAY,GAChB,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,sBAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAChE,MAAM,IAAI,GACR,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,sBAAc,CAAC,OAAO;gBACtC,CAAC,CAAC,IAAA,2BAAoB,EAAC,IAAI,CAAC,GAAG,CAAC;gBAChC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;YAE1B,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;QACzD,CAAC;QAED;;;;WAIG;QACH,SAAS,YAAY,CACnB,IAAoE;YAEpE,MAAM,YAAY,GAAG,UAAU,EAAE,CAAC;YAClC,IACE,YAAY,EAAE,MAAM,IAAI,IAAI;gBAC5B,YAAY,CAAC,QAAQ;gBACrB,CAAC,qBAAqB,IAAI,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC;gBACvD,CAAC,qCAAqC,KAAK,IAAI;oBAC7C,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;gBAC3C,CAAC,qCAAqC,KAAK,eAAe;oBACxD,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;oBACxC,aAAa,CAAC,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EACnD,CAAC;gBACD,OAAO;YACT,CAAC;YAED,IAAI,wBAAwB,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;gBAClD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,GAAG,EAAE,IAAA,yBAAkB,EAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC;oBACjD,SAAS,EAAE,aAAa;oBACxB,IAAI,EAAE;wBACJ,IAAI,EAAE,IAAA,8BAAuB,EAAC,IAAI,CAAC;qBACpC;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO;YACL,sDAAsD;YACtD,mBAAmB;gBACjB,WAAW,EAAE,CAAC;YAChB,CAAC;YACD,0BAA0B;gBACxB,UAAU,EAAE,CAAC;YACf,CAAC;YAED,kBAAkB,CAAC,IAAI;gBACrB,aAAa,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;YACD,yBAAyB,CAAC,IAAI;gBAC5B,YAAY,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;YACD,GAAG,CAAC,qBAAqB;gBACvB,CAAC,CAAC;oBACE,oDAAoD,CAClD,IAAsC;wBAEtC,aAAa,CAAC,IAAI,CAAC,CAAC;oBACtB,CAAC;oBACD,yDAAyD,CACvD,IAAsC;wBAEtC,YAAY,CAAC,IAAI,CAAC,CAAC;oBACrB,CAAC;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;YAEP;;eAEG;YACH,iCAAiC;gBAC/B,WAAW,EAAE,CAAC;YAChB,CAAC;YACD,yBAAyB;gBACvB,UAAU,EAAE,CAAC;YACf,CAAC;YAED;;;;;eAKG;YACH,WAAW;gBACT,WAAW,EAAE,CAAC;YAChB,CAAC;YACD,kBAAkB;gBAChB,UAAU,EAAE,CAAC;YACf,CAAC;YAED,uBAAuB;gBACrB,IAAI,KAAK,EAAE,CAAC;oBACV,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACxB,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
{"version":3,"file":"class-methods-use-this.js","sourceRoot":"","sources":["../../src/rules/class-methods-use-this.ts"],"names":[],"mappings":";;AACA,oDAA0D;AAE1D,kCAKiB;AAYjB,kBAAe,IAAA,iBAAU,EAAsB;IAC7C,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE;YACJ,WAAW,EAAE,2CAA2C;YACxD,eAAe,EAAE,IAAI;YACrB,oBAAoB,EAAE,KAAK;SAC5B;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,aAAa,EAAE;wBACb,IAAI,EAAE,OAAO;wBACb,WAAW,EACT,4DAA4D;wBAC9D,KAAK,EAAE;4BACL,IAAI,EAAE,QAAQ;yBACf;qBACF;oBACD,qBAAqB,EAAE;wBACrB,IAAI,EAAE,SAAS;wBACf,WAAW,EACT,4EAA4E;wBAC9E,OAAO,EAAE,IAAI;qBACd;oBACD,qBAAqB,EAAE;wBACrB,IAAI,EAAE,SAAS;wBACf,WAAW,EAAE,oDAAoD;qBAClE;oBACD,qCAAqC,EAAE;wBACrC,KAAK,EAAE;4BACL;gCACE,IAAI,EAAE,SAAS;gCACf,WAAW,EAAE,gDAAgD;6BAC9D;4BACD;gCACE,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,CAAC,eAAe,CAAC;gCACvB,WAAW,EACT,sEAAsE;6BACzE;yBACF;wBACD,WAAW,EACT,2DAA2D;qBAC9D;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,+CAA+C;SAC7D;KACF;IACD,cAAc,EAAE;QACd;YACE,qBAAqB,EAAE,IAAI;YAC3B,aAAa,EAAE,EAAE;YACjB,qCAAqC,EAAE,KAAK;YAC5C,qBAAqB,EAAE,KAAK;SAC7B;KACF;IACD,MAAM,CACJ,OAAO,EACP,CACE,EACE,qBAAqB,EACrB,aAAa,EAAE,gBAAgB,EAC/B,qCAAqC,EACrC,qBAAqB,GACtB,EACF;QAED,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAchD,IAAI,KAAwB,CAAC;QAE7B,SAAS,WAAW,CAClB,MAAgE;YAEhE,IAAI,MAAM,EAAE,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,SAAS,EAAE,CAAC;gBACrD,KAAK,GAAG;oBACN,MAAM;oBACN,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;oBAC3B,QAAQ,EAAE,KAAK;oBACf,MAAM,EAAE,KAAK;iBACd,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,KAAK,GAAG;oBACN,MAAM,EAAE,IAAI;oBACZ,KAAK,EAAE,IAAI;oBACX,QAAQ,EAAE,KAAK;oBACf,MAAM,EAAE,KAAK;iBACd,CAAC;YACJ,CAAC;QACH,CAAC;QAED,SAAS,aAAa,CACpB,IAAoE;YAEpE,IACE,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,gBAAgB;gBACpD,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,kBAAkB,EACtD,CAAC;gBACD,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC3B,CAAC;iBAAM,CAAC;gBACN,WAAW,EAAE,CAAC;YAChB,CAAC;QACH,CAAC;QAED;;WAEG;QACH,SAAS,UAAU;YACjB,MAAM,QAAQ,GAAG,KAAK,CAAC;YACvB,KAAK,GAAG,KAAK,EAAE,MAAM,CAAC;YACtB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,SAAS,aAAa,CACpB,aAAiD;YAEjD,IAAI,CAAC,aAAa,IAAI,aAAa,KAAK,QAAQ,EAAE,CAAC;gBACjD,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;QAED;;WAEG;QACH,SAAS,wBAAwB,CAC/B,IAAkC;YAElC,IACE,IAAI,CAAC,MAAM;gBACX,CAAC,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,gBAAgB;oBAC5C,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC;gBAC9B,CAAC,IAAI,CAAC,IAAI,KAAK,sBAAc,CAAC,kBAAkB;oBAC9C,CAAC,qBAAqB,CAAC,EACzB,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;YAED,IAAI,IAAI,CAAC,QAAQ,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;gBAC9C,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,YAAY,GAChB,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,sBAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAChE,MAAM,IAAI,GAAG,IAAA,iCAA0B,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAEvD,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;QACzD,CAAC;QAED;;;;WAIG;QACH,SAAS,YAAY,CACnB,IAAoE;YAEpE,MAAM,YAAY,GAAG,UAAU,EAAE,CAAC;YAClC,IACE,YAAY,EAAE,MAAM,IAAI,IAAI;gBAC5B,YAAY,CAAC,QAAQ;gBACrB,CAAC,qBAAqB,IAAI,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC;gBACvD,CAAC,qCAAqC,KAAK,IAAI;oBAC7C,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;gBAC3C,CAAC,qCAAqC,KAAK,eAAe;oBACxD,YAAY,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;oBACxC,aAAa,CAAC,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EACnD,CAAC;gBACD,OAAO;YACT,CAAC;YAED,IAAI,wBAAwB,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;gBAClD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,GAAG,EAAE,IAAA,yBAAkB,EAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC;oBACjD,SAAS,EAAE,aAAa;oBACxB,IAAI,EAAE;wBACJ,IAAI,EAAE,IAAA,8BAAuB,EAAC,IAAI,CAAC;qBACpC;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO;YACL,sDAAsD;YACtD,mBAAmB;gBACjB,WAAW,EAAE,CAAC;YAChB,CAAC;YACD,0BAA0B;gBACxB,UAAU,EAAE,CAAC;YACf,CAAC;YAED,kBAAkB,CAAC,IAAI;gBACrB,aAAa,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;YACD,yBAAyB,CAAC,IAAI;gBAC5B,YAAY,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC;YACD,GAAG,CAAC,qBAAqB;gBACvB,CAAC,CAAC;oBACE,oDAAoD,CAClD,IAAsC;wBAEtC,aAAa,CAAC,IAAI,CAAC,CAAC;oBACtB,CAAC;oBACD,yDAAyD,CACvD,IAAsC;wBAEtC,YAAY,CAAC,IAAI,CAAC,CAAC;oBACrB,CAAC;iBACF;gBACH,CAAC,CAAC,EAAE,CAAC;YAEP;;eAEG;YACH,iCAAiC;gBAC/B,WAAW,EAAE,CAAC;YAChB,CAAC;YACD,yBAAyB;gBACvB,UAAU,EAAE,CAAC;YACf,CAAC;YAED;;;;;eAKG;YACH,WAAW;gBACT,WAAW,EAAE,CAAC;YAChB,CAAC;YACD,kBAAkB;gBAChB,UAAU,EAAE,CAAC;YACf,CAAC;YAED,uBAAuB;gBACrB,IAAI,KAAK,EAAE,CAAC;oBACV,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACxB,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
||||
@@ -88,7 +88,6 @@ exports.default = (0, util_1.createRule)({
|
||||
},
|
||||
],
|
||||
create(context, [options]) {
|
||||
const parserServices = (0, util_1.getParserServices)(context, true);
|
||||
function isConst(node) {
|
||||
if (node.type !== utils_1.AST_NODE_TYPES.TSTypeReference) {
|
||||
return false;
|
||||
@@ -110,7 +109,8 @@ exports.default = (0, util_1.createRule)({
|
||||
: {},
|
||||
fix: messageId === 'as'
|
||||
? (fixer) => {
|
||||
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
|
||||
// lazily access parserServices to avoid crashing on non TS files (#9860)
|
||||
const tsNode = (0, util_1.getParserServices)(context, true).esTreeNodeToTSNodeMap.get(node);
|
||||
const expressionCode = context.sourceCode.getText(node.expression);
|
||||
const typeAnnotationCode = context.sourceCode.getText(node.typeAnnotation);
|
||||
const asPrecedence = (0, util_1.getOperatorPrecedence)(ts.SyntaxKind.AsExpression, ts.SyntaxKind.Unknown);
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-exports.js
generated
vendored
2
node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-exports.js
generated
vendored
@@ -199,7 +199,7 @@ function* fixExportInsertType(fixer, sourceCode, node) {
|
||||
*/
|
||||
function* fixSeparateNamedExports(fixer, sourceCode, report) {
|
||||
const { node, typeBasedSpecifiers, inlineTypeSpecifiers, valueSpecifiers } = report;
|
||||
const typeSpecifiers = typeBasedSpecifiers.concat(inlineTypeSpecifiers);
|
||||
const typeSpecifiers = [...typeBasedSpecifiers, ...inlineTypeSpecifiers];
|
||||
const source = getSourceFromExport(node);
|
||||
const specifierNames = typeSpecifiers.map(getSpecifierText).join(', ');
|
||||
const exportToken = (0, util_1.nullThrows)(sourceCode.getFirstToken(node), util_1.NullThrowsReasons.MissingToken('export', node.type));
|
||||
|
||||
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user