added unit testing, and started implementing unit tests...phew
This commit is contained in:
27
node_modules/@sinonjs/samsam/LICENSE
generated
vendored
Normal file
27
node_modules/@sinonjs/samsam/LICENSE
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
(The BSD License)
|
||||
|
||||
Copyright (c) 2010-2012, Christian Johansen, christian@cjohansen.no and
|
||||
August Lilleaas, august.lilleaas@gmail.com. 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 Christian Johansen nor the names of his 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.
|
83
node_modules/@sinonjs/samsam/README.md
generated
vendored
Normal file
83
node_modules/@sinonjs/samsam/README.md
generated
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
# samsam
|
||||
|
||||
[](http://travis-ci.org/sinonjs/samsam)
|
||||
[](https://coveralls.io/github/sinonjs/samsam?branch=master)
|
||||
|
||||
Value identification and comparison functions
|
||||
|
||||
Documentation: http://sinonjs.github.io/samsam/
|
||||
|
||||
## Backers
|
||||
|
||||
Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/sinon#backer)]
|
||||
|
||||
<a href="https://opencollective.com/sinon/backer/0/website" target="_blank"><img src="https://opencollective.com/sinon/backer/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/1/website" target="_blank"><img src="https://opencollective.com/sinon/backer/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/2/website" target="_blank"><img src="https://opencollective.com/sinon/backer/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/3/website" target="_blank"><img src="https://opencollective.com/sinon/backer/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/4/website" target="_blank"><img src="https://opencollective.com/sinon/backer/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/5/website" target="_blank"><img src="https://opencollective.com/sinon/backer/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/6/website" target="_blank"><img src="https://opencollective.com/sinon/backer/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/7/website" target="_blank"><img src="https://opencollective.com/sinon/backer/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/8/website" target="_blank"><img src="https://opencollective.com/sinon/backer/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/9/website" target="_blank"><img src="https://opencollective.com/sinon/backer/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/10/website" target="_blank"><img src="https://opencollective.com/sinon/backer/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/11/website" target="_blank"><img src="https://opencollective.com/sinon/backer/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/12/website" target="_blank"><img src="https://opencollective.com/sinon/backer/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/13/website" target="_blank"><img src="https://opencollective.com/sinon/backer/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/14/website" target="_blank"><img src="https://opencollective.com/sinon/backer/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/15/website" target="_blank"><img src="https://opencollective.com/sinon/backer/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/16/website" target="_blank"><img src="https://opencollective.com/sinon/backer/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/17/website" target="_blank"><img src="https://opencollective.com/sinon/backer/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/18/website" target="_blank"><img src="https://opencollective.com/sinon/backer/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/19/website" target="_blank"><img src="https://opencollective.com/sinon/backer/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/20/website" target="_blank"><img src="https://opencollective.com/sinon/backer/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/21/website" target="_blank"><img src="https://opencollective.com/sinon/backer/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/22/website" target="_blank"><img src="https://opencollective.com/sinon/backer/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/23/website" target="_blank"><img src="https://opencollective.com/sinon/backer/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/24/website" target="_blank"><img src="https://opencollective.com/sinon/backer/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/25/website" target="_blank"><img src="https://opencollective.com/sinon/backer/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/26/website" target="_blank"><img src="https://opencollective.com/sinon/backer/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/27/website" target="_blank"><img src="https://opencollective.com/sinon/backer/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/28/website" target="_blank"><img src="https://opencollective.com/sinon/backer/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/backer/29/website" target="_blank"><img src="https://opencollective.com/sinon/backer/29/avatar.svg"></a>
|
||||
|
||||
|
||||
## Sponsors
|
||||
|
||||
Become a sponsor and get your logo on our README on GitHub with a link to your site. [[Become a sponsor](https://opencollective.com/sinon#sponsor)]
|
||||
|
||||
<a href="https://opencollective.com/sinon/sponsor/0/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/1/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/2/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/3/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/4/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/5/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/6/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/7/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/8/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/9/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/9/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/10/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/10/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/11/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/11/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/12/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/12/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/13/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/13/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/14/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/14/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/15/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/15/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/16/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/16/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/17/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/17/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/18/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/18/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/19/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/19/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/20/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/20/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/21/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/21/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/22/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/22/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/23/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/23/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/24/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/24/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/25/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/25/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/26/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/26/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/27/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/27/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/28/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/28/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/sinon/sponsor/29/website" target="_blank"><img src="https://opencollective.com/sinon/sponsor/29/avatar.svg"></a>
|
||||
|
||||
## Licence
|
||||
|
||||
samsam was released under [BSD-3](LICENSE)
|
1100
node_modules/@sinonjs/samsam/dist/samsam.js
generated
vendored
Normal file
1100
node_modules/@sinonjs/samsam/dist/samsam.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
203
node_modules/@sinonjs/samsam/docs/index.md
generated
vendored
Normal file
203
node_modules/@sinonjs/samsam/docs/index.md
generated
vendored
Normal file
@ -0,0 +1,203 @@
|
||||
# samsam
|
||||
|
||||
> Same same, but different
|
||||
|
||||
`samsam` is a collection of predicate and comparison functions useful for
|
||||
identifiying the type of values and to compare values with varying degrees of
|
||||
strictness.
|
||||
|
||||
`samsam` is a general-purpose library with no dependencies. It works in browsers
|
||||
(including old and rowdy ones, like IE6) and Node. It will define itself as an
|
||||
AMD module if you want it to (i.e. if there's a `define` function available).
|
||||
|
||||
## Predicate functions
|
||||
|
||||
|
||||
### `isArguments(value)`
|
||||
|
||||
Returns `true` if `value` is an `arguments` object, `false` otherwise.
|
||||
|
||||
|
||||
### `isNegZero(value)`
|
||||
|
||||
Returns `true` if `value` is `-0`.
|
||||
|
||||
|
||||
### `isElement(value)`
|
||||
|
||||
Returns `true` if `value` is a DOM element node. Unlike
|
||||
Underscore.js/lodash, this function will return `false` if `value` is an
|
||||
*element-like* object, i.e. a regular object with a `nodeType` property that
|
||||
holds the value `1`.
|
||||
|
||||
### `isSet(value)`
|
||||
|
||||
Returns `true` if `value` is a [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set).
|
||||
|
||||
|
||||
## Comparison functions
|
||||
|
||||
|
||||
### `identical(x, y)`
|
||||
|
||||
Strict equality check according to EcmaScript Harmony's `egal`.
|
||||
|
||||
**From the Harmony wiki:**
|
||||
|
||||
> An egal function simply makes available the internal `SameValue` function
|
||||
from section 9.12 of the ES5 spec. If two values are egal, then they are not
|
||||
observably distinguishable.
|
||||
|
||||
`identical` returns `true` when `===` is `true`, except for `-0` and
|
||||
`+0`, where it returns `false`. Additionally, it returns `true` when
|
||||
`NaN` is compared to itself.
|
||||
|
||||
|
||||
### `deepEqual(actual, expectation)`
|
||||
|
||||
Deep equal comparison. Two values are "deep equal" if:
|
||||
|
||||
* They are identical
|
||||
* They are both date objects representing the same time
|
||||
* They are both arrays containing elements that are all deepEqual
|
||||
* They are objects with the same set of properties, and each property
|
||||
in `actual` is deepEqual to the corresponding property in `expectation`
|
||||
|
||||
* `actual` can have [symbolic properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) that are missing from `expectation`
|
||||
|
||||
|
||||
### `match(object, matcher)`
|
||||
|
||||
Partial equality check. Compares `object` with matcher according a wide set of
|
||||
rules:
|
||||
|
||||
#### String matcher
|
||||
|
||||
In its simplest form, `match` performs a case insensitive substring match.
|
||||
When the matcher is a string, `object` is converted to a string, and the
|
||||
function returns `true` if the matcher is a case-insensitive substring of
|
||||
`object` as a string.
|
||||
|
||||
```javascript
|
||||
samsam.match("Give me something", "Give"); //true
|
||||
samsam.match("Give me something", "sumptn"); // false
|
||||
samsam.match({ toString: function () { return "yeah"; } }, "Yeah!"); // true
|
||||
```
|
||||
|
||||
The last example is not symmetric. When the matcher is a string, the `object`
|
||||
is coerced to a string - in this case using `toString`. Changing the order of
|
||||
the arguments would cause the matcher to be an object, in which case different
|
||||
rules apply (see below).
|
||||
|
||||
|
||||
#### Boolean matcher
|
||||
|
||||
Performs a strict (i.e. `===`) match with the object. So, only `true`
|
||||
matches `true`, and only `false` matches `false`.
|
||||
|
||||
|
||||
#### Regular expression matcher
|
||||
|
||||
When the matcher is a regular expression, the function will pass if
|
||||
`object.test(matcher)` is `true`. `match` is written in a generic way, so
|
||||
any object with a `test` method will be used as a matcher this way.
|
||||
|
||||
```javascript
|
||||
samsam.match("Give me something", /^[a-z\s]$/i); // true
|
||||
samsam.match("Give me something", /[0-9]/); // false
|
||||
samsam.match({ toString: function () { return "yeah!"; } }, /yeah/); // true
|
||||
samsam.match(234, /[a-z]/); // false
|
||||
```
|
||||
|
||||
|
||||
#### Number matcher
|
||||
|
||||
When the matcher is a number, the assertion will pass if `object == matcher`.
|
||||
|
||||
```javascript
|
||||
samsam.match("123", 123); // true
|
||||
samsam.match("Give me something", 425); // false
|
||||
samsam.match({ toString: function () { return "42"; } }, 42); // true
|
||||
samsam.match(234, 1234); // false
|
||||
```
|
||||
|
||||
|
||||
#### Function matcher
|
||||
|
||||
When the matcher is a function, it is called with `object` as its only
|
||||
argument. `match` returns `true` if the function returns `true`. A strict
|
||||
match is performed against the return value, so a boolean `true` is required,
|
||||
truthy is not enough.
|
||||
|
||||
```javascript
|
||||
// true
|
||||
samsam.match("123", function (exp) {
|
||||
return exp == "123";
|
||||
});
|
||||
|
||||
// false
|
||||
samsam.match("Give me something", function () {
|
||||
return "ok";
|
||||
});
|
||||
|
||||
// true
|
||||
samsam.match({
|
||||
toString: function () {
|
||||
return "42";
|
||||
}
|
||||
}, function () { return true; });
|
||||
|
||||
// false
|
||||
samsam.match(234, function () {});
|
||||
```
|
||||
|
||||
|
||||
#### Object matcher
|
||||
|
||||
As mentioned above, if an object matcher defines a `test` method, `match`
|
||||
will return `true` if `matcher.test(object)` returns truthy.
|
||||
|
||||
If the matcher does not have a test method, a recursive match is performed. If
|
||||
all properties of `matcher` matches corresponding properties in `object`,
|
||||
`match` returns `true`. Note that the object matcher does not care if the
|
||||
number of properties in the two objects are the same - only if all properties in
|
||||
the matcher recursively matches ones in `object`.
|
||||
|
||||
```javascript
|
||||
// true
|
||||
samsam.match("123", {
|
||||
test: function (arg) {
|
||||
return arg == 123;
|
||||
}
|
||||
});
|
||||
|
||||
// false
|
||||
samsam.match({}, { prop: 42 });
|
||||
|
||||
// true
|
||||
samsam.match({
|
||||
name: "Chris",
|
||||
profession: "Programmer"
|
||||
}, {
|
||||
name: "Chris"
|
||||
});
|
||||
|
||||
// false
|
||||
samsam.match(234, { name: "Chris" });
|
||||
```
|
||||
|
||||
|
||||
#### DOM elements
|
||||
|
||||
`match` can be very helpful when comparing DOM elements, because it allows
|
||||
you to compare several properties with one call:
|
||||
|
||||
```javascript
|
||||
var el = document.getElementById("myEl");
|
||||
|
||||
samsam.match(el, {
|
||||
tagName: "h2",
|
||||
className: "item",
|
||||
innerHTML: "Howdy"
|
||||
});
|
||||
```
|
27
node_modules/@sinonjs/samsam/lib/create-set.js
generated
vendored
Normal file
27
node_modules/@sinonjs/samsam/lib/create-set.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
var typeOf = require("@sinonjs/commons").typeOf;
|
||||
|
||||
// This helper makes it convenient to create Set instances from a
|
||||
// collection, an overcomes the shortcoming that IE11 doesn't support
|
||||
// collection arguments
|
||||
//
|
||||
// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
||||
function createSet(array) {
|
||||
if (arguments.length > 0 && !Array.isArray(array)) {
|
||||
throw new TypeError(
|
||||
"createSet can be called with either no arguments or an Array"
|
||||
);
|
||||
}
|
||||
|
||||
var items = typeOf(array) === "array" ? array : [];
|
||||
var set = new Set();
|
||||
|
||||
items.forEach(function(item) {
|
||||
set.add(item);
|
||||
});
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
module.exports = createSet;
|
74
node_modules/@sinonjs/samsam/lib/deep-equal-benchmark.js
generated
vendored
Normal file
74
node_modules/@sinonjs/samsam/lib/deep-equal-benchmark.js
generated
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
"use strict";
|
||||
|
||||
var Benchmark = require("benchmark");
|
||||
var deepEqual = require("./deep-equal");
|
||||
|
||||
var suite = new Benchmark.Suite();
|
||||
var complex1 = {
|
||||
"1e116061-59bf-433a-8ab0-017b67a51d26":
|
||||
"a7fd22ab-e809-414f-ad55-9c97598395d8",
|
||||
"3824e8b7-22f5-489c-9919-43b432e3af6b":
|
||||
"548baefd-f43c-4dc9-9df5-f7c9c96223b0",
|
||||
"123e5750-eb66-45e5-a770-310879203b33":
|
||||
"89ff817d-65a2-4598-b190-21c128096e6a",
|
||||
"1d66be95-8aaa-4167-9a47-e7ee19bb0735":
|
||||
"64349492-56e8-4100-9552-a89fb4a9aef4",
|
||||
"f5538565-dc92-4ee4-a762-1ba5fe0528f6": {
|
||||
"53631f78-2f2a-448f-89c7-ed3585e8e6f0":
|
||||
"2cce00ee-f5ee-43ef-878f-958597b23225",
|
||||
"73e8298b-72fd-4969-afc1-d891b61e744f":
|
||||
"4e57aa30-af51-4d78-887c-019755e5d117",
|
||||
"85439907-5b0e-4a08-8cfa-902a68dc3cc0":
|
||||
"9639add9-6897-4cf0-b3d3-2ebf9c214f01",
|
||||
"d4ae9d87-bd6c-47e0-95a1-6f4eb4211549":
|
||||
"41fd3dd2-43ce-47f2-b92e-462474d07a6f",
|
||||
"f70345a2-0ea3-45a6-bafa-8c7a72379277": {
|
||||
"1bce714b-cd0a-417d-9a0c-bf4b7d35c0c4":
|
||||
"3b8b0dde-e2ed-4b34-ac8d-729ba3c9667e",
|
||||
"13e05c60-97d1-43f0-a6ef-d5247f4dd11f":
|
||||
"60f685a4-6558-4ade-9d4b-28281c3989db",
|
||||
"925b2609-e7b7-42f5-82cf-2d995697cec5":
|
||||
"79115261-8161-4a6c-9487-47847276a717",
|
||||
"52d644ac-7b33-4b79-b5b3-5afe7fd4ec2c": [
|
||||
"3c2ae716-92f1-4a3d-b98f-50ea49f51c45",
|
||||
"de76b822-71b3-4b5a-a041-4140378b70e2",
|
||||
"0302a405-1d58-44fa-a0c6-dd07bb0ca26e",
|
||||
new Date(),
|
||||
new Error(),
|
||||
new RegExp(),
|
||||
// eslint-disable-next-line no-undef
|
||||
new Map(),
|
||||
new Set(),
|
||||
// eslint-disable-next-line no-undef, ie11/no-weak-collections
|
||||
new WeakMap(),
|
||||
// eslint-disable-next-line no-undef, ie11/no-weak-collections
|
||||
new WeakSet()
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
var complex2 = Object.create(complex1);
|
||||
|
||||
var cyclic1 = {
|
||||
"4a092cd1-225e-4739-8331-d6564aafb702":
|
||||
"d0cebbe0-23fb-4cc4-8fa0-ef11ceedf12e"
|
||||
};
|
||||
cyclic1.cyclicRef = cyclic1;
|
||||
|
||||
var cyclic2 = Object.create(cyclic1);
|
||||
|
||||
// add tests
|
||||
suite
|
||||
.add("complex objects", function() {
|
||||
return deepEqual(complex1, complex2);
|
||||
})
|
||||
.add("cyclic references", function() {
|
||||
return deepEqual(cyclic1, cyclic2);
|
||||
})
|
||||
// add listeners
|
||||
.on("cycle", function(event) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(String(event.target));
|
||||
})
|
||||
// run async
|
||||
.run({ async: true });
|
227
node_modules/@sinonjs/samsam/lib/deep-equal.js
generated
vendored
Normal file
227
node_modules/@sinonjs/samsam/lib/deep-equal.js
generated
vendored
Normal file
@ -0,0 +1,227 @@
|
||||
"use strict";
|
||||
|
||||
var valueToString = require("@sinonjs/commons").valueToString;
|
||||
|
||||
var getClass = require("./get-class");
|
||||
var identical = require("./identical");
|
||||
var isArguments = require("./is-arguments");
|
||||
var isDate = require("./is-date");
|
||||
var isElement = require("./is-element");
|
||||
var isNaN = require("./is-nan");
|
||||
var isObject = require("./is-object");
|
||||
var isSet = require("./is-set");
|
||||
var isSubset = require("./is-subset");
|
||||
var getClassName = require("./get-class-name");
|
||||
|
||||
var every = Array.prototype.every;
|
||||
var getTime = Date.prototype.getTime;
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var indexOf = Array.prototype.indexOf;
|
||||
var keys = Object.keys;
|
||||
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
||||
|
||||
/**
|
||||
* @name samsam.deepEqual
|
||||
* @param Object actual
|
||||
* @param Object expectation
|
||||
*
|
||||
* Deep equal comparison. Two values are "deep equal" if:
|
||||
*
|
||||
* - They are equal, according to samsam.identical
|
||||
* - They are both date objects representing the same time
|
||||
* - They are both arrays containing elements that are all deepEqual
|
||||
* - They are objects with the same set of properties, and each property
|
||||
* in ``actual`` is deepEqual to the corresponding property in ``expectation``
|
||||
*
|
||||
* Supports cyclic objects.
|
||||
*/
|
||||
function deepEqualCyclic(actual, expectation, match) {
|
||||
// used for cyclic comparison
|
||||
// contain already visited objects
|
||||
var actualObjects = [];
|
||||
var expectationObjects = [];
|
||||
// contain pathes (position in the object structure)
|
||||
// of the already visited objects
|
||||
// indexes same as in objects arrays
|
||||
var actualPaths = [];
|
||||
var expectationPaths = [];
|
||||
// contains combinations of already compared objects
|
||||
// in the manner: { "$1['ref']$2['ref']": true }
|
||||
var compared = {};
|
||||
|
||||
// does the recursion for the deep equal check
|
||||
return (function deepEqual(
|
||||
actualObj,
|
||||
expectationObj,
|
||||
actualPath,
|
||||
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
|
||||
// matcher against the other
|
||||
if (match && match.isMatcher(expectationObj)) {
|
||||
if (match.isMatcher(actualObj)) {
|
||||
return actualObj === expectationObj;
|
||||
}
|
||||
return expectationObj.test(actualObj);
|
||||
}
|
||||
|
||||
var actualType = typeof actualObj;
|
||||
var expectationType = typeof expectationObj;
|
||||
|
||||
// == null also matches undefined
|
||||
if (
|
||||
actualObj === expectationObj ||
|
||||
isNaN(actualObj) ||
|
||||
isNaN(expectationObj) ||
|
||||
actualObj == null ||
|
||||
expectationObj == null ||
|
||||
actualType !== "object" ||
|
||||
expectationType !== "object"
|
||||
) {
|
||||
return identical(actualObj, expectationObj);
|
||||
}
|
||||
|
||||
// Elements are only equal if identical(expected, actual)
|
||||
if (isElement(actualObj) || isElement(expectationObj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var isActualDate = isDate(actualObj);
|
||||
var isExpectationDate = isDate(expectationObj);
|
||||
if (isActualDate || isExpectationDate) {
|
||||
if (
|
||||
!isActualDate ||
|
||||
!isExpectationDate ||
|
||||
getTime.call(actualObj) !== getTime.call(expectationObj)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (actualObj instanceof RegExp && expectationObj instanceof RegExp) {
|
||||
if (valueToString(actualObj) !== valueToString(expectationObj)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (actualObj instanceof Error && expectationObj instanceof Error) {
|
||||
return actualObj === expectationObj;
|
||||
}
|
||||
|
||||
var actualClass = getClass(actualObj);
|
||||
var expectationClass = getClass(expectationObj);
|
||||
var actualKeys = keys(actualObj);
|
||||
var expectationKeys = keys(expectationObj);
|
||||
var actualName = getClassName(actualObj);
|
||||
var expectationName = getClassName(expectationObj);
|
||||
var expectationSymbols =
|
||||
typeof Object.getOwnPropertySymbols === "function"
|
||||
? getOwnPropertySymbols(expectationObj)
|
||||
: [];
|
||||
var expectationKeysAndSymbols = expectationKeys.concat(
|
||||
expectationSymbols
|
||||
);
|
||||
|
||||
if (isArguments(actualObj) || isArguments(expectationObj)) {
|
||||
if (actualObj.length !== expectationObj.length) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
actualType !== expectationType ||
|
||||
actualClass !== expectationClass ||
|
||||
actualKeys.length !== expectationKeys.length ||
|
||||
(actualName &&
|
||||
expectationName &&
|
||||
actualName !== expectationName)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isSet(actualObj) || isSet(expectationObj)) {
|
||||
if (
|
||||
!isSet(actualObj) ||
|
||||
!isSet(expectationObj) ||
|
||||
actualObj.size !== expectationObj.size
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isSubset(actualObj, expectationObj, deepEqual);
|
||||
}
|
||||
|
||||
return every.call(expectationKeysAndSymbols, function(key) {
|
||||
if (!hasOwnProperty.call(actualObj, key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var actualValue = actualObj[key];
|
||||
var expectationValue = expectationObj[key];
|
||||
var actualObject = isObject(actualValue);
|
||||
var expectationObject = isObject(expectationValue);
|
||||
// determines, if the objects were already visited
|
||||
// (it's faster to check for isObject first, than to
|
||||
// get -1 from getIndex for non objects)
|
||||
var actualIndex = actualObject
|
||||
? indexOf.call(actualObjects, actualValue)
|
||||
: -1;
|
||||
var expectationIndex = expectationObject
|
||||
? indexOf.call(expectationObjects, expectationValue)
|
||||
: -1;
|
||||
// determines the new paths of the objects
|
||||
// - for non cyclic objects the current path will be extended
|
||||
// by current property name
|
||||
// - for cyclic objects the stored path is taken
|
||||
var newActualPath =
|
||||
actualIndex !== -1
|
||||
? actualPaths[actualIndex]
|
||||
: actualPath + "[" + JSON.stringify(key) + "]";
|
||||
var newExpectationPath =
|
||||
expectationIndex !== -1
|
||||
? expectationPaths[expectationIndex]
|
||||
: expectationPath + "[" + JSON.stringify(key) + "]";
|
||||
var combinedPath = newActualPath + newExpectationPath;
|
||||
|
||||
// stop recursion if current objects are already compared
|
||||
if (compared[combinedPath]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// remember the current objects and their paths
|
||||
if (actualIndex === -1 && actualObject) {
|
||||
actualObjects.push(actualValue);
|
||||
actualPaths.push(newActualPath);
|
||||
}
|
||||
if (expectationIndex === -1 && expectationObject) {
|
||||
expectationObjects.push(expectationValue);
|
||||
expectationPaths.push(newExpectationPath);
|
||||
}
|
||||
|
||||
// remember that the current objects are already compared
|
||||
if (actualObject && expectationObject) {
|
||||
compared[combinedPath] = true;
|
||||
}
|
||||
|
||||
// End of cyclic logic
|
||||
|
||||
// neither actualValue nor expectationValue is a cycle
|
||||
// continue with next level
|
||||
return deepEqual(
|
||||
actualValue,
|
||||
expectationValue,
|
||||
newActualPath,
|
||||
newExpectationPath
|
||||
);
|
||||
});
|
||||
})(actual, expectation, "$1", "$2");
|
||||
}
|
||||
|
||||
deepEqualCyclic.use = function(match) {
|
||||
return function(a, b) {
|
||||
return deepEqualCyclic(a, b, match);
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = deepEqualCyclic;
|
22
node_modules/@sinonjs/samsam/lib/get-class-name.js
generated
vendored
Normal file
22
node_modules/@sinonjs/samsam/lib/get-class-name.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
var valueToString = require("@sinonjs/commons").valueToString;
|
||||
|
||||
var re = /function (\w+)\s*\(/;
|
||||
|
||||
function getClassName(value) {
|
||||
if (value.constructor && "name" in value.constructor) {
|
||||
return value.constructor.name;
|
||||
}
|
||||
|
||||
if (typeof value.constructor === "function") {
|
||||
var match = valueToString(value.constructor).match(re);
|
||||
if (match.length > 1) {
|
||||
return match[1];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = getClassName;
|
12
node_modules/@sinonjs/samsam/lib/get-class.js
generated
vendored
Normal file
12
node_modules/@sinonjs/samsam/lib/get-class.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var o = Object.prototype;
|
||||
|
||||
function getClass(value) {
|
||||
// Returns the internal [[Class]] by calling Object.prototype.toString
|
||||
// with the provided value as this. Return value is a string, naming the
|
||||
// internal class, e.g. "Array"
|
||||
return o.toString.call(value).split(/[ \]]/)[1];
|
||||
}
|
||||
|
||||
module.exports = getClass;
|
25
node_modules/@sinonjs/samsam/lib/identical.js
generated
vendored
Normal file
25
node_modules/@sinonjs/samsam/lib/identical.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
var isNaN = require("./is-nan");
|
||||
var isNegZero = require("./is-neg-zero");
|
||||
|
||||
/**
|
||||
* @name samsam.equal
|
||||
* @param Object obj1
|
||||
* @param Object obj2
|
||||
*
|
||||
* Returns ``true`` if two objects are strictly equal. Compared to
|
||||
* ``===`` there are two exceptions:
|
||||
*
|
||||
* - NaN is considered equal to NaN
|
||||
* - -0 and +0 are not considered equal
|
||||
*/
|
||||
function identical(obj1, obj2) {
|
||||
if (obj1 === obj2 || (isNaN(obj1) && isNaN(obj2))) {
|
||||
return obj1 !== 0 || isNegZero(obj1) === isNegZero(obj2);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = identical;
|
35
node_modules/@sinonjs/samsam/lib/is-arguments.js
generated
vendored
Normal file
35
node_modules/@sinonjs/samsam/lib/is-arguments.js
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
|
||||
var getClass = require("./get-class");
|
||||
|
||||
/**
|
||||
* @name samsam.isArguments
|
||||
* @param Object object
|
||||
*
|
||||
* Returns ``true`` if ``object`` is an ``arguments`` object,
|
||||
* ``false`` otherwise.
|
||||
*/
|
||||
function isArguments(object) {
|
||||
if (getClass(object) === "Arguments") {
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
typeof object !== "object" ||
|
||||
typeof object.length !== "number" ||
|
||||
getClass(object) === "Array"
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (typeof object.callee === "function") {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
object[object.length] = 6;
|
||||
delete object[object.length];
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
module.exports = isArguments;
|
7
node_modules/@sinonjs/samsam/lib/is-date.js
generated
vendored
Normal file
7
node_modules/@sinonjs/samsam/lib/is-date.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
function isDate(value) {
|
||||
return value instanceof Date;
|
||||
}
|
||||
|
||||
module.exports = isDate;
|
27
node_modules/@sinonjs/samsam/lib/is-element.js
generated
vendored
Normal file
27
node_modules/@sinonjs/samsam/lib/is-element.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
var div = typeof document !== "undefined" && document.createElement("div");
|
||||
|
||||
/**
|
||||
* @name samsam.isElement
|
||||
* @param Object object
|
||||
*
|
||||
* Returns ``true`` if ``object`` is a DOM element node. Unlike
|
||||
* Underscore.js/lodash, this function will return ``false`` if ``object``
|
||||
* is an *element-like* object, i.e. a regular object with a ``nodeType``
|
||||
* property that holds the value ``1``.
|
||||
*/
|
||||
function isElement(object) {
|
||||
if (!object || object.nodeType !== 1 || !div) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
object.appendChild(div);
|
||||
object.removeChild(div);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = isElement;
|
11
node_modules/@sinonjs/samsam/lib/is-nan.js
generated
vendored
Normal file
11
node_modules/@sinonjs/samsam/lib/is-nan.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
function isNaN(value) {
|
||||
// Unlike global isNaN, this avoids type coercion
|
||||
// typeof check avoids IE host object issues, hat tip to
|
||||
// lodash
|
||||
var val = value; // JsLint thinks value !== value is "weird"
|
||||
return typeof value === "number" && value !== val;
|
||||
}
|
||||
|
||||
module.exports = isNaN;
|
13
node_modules/@sinonjs/samsam/lib/is-neg-zero.js
generated
vendored
Normal file
13
node_modules/@sinonjs/samsam/lib/is-neg-zero.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* @name samsam.isNegZero
|
||||
* @param Object value
|
||||
*
|
||||
* Returns ``true`` if ``value`` is ``-0``.
|
||||
*/
|
||||
function isNegZero(value) {
|
||||
return value === 0 && 1 / value === -Infinity;
|
||||
}
|
||||
|
||||
module.exports = isNegZero;
|
24
node_modules/@sinonjs/samsam/lib/is-object.js
generated
vendored
Normal file
24
node_modules/@sinonjs/samsam/lib/is-object.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
|
||||
// Returns true when the value is a regular Object and not a specialized Object
|
||||
//
|
||||
// This helps speeding up deepEqual cyclic checks
|
||||
// The premise is that only Objects are stored in the visited array.
|
||||
// So if this function returns false, we don't have to do the
|
||||
// expensive operation of searching for the value in the the array of already
|
||||
// visited objects
|
||||
function isObject(value) {
|
||||
return (
|
||||
typeof value === "object" &&
|
||||
value !== null &&
|
||||
// none of these are collection objects, so we can return false
|
||||
!(value instanceof Boolean) &&
|
||||
!(value instanceof Date) &&
|
||||
!(value instanceof Error) &&
|
||||
!(value instanceof Number) &&
|
||||
!(value instanceof RegExp) &&
|
||||
!(value instanceof String)
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = isObject;
|
7
node_modules/@sinonjs/samsam/lib/is-set.js
generated
vendored
Normal file
7
node_modules/@sinonjs/samsam/lib/is-set.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
function isSet(val) {
|
||||
return (typeof Set !== "undefined" && val instanceof Set) || false;
|
||||
}
|
||||
|
||||
module.exports = isSet;
|
18
node_modules/@sinonjs/samsam/lib/is-subset.js
generated
vendored
Normal file
18
node_modules/@sinonjs/samsam/lib/is-subset.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
|
||||
function isSubset(s1, s2, compare) {
|
||||
var allContained = true;
|
||||
s1.forEach(function(v1) {
|
||||
var includes = false;
|
||||
s2.forEach(function(v2) {
|
||||
if (compare(v2, v1)) {
|
||||
includes = true;
|
||||
}
|
||||
});
|
||||
allContained = allContained && includes;
|
||||
});
|
||||
|
||||
return allContained;
|
||||
}
|
||||
|
||||
module.exports = isSubset;
|
42
node_modules/@sinonjs/samsam/lib/iterable-to-string.js
generated
vendored
Normal file
42
node_modules/@sinonjs/samsam/lib/iterable-to-string.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
|
||||
var slice = require("@sinonjs/commons").prototypes.string.slice;
|
||||
var typeOf = require("@sinonjs/commons").typeOf;
|
||||
var valueToString = require("@sinonjs/commons").valueToString;
|
||||
|
||||
module.exports = function iterableToString(obj) {
|
||||
var representation = "";
|
||||
|
||||
function stringify(item) {
|
||||
return typeof item === "string"
|
||||
? "'" + item + "'"
|
||||
: valueToString(item);
|
||||
}
|
||||
|
||||
function mapToString(map) {
|
||||
/* eslint-disable-next-line local-rules/no-prototype-methods */
|
||||
map.forEach(function(value, key) {
|
||||
representation +=
|
||||
"[" + stringify(key) + "," + stringify(value) + "],";
|
||||
});
|
||||
|
||||
representation = slice(representation, 0, -1);
|
||||
return representation;
|
||||
}
|
||||
|
||||
function genericIterableToString(iterable) {
|
||||
/* eslint-disable-next-line local-rules/no-prototype-methods */
|
||||
iterable.forEach(function(value) {
|
||||
representation += stringify(value) + ",";
|
||||
});
|
||||
|
||||
representation = slice(representation, 0, -1);
|
||||
return representation;
|
||||
}
|
||||
|
||||
if (typeOf(obj) === "map") {
|
||||
return mapToString(obj);
|
||||
}
|
||||
|
||||
return genericIterableToString(obj);
|
||||
};
|
136
node_modules/@sinonjs/samsam/lib/match.js
generated
vendored
Normal file
136
node_modules/@sinonjs/samsam/lib/match.js
generated
vendored
Normal file
@ -0,0 +1,136 @@
|
||||
"use strict";
|
||||
|
||||
var valueToString = require("@sinonjs/commons").valueToString;
|
||||
|
||||
var deepEqual = require("./deep-equal").use(match); // eslint-disable-line no-use-before-define
|
||||
var getClass = require("./get-class");
|
||||
var isDate = require("./is-date");
|
||||
var isSet = require("./is-set");
|
||||
var isSubset = require("./is-subset");
|
||||
var createMatcher = require("./matcher");
|
||||
|
||||
function arrayContains(array, subset, compare) {
|
||||
if (subset.length === 0) {
|
||||
return true;
|
||||
}
|
||||
var i, l, j, k;
|
||||
for (i = 0, l = array.length; i < l; ++i) {
|
||||
if (compare(array[i], subset[0])) {
|
||||
for (j = 0, k = subset.length; j < k; ++j) {
|
||||
if (i + j >= l) {
|
||||
return false;
|
||||
}
|
||||
if (!compare(array[i + j], subset[j])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name samsam.match
|
||||
* @param Object object
|
||||
* @param Object matcher
|
||||
*
|
||||
* Compare arbitrary value ``object`` with matcher.
|
||||
*/
|
||||
function match(object, matcher) {
|
||||
if (matcher && typeof matcher.test === "function") {
|
||||
return matcher.test(object);
|
||||
}
|
||||
|
||||
if (typeof matcher === "function") {
|
||||
return matcher(object) === true;
|
||||
}
|
||||
|
||||
if (typeof matcher === "string") {
|
||||
matcher = matcher.toLowerCase();
|
||||
var notNull = typeof object === "string" || !!object;
|
||||
return (
|
||||
notNull &&
|
||||
valueToString(object)
|
||||
.toLowerCase()
|
||||
.indexOf(matcher) >= 0
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof matcher === "number") {
|
||||
return matcher === object;
|
||||
}
|
||||
|
||||
if (typeof matcher === "boolean") {
|
||||
return matcher === object;
|
||||
}
|
||||
|
||||
if (typeof matcher === "undefined") {
|
||||
return typeof object === "undefined";
|
||||
}
|
||||
|
||||
if (matcher === null) {
|
||||
return object === null;
|
||||
}
|
||||
|
||||
if (object === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isSet(object)) {
|
||||
return isSubset(matcher, object, match);
|
||||
}
|
||||
|
||||
if (getClass(object) === "Array" && getClass(matcher) === "Array") {
|
||||
return arrayContains(object, matcher, match);
|
||||
}
|
||||
|
||||
if (isDate(matcher)) {
|
||||
return isDate(object) && object.getTime() === matcher.getTime();
|
||||
}
|
||||
|
||||
if (matcher && typeof matcher === "object") {
|
||||
if (matcher === object) {
|
||||
return true;
|
||||
}
|
||||
if (typeof object !== "object") {
|
||||
return false;
|
||||
}
|
||||
var prop;
|
||||
// eslint-disable-next-line guard-for-in
|
||||
for (prop in matcher) {
|
||||
var value = object[prop];
|
||||
if (
|
||||
typeof value === "undefined" &&
|
||||
typeof object.getAttribute === "function"
|
||||
) {
|
||||
value = object.getAttribute(prop);
|
||||
}
|
||||
if (
|
||||
matcher[prop] === null ||
|
||||
typeof matcher[prop] === "undefined"
|
||||
) {
|
||||
if (value !== matcher[prop]) {
|
||||
return false;
|
||||
}
|
||||
} else if (
|
||||
typeof value === "undefined" ||
|
||||
!deepEqual(value, matcher[prop])
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Matcher was not a string, a number, a " +
|
||||
"function, a boolean or an object"
|
||||
);
|
||||
}
|
||||
|
||||
Object.keys(createMatcher).forEach(function(key) {
|
||||
match[key] = createMatcher[key];
|
||||
});
|
||||
|
||||
module.exports = match;
|
470
node_modules/@sinonjs/samsam/lib/matcher.js
generated
vendored
Normal file
470
node_modules/@sinonjs/samsam/lib/matcher.js
generated
vendored
Normal file
@ -0,0 +1,470 @@
|
||||
"use strict";
|
||||
|
||||
var arrayProto = require("@sinonjs/commons").prototypes.array;
|
||||
var deepEqual = require("./deep-equal").use(match); // eslint-disable-line no-use-before-define
|
||||
var every = require("@sinonjs/commons").every;
|
||||
var functionName = require("@sinonjs/commons").functionName;
|
||||
var get = require("lodash").get;
|
||||
var iterableToString = require("./iterable-to-string");
|
||||
var objectProto = require("@sinonjs/commons").prototypes.object;
|
||||
var stringProto = require("@sinonjs/commons").prototypes.string;
|
||||
var typeOf = require("@sinonjs/commons").typeOf;
|
||||
var valueToString = require("@sinonjs/commons").valueToString;
|
||||
|
||||
var arrayIndexOf = arrayProto.indexOf;
|
||||
var arrayEvery = arrayProto.every;
|
||||
var join = arrayProto.join;
|
||||
var map = arrayProto.map;
|
||||
var some = arrayProto.some;
|
||||
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
var isPrototypeOf = objectProto.isPrototypeOf;
|
||||
|
||||
var stringIndexOf = stringProto.indexOf;
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function assertMethodExists(value, method, name, methodPath) {
|
||||
if (value[method] == null) {
|
||||
throw new TypeError(
|
||||
"Expected " + name + " to have method " + methodPath
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
var matcher = {
|
||||
toString: function() {
|
||||
return this.message;
|
||||
}
|
||||
};
|
||||
|
||||
function isMatcher(object) {
|
||||
return isPrototypeOf(matcher, object);
|
||||
}
|
||||
|
||||
function matchObject(actual, expectation) {
|
||||
if (actual === null || actual === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return arrayEvery(Object.keys(expectation), function(key) {
|
||||
var exp = expectation[key];
|
||||
var act = actual[key];
|
||||
|
||||
if (isMatcher(exp)) {
|
||||
if (!exp.test(act)) {
|
||||
return false;
|
||||
}
|
||||
} else if (typeOf(exp) === "object") {
|
||||
if (!matchObject(act, exp)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!deepEqual(act, exp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
var TYPE_MAP = {
|
||||
function: function(m, expectation, message) {
|
||||
m.test = expectation;
|
||||
m.message = message || "match(" + functionName(expectation) + ")";
|
||||
},
|
||||
number: function(m, expectation) {
|
||||
m.test = function(actual) {
|
||||
// we need type coercion here
|
||||
return expectation == actual; // eslint-disable-line eqeqeq
|
||||
};
|
||||
},
|
||||
object: function(m, expectation) {
|
||||
var array = [];
|
||||
|
||||
if (typeof expectation.test === "function") {
|
||||
m.test = function(actual) {
|
||||
return expectation.test(actual) === true;
|
||||
};
|
||||
m.message = "match(" + functionName(expectation.test) + ")";
|
||||
return m;
|
||||
}
|
||||
|
||||
array = map(Object.keys(expectation), function(key) {
|
||||
return key + ": " + valueToString(expectation[key]);
|
||||
});
|
||||
|
||||
m.test = function(actual) {
|
||||
return matchObject(actual, expectation);
|
||||
};
|
||||
m.message = "match(" + join(array, ", ") + ")";
|
||||
|
||||
return m;
|
||||
},
|
||||
regexp: function(m, expectation) {
|
||||
m.test = function(actual) {
|
||||
return typeof actual === "string" && expectation.test(actual);
|
||||
};
|
||||
},
|
||||
string: function(m, expectation) {
|
||||
m.test = function(actual) {
|
||||
return (
|
||||
typeof actual === "string" &&
|
||||
stringIndexOf(actual, expectation) !== -1
|
||||
);
|
||||
};
|
||||
m.message = 'match("' + expectation + '")';
|
||||
}
|
||||
};
|
||||
|
||||
function match(expectation, message) {
|
||||
var m = Object.create(matcher);
|
||||
var type = typeOf(expectation);
|
||||
|
||||
if (message !== undefined && typeof message !== "string") {
|
||||
throw new TypeError("Message should be a string");
|
||||
}
|
||||
|
||||
if (arguments.length > 2) {
|
||||
throw new TypeError(
|
||||
"Expected 1 or 2 arguments, received " + arguments.length
|
||||
);
|
||||
}
|
||||
|
||||
if (type in TYPE_MAP) {
|
||||
TYPE_MAP[type](m, expectation, message);
|
||||
} else {
|
||||
m.test = function(actual) {
|
||||
return deepEqual(actual, expectation);
|
||||
};
|
||||
}
|
||||
|
||||
if (!m.message) {
|
||||
m.message = "match(" + valueToString(expectation) + ")";
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
matcher.or = function(m2) {
|
||||
if (!arguments.length) {
|
||||
throw new TypeError("Matcher expected");
|
||||
} else if (!isMatcher(m2)) {
|
||||
m2 = match(m2);
|
||||
}
|
||||
var m1 = this;
|
||||
var or = Object.create(matcher);
|
||||
or.test = function(actual) {
|
||||
return m1.test(actual) || m2.test(actual);
|
||||
};
|
||||
or.message = m1.message + ".or(" + m2.message + ")";
|
||||
return or;
|
||||
};
|
||||
|
||||
matcher.and = function(m2) {
|
||||
if (!arguments.length) {
|
||||
throw new TypeError("Matcher expected");
|
||||
} else if (!isMatcher(m2)) {
|
||||
m2 = match(m2);
|
||||
}
|
||||
var m1 = this;
|
||||
var and = Object.create(matcher);
|
||||
and.test = function(actual) {
|
||||
return m1.test(actual) && m2.test(actual);
|
||||
};
|
||||
and.message = m1.message + ".and(" + m2.message + ")";
|
||||
return and;
|
||||
};
|
||||
|
||||
match.isMatcher = isMatcher;
|
||||
|
||||
match.any = match(function() {
|
||||
return true;
|
||||
}, "any");
|
||||
|
||||
match.defined = match(function(actual) {
|
||||
return actual !== null && actual !== undefined;
|
||||
}, "defined");
|
||||
|
||||
match.truthy = match(function(actual) {
|
||||
return !!actual;
|
||||
}, "truthy");
|
||||
|
||||
match.falsy = match(function(actual) {
|
||||
return !actual;
|
||||
}, "falsy");
|
||||
|
||||
match.same = function(expectation) {
|
||||
return match(function(actual) {
|
||||
return expectation === actual;
|
||||
}, "same(" + valueToString(expectation) + ")");
|
||||
};
|
||||
|
||||
match.in = function(arrayOfExpectations) {
|
||||
if (typeOf(arrayOfExpectations) !== "array") {
|
||||
throw new TypeError("array expected");
|
||||
}
|
||||
|
||||
return match(function(actual) {
|
||||
return some(arrayOfExpectations, function(expectation) {
|
||||
return expectation === actual;
|
||||
});
|
||||
}, "in(" + valueToString(arrayOfExpectations) + ")");
|
||||
};
|
||||
|
||||
match.typeOf = function(type) {
|
||||
assertType(type, "string", "type");
|
||||
return match(function(actual) {
|
||||
return typeOf(actual) === type;
|
||||
}, 'typeOf("' + type + '")');
|
||||
};
|
||||
|
||||
match.instanceOf = function(type) {
|
||||
if (
|
||||
typeof Symbol === "undefined" ||
|
||||
typeof Symbol.hasInstance === "undefined"
|
||||
) {
|
||||
assertType(type, "function", "type");
|
||||
} else {
|
||||
assertMethodExists(
|
||||
type,
|
||||
Symbol.hasInstance,
|
||||
"type",
|
||||
"[Symbol.hasInstance]"
|
||||
);
|
||||
}
|
||||
return match(function(actual) {
|
||||
return actual instanceof type;
|
||||
}, "instanceOf(" +
|
||||
(functionName(type) || Object.prototype.toString.call(type)) +
|
||||
")");
|
||||
};
|
||||
|
||||
function createPropertyMatcher(propertyTest, messagePrefix) {
|
||||
return function(property, value) {
|
||||
assertType(property, "string", "property");
|
||||
var onlyProperty = arguments.length === 1;
|
||||
var message = messagePrefix + '("' + property + '"';
|
||||
if (!onlyProperty) {
|
||||
message += ", " + valueToString(value);
|
||||
}
|
||||
message += ")";
|
||||
return match(function(actual) {
|
||||
if (
|
||||
actual === undefined ||
|
||||
actual === null ||
|
||||
!propertyTest(actual, property)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return onlyProperty || deepEqual(actual[property], value);
|
||||
}, message);
|
||||
};
|
||||
}
|
||||
|
||||
match.has = createPropertyMatcher(function(actual, property) {
|
||||
if (typeof actual === "object") {
|
||||
return property in actual;
|
||||
}
|
||||
return actual[property] !== undefined;
|
||||
}, "has");
|
||||
|
||||
match.hasOwn = createPropertyMatcher(function(actual, property) {
|
||||
return hasOwnProperty(actual, property);
|
||||
}, "hasOwn");
|
||||
|
||||
match.hasNested = function(property, value) {
|
||||
assertType(property, "string", "property");
|
||||
var onlyProperty = arguments.length === 1;
|
||||
var message = 'hasNested("' + property + '"';
|
||||
if (!onlyProperty) {
|
||||
message += ", " + valueToString(value);
|
||||
}
|
||||
message += ")";
|
||||
return match(function(actual) {
|
||||
if (
|
||||
actual === undefined ||
|
||||
actual === null ||
|
||||
get(actual, property) === undefined
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return onlyProperty || deepEqual(get(actual, property), value);
|
||||
}, message);
|
||||
};
|
||||
|
||||
match.every = function(predicate) {
|
||||
if (!isMatcher(predicate)) {
|
||||
throw new TypeError("Matcher expected");
|
||||
}
|
||||
|
||||
return match(function(actual) {
|
||||
if (typeOf(actual) === "object") {
|
||||
return every(Object.keys(actual), function(key) {
|
||||
return predicate.test(actual[key]);
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
!!actual &&
|
||||
typeOf(actual.forEach) === "function" &&
|
||||
every(actual, function(element) {
|
||||
return predicate.test(element);
|
||||
})
|
||||
);
|
||||
}, "every(" + predicate.message + ")");
|
||||
};
|
||||
|
||||
match.some = function(predicate) {
|
||||
if (!isMatcher(predicate)) {
|
||||
throw new TypeError("Matcher expected");
|
||||
}
|
||||
|
||||
return match(function(actual) {
|
||||
if (typeOf(actual) === "object") {
|
||||
return !every(Object.keys(actual), function(key) {
|
||||
return !predicate.test(actual[key]);
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
!!actual &&
|
||||
typeOf(actual.forEach) === "function" &&
|
||||
!every(actual, function(element) {
|
||||
return !predicate.test(element);
|
||||
})
|
||||
);
|
||||
}, "some(" + predicate.message + ")");
|
||||
};
|
||||
|
||||
match.array = match.typeOf("array");
|
||||
|
||||
match.array.deepEquals = function(expectation) {
|
||||
return match(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"
|
||||
? match.array.deepEquals(expected).test(element)
|
||||
: deepEqual(expected, element);
|
||||
})
|
||||
);
|
||||
}, "deepEquals([" + iterableToString(expectation) + "])");
|
||||
};
|
||||
|
||||
match.array.startsWith = function(expectation) {
|
||||
return match(function(actual) {
|
||||
return (
|
||||
typeOf(actual) === "array" &&
|
||||
every(expectation, function(expectedElement, index) {
|
||||
return actual[index] === expectedElement;
|
||||
})
|
||||
);
|
||||
}, "startsWith([" + iterableToString(expectation) + "])");
|
||||
};
|
||||
|
||||
match.array.endsWith = function(expectation) {
|
||||
return match(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) + "])");
|
||||
};
|
||||
|
||||
match.array.contains = function(expectation) {
|
||||
return match(function(actual) {
|
||||
return (
|
||||
typeOf(actual) === "array" &&
|
||||
every(expectation, function(expectedElement) {
|
||||
return arrayIndexOf(actual, expectedElement) !== -1;
|
||||
})
|
||||
);
|
||||
}, "contains([" + iterableToString(expectation) + "])");
|
||||
};
|
||||
|
||||
match.map = match.typeOf("map");
|
||||
|
||||
match.map.deepEquals = function mapDeepEquals(expectation) {
|
||||
return match(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) + "])");
|
||||
};
|
||||
|
||||
match.map.contains = function mapContains(expectation) {
|
||||
return match(function(actual) {
|
||||
return (
|
||||
typeOf(actual) === "map" &&
|
||||
every(expectation, function(element, key) {
|
||||
return actual.has(key) && actual.get(key) === element;
|
||||
})
|
||||
);
|
||||
}, "contains(Map[" + iterableToString(expectation) + "])");
|
||||
};
|
||||
|
||||
match.set = match.typeOf("set");
|
||||
|
||||
match.set.deepEquals = function setDeepEquals(expectation) {
|
||||
return match(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) + "])");
|
||||
};
|
||||
|
||||
match.set.contains = function setContains(expectation) {
|
||||
return match(function(actual) {
|
||||
return (
|
||||
typeOf(actual) === "set" &&
|
||||
every(expectation, function(element) {
|
||||
return actual.has(element);
|
||||
})
|
||||
);
|
||||
}, "contains(Set[" + iterableToString(expectation) + "])");
|
||||
};
|
||||
|
||||
match.bool = match.typeOf("boolean");
|
||||
match.number = match.typeOf("number");
|
||||
match.string = match.typeOf("string");
|
||||
match.object = match.typeOf("object");
|
||||
match.func = match.typeOf("function");
|
||||
match.regexp = match.typeOf("regexp");
|
||||
match.date = match.typeOf("date");
|
||||
match.symbol = match.typeOf("symbol");
|
||||
|
||||
module.exports = match;
|
21
node_modules/@sinonjs/samsam/lib/samsam.js
generated
vendored
Normal file
21
node_modules/@sinonjs/samsam/lib/samsam.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
var identical = require("./identical");
|
||||
var isArguments = require("./is-arguments");
|
||||
var isElement = require("./is-element");
|
||||
var isNegZero = require("./is-neg-zero");
|
||||
var isSet = require("./is-set");
|
||||
var match = require("./match");
|
||||
var deepEqualCyclic = require("./deep-equal").use(match);
|
||||
var createMatcher = require("./matcher");
|
||||
|
||||
module.exports = {
|
||||
createMatcher: createMatcher,
|
||||
deepEqual: deepEqualCyclic,
|
||||
identical: identical,
|
||||
isArguments: isArguments,
|
||||
isElement: isElement,
|
||||
isNegZero: isNegZero,
|
||||
isSet: isSet,
|
||||
match: match
|
||||
};
|
94
node_modules/@sinonjs/samsam/package.json
generated
vendored
Normal file
94
node_modules/@sinonjs/samsam/package.json
generated
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
{
|
||||
"_from": "@sinonjs/samsam@^3.2.0",
|
||||
"_id": "@sinonjs/samsam@3.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-beHeJM/RRAaLLsMJhsCvHK31rIqZuobfPLa/80yGH5hnD8PV1hyh9xJBJNFfNmO7yWqm+zomijHsXpI6iTQJfQ==",
|
||||
"_location": "/@sinonjs/samsam",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@sinonjs/samsam@^3.2.0",
|
||||
"name": "@sinonjs/samsam",
|
||||
"escapedName": "@sinonjs%2fsamsam",
|
||||
"scope": "@sinonjs",
|
||||
"rawSpec": "^3.2.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^3.2.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@sinonjs/formatio",
|
||||
"/sinon"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@sinonjs/samsam/-/samsam-3.3.0.tgz",
|
||||
"_shasum": "9557ea89cd39dbc94ffbd093c8085281cac87416",
|
||||
"_spec": "@sinonjs/samsam@^3.2.0",
|
||||
"_where": "/Users/josh.burman/Projects/braid/node_modules/sinon",
|
||||
"author": {
|
||||
"name": "Christian Johansen"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sinonjs/samsam/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@sinonjs/commons": "^1.0.2",
|
||||
"array-from": "^2.1.1",
|
||||
"lodash": "^4.17.11"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Value identification and comparison functions",
|
||||
"devDependencies": {
|
||||
"@sinonjs/referee": "^2.0.0",
|
||||
"benchmark": "2.1.4",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-config-prettier": "2.9.0",
|
||||
"eslint-config-sinon": "^1.0.3",
|
||||
"eslint-plugin-ie11": "^1.0.0",
|
||||
"eslint-plugin-mocha": "^4.11.0",
|
||||
"eslint-plugin-prettier": "2.6.2",
|
||||
"husky": "^0.14.3",
|
||||
"jsdom": "^13.0.0",
|
||||
"jsdom-global": "^3.0.2",
|
||||
"lint-staged": "^6.1.0",
|
||||
"microtime": "2.1.8",
|
||||
"mkdirp": "^0.5.1",
|
||||
"mocha": "^5.0.0",
|
||||
"mochify": "^5.8.1",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"nyc": "^13.2.0",
|
||||
"prettier": "1.13.7",
|
||||
"rollup": "^0.57.1",
|
||||
"rollup-plugin-commonjs": "^9.1.0"
|
||||
},
|
||||
"files": [
|
||||
"dist/",
|
||||
"docs/",
|
||||
"lib/",
|
||||
"!lib/**/*.test.js"
|
||||
],
|
||||
"homepage": "http://sinonjs.github.io/samsam/",
|
||||
"license": "BSD-3-Clause",
|
||||
"lint-staged": {
|
||||
"*.js": "eslint"
|
||||
},
|
||||
"main": "./lib/samsam",
|
||||
"name": "@sinonjs/samsam",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sinonjs/samsam.git"
|
||||
},
|
||||
"scripts": {
|
||||
"benchmark": "node lib/deep-equal-benchmark.js",
|
||||
"build": "run-s build:dist-folder build:bundle",
|
||||
"build:bundle": "rollup -c > dist/samsam.js",
|
||||
"build:dist-folder": "mkdirp dist",
|
||||
"lint": "eslint .",
|
||||
"prepublishOnly": "npm run build && mkdocs gh-deploy -r upstream || mkdocs gh-deploy -r origin",
|
||||
"test": "mocha ./lib/*.test.js",
|
||||
"test-cloud": "npm run test-headless -- --wd",
|
||||
"test-coverage": "nyc --reporter text --reporter html --reporter lcovonly npm run test",
|
||||
"test-headless": "mochify lib/*.test.js"
|
||||
},
|
||||
"version": "3.3.0"
|
||||
}
|
Reference in New Issue
Block a user