Initial commit

This commit is contained in:
WatermelonModders
2022-05-31 12:35:46 -04:00
commit fc5cb0c32c
4097 changed files with 447075 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
docs/
test/
build/
components/
support/
coverage.html
component.json
lib-cov
.travis.yml
Makefile
*.swp
+28
View File
@@ -0,0 +1,28 @@
0.1.3 / 2013-10-10
==================
* pkg: update type-detect version
* index,test: conditional require in test bootstrap
0.1.2 / 2013-09-18
==================
* bug: [fix] misnamed variable from code migration (reference error)
0.1.1 / 2013-09-18
==================
* bug: [fix] last key of deep object ignored
0.1.0 / 2013-09-18
==================
* tests: add iterable
* docs: readme
* makefile: [ci] update cov handling
* testing: [env] use karma for phantom
* add tests (uncompleted)
* add library
* add dependencies
* "Initial commit"
+52
View File
@@ -0,0 +1,52 @@
# deep-eql [![Build Status](https://travis-ci.org/chaijs/deep-eql.png?branch=master)](https://travis-ci.org/chaijs/deep-eql) [![Coverage Status](https://coveralls.io/repos/chaijs/deep-eql/badge.png?branch=master)](https://coveralls.io/r/chaijs/deep-eql?branch=master)
> Improved deep equality testing for Node.js and the browser.
## Installation
### Node.js
`deep-eql` is available on [npm](http://npmjs.org).
$ npm install deep-eql
### Component
`deep-eql` is available as a [component](https://github.com/component/component).
$ component install chaijs/deep-eql
## Usage
### Rules
- Strict equality for non-traversable nodes according to [egal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
- `eql(NaN, NaN).should.be.true;`
- `eql(-0, +0).should.be.false;`
- Arguments are not Arrays:
- `eql([], arguments).should.be.false;`
- `eql([], Array.prototype.slice.call(arguments)).should.be.true;`
## License
(The MIT License)
Copyright (c) 2013 Jake Luer <jake@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
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.
+1
View File
@@ -0,0 +1 @@
module.exports = require('./lib/eql');
+20
View File
@@ -0,0 +1,20 @@
module.exports = function(config) {
config.set({
basePath: ''
, frameworks: [ 'mocha' ]
, files: [
'build/build.js'
, 'test/bootstrap/karma.js'
, 'test/*.js'
]
, exclude: []
, reporters: [ 'progress' ]
, port: 9876
, colors: true
, logLevel: config.LOG_INFO
, autoWatch: true
, browsers: [ 'PhantomJS' ]
, captureTimeout: 60000
, singleRun: false
});
};
+257
View File
@@ -0,0 +1,257 @@
/*!
* deep-eql
* Copyright(c) 2013 Jake Luer <jake@alogicalparadox.com>
* MIT Licensed
*/
/*!
* Module dependencies
*/
var type = require('type-detect');
/*!
* Buffer.isBuffer browser shim
*/
var Buffer;
try { Buffer = require('buffer').Buffer; }
catch(ex) {
Buffer = {};
Buffer.isBuffer = function() { return false; }
}
/*!
* Primary Export
*/
module.exports = deepEqual;
/**
* Assert super-strict (egal) equality between
* two objects of any type.
*
* @param {Mixed} a
* @param {Mixed} b
* @param {Array} memoised (optional)
* @return {Boolean} equal match
*/
function deepEqual(a, b, m) {
if (sameValue(a, b)) {
return true;
} else if ('date' === type(a)) {
return dateEqual(a, b);
} else if ('regexp' === type(a)) {
return regexpEqual(a, b);
} else if (Buffer.isBuffer(a)) {
return bufferEqual(a, b);
} else if ('arguments' === type(a)) {
return argumentsEqual(a, b, m);
} else if (!typeEqual(a, b)) {
return false;
} else if (('object' !== type(a) && 'object' !== type(b))
&& ('array' !== type(a) && 'array' !== type(b))) {
return sameValue(a, b);
} else {
return objectEqual(a, b, m);
}
}
/*!
* Strict (egal) equality test. Ensures that NaN always
* equals NaN and `-0` does not equal `+0`.
*
* @param {Mixed} a
* @param {Mixed} b
* @return {Boolean} equal match
*/
function sameValue(a, b) {
if (a === b) return a !== 0 || 1 / a === 1 / b;
return a !== a && b !== b;
}
/*!
* Compare the types of two given objects and
* return if they are equal. Note that an Array
* has a type of `array` (not `object`) and arguments
* have a type of `arguments` (not `array`/`object`).
*
* @param {Mixed} a
* @param {Mixed} b
* @return {Boolean} result
*/
function typeEqual(a, b) {
return type(a) === type(b);
}
/*!
* Compare two Date objects by asserting that
* the time values are equal using `saveValue`.
*
* @param {Date} a
* @param {Date} b
* @return {Boolean} result
*/
function dateEqual(a, b) {
if ('date' !== type(b)) return false;
return sameValue(a.getTime(), b.getTime());
}
/*!
* Compare two regular expressions by converting them
* to string and checking for `sameValue`.
*
* @param {RegExp} a
* @param {RegExp} b
* @return {Boolean} result
*/
function regexpEqual(a, b) {
if ('regexp' !== type(b)) return false;
return sameValue(a.toString(), b.toString());
}
/*!
* Assert deep equality of two `arguments` objects.
* Unfortunately, these must be sliced to arrays
* prior to test to ensure no bad behavior.
*
* @param {Arguments} a
* @param {Arguments} b
* @param {Array} memoize (optional)
* @return {Boolean} result
*/
function argumentsEqual(a, b, m) {
if ('arguments' !== type(b)) return false;
a = [].slice.call(a);
b = [].slice.call(b);
return deepEqual(a, b, m);
}
/*!
* Get enumerable properties of a given object.
*
* @param {Object} a
* @return {Array} property names
*/
function enumerable(a) {
var res = [];
for (var key in a) res.push(key);
return res;
}
/*!
* Simple equality for flat iterable objects
* such as Arrays or Node.js buffers.
*
* @param {Iterable} a
* @param {Iterable} b
* @return {Boolean} result
*/
function iterableEqual(a, b) {
if (a.length !== b.length) return false;
var i = 0;
var match = true;
for (; i < a.length; i++) {
if (a[i] !== b[i]) {
match = false;
break;
}
}
return match;
}
/*!
* Extension to `iterableEqual` specifically
* for Node.js Buffers.
*
* @param {Buffer} a
* @param {Mixed} b
* @return {Boolean} result
*/
function bufferEqual(a, b) {
if (!Buffer.isBuffer(b)) return false;
return iterableEqual(a, b);
}
/*!
* Block for `objectEqual` ensuring non-existing
* values don't get in.
*
* @param {Mixed} object
* @return {Boolean} result
*/
function isValue(a) {
return a !== null && a !== undefined;
}
/*!
* Recursively check the equality of two objects.
* Once basic sameness has been established it will
* defer to `deepEqual` for each enumerable key
* in the object.
*
* @param {Mixed} a
* @param {Mixed} b
* @return {Boolean} result
*/
function objectEqual(a, b, m) {
if (!isValue(a) || !isValue(b)) {
return false;
}
if (a.prototype !== b.prototype) {
return false;
}
var i;
if (m) {
for (i = 0; i < m.length; i++) {
if ((m[i][0] === a && m[i][1] === b)
|| (m[i][0] === b && m[i][1] === a)) {
return true;
}
}
} else {
m = [];
}
try {
var ka = enumerable(a);
var kb = enumerable(b);
} catch (ex) {
return false;
}
ka.sort();
kb.sort();
if (!iterableEqual(ka, kb)) {
return false;
}
m.push([ a, b ]);
var key;
for (i = ka.length - 1; i >= 0; i--) {
key = ka[i];
if (!deepEqual(a[key], b[key], m)) {
return false;
}
}
return true;
}
+11
View File
@@ -0,0 +1,11 @@
docs/
test/
build/
components/
support/
coverage.html
component.json
lib-cov
.travis.yml
Makefile
*.swp
+18
View File
@@ -0,0 +1,18 @@
0.1.1 / 2013-10-10
==================
* Merge pull request #2 from strongloop/fix-browserify
* index,test: support browserify
0.1.0 / 2013-08-14
==================
* readme: document all methods
* readme: add badges
* library: [test] ensure test runs
* travis: change script to run coveralls reportwq
* tests: add tests
* lib: add type detect lib
* pkg: prepare for coverage based tests
* "Initial commit"
+193
View File
@@ -0,0 +1,193 @@
# type-detect [![Build Status](https://travis-ci.org/chaijs/type-detect.png?branch=master)](https://travis-ci.org/chaijs/type-detect) [![Coverage Status](https://coveralls.io/repos/chaijs/type-detect/badge.png?branch=master)](https://coveralls.io/r/chaijs/type-detect?branch=master)
> Improved typeof detection for node.js and the browser.
## Installation
### Node.js
`type-detect` is available on [npm](http://npmjs.org).
$ npm install type-detect
### Component
`type-detect` is available as a [component](https://github.com/component/component).
$ component install chaijs/type-detect
## Usage
### Primary
The primary export of `type-detect` is function that can server 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');
```
#### array
```js
assert('array' === type([]));
assert('array' === type(new Array()));
```
#### regexp
```js
assert('regexp' === type(/a-z/gi));
assert('regexp' === type(new RegExp('a-z')));
```
#### function
```js
assert('function' === type(function () {}));
```
#### arguments
```js
(function () {
assert('arguments' === type(arguments));
})();
```
#### date
```js
assert('date' === type(new Date));
```
#### number
```js
assert('number' === type(1));
assert('number' === type(1.234));
assert('number' === type(-1));
assert('number' === type(-1.234));
assert('number' === type(Infinity));
assert('number' === type(NaN));
```
#### string
```js
assert('string' === type('hello world'));
```
#### null
```js
assert('null' === type(null));
assert('null' !== type(undefined));
```
#### undefined
```js
assert('undefined' === type(undefined));
assert('undefined' !== type(null));
```
#### object
```js
var Noop = function () {};
assert('object' === type({}));
assert('object' !== type(Noop));
assert('object' === type(new Noop));
assert('object' === type(new Object));
assert('object' === type(new String('hello')));
```
### Library
A `Library` is a small constructed repository for custom type detections.
```js
var lib = new type.Library;
```
#### .of (obj)
* **@param** _{Mixed}_ object to test
* **@return** _{String}_ type
Expose replacement `typeof` detection to the library.
```js
if ('string' === lib.of('hello world')) {
// ...
}
```
#### .define (type, test)
* **@param** _{String}_ type
* **@param** _{RegExp|Function}_ test
Add a test to for the `.test()` assertion.
Can be defined as a regular expression:
```js
lib.define('int', /^[0-9]+$/);
```
... or as a function:
```js
lib.define('bln', function (obj) {
if ('boolean' === lib.of(obj)) return true;
var blns = [ 'yes', 'no', 'true', 'false', 1, 0 ];
if ('string' === lib.of(obj)) obj = obj.toLowerCase();
return !! ~blns.indexOf(obj);
});
```
#### .test (obj, test)
* **@param** _{Mixed}_ object
* **@param** _{String}_ type
* **@return** _{Boolean}_ result
Assert that an object is of type. Will first
check natives, and if that does not pass it will
use the user defined custom tests.
```js
assert(lib.test('1', 'int'));
assert(lib.test('yes', 'bln'));
```
## License
(The MIT License)
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
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.
+1
View File
@@ -0,0 +1 @@
module.exports = require('./lib/type');
+142
View File
@@ -0,0 +1,142 @@
/*!
* type-detect
* Copyright(c) 2013 jake luer <jake@alogicalparadox.com>
* MIT Licensed
*/
/*!
* Primary Exports
*/
var exports = module.exports = getType;
/*!
* Detectable javascript natives
*/
var natives = {
'[object Array]': 'array'
, '[object RegExp]': 'regexp'
, '[object Function]': 'function'
, '[object Arguments]': 'arguments'
, '[object Date]': 'date'
};
/**
* ### typeOf (obj)
*
* Use several different techniques to determine
* the type of object being tested.
*
*
* @param {Mixed} object
* @return {String} object type
* @api public
*/
function getType (obj) {
var str = Object.prototype.toString.call(obj);
if (natives[str]) return natives[str];
if (obj === null) return 'null';
if (obj === undefined) return 'undefined';
if (obj === Object(obj)) return 'object';
return typeof obj;
}
exports.Library = Library;
/**
* ### Library
*
* Create a repository for custom type detection.
*
* ```js
* var lib = new type.Library;
* ```
*
*/
function Library () {
this.tests = {};
}
/**
* #### .of (obj)
*
* Expose replacement `typeof` detection to the library.
*
* ```js
* if ('string' === lib.of('hello world')) {
* // ...
* }
* ```
*
* @param {Mixed} object to test
* @return {String} type
*/
Library.prototype.of = getType;
/**
* #### .define (type, test)
*
* Add a test to for the `.test()` assertion.
*
* Can be defined as a regular expression:
*
* ```js
* lib.define('int', /^[0-9]+$/);
* ```
*
* ... or as a function:
*
* ```js
* lib.define('bln', function (obj) {
* if ('boolean' === lib.of(obj)) return true;
* var blns = [ 'yes', 'no', 'true', 'false', 1, 0 ];
* if ('string' === lib.of(obj)) obj = obj.toLowerCase();
* return !! ~blns.indexOf(obj);
* });
* ```
*
* @param {String} type
* @param {RegExp|Function} test
* @api public
*/
Library.prototype.define = function (type, test) {
if (arguments.length === 1) return this.tests[type];
this.tests[type] = test;
return this;
};
/**
* #### .test (obj, test)
*
* Assert that an object is of type. Will first
* check natives, and if that does not pass it will
* use the user defined custom tests.
*
* ```js
* assert(lib.test('1', 'int'));
* assert(lib.test('yes', 'bln'));
* ```
*
* @param {Mixed} object
* @param {String} type
* @return {Boolean} result
* @api public
*/
Library.prototype.test = function (obj, type) {
if (type === getType(obj)) return true;
var test = this.tests[type];
if (test && 'regexp' === getType(test)) {
return test.test(obj);
} else if (test && 'function' === getType(test)) {
return test(obj);
} else {
throw new ReferenceError('Type test "' + type + '" not defined or invalid.');
}
};
+83
View File
@@ -0,0 +1,83 @@
{
"_args": [
[
"type-detect@0.1.1",
"/home/xor/shared_vm/git/node-sunwell/node_modules/deep-eql"
]
],
"_from": "type-detect@0.1.1",
"_id": "type-detect@0.1.1",
"_inCache": true,
"_installable": true,
"_location": "/deep-eql/type-detect",
"_npmUser": {
"email": "jake@alogicalparadox.com",
"name": "jakeluer"
},
"_npmVersion": "1.3.11",
"_phantomChildren": {},
"_requested": {
"name": "type-detect",
"raw": "type-detect@0.1.1",
"rawSpec": "0.1.1",
"scope": null,
"spec": "0.1.1",
"type": "version"
},
"_requiredBy": [
"/deep-eql"
],
"_resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz",
"_shasum": "0ba5ec2a885640e470ea4e8505971900dac58822",
"_shrinkwrap": null,
"_spec": "type-detect@0.1.1",
"_where": "/home/xor/shared_vm/git/node-sunwell/node_modules/deep-eql",
"author": {
"email": "jake@alogicalparadox.com",
"name": "Jake Luer",
"url": "http://alogicalparadox.com"
},
"bugs": {
"url": "https://github.com/chaijs/type-detect/issues"
},
"dependencies": {},
"description": "Improved typeof detection for node.js and the browser.",
"devDependencies": {
"component": "*",
"coveralls": "2.0.16",
"jscoverage": "0.3.7",
"mocha": "*",
"mocha-lcov-reporter": "0.0.1",
"mocha-phantomjs": "*",
"simple-assert": "*"
},
"directories": {},
"dist": {
"shasum": "0ba5ec2a885640e470ea4e8505971900dac58822",
"tarball": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz"
},
"engines": {
"node": "*"
},
"homepage": "https://github.com/chaijs/type-detect#readme",
"keywords": [],
"license": "MIT",
"main": "./index",
"maintainers": [
{
"name": "jakeluer",
"email": "jake@alogicalparadox.com"
}
],
"name": "type-detect",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/chaijs/type-detect.git"
},
"scripts": {
"test": "make test"
},
"version": "0.1.1"
}
+90
View File
@@ -0,0 +1,90 @@
{
"_args": [
[
"deep-eql@^0.1.3",
"/home/xor/shared_vm/git/node-sunwell/node_modules/chai"
]
],
"_from": "deep-eql@>=0.1.3 <0.2.0",
"_id": "deep-eql@0.1.3",
"_inCache": true,
"_installable": true,
"_location": "/deep-eql",
"_npmUser": {
"email": "jake@alogicalparadox.com",
"name": "jakeluer"
},
"_npmVersion": "1.3.11",
"_phantomChildren": {},
"_requested": {
"name": "deep-eql",
"raw": "deep-eql@^0.1.3",
"rawSpec": "^0.1.3",
"scope": null,
"spec": ">=0.1.3 <0.2.0",
"type": "range"
},
"_requiredBy": [
"/chai"
],
"_resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz",
"_shasum": "ef558acab8de25206cd713906d74e56930eb69f2",
"_shrinkwrap": null,
"_spec": "deep-eql@^0.1.3",
"_where": "/home/xor/shared_vm/git/node-sunwell/node_modules/chai",
"author": {
"email": "jake@alogicalparadox.com",
"name": "Jake Luer"
},
"bugs": {
"url": "https://github.com/chaijs/deep-eql/issues"
},
"dependencies": {
"type-detect": "0.1.1"
},
"description": "Improved deep equality testing for Node.js and the browser.",
"devDependencies": {
"component": "*",
"coveralls": "2.0.16",
"jscoverage": "0.3.7",
"karma": "0.10.x",
"karma-mocha": "*",
"mocha": "*",
"mocha-lcov-reporter": "0.0.1",
"simple-assert": "*"
},
"directories": {},
"dist": {
"shasum": "ef558acab8de25206cd713906d74e56930eb69f2",
"tarball": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz"
},
"engines": {
"node": "*"
},
"homepage": "https://github.com/chaijs/deep-eql#readme",
"keywords": [
"chai util",
"deep equal",
"object equal",
"testing"
],
"license": "MIT",
"main": "./index",
"maintainers": [
{
"name": "jakeluer",
"email": "jake@alogicalparadox.com"
}
],
"name": "deep-eql",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/chaijs/deep-eql.git"
},
"scripts": {
"test": "make test"
},
"version": "0.1.3"
}