This commit is contained in:
21
node_modules/@wry/equality/LICENSE
generated
vendored
Normal file
21
node_modules/@wry/equality/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Ben Newman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
4
node_modules/@wry/equality/README.md
generated
vendored
Normal file
4
node_modules/@wry/equality/README.md
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# @wry/equality
|
||||
|
||||
Structural equality checking for JavaScript values, with correct handling
|
||||
of cyclic references, and minimal bundle size.
|
||||
5
node_modules/@wry/equality/lib/equality.d.ts
generated
vendored
Normal file
5
node_modules/@wry/equality/lib/equality.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Performs a deep equality check on two JavaScript values, tolerating cycles.
|
||||
*/
|
||||
export declare function equal(a: any, b: any): boolean;
|
||||
export default equal;
|
||||
129
node_modules/@wry/equality/lib/equality.esm.js
generated
vendored
Normal file
129
node_modules/@wry/equality/lib/equality.esm.js
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
var _a = Object.prototype, toString = _a.toString, hasOwnProperty = _a.hasOwnProperty;
|
||||
var previousComparisons = new Map();
|
||||
/**
|
||||
* Performs a deep equality check on two JavaScript values, tolerating cycles.
|
||||
*/
|
||||
function equal(a, b) {
|
||||
try {
|
||||
return check(a, b);
|
||||
}
|
||||
finally {
|
||||
previousComparisons.clear();
|
||||
}
|
||||
}
|
||||
function check(a, b) {
|
||||
// If the two values are strictly equal, our job is easy.
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
// Object.prototype.toString returns a representation of the runtime type of
|
||||
// the given value that is considerably more precise than typeof.
|
||||
var aTag = toString.call(a);
|
||||
var bTag = toString.call(b);
|
||||
// If the runtime types of a and b are different, they could maybe be equal
|
||||
// under some interpretation of equality, but for simplicity and performance
|
||||
// we just return false instead.
|
||||
if (aTag !== bTag) {
|
||||
return false;
|
||||
}
|
||||
switch (aTag) {
|
||||
case '[object Array]':
|
||||
// Arrays are a lot like other objects, but we can cheaply compare their
|
||||
// lengths as a short-cut before comparing their elements.
|
||||
if (a.length !== b.length)
|
||||
return false;
|
||||
// Fall through to object case...
|
||||
case '[object Object]': {
|
||||
if (previouslyCompared(a, b))
|
||||
return true;
|
||||
var aKeys = Object.keys(a);
|
||||
var bKeys = Object.keys(b);
|
||||
// If `a` and `b` have a different number of enumerable keys, they
|
||||
// must be different.
|
||||
var keyCount = aKeys.length;
|
||||
if (keyCount !== bKeys.length)
|
||||
return false;
|
||||
// Now make sure they have the same keys.
|
||||
for (var k = 0; k < keyCount; ++k) {
|
||||
if (!hasOwnProperty.call(b, aKeys[k])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Finally, check deep equality of all child properties.
|
||||
for (var k = 0; k < keyCount; ++k) {
|
||||
var key = aKeys[k];
|
||||
if (!check(a[key], b[key])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case '[object Error]':
|
||||
return a.name === b.name && a.message === b.message;
|
||||
case '[object Number]':
|
||||
// Handle NaN, which is !== itself.
|
||||
if (a !== a)
|
||||
return b !== b;
|
||||
// Fall through to shared +a === +b case...
|
||||
case '[object Boolean]':
|
||||
case '[object Date]':
|
||||
return +a === +b;
|
||||
case '[object RegExp]':
|
||||
case '[object String]':
|
||||
return a == "" + b;
|
||||
case '[object Map]':
|
||||
case '[object Set]': {
|
||||
if (a.size !== b.size)
|
||||
return false;
|
||||
if (previouslyCompared(a, b))
|
||||
return true;
|
||||
var aIterator = a.entries();
|
||||
var isMap = aTag === '[object Map]';
|
||||
while (true) {
|
||||
var info = aIterator.next();
|
||||
if (info.done)
|
||||
break;
|
||||
// If a instanceof Set, aValue === aKey.
|
||||
var _a = info.value, aKey = _a[0], aValue = _a[1];
|
||||
// So this works the same way for both Set and Map.
|
||||
if (!b.has(aKey)) {
|
||||
return false;
|
||||
}
|
||||
// However, we care about deep equality of values only when dealing
|
||||
// with Map structures.
|
||||
if (isMap && !check(aValue, b.get(aKey))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Otherwise the values are not equal.
|
||||
return false;
|
||||
}
|
||||
function previouslyCompared(a, b) {
|
||||
// Though cyclic references can make an object graph appear infinite from the
|
||||
// perspective of a depth-first traversal, the graph still contains a finite
|
||||
// number of distinct object references. We use the previousComparisons cache
|
||||
// to avoid comparing the same pair of object references more than once, which
|
||||
// guarantees termination (even if we end up comparing every object in one
|
||||
// graph to every object in the other graph, which is extremely unlikely),
|
||||
// while still allowing weird isomorphic structures (like rings with different
|
||||
// lengths) a chance to pass the equality test.
|
||||
var bSet = previousComparisons.get(a);
|
||||
if (bSet) {
|
||||
// Return true here because we can be sure false will be returned somewhere
|
||||
// else if the objects are not equivalent.
|
||||
if (bSet.has(b))
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
previousComparisons.set(a, bSet = new Set);
|
||||
}
|
||||
bSet.add(b);
|
||||
return false;
|
||||
}
|
||||
|
||||
export default equal;
|
||||
export { equal };
|
||||
//# sourceMappingURL=equality.esm.js.map
|
||||
1
node_modules/@wry/equality/lib/equality.esm.js.map
generated
vendored
Normal file
1
node_modules/@wry/equality/lib/equality.esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
133
node_modules/@wry/equality/lib/equality.js
generated
vendored
Normal file
133
node_modules/@wry/equality/lib/equality.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var _a = Object.prototype, toString = _a.toString, hasOwnProperty = _a.hasOwnProperty;
|
||||
var previousComparisons = new Map();
|
||||
/**
|
||||
* Performs a deep equality check on two JavaScript values, tolerating cycles.
|
||||
*/
|
||||
function equal(a, b) {
|
||||
try {
|
||||
return check(a, b);
|
||||
}
|
||||
finally {
|
||||
previousComparisons.clear();
|
||||
}
|
||||
}
|
||||
function check(a, b) {
|
||||
// If the two values are strictly equal, our job is easy.
|
||||
if (a === b) {
|
||||
return true;
|
||||
}
|
||||
// Object.prototype.toString returns a representation of the runtime type of
|
||||
// the given value that is considerably more precise than typeof.
|
||||
var aTag = toString.call(a);
|
||||
var bTag = toString.call(b);
|
||||
// If the runtime types of a and b are different, they could maybe be equal
|
||||
// under some interpretation of equality, but for simplicity and performance
|
||||
// we just return false instead.
|
||||
if (aTag !== bTag) {
|
||||
return false;
|
||||
}
|
||||
switch (aTag) {
|
||||
case '[object Array]':
|
||||
// Arrays are a lot like other objects, but we can cheaply compare their
|
||||
// lengths as a short-cut before comparing their elements.
|
||||
if (a.length !== b.length)
|
||||
return false;
|
||||
// Fall through to object case...
|
||||
case '[object Object]': {
|
||||
if (previouslyCompared(a, b))
|
||||
return true;
|
||||
var aKeys = Object.keys(a);
|
||||
var bKeys = Object.keys(b);
|
||||
// If `a` and `b` have a different number of enumerable keys, they
|
||||
// must be different.
|
||||
var keyCount = aKeys.length;
|
||||
if (keyCount !== bKeys.length)
|
||||
return false;
|
||||
// Now make sure they have the same keys.
|
||||
for (var k = 0; k < keyCount; ++k) {
|
||||
if (!hasOwnProperty.call(b, aKeys[k])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Finally, check deep equality of all child properties.
|
||||
for (var k = 0; k < keyCount; ++k) {
|
||||
var key = aKeys[k];
|
||||
if (!check(a[key], b[key])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case '[object Error]':
|
||||
return a.name === b.name && a.message === b.message;
|
||||
case '[object Number]':
|
||||
// Handle NaN, which is !== itself.
|
||||
if (a !== a)
|
||||
return b !== b;
|
||||
// Fall through to shared +a === +b case...
|
||||
case '[object Boolean]':
|
||||
case '[object Date]':
|
||||
return +a === +b;
|
||||
case '[object RegExp]':
|
||||
case '[object String]':
|
||||
return a == "" + b;
|
||||
case '[object Map]':
|
||||
case '[object Set]': {
|
||||
if (a.size !== b.size)
|
||||
return false;
|
||||
if (previouslyCompared(a, b))
|
||||
return true;
|
||||
var aIterator = a.entries();
|
||||
var isMap = aTag === '[object Map]';
|
||||
while (true) {
|
||||
var info = aIterator.next();
|
||||
if (info.done)
|
||||
break;
|
||||
// If a instanceof Set, aValue === aKey.
|
||||
var _a = info.value, aKey = _a[0], aValue = _a[1];
|
||||
// So this works the same way for both Set and Map.
|
||||
if (!b.has(aKey)) {
|
||||
return false;
|
||||
}
|
||||
// However, we care about deep equality of values only when dealing
|
||||
// with Map structures.
|
||||
if (isMap && !check(aValue, b.get(aKey))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Otherwise the values are not equal.
|
||||
return false;
|
||||
}
|
||||
function previouslyCompared(a, b) {
|
||||
// Though cyclic references can make an object graph appear infinite from the
|
||||
// perspective of a depth-first traversal, the graph still contains a finite
|
||||
// number of distinct object references. We use the previousComparisons cache
|
||||
// to avoid comparing the same pair of object references more than once, which
|
||||
// guarantees termination (even if we end up comparing every object in one
|
||||
// graph to every object in the other graph, which is extremely unlikely),
|
||||
// while still allowing weird isomorphic structures (like rings with different
|
||||
// lengths) a chance to pass the equality test.
|
||||
var bSet = previousComparisons.get(a);
|
||||
if (bSet) {
|
||||
// Return true here because we can be sure false will be returned somewhere
|
||||
// else if the objects are not equivalent.
|
||||
if (bSet.has(b))
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
previousComparisons.set(a, bSet = new Set);
|
||||
}
|
||||
bSet.add(b);
|
||||
return false;
|
||||
}
|
||||
|
||||
exports.default = equal;
|
||||
exports.equal = equal;
|
||||
//# sourceMappingURL=equality.js.map
|
||||
1
node_modules/@wry/equality/lib/equality.js.map
generated
vendored
Normal file
1
node_modules/@wry/equality/lib/equality.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
32
node_modules/@wry/equality/package.json
generated
vendored
Normal file
32
node_modules/@wry/equality/package.json
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "@wry/equality",
|
||||
"version": "0.1.11",
|
||||
"author": "Ben Newman <ben@eloper.dev>",
|
||||
"description": "Structural equality checking for JavaScript values",
|
||||
"license": "MIT",
|
||||
"main": "lib/equality.js",
|
||||
"module": "lib/equality.esm.js",
|
||||
"types": "lib/equality.d.ts",
|
||||
"keywords": [],
|
||||
"homepage": "https://github.com/benjamn/wryware",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/benjamn/wryware.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/benjamn/wryware/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "../../node_modules/.bin/rimraf lib",
|
||||
"tsc": "../../node_modules/.bin/tsc",
|
||||
"rollup": "../../node_modules/.bin/rollup -c",
|
||||
"build": "npm run clean && npm run tsc && npm run rollup",
|
||||
"mocha": "../../scripts/test.sh lib/tests.js",
|
||||
"prepublish": "npm run build",
|
||||
"test": "npm run build && npm run mocha"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": "^1.9.3"
|
||||
},
|
||||
"gitHead": "925e08dec81c57f9557e61f9b5153f349c1a5896"
|
||||
}
|
||||
40
node_modules/@wry/equality/rollup.config.js
generated
vendored
Normal file
40
node_modules/@wry/equality/rollup.config.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
import typescriptPlugin from 'rollup-plugin-typescript2';
|
||||
import typescript from 'typescript';
|
||||
|
||||
const globals = {
|
||||
__proto__: null,
|
||||
tslib: "tslib",
|
||||
};
|
||||
|
||||
function external(id) {
|
||||
return id in globals;
|
||||
}
|
||||
|
||||
export default [{
|
||||
input: "src/equality.ts",
|
||||
external,
|
||||
output: {
|
||||
file: "lib/equality.esm.js",
|
||||
format: "esm",
|
||||
sourcemap: true,
|
||||
globals,
|
||||
},
|
||||
plugins: [
|
||||
typescriptPlugin({
|
||||
typescript,
|
||||
tsconfig: "./tsconfig.rollup.json",
|
||||
}),
|
||||
],
|
||||
}, {
|
||||
input: "lib/equality.esm.js",
|
||||
external,
|
||||
output: {
|
||||
// Intentionally overwrite the equality.js file written by tsc:
|
||||
file: "lib/equality.js",
|
||||
format: "cjs",
|
||||
exports: "named",
|
||||
sourcemap: true,
|
||||
name: "equality",
|
||||
globals,
|
||||
},
|
||||
}];
|
||||
7
node_modules/@wry/equality/tsconfig.json
generated
vendored
Normal file
7
node_modules/@wry/equality/tsconfig.json
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib"
|
||||
}
|
||||
}
|
||||
6
node_modules/@wry/equality/tsconfig.rollup.json
generated
vendored
Normal file
6
node_modules/@wry/equality/tsconfig.rollup.json
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "es2015",
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user