From ccdc42567d51f3543af0a83956fd78de054ddb3e Mon Sep 17 00:00:00 2001 From: joncloud Date: Sat, 25 Jun 2022 13:55:09 -0700 Subject: [PATCH 1/2] Removes chai * Updates existing tests to use assert --- package.json | 1 - test/installer.spec.js | 77 +++++++++++++++++++++++++++++------------- test/makensis.spec.js | 31 ++++++++++++----- test/readme.spec.js | 15 ++++---- 4 files changed, 85 insertions(+), 39 deletions(-) diff --git a/package.json b/package.json index 1f13724..08526d5 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "@actions/github": "^5.0.3" }, "devDependencies": { - "chai": "^4.3.6", "mocha": "^10.0.0", "yaml": "^2.1.1" } diff --git a/test/installer.spec.js b/test/installer.spec.js index 557f040..0d38271 100644 --- a/test/installer.spec.js +++ b/test/installer.spec.js @@ -1,19 +1,26 @@ -const { promisify } = require('util'); - -const { exists, unlink } = require('fs'); -const existsAsync = promisify(exists); -const unlinkAsync = promisify(unlink); +'use strict'; +const { access, unlink } = require('fs/promises'); const path = require('path'); -const { expect } = require('chai'); +const assert = require('assert'); const { Installer } = require('../installer'); +const exists = async (path) => { + try { + await access(path); + return true; + } + catch { + return false; + } +}; + /** * @param {string} path */ const unlinkIfExistsAsync = async (path) => { - if (await existsAsync(path)) { - unlinkAsync(path); + if (await exists(path)) { + unlink(path); } }; @@ -31,7 +38,7 @@ describe('Installer', () => { it(`should create installer for ${script}.nsi`, async () => { const debugMode = true; const target = new Installer(debugMode); - + if (fn) { fn(target); } @@ -43,11 +50,12 @@ describe('Installer', () => { console.error(err); throw err; } - - const actual = await existsAsync(`./test/${script}.exe`); - - expect(actual).to.equal( - true, + + const actual = await exists(`./test/${script}.exe`); + + assert.strictEqual( + actual, + true, `Installer \`./test/${script}.exe\` should exist` ); }); @@ -64,19 +72,19 @@ describe('Installer', () => { const args = target.getCustomArguments(); - expect(args).to.equal(''); + assert.strictEqual(args, ''); }); it('should return value, given setCustomArguments call', () => { const debugMode = false; const target = new Installer(debugMode); - + const expected = Math.random().toString(); target.setCustomArguments(expected); const args = target.getCustomArguments(); - expect(args).to.equal(expected); + assert.strictEqual(args, expected); }); }); @@ -87,7 +95,10 @@ describe('Installer', () => { const args = target.getProcessArguments(existingScriptPath); - expect(args).to.contain('-V1'); + assert( + args.includes('-V1'), + `'${args.join(',')}' should include -V1` + ); }); it('should default to all verbosity, given **debug** mode', () => { @@ -96,7 +107,10 @@ describe('Installer', () => { const args = target.getProcessArguments(existingScriptPath); - expect(args).to.contain('-V4'); + assert( + args.includes('-V4'), + `'${args.join(',')}' should include -V4` + ); }); it('should not add verbosity, given /V is in arguments', () => { @@ -107,8 +121,14 @@ describe('Installer', () => { const args = target.getProcessArguments(existingScriptPath); - expect(args).to.not.contain('-V1'); - expect(args).to.contain('/V2'); + assert( + !args.includes('-V1'), + `'${args.join(',')}' should not include -V1` + ); + assert( + args.includes('/V2'), + `'${args.join(',')}' should include /V2` + ); }); it('should not add verbosity, given -V is in arguments', () => { @@ -119,8 +139,14 @@ describe('Installer', () => { const args = target.getProcessArguments(existingScriptPath); - expect(args).to.not.contain('-V1'); - expect(args).to.contain('-V2'); + assert( + !args.includes('-V1'), + `'${args.join(',')}' should not include -V1` + ); + assert( + args.includes('-V2'), + `'${args.join(',')}' should include -V2` + ); }); it('should resolve and quote script path', () => { @@ -132,7 +158,10 @@ describe('Installer', () => { const args = target.getProcessArguments(existingScriptPath); const actualScriptPath = args[args.length - 1]; - expect(actualScriptPath).to.equal(`"${path.resolve(existingScriptPath)}"`); + assert.strictEqual( + actualScriptPath, + `"${path.resolve(existingScriptPath)}"` + ); }); }); }); diff --git a/test/makensis.spec.js b/test/makensis.spec.js index c3582f2..a72b52f 100644 --- a/test/makensis.spec.js +++ b/test/makensis.spec.js @@ -1,5 +1,7 @@ -const { expect } = require('chai'); -const fs = require('fs'); +'use strict'; + +const assert = require('assert'); +const fs = require('fs/promises'); const makensis = require('../makensis'); describe('Makensis', () => { @@ -7,9 +9,18 @@ describe('Makensis', () => { it('should return help information', async () => { const output = await makensis.execAsync('-HELP'); - expect(output).to.contain('makensis'); - expect(output).to.contain('CMDHELP'); - expect(output).to.contain('VERSION'); + assert( + output.includes('makensis'), + `'${output}' should include makensis` + ); + assert( + output.includes('CMDHELP'), + `'${output}' should include CMDHELP` + ); + assert( + output.includes('VERSION'), + `'${output}' should include VERSION` + ); }); }); @@ -18,8 +29,12 @@ describe('Makensis', () => { const symbols = await makensis.getSymbolsAsync(); const nsisDir = symbols.NSISDIR; - expect(nsisDir).to.be.ok; - expect(fs.existsSync(nsisDir)).to.be.true; + assert(nsisDir, 'NSISDIR should be defined'); + + assert.doesNotThrow( + () => fs.access(nsisDir), + `NSISDIR (${nsisDir}) should exist` + ); }); it('should include the NSIS_VERSION', async () => { @@ -27,7 +42,7 @@ describe('Makensis', () => { const expected = await makensis.execAsync('-VERSION'); const nsisVersion = symbols.NSIS_VERSION; - expect(nsisVersion).to.equal(expected); + assert.strictEqual(nsisVersion, expected); }); }); }); diff --git a/test/readme.spec.js b/test/readme.spec.js index 6adede8..b5a2b9e 100644 --- a/test/readme.spec.js +++ b/test/readme.spec.js @@ -1,18 +1,20 @@ -const fs = require('fs'); +'use strict'; + +const fs = require('fs/promises'); const YAML = require('yaml'); -const { expect } = require('chai'); +const assert = require('assert'); describe('README', () => { let readmeLines = []; let action; - before(() => { - readmeLines = fs.readFileSync('./README.md', 'utf8') + before(async () => { + readmeLines = (await fs.readFile('./README.md', 'utf8')) .toString() .split(/(?:\r\n|\r|\n)/g); action = YAML.parse( - fs.readFileSync('./action.yml', 'utf8') + await fs.readFile('./action.yml', 'utf8') ); }); @@ -25,7 +27,8 @@ describe('README', () => { return null; }).filter(x => !!x).sort(); - expect(inputs).to.eql( + assert.deepStrictEqual( + inputs, Object.getOwnPropertyNames(action.inputs).sort() ); }); From fef53d6190721160696c4449f36ac876af0c1eae Mon Sep 17 00:00:00 2001 From: joncloud Date: Sat, 25 Jun 2022 13:55:17 -0700 Subject: [PATCH 2/2] npm install --- node_modules/.package-lock.json | 84 - node_modules/assertion-error/History.md | 24 - node_modules/assertion-error/README.md | 41 - node_modules/assertion-error/index.d.ts | 11 - node_modules/assertion-error/index.js | 116 - node_modules/assertion-error/package.json | 62 - node_modules/chai/CODEOWNERS | 1 - node_modules/chai/CODE_OF_CONDUCT.md | 58 - node_modules/chai/CONTRIBUTING.md | 218 - node_modules/chai/History.md | 1059 -- node_modules/chai/LICENSE | 21 - node_modules/chai/README.md | 212 - node_modules/chai/ReleaseNotes.md | 737 - node_modules/chai/bower.json | 26 - node_modules/chai/chai.js | 11464 ---------------- node_modules/chai/index.js | 1 - node_modules/chai/index.mjs | 14 - node_modules/chai/karma.conf.js | 34 - node_modules/chai/karma.sauce.js | 41 - node_modules/chai/lib/chai.js | 92 - node_modules/chai/lib/chai/assertion.js | 175 - node_modules/chai/lib/chai/config.js | 94 - node_modules/chai/lib/chai/core/assertions.js | 3853 ------ .../chai/lib/chai/interface/assert.js | 3113 ----- .../chai/lib/chai/interface/expect.js | 47 - .../chai/lib/chai/interface/should.js | 219 - .../chai/lib/chai/utils/addChainableMethod.js | 152 - .../chai/lib/chai/utils/addLengthGuard.js | 60 - node_modules/chai/lib/chai/utils/addMethod.js | 68 - .../chai/lib/chai/utils/addProperty.js | 72 - .../chai/lib/chai/utils/compareByInspect.js | 31 - .../chai/lib/chai/utils/expectTypes.js | 51 - node_modules/chai/lib/chai/utils/flag.js | 33 - node_modules/chai/lib/chai/utils/getActual.js | 20 - .../lib/chai/utils/getEnumerableProperties.js | 26 - .../chai/lib/chai/utils/getMessage.js | 50 - .../chai/lib/chai/utils/getOperator.js | 55 - .../chai/utils/getOwnEnumerableProperties.js | 29 - .../utils/getOwnEnumerablePropertySymbols.js | 27 - .../chai/lib/chai/utils/getProperties.js | 36 - node_modules/chai/lib/chai/utils/index.js | 178 - node_modules/chai/lib/chai/utils/inspect.js | 33 - node_modules/chai/lib/chai/utils/isNaN.js | 26 - .../chai/lib/chai/utils/isProxyEnabled.js | 24 - .../chai/lib/chai/utils/objDisplay.js | 50 - .../chai/utils/overwriteChainableMethod.js | 69 - .../chai/lib/chai/utils/overwriteMethod.js | 92 - .../chai/lib/chai/utils/overwriteProperty.js | 92 - node_modules/chai/lib/chai/utils/proxify.js | 147 - node_modules/chai/lib/chai/utils/test.js | 28 - .../chai/lib/chai/utils/transferFlags.js | 45 - node_modules/chai/package.json | 63 - node_modules/chai/register-assert.js | 1 - node_modules/chai/register-expect.js | 1 - node_modules/chai/register-should.js | 1 - node_modules/chai/sauce.browsers.js | 106 - node_modules/check-error/LICENSE | 19 - node_modules/check-error/README.md | 207 - node_modules/check-error/check-error.js | 176 - node_modules/check-error/index.js | 172 - node_modules/check-error/package.json | 130 - node_modules/deep-eql/LICENSE | 19 - node_modules/deep-eql/README.md | 116 - node_modules/deep-eql/deep-eql.js | 833 -- node_modules/deep-eql/index.js | 455 - node_modules/deep-eql/package.json | 131 - node_modules/get-func-name/LICENSE | 19 - node_modules/get-func-name/README.md | 123 - node_modules/get-func-name/get-func-name.js | 48 - node_modules/get-func-name/index.js | 44 - node_modules/get-func-name/package.json | 133 - node_modules/loupe/CHANGELOG.md | 5 - node_modules/loupe/LICENSE | 9 - node_modules/loupe/README.md | 63 - node_modules/loupe/index.js | 195 - node_modules/loupe/lib/arguments.js | 7 - node_modules/loupe/lib/array.js | 20 - node_modules/loupe/lib/bigint.js | 7 - node_modules/loupe/lib/class.js | 18 - node_modules/loupe/lib/date.js | 8 - node_modules/loupe/lib/error.js | 34 - node_modules/loupe/lib/function.js | 10 - node_modules/loupe/lib/helpers.js | 177 - node_modules/loupe/lib/html.js | 40 - node_modules/loupe/lib/map.js | 27 - node_modules/loupe/lib/number.js | 18 - node_modules/loupe/lib/object.js | 31 - node_modules/loupe/lib/promise.js | 16 - node_modules/loupe/lib/regexp.js | 8 - node_modules/loupe/lib/set.js | 16 - node_modules/loupe/lib/string.js | 29 - node_modules/loupe/lib/symbol.js | 6 - node_modules/loupe/lib/typedarray.js | 45 - node_modules/loupe/loupe.js | 852 -- node_modules/loupe/package.json | 141 - node_modules/pathval/CHANGELOG.md | 18 - node_modules/pathval/LICENSE | 16 - node_modules/pathval/README.md | 147 - node_modules/pathval/index.js | 301 - node_modules/pathval/package.json | 111 - node_modules/pathval/pathval.js | 1 - node_modules/type-detect/LICENSE | 19 - node_modules/type-detect/README.md | 228 - node_modules/type-detect/index.js | 378 - node_modules/type-detect/package.json | 169 - node_modules/type-detect/type-detect.js | 388 - package-lock.json | 148 - 107 files changed, 29814 deletions(-) delete mode 100644 node_modules/assertion-error/History.md delete mode 100644 node_modules/assertion-error/README.md delete mode 100644 node_modules/assertion-error/index.d.ts delete mode 100644 node_modules/assertion-error/index.js delete mode 100644 node_modules/assertion-error/package.json delete mode 100644 node_modules/chai/CODEOWNERS delete mode 100644 node_modules/chai/CODE_OF_CONDUCT.md delete mode 100644 node_modules/chai/CONTRIBUTING.md delete mode 100644 node_modules/chai/History.md delete mode 100644 node_modules/chai/LICENSE delete mode 100644 node_modules/chai/README.md delete mode 100644 node_modules/chai/ReleaseNotes.md delete mode 100644 node_modules/chai/bower.json delete mode 100644 node_modules/chai/chai.js delete mode 100644 node_modules/chai/index.js delete mode 100644 node_modules/chai/index.mjs delete mode 100644 node_modules/chai/karma.conf.js delete mode 100644 node_modules/chai/karma.sauce.js delete mode 100644 node_modules/chai/lib/chai.js delete mode 100644 node_modules/chai/lib/chai/assertion.js delete mode 100644 node_modules/chai/lib/chai/config.js delete mode 100644 node_modules/chai/lib/chai/core/assertions.js delete mode 100644 node_modules/chai/lib/chai/interface/assert.js delete mode 100644 node_modules/chai/lib/chai/interface/expect.js delete mode 100644 node_modules/chai/lib/chai/interface/should.js delete mode 100644 node_modules/chai/lib/chai/utils/addChainableMethod.js delete mode 100644 node_modules/chai/lib/chai/utils/addLengthGuard.js delete mode 100644 node_modules/chai/lib/chai/utils/addMethod.js delete mode 100644 node_modules/chai/lib/chai/utils/addProperty.js delete mode 100644 node_modules/chai/lib/chai/utils/compareByInspect.js delete mode 100644 node_modules/chai/lib/chai/utils/expectTypes.js delete mode 100644 node_modules/chai/lib/chai/utils/flag.js delete mode 100644 node_modules/chai/lib/chai/utils/getActual.js delete mode 100644 node_modules/chai/lib/chai/utils/getEnumerableProperties.js delete mode 100644 node_modules/chai/lib/chai/utils/getMessage.js delete mode 100644 node_modules/chai/lib/chai/utils/getOperator.js delete mode 100644 node_modules/chai/lib/chai/utils/getOwnEnumerableProperties.js delete mode 100644 node_modules/chai/lib/chai/utils/getOwnEnumerablePropertySymbols.js delete mode 100644 node_modules/chai/lib/chai/utils/getProperties.js delete mode 100644 node_modules/chai/lib/chai/utils/index.js delete mode 100644 node_modules/chai/lib/chai/utils/inspect.js delete mode 100644 node_modules/chai/lib/chai/utils/isNaN.js delete mode 100644 node_modules/chai/lib/chai/utils/isProxyEnabled.js delete mode 100644 node_modules/chai/lib/chai/utils/objDisplay.js delete mode 100644 node_modules/chai/lib/chai/utils/overwriteChainableMethod.js delete mode 100644 node_modules/chai/lib/chai/utils/overwriteMethod.js delete mode 100644 node_modules/chai/lib/chai/utils/overwriteProperty.js delete mode 100644 node_modules/chai/lib/chai/utils/proxify.js delete mode 100644 node_modules/chai/lib/chai/utils/test.js delete mode 100644 node_modules/chai/lib/chai/utils/transferFlags.js delete mode 100644 node_modules/chai/package.json delete mode 100644 node_modules/chai/register-assert.js delete mode 100644 node_modules/chai/register-expect.js delete mode 100644 node_modules/chai/register-should.js delete mode 100644 node_modules/chai/sauce.browsers.js delete mode 100644 node_modules/check-error/LICENSE delete mode 100644 node_modules/check-error/README.md delete mode 100644 node_modules/check-error/check-error.js delete mode 100644 node_modules/check-error/index.js delete mode 100644 node_modules/check-error/package.json delete mode 100644 node_modules/deep-eql/LICENSE delete mode 100644 node_modules/deep-eql/README.md delete mode 100644 node_modules/deep-eql/deep-eql.js delete mode 100644 node_modules/deep-eql/index.js delete mode 100644 node_modules/deep-eql/package.json delete mode 100644 node_modules/get-func-name/LICENSE delete mode 100644 node_modules/get-func-name/README.md delete mode 100644 node_modules/get-func-name/get-func-name.js delete mode 100644 node_modules/get-func-name/index.js delete mode 100644 node_modules/get-func-name/package.json delete mode 100644 node_modules/loupe/CHANGELOG.md delete mode 100644 node_modules/loupe/LICENSE delete mode 100644 node_modules/loupe/README.md delete mode 100644 node_modules/loupe/index.js delete mode 100644 node_modules/loupe/lib/arguments.js delete mode 100644 node_modules/loupe/lib/array.js delete mode 100644 node_modules/loupe/lib/bigint.js delete mode 100644 node_modules/loupe/lib/class.js delete mode 100644 node_modules/loupe/lib/date.js delete mode 100644 node_modules/loupe/lib/error.js delete mode 100644 node_modules/loupe/lib/function.js delete mode 100644 node_modules/loupe/lib/helpers.js delete mode 100644 node_modules/loupe/lib/html.js delete mode 100644 node_modules/loupe/lib/map.js delete mode 100644 node_modules/loupe/lib/number.js delete mode 100644 node_modules/loupe/lib/object.js delete mode 100644 node_modules/loupe/lib/promise.js delete mode 100644 node_modules/loupe/lib/regexp.js delete mode 100644 node_modules/loupe/lib/set.js delete mode 100644 node_modules/loupe/lib/string.js delete mode 100644 node_modules/loupe/lib/symbol.js delete mode 100644 node_modules/loupe/lib/typedarray.js delete mode 100644 node_modules/loupe/loupe.js delete mode 100644 node_modules/loupe/package.json delete mode 100644 node_modules/pathval/CHANGELOG.md delete mode 100644 node_modules/pathval/LICENSE delete mode 100644 node_modules/pathval/README.md delete mode 100644 node_modules/pathval/index.js delete mode 100644 node_modules/pathval/package.json delete mode 100644 node_modules/pathval/pathval.js delete mode 100644 node_modules/type-detect/LICENSE delete mode 100644 node_modules/type-detect/README.md delete mode 100644 node_modules/type-detect/index.js delete mode 100644 node_modules/type-detect/package.json delete mode 100644 node_modules/type-detect/type-detect.js diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 0cf4790..feb5390 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -190,15 +190,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "node_modules/assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -258,24 +249,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/chai": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", - "integrity": "sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==", - "dev": true, - "dependencies": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "loupe": "^2.3.1", - "pathval": "^1.1.1", - "type-detect": "^4.0.5" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -304,15 +277,6 @@ "node": ">=8" } }, - "node_modules/check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -410,18 +374,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "dev": true, - "dependencies": { - "type-detect": "^4.0.0" - }, - "engines": { - "node": ">=0.12" - } - }, "node_modules/deprecation": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", @@ -515,15 +467,6 @@ "node": "6.* || 8.* || >= 10.*" } }, - "node_modules/get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -735,15 +678,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/loupe": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz", - "integrity": "sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==", - "dev": true, - "dependencies": { - "get-func-name": "^2.0.0" - } - }, "node_modules/minimatch": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", @@ -899,15 +833,6 @@ "node": ">=0.10.0" } }, - "node_modules/pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -1057,15 +982,6 @@ "node": ">=0.6.11 <=0.7.0 || >=0.7.3" } }, - "node_modules/type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/universal-user-agent": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", diff --git a/node_modules/assertion-error/History.md b/node_modules/assertion-error/History.md deleted file mode 100644 index b240018..0000000 --- a/node_modules/assertion-error/History.md +++ /dev/null @@ -1,24 +0,0 @@ -1.1.0 / 2018-01-02 -================== - - * Add type definitions ([#11](https://github.com/chaijs/assertion-error/pull/11)) - -1.0.1 / 2015-03-04 -================== - - * Merge pull request #2 from simonzack/master - * fixes `.stack` on firefox - -1.0.0 / 2013-06-08 -================== - - * readme: change travis and component urls - * refactor: [*] prepare for move to chaijs gh org - -0.1.0 / 2013-04-07 -================== - - * test: use vanilla test runner/assert - * pgk: remove unused deps - * lib: implement - * "Initial commit" diff --git a/node_modules/assertion-error/README.md b/node_modules/assertion-error/README.md deleted file mode 100644 index 6cf03c8..0000000 --- a/node_modules/assertion-error/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# AssertionError [![Build Status](https://travis-ci.org/chaijs/assertion-error.png?branch=master)](https://travis-ci.org/chaijs/assertion-error) - -> Error constructor for test and validation frameworks that implements standardized AssertionError specification. - -## Installation - -### Node.js - -`assertion-error` is available on [npm](http://npmjs.org). - - $ npm install assertion-error - -### Component - -`assertion-error` is available as a [component](https://github.com/component/component). - - $ component install chaijs/assertion-error - -## License - -(The MIT License) - -Copyright (c) 2013 Jake Luer (http://qualiancy.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. diff --git a/node_modules/assertion-error/index.d.ts b/node_modules/assertion-error/index.d.ts deleted file mode 100644 index 2b9becd..0000000 --- a/node_modules/assertion-error/index.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -type AssertionError = Error & T & { - showDiff: boolean; -}; - -interface AssertionErrorConstructor { - new(message: string, props?: T, ssf?: Function): AssertionError; -} - -declare const AssertionError: AssertionErrorConstructor; - -export = AssertionError; diff --git a/node_modules/assertion-error/index.js b/node_modules/assertion-error/index.js deleted file mode 100644 index 8466da8..0000000 --- a/node_modules/assertion-error/index.js +++ /dev/null @@ -1,116 +0,0 @@ -/*! - * assertion-error - * Copyright(c) 2013 Jake Luer - * MIT Licensed - */ - -/*! - * Return a function that will copy properties from - * one object to another excluding any originally - * listed. Returned function will create a new `{}`. - * - * @param {String} excluded properties ... - * @return {Function} - */ - -function exclude () { - var excludes = [].slice.call(arguments); - - function excludeProps (res, obj) { - Object.keys(obj).forEach(function (key) { - if (!~excludes.indexOf(key)) res[key] = obj[key]; - }); - } - - return function extendExclude () { - var args = [].slice.call(arguments) - , i = 0 - , res = {}; - - for (; i < args.length; i++) { - excludeProps(res, args[i]); - } - - return res; - }; -}; - -/*! - * Primary Exports - */ - -module.exports = AssertionError; - -/** - * ### AssertionError - * - * An extension of the JavaScript `Error` constructor for - * assertion and validation scenarios. - * - * @param {String} message - * @param {Object} properties to include (optional) - * @param {callee} start stack function (optional) - */ - -function AssertionError (message, _props, ssf) { - var extend = exclude('name', 'message', 'stack', 'constructor', 'toJSON') - , props = extend(_props || {}); - - // default values - this.message = message || 'Unspecified AssertionError'; - this.showDiff = false; - - // copy from properties - for (var key in props) { - this[key] = props[key]; - } - - // capture stack trace - ssf = ssf || AssertionError; - if (Error.captureStackTrace) { - Error.captureStackTrace(this, ssf); - } else { - try { - throw new Error(); - } catch(e) { - this.stack = e.stack; - } - } -} - -/*! - * Inherit from Error.prototype - */ - -AssertionError.prototype = Object.create(Error.prototype); - -/*! - * Statically set name - */ - -AssertionError.prototype.name = 'AssertionError'; - -/*! - * Ensure correct constructor - */ - -AssertionError.prototype.constructor = AssertionError; - -/** - * Allow errors to be converted to JSON for static transfer. - * - * @param {Boolean} include stack (default: `true`) - * @return {Object} object that can be `JSON.stringify` - */ - -AssertionError.prototype.toJSON = function (stack) { - var extend = exclude('constructor', 'toJSON', 'stack') - , props = extend({ name: this.name }, this); - - // include stack if exists and not turned off - if (false !== stack && this.stack) { - props.stack = this.stack; - } - - return props; -}; diff --git a/node_modules/assertion-error/package.json b/node_modules/assertion-error/package.json deleted file mode 100644 index b552526..0000000 --- a/node_modules/assertion-error/package.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "_from": "assertion-error@^1.1.0", - "_id": "assertion-error@1.1.0", - "_inBundle": false, - "_integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "_location": "/assertion-error", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "assertion-error@^1.1.0", - "name": "assertion-error", - "escapedName": "assertion-error", - "rawSpec": "^1.1.0", - "saveSpec": null, - "fetchSpec": "^1.1.0" - }, - "_requiredBy": [ - "/chai" - ], - "_resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "_shasum": "e60b6b0e8f301bd97e5375215bda406c85118c0b", - "_spec": "assertion-error@^1.1.0", - "_where": "C:\\src\\github\\makensis-action\\node_modules\\chai", - "author": { - "name": "Jake Luer", - "email": "jake@qualiancy.com", - "url": "http://qualiancy.com" - }, - "bugs": { - "url": "https://github.com/chaijs/assertion-error/issues" - }, - "bundleDependencies": false, - "dependencies": {}, - "deprecated": false, - "description": "Error constructor for test and validation frameworks that implements standardized AssertionError specification.", - "devDependencies": { - "component": "*", - "typescript": "^2.6.1" - }, - "engines": { - "node": "*" - }, - "homepage": "https://github.com/chaijs/assertion-error#readme", - "keywords": [ - "test", - "assertion", - "assertion-error" - ], - "license": "MIT", - "main": "./index", - "name": "assertion-error", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/chaijs/assertion-error.git" - }, - "scripts": { - "test": "make test" - }, - "types": "./index.d.ts", - "version": "1.1.0" -} diff --git a/node_modules/chai/CODEOWNERS b/node_modules/chai/CODEOWNERS deleted file mode 100644 index ea74b66..0000000 --- a/node_modules/chai/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @chaijs/chai diff --git a/node_modules/chai/CODE_OF_CONDUCT.md b/node_modules/chai/CODE_OF_CONDUCT.md deleted file mode 100644 index 074addc..0000000 --- a/node_modules/chai/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,58 +0,0 @@ -# Contributor Code of Conduct - -> Read in: [Español](http://contributor-covenant.org/version/1/3/0/es/) | -[Français](http://contributor-covenant.org/version/1/3/0/fr/) | -[Italiano](http://contributor-covenant.org/version/1/3/0/it/) | -[Magyar](http://contributor-covenant.org/version/1/3/0/hu/) | -[Polskie](http://contributor-covenant.org/version/1/3/0/pl/) | -[Português](http://contributor-covenant.org/version/1/3/0/pt/) | -[Português do Brasil](http://contributor-covenant.org/version/1/3/0/pt_br/) - -As contributors and maintainers of this project, and in the interest of -fostering an open and welcoming community, we pledge to respect all people who -contribute through reporting issues, posting feature requests, updating -documentation, submitting pull requests or patches, and other activities. - -We are committed to making participation in this project a harassment-free -experience for everyone, regardless of level of experience, gender, gender -identity and expression, sexual orientation, disability, personal appearance, -body size, race, ethnicity, age, religion, or nationality. - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery -* Personal attacks -* Trolling or insulting/derogatory comments -* Public or private harassment -* Publishing other's private information, such as physical or electronic - addresses, without explicit permission -* Other unethical or unprofessional conduct - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -By adopting this Code of Conduct, project maintainers commit themselves to -fairly and consistently applying these principles to every aspect of managing -this project. Project maintainers who do not follow or enforce the Code of -Conduct may be permanently removed from the project team. - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting a project maintainer at chaijs@keithcirkel.co.uk. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. Maintainers are -obligated to maintain confidentiality with regard to the reporter of an -incident. - - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 1.3.0, available at -[http://contributor-covenant.org/version/1/3/0/][version] - -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/3/0/ diff --git a/node_modules/chai/CONTRIBUTING.md b/node_modules/chai/CONTRIBUTING.md deleted file mode 100644 index 88072d4..0000000 --- a/node_modules/chai/CONTRIBUTING.md +++ /dev/null @@ -1,218 +0,0 @@ -# Chai Contribution Guidelines - -We like to encourage you to contribute to the Chai.js repository. This should be as easy as possible for you but there are a few things to consider when contributing. The following guidelines for contribution should be followed if you want to submit a pull request or open an issue. - -Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue or assessing patches and features. - -#### Table of Contents - -- [TLDR;](#tldr) -- [Contributing](#contributing) - - [Bug Reports](#bugs) - - [Feature Requests](#features) - - [Pull Requests](#pull-requests) -- [Releasing](#releasing) -- [Support](#support) - - [Resources](#resources) - - [Core Contributors](#contributors) - - -## TLDR; - -- Creating an Issue or Pull Request requires a [GitHub](http://github.com) account. -- Issue reports should be **clear**, **concise** and **reproducible**. Check to see if your issue has already been resolved in the [master]() branch or already reported in Chai's [GitHub Issue Tracker](https://github.com/chaijs/chai/issues). -- Pull Requests must adhere to strict [coding style guidelines](https://github.com/chaijs/chai/wiki/Chai-Coding-Style-Guide). -- In general, avoid submitting PRs for new Assertions without asking core contributors first. More than likely it would be better implemented as a plugin. -- Additional support is available via the [Google Group](http://groups.google.com/group/chaijs) or on irc.freenode.net#chaijs. -- **IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the same license as that used by the project. - - - - -## Contributing - -The issue tracker is the preferred channel for [bug reports](#bugs), -[feature requests](#features) and [submitting pull -requests](#pull-requests), but please respect the following restrictions: - -* Please **do not** use the issue tracker for personal support requests (use - [Google Group](https://groups.google.com/forum/#!forum/chaijs) or IRC). -* Please **do not** derail or troll issues. Keep the discussion on topic and - respect the opinions of others - - -### Bug Reports - -A bug is a **demonstrable problem** that is caused by the code in the repository. - -Guidelines for bug reports: - -1. **Use the GitHub issue search** — check if the issue has already been reported. -2. **Check if the issue has been fixed** — try to reproduce it using the latest `master` or development branch in the repository. -3. **Isolate the problem** — create a test case to demonstrate your issue. Provide either a repo, gist, or code sample to demonstrate you problem. - -A good bug report shouldn't leave others needing to chase you up for more information. Please try to be as detailed as possible in your report. What is your environment? What steps will reproduce the issue? What browser(s) and/or Node.js versions experience the problem? What would you expect to be the outcome? All these details will help people to fix any potential bugs. - -Example: - -> Short and descriptive example bug report title -> -> A summary of the issue and the browser/OS environment in which it occurs. If suitable, include the steps required to reproduce the bug. -> -> 1. This is the first step -> 2. This is the second step -> 3. Further steps, etc. -> -> `` - a link to the reduced test case OR -> ```js -> expect(a).to.equal('a'); -> // code sample -> ``` -> -> Any other information you want to share that is relevant to the issue being reported. This might include the lines of code that you have identified as causing the bug, and potential solutions (and your opinions on their merits). - - -### Feature Requests - -Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to *you* to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible. - -Furthermore, since Chai.js has a [robust plugin API](http://chaijs.com/guide/plugins/), we encourage you to publish **new Assertions** as plugins. If your feature is an enhancement to an **existing Assertion**, please propose your changes as an issue prior to opening a pull request. If the core Chai.js contributors feel your plugin would be better suited as a core assertion, they will invite you to open a PR in [chaijs/chai](https://github.com/chaijs/chai). - - -### Pull Requests - -- PRs for new core-assertions are advised against. -- PRs for core-assertion bug fixes are always welcome. -- PRs for enhancing the interfaces are always welcome. -- PRs that increase test coverage are always welcome. -- PRs are scrutinized for coding-style. - -Good pull requests - patches, improvements, new features - are a fantastic help. They should remain focused in scope and avoid containing unrelated commits. - -**Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project. - -Please adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.) and any other requirements (such as test coverage). Please review the [Chai.js Coding Style Guide](https://github.com/chaijs/chai/wiki/Chai-Coding-Style-Guide). - -Follow this process if you'd like your work considered for inclusion in the project: - -1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes: - -```bash -# Clone your fork of the repo into the current directory -git clone https://github.com// -# Navigate to the newly cloned directory -cd -# Assign the original repo to a remote called "upstream" -git remote add upstream https://github.com// -``` - -2. If you cloned a while ago, get the latest changes from upstream: - -```bash -git checkout -git pull upstream -``` - -3. Create a new topic branch (off the main project development branch) to contain your feature, change, or fix: - -```bash -git checkout -b -``` - -4. Commit your changes in logical chunks. Use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase) feature to tidy up your commits before making them public. - -5. Run you code to make sure it works. If you're still having problems please try to run `make clean` and then test your code again. - -```bash -npm test -# when finished running tests... -git checkout chai.js -``` - -6. Locally merge (or rebase) the upstream development branch into your topic branch: - -```bash -git pull [--rebase] upstream -``` - -7. Push your topic branch up to your fork: - -```bash -git push origin -``` - -8. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description. - -**IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the same license as that used by the project. - - -## Releasing - -Releases can be **prepared** by anyone with access to the code. - -Simply run `make release-major`, `make release-minor`, or `make-release-patch` -and it will automatically do the following: - - - Build chai.js - - Bump the version numbers across the project - - Make a commit within git - -All you need to do is push the commit up and make a pull request, one of the core contributors will merge it and publish a release. - -### Publishing a Release - -Anyone who is a core contributor (see the [Core Contributors Heading in the Readme](https://github.com/chaijs/chai#core-contributors)) can publish a release: - -1. Go to the [Releases page on Github](https://github.com/chaijs/chai/releases) -2. Hit "Draft a new release" (if you can't see this, you're not a core contributor!) -3. Write human-friendly Release Notes based on changelog. - - The release title is "x.x.x / YYYY-MM-DD" (where x.x.x is the version number) - - If breaking changes, write migration tutorial(s) and reasoning. - - Callouts for community contributions (PRs) with links to PR and contributing user. - - Callouts for other fixes made by core contributors with links to issue. -4. Hit "Save Draft" and get other core contributors to check your work, or alternatively hit "Publish release" -5. That's it! - - -## Support - - -### Resources - -For most of the documentation you are going to want to visit [ChaiJS.com](http://chaijs.com). - -- [Getting Started Guide](http://chaijs.com/guide/) -- [API Reference](http://chaijs.com/api/) -- [Plugins](http://chaijs.com/plugins/) - -Alternatively, the [wiki](https://github.com/chaijs/chai/wiki) might be what you are looking for. - -- [Chai Coding Style Guide](https://github.com/chaijs/chai/wiki/Chai-Coding-Style-Guide) -- [Third-party Resources](https://github.com/chaijs/chai/wiki/Third-Party-Resources) - -Or finally, you may find a core-contributor or like-minded developer in any of our support channels. - -- IRC: irc.freenode.org #chaijs -- [Mailing List / Google Group](https://groups.google.com/forum/#!forum/chaijs) - - -### Core Contributors - -Feel free to reach out to any of the core-contributors with you questions or concerns. We will do our best to respond in a timely manner. - -- Jake Luer - - GH: [@logicalparadox](https://github.com/logicalparadox) - - TW: [@jakeluer](http://twitter.com/jakeluer) - - IRC: logicalparadox -- Veselin Todorov - - GH: [@vesln](https://github.com/vesln/) - - TW: [@vesln](http://twitter.com/vesln) - - IRC: vesln -- Keith Cirkel - - GH: [@keithamus](https://github.com/keithamus) - - TW: [@keithamus](http://twitter.com/keithamus) - - IRC: keithamus -- Lucas Fernandes da Costa - - GH: [@lucasfcosta](https://github.com/lucasfcosta) - - TW: [@lfernandescosta](https://twitter.com/lfernandescosta) - - IRC: lucasfcosta diff --git a/node_modules/chai/History.md b/node_modules/chai/History.md deleted file mode 100644 index ae4d323..0000000 --- a/node_modules/chai/History.md +++ /dev/null @@ -1,1059 +0,0 @@ -### Note - -As of 3.0.0, the History.md file has been deprecated. [Please refer to the full -commit logs available on GitHub](https://github.com/chaijs/chai/commits/master). - ---- - -2.3.0 / 2015-04-26 -================== - - * Merge pull request #423 from ehntoo/patch-1 - * Merge pull request #422 from ljharb/fix_descriptor_tests - * Fix a small bug in the .null assertion docs - * Use a regex to account for property ordering issues across engines. - * Add `make test-firefox` - * Merge pull request #417 from astorije/astorije/minimalist-typo - * Remove trailing whitespaces - * Fix super minor typo in an example - * Merge pull request #408 from ljharb/enumerableProperty - * Add `ownPropertyDescriptor` assertion. - -2.2.0 / 2015-03-26 -================== - - * Merge pull request #405 from chaijs/deep-escape-doc-tweaks - * Tweak documentation on `.deep` flag. - * Merge pull request #402 from umireon/escaping-dot-should-be-taken - * Documentation of escaping in `.deep` flag. - * take regular expression apart - * Feature: backslash-escaping in `.deep.property` - * Escaping dot should be taken in deep property - -2.1.2 / 2015-03-15 -================== - - * Merge pull request #396 from chaijs/add-keith-cirkel-contributing-md - * Add Keith Cirkel to CONTRIBUTING.md - * Merge pull request #395 from cjqed/386-assert-operator-no-eval - * No longer using eval on assert operator #386 - * Merge pull request #389 from chaijs/update-git-summary - * Update `git summary` in README - -2.1.1 / 2015-03-04 -================== - - * Merge pull request #385 from eldritch-fossicker/master - * updates to reflect code style preference from @keithamus - * fix indexing into array with deep propery - * Merge pull request #382 from astorije/patch-2 - * Merge pull request #383 from gurdiga/config-doc-wording-improvement - * config.truncateThreshold docs: simpler wording - * Add missing docstring for showDiff argument of assert - * Merge pull request #381 from astorije/patch-1 - * Add a minor precision that empty asserts on strings too. - * Merge pull request #379 from dcneiner/should-primitive-fix - * Primitives now use valueOf in shouldGetter - -2.1.0 / 2015-02-23 -================== - - * Merge pull request #374 from jmm/v2.0.1 - * Increment version to 2.0.1. - * Merge pull request #365 from chaijs/fix-travis - * Fix travis.yml deploy - * Merge pull request #356 from Soviut/master - * documented fail methods for expect and should interfaces - * fail method added directly to expect - -2.0.0 / 2015-02-09 -================== - - * Merge pull request #361 from gregglind/b265-keys-object - * fix #359. Add `.keys(object)` - * Merge pull request #359 from gregglind/b359-unexpected-keys-sort - * Fix #359 keys() sorts input unexpectedly - * contrib: publish release strategy and travis npm creds #337 - * Merge pull request #357 from danilovaz/master - * Update copyright date - * Merge pull request #349 from toastynerd/add-which-chain-method - * add the which chain method as per issue #347 - * Merge pull request #333 from cmpolis/change-assertions - * more `by` cleanup - * cleaned out `.by` for #333 - * Merge pull request #335 from DingoEatingFuzz/expose-util - * Expose chai util through the chai object - * cleanup (per notes on pr #333) - * updated `change` to work w/ non-number values + tests - * Merge pull request #334 from hurrymaplelad/patch-1 - * Typo, the flag is called 'contains' with an 's' - * updated assertion interface with `change` (#330) - * added `change`,`increase`,`decrease` assertions (#330) - * assert tests for `change`,`increase`,`decrease` - * expect/should tests for `change`,`increase`,`decrease` - * Merge pull request #328 from lo1tuma/issue-327 - * Add includes and contains alias (fixes #327) - * Merge pull request #325 from chasenlehara/overwriteChainableMethodDocs - * Fix docs for overwriteChainableMethod parameters - * Merge pull request #317 from jasonkarns/patch-2 - * Merge pull request #318 from jasonkarns/patch-3 - * Merge pull request #316 from jasonkarns/patch-1 - * typos in docs - * minor docs typo - * update docs: getAllFlags -> transferFlags - * Merge pull request #313 from cjqed/254-expect-any-all - * Added the all and any flags for keys assertion, with all being the default behavior - * Merge pull request #312 from cjqed/291-assert-same-deep-members - * Changed public comment of sameDeepMemebers to be more clear - * Fixes issue #291, adds assert.sameDeepMembers - * Merge pull request #311 from cjqed/305-above-below-on-assert - * Merge pull request #308 from prodatakey/hasproperty - * Issue #305 fixed, added assert.isAbove and assert.isBelow - * Fix typo - * More unit tests for new utility functions - * Refactor common functionality, document, test - * Refactor if statement out - * Small unit test fix - * Handle array indexing terminating paths - * Merge pull request #309 from ericdouglas/iterableEqual-couting-once - * couting variables just once - * Fix properties with `undefined` value pass property assertion - * Merge pull request #306 from chaijs/revert-297-noopchainfunc - * Revert "Allows writing lint-friendly tests" - -1.10.0 / 2014-11-10 -================== - - * Merge pull request #297 from prodatakey/noopchainfunc - * Merge pull request #300 from julienw/299-fix-getMessage-test - * Fix #299: the test is defining global variables - * Add a couple more unit tests - * Add unit tests for chained terminating property asserts - * Revise documentation wording - * Add docs for function style NOOP asserts - * Make the NOOP function a shared constant - * Merge pull request #298 from dasilvacontin/negativeZeroLogging - * why not more assertions - * added test for inspecting `-0` - * a more readable/simple condition statement, as pointed out by @keithamus - * added check for logging negative zero - * Change test to not trigger argument bug - * Allows writing lint-friendly tests - * readme: update contributors for 1.9.2 - -1.9.2 / 2014-09-29 -================== - - * Merge pull request #268 from charlierudolph/cr-lazyMessages - * Merge pull request #269 from charlierudolph/cr-codeCleanup - * Merge pull request #277 from charlierudolph/fix-doc - * Merge pull request #279 from mohayonao/fix-closeTo - * Merge pull request #292 from boneskull/mocha - * resolves #255: upgrade mocha - * Merge pull request #289 from charlierudolph/cr-dryUpCode - * Dry up code - * Merge pull request #275 from DrRataplan/master - * assert: .closeTo() verify value's type before assertion - * Rewrite pretty-printing HTML elements to prevent throwing internal errors Fixes errors occuring when using a non-native DOM implementation - * Fix assert documentation - * Remove unused argument - * Allow messages to be functions - * Merge pull request #267 from shinnn/master - * Use SVG badge - * Merge pull request #264 from cjthompson/keys_diff - * Show diff for keys assertion - -1.9.1 / 2014-03-19 -================== - - * deps update - * util: [getActual] select actual logic now allows undefined for actual. Closes #183 - * docs: [config] make public, express param type - * Merge pull request #251 from romario333/threshold3 - * Fix issue #166 - configurable threshold in objDisplay. - * Move configuration options to config.js. - * Merge pull request #233 from Empeeric/master - * Merge pull request #244 from leider/fix_for_contains - * Merge pull request #247 from didoarellano/typo-fixes - * Fix typos - * Merge pull request #245 from lfac-pt/patch-1 - * Update `exports.version` to 1.9.0 - * aborting loop on finding - * declaring variable only once - * additional test finds incomplete implementation - * simplified code - * fixing #239 (without changing chai.js) - * ssfi as it should be - * Merge pull request #228 from duncanbeevers/deep_members - * Deep equality check for collection membership - -1.9.0 / 2014-01-29 -================== - - * docs: add contributing.md #238 - * assert: .throws() returns thrown error. Closes #185 - * Merge pull request #232 from laconbass/assert-throws - * assert: .fail() parameter mismatch. Closes #206 - * Merge branch 'karma-fixes' - * Add karma phantomjs launcher - * Use latest karma and sauce launcher - * Karma tweaks - * Merge pull request #230 from jkroso/include - * Merge pull request #237 from chaijs/coverage - * Add coverage to npmignore - * Remove lib-cov from test-travisci dependents - * Remove the not longer needed lcov reporter - * Test coverage with istanbul - * Remove jscoverage - * Remove coveralls - * Merge pull request #226 from duncanbeevers/add_has - * Avoid error instantiation if possible on assert.throws - * Merge pull request #231 from duncanbeevers/update_copyright_year - * Update Copyright notices to 2014 - * handle negation correctly - * add failing test case - * support `{a:1,b:2}.should.include({a:1})` - * Merge pull request #224 from vbardales/master - * Add `has` to language chains - * Merge pull request #219 from demands/overwrite_chainable - * return error on throw method to chain on error properties, possibly different from message - * util: store chainable behavior in a __methods object on ctx - * util: code style fix - * util: add overwriteChainableMethod utility (for #215) - * Merge pull request #217 from demands/test_cleanup - * test: make it possible to run utilities tests with --watch - * makefile: change location of karma-runner bin script - * Merge pull request #202 from andreineculau/patch-2 - * test: add tests for throwing custom errors - * Merge pull request #201 from andreineculau/patch-1 - * test: updated for the new assertion errors - * core: improve message for assertion errors (throw assertion) - -1.8.1 / 2013-10-10 -================== - - * pkg: update deep-eql version - -1.8.0 / 2013-09-18 -================== - - * test: [sauce] add a few more browsers - * Merge branch 'refactor/deep-equal' - * util: remove embedded deep equal utility - * util: replace embedded deep equal with external module - * Merge branch 'feature/karma' - * docs: add sauce badge to readme [ci skip] - * test: [sauce] use karma@canary to prevent timeouts - * travis: only run on node 0.10 - * test: [karma] use karma phantomjs runner - * Merge pull request #181 from tricknotes/fix-highlight - * Fix highlight for example code - -1.7.2 / 2013-06-27 -================== - - * coverage: add coveralls badge - * test: [coveralls] add coveralls api integration. testing travis-ci integration - * Merge branch 'master' of github.com:chaijs/chai - * Merge branch 'feature/bower' - * Merge pull request #180 from tricknotes/modify-method-title - * Merge pull request #179 from tricknotes/highlight-code-example - * Modify method title to include argument name - * Fix to highlight code example - * bower: granular ignores - -1.7.1 / 2013-06-24 -================== - - * Merge branch 'feature/bower'. #175 - * bower: add json file - * build: browser - -1.7.0 / 2013-06-17 -================== - - * error: remove internal assertion error constructor - * core: [assertion-error] replace internal assertion error with dep - * deps: add chaijs/assertion-error@1.0.0 - * docs: fix typo in source file. #174 - * Merge pull request #174 from piecioshka/master - * typo - * Merge branch 'master' of github.com:chaijs/chai - * pkg: lock mocha/mocha-phantomjs versions (for now) - * Merge pull request #173 from chaijs/inspect-fix - * Fix `utils.inspect` with custom object-returning inspect()s. - * Merge pull request #171 from Bartvds/master - * replaced tabs with 2 spaces - * added assert.notOk() - * Merge pull request #169 from katsgeorgeek/topics/master - * Fix comparison objects. - -1.6.1 / 2013-06-05 -================== - - * Merge pull request #168 from katsgeorgeek/topics/master - * Add test for different RegExp flags. - * Add test for regexp comparison. - * Downgrade mocha version for fix running Phantom tests. - * Fix comparison equality of two regexps. - * Merge pull request #161 from brandonpayton/master - * Fix documented name for assert interfaces isDefined method - -1.6.0 / 2013-04-29 -================== - - * build: browser - * assert: [(not)include] throw on incompatible haystack. Closes #142 - * assert: [notInclude] add assert.notInclude. Closes #158 - * browser build - * makefile: force browser build on browser-test - * makefile: use component for browser build - * core: [assertions] remove extraneous comments - * Merge branch 'master' of github.com:chaijs/chai - * test: [assert] deep equal ordering - * Merge pull request #153 from NickHeiner/array-assertions - * giving members a no-flag assertion - * Code review comments - changing syntax - * Code review comments - * Adding members and memberEquals assertions for checking for subsets and set equality. Implements chaijs/chai#148. - * Merge pull request #140 from RubenVerborgh/function-prototype - * Restore the `call` and `apply` methods of Function when adding a chainable method. - * readme: 2013 - * notes: migration notes for deep equal changes - * test: for ever err() there must be a passing version - -1.5.0 / 2013-02-03 -================== - - * docs: add Release Notes for non-gitlog summary of changes. - * lib: update copyright to 2013 - * Merge branch 'refactor/travis' - * makefile: remove test-component for full test run - * pkg: script test now runs make test so travis will test browser - * browser: build - * tests: refactor some tests to support new objDisplay output - * test: [bootstrap] normalize boostrap across all test scenarios - * assertions: refactor some assertions to use objDisplay instead of inspect - * util: [objDisplay] normalize output of functions - * makefile: refactor for full build scenarios - * component: fix build bug where missing util:type file - * assertions: [throw] code cleanup - * Merge branch 'refactor/typeDetection' - * browser: build - * makefile: chai.js is .PHONY so it builds every time - * test: [expect] add arguments type detection test - * core/assertions: [type] (a/an) refactor to use type detection utility - * util: add cross-browser type detection utility - * Merge branch 'feature/component' - * browser: build - * component: add component.json file - * makefile: refactor for fine grain control of testing scenarios - * test: add mochaPhantomJS support and component test file - * deps: add component and mocha-phantomjs for browser testing - * ignore: update ignore files for component support - * travis: run for all branches - * Merge branch 'feature/showDiff' - * test: [Assertion] configruable showDiff flag. Closes #132 - * lib: [Assertion] add configurable showDiff flag. #132 - * Merge branch 'feature/saucelabs' - * Merge branch 'master' into feature/saucelabs - * browser: build - * support: add mocha cloud runner, client, and html test page - * test: [saucelabs] add auth placeholder - * deps: add mocha-cloud - * Merge pull request #136 from whatthejeff/message_fix - * Merge pull request #138 from timnew/master - * Fix issue #137, test message existence by using message!=null rather than using message - * Fixed backwards negation messages. - * Merge pull request #133 from RubenVerborgh/throw - * Functions throwing strings can reliably be tested. - * Merge pull request #131 from RubenVerborgh/proto - * Cache whether __proto__ is supported. - * Use __proto__ if available. - * Determine the property names to exclude beforehand. - * Merge pull request #126 from RubenVerborgh/eqls - * Add alias eqls for eql. - * Use inherited enumerable properties in deep equality comparison. - * Show inherited properties when inspecting an object. - * Add new getProperties and getEnumerableProperties utils. - * showDiff: force true for equal and eql - -1.4.2 / 2012-12-21 -================== - - * browser build: (object diff support when used with mocha) #106 - * test: [display] array test for mocha object diff - * browser: no longer need different AssertionError constructor - -1.4.1 / 2012-12-21 -================== - - * showDiff: force diff for equal and eql. #106 - * test: [expect] type null. #122 - * Merge pull request #115 from eshao/fix-assert-Throw - * FIX: assert.Throw checks error type/message - * TST: assert.Throw should check error type/message - -1.4.0 / 2012-11-29 -================== - - * pre-release browser build - * clean up index.js to not check for cov, revert package.json to use index.js - * convert tests to use new bootstrap - * refactor testing bootstrap - * use spaces (not tabs). Clean up #114 - * Merge pull request #114 from trantorLiu/master - * Add most() (alias: lte) and least() (alias: gte) to the API with new chainers "at" and "of". - * Change `main` to ./lib/chai. Fixes #28. - * Merge pull request #104 from connec/deep_equals_circular_references_ - * Merge pull request #109 from nnarhinen/patch-1 - * Check for 'actual' type - * Added support for circular references when checking deep (in)equality. - -1.3.0 / 2012-10-01 -================== - - * browser build w/ folio >= 0.3.4. Closes #99 - * add back buffer test for deep equal - * do not write flags to assertion.prototype - * remove buffer test from expect - * browser build - * improve documentation of custom error messages - * Merge branch 'master' of git://github.com/Liffft/chai into Liffft-master - * browser build - * improved buffer deep equal checking - * mocha is npm test command - * Cleaning up the js style… - * expect tests now include message pass-through - * packaging up browser-side changes… - * Increasing Throws error message verbosity - * Should syntax: piping message through - * Make globalShould test work in browser too. - * Add a setter for `Object.prototype.should`. Closes #86. - -1.2.0 / 2012-08-07 -================== - - * Merge branch 'feature/errmsg' - * browser build - * comment updates for utilities - * tweak objDislay to only kick in if object inspection is too long - * Merge branch 'master' into feature/errmsg - * add display sample for error message refactor - * first draft of error message refactor. #93 - * add `closeTo` assertion to `assert` interface. Closes #89. - * update folio build for better require.js handling. Closes #85 - * Merge pull request #92 from paulmillr/topics/add-dom-checks - * Add check for DOM objects. - * browser build - * Merge branch 'master' of github.com:chaijs/chai - * bug - getActual not defaulting to assertion subject - * Merge pull request #88 from pwnall/master - * Don't inspect() assertion arguments if the assertion passes. - -1.1.1 / 2012-07-09 -================== - - * improve commonjs support on browser build - * Merge pull request #83 from tkazec/equals - * Document .equals - * Add .equals as an alias of .equal - * remove unused browser prefix/suffix - * Merge branch 'feature/folio-build' - * browser build - * using folio to compile - * clean up makefile - * early folio 0.3.x support - -1.1.0 / 2012-06-26 -================== - - * browser build - * Disable "Assertion.includeStack is false" test in IE. - * Use `utils.getName` for all function inspections. - * Merge pull request #80 from kilianc/closeTo - * fixes #79 - * browser build - * expand docs to indicate change of subject for chaining. Closes #78 - * add `that` chain noop - * Merge branch 'bug/74' - * comments on how to property use `length` as chain. Closes #74 - * tests for length as chainable property. #74 - * add support for `length` as chainable prop/method. - * Merge branch 'bug/77' - * tests for getPathValue when working with nested arrays. Closes #77 - * add getPathValue support for nested arrays - * browser build - * fix bug for missing browser utils - * compile tool aware of new folder layout - * Merge branch 'refactor/1dot1' - * move core assertions to own file and refactor all using utils - * rearrange folder structure - -1.0.4 / 2012-06-03 -================== - - * Merge pull request #68 from fizker/itself - * Added itself chain. - * simplify error inspections for cross browser compatibility - * fix safari `addChainableMethod` errors. Closes #69 - -1.0.3 / 2012-05-27 -================== - - * Point Travis badge to the right place. - * Make error message for eql/deep.equal more clear. - * Fix .not.deep.equal. - * contributors list - -1.0.2 / 2012-05-26 -================== - - * Merge pull request #67 from chaijs/chaining-and-flags - * Browser build. - * Use `addChainableMethod` to get away from `__proto__` manipulation. - * New `addChainableMethod` utility. - * Replace `getAllFlags` with `transferFlags` utility. - * browser build - * test - get all flags - * utility - get all flags - * Add .mailmap to .npmignore. - * Add a .mailmap file to fix my name in shortlogs. - -1.0.1 / 2012-05-18 -================== - - * browser build - * Fixing "an" vs. "a" grammar in type assertions. - * Uniformize `assert` interface inline docs. - * Don't use `instanceof` for `assert.isArray`. - * Add `deep` flag for equality and property value. - * Merge pull request #64 from chaijs/assertion-docs - * Uniformize assertion inline docs. - * Add npm-debug.log to .gitignore. - * no reserved words as actuals. #62 - -1.0.0 / 2012-05-15 -================== - - * readme cleanup - * browser build - * utility comments - * removed docs - * update to package.json - * docs build - * comments / docs updates - * plugins app cleanup - * Merge pull request #61 from joliss/doc - * Fix and improve documentation of assert.equal and friends - * browser build - * doc checkpoint - texture - * Update chai-jquery link - * Use defined return value of Assertion extension functions - * Update utility docs - -1.0.0-rc3 / 2012-05-09 -================== - - * Merge branch 'feature/rc3' - * docs update - * browser build - * assert test conformity for minor refactor api - * assert minor refactor - * update util tests for new add/overwrite prop/method format - * added chai.Assertion.add/overwrite prop/method for plugin toolbox - * add/overwrite prop/method don't make assumptions about context - * doc test suite - * docs don't need coverage - * refactor all simple chains into one forEach loop, for clean documentation - * updated npm ignore - * remove old docs - * docs checkpoint - guide styled - * Merge pull request #59 from joliss/doc - * Document how to run the test suite - * don't need to rebuild docs to view - * dep update - * docs checkpoint - api section - * comment updates for docs - * new doc site checkpoint - plugin directory! - * Merge pull request #57 from kossnocorp/patch-1 - * Fix typo: devDependancies → devDependencies - * Using message flag in `getMessage` util instead of old `msg` property. - * Adding self to package.json contributors. - * `getMessage` shouldn't choke on null/omitted messages. - * `return this` not necessary in example. - * `return this` not necessary in example. - * Sinon–Chai has a dash - * updated plugins list for docs - -1.0.0-rc2 / 2012-05-06 -================== - - * Merge branch 'feature/test-cov' - * browser build - * missing assert tests for ownProperty - * appropriate assert equivalent for expect.to.have.property(key, val) - * reset AssertionError to include full stack - * test for plugin utilities - * overwrite Property and Method now ensure chain - * version notes in readme - -1.0.0-rc1 / 2012-05-04 -================== - - * browser build (rc1) - * assert match/notMatch tests - * assert interface - notMatch, ownProperty, notOwnProperty, ownPropertyVal, ownPropertyNotVal - * cleaner should interface export. - * added chai.Assertion.prototype._obj (getter) for quick access to object flag - * moved almostEqual / almostDeepEqual to stats plugin - * added mocha.opts - * Add test for `utils.addMethod` - * Fix a typo - * Add test for `utils.overwriteMethod` - * Fix a typo - * Browser build - * Add undefined assertion - * Add null assertion - * Fix an issue with `mocha --watch` - * travis no longer tests on node 0.4.x - * removing unnecissary carbon dep - * Merge branch 'feature/plugins-app' - * docs build - * templates for docs express app for plugin directory - * express app for plugin and static serving - * added web server deps - * Merge pull request #54 from josher19/master - * Remove old test.assert code - * Use util.inspect instead of inspect for deepAlmostEqual and almostEqual - * browser build - * Added almostEqual and deepAlmostEqual to assert test suite. - * bug - context determinants for utils - * dec=0 means rounding, so assert.deepAlmostEqual({pi: 3.1416}, {pi: 3}, 0) is true - * wrong travis link - * readme updates for version information - * travis tests 0.5.x branch as well - * [bug] util `addProperty` not correctly exporting - * read me version notes - * browser build 1.0.0alpha1 - * not using reserved words in internal assertions. #52 - * version tick - * clean up redundant tests - * Merge branch 'refs/heads/0.6.x' - * update version tag in package 1.0.0alpha1 - * browser build - * added utility tests to browser specs - * beginning utility testing - * updated utility comments - * utility - overwriteMethod - * utility - overwriteProperty - * utility - addMethod - * utility - addProperty - * missing ; - * contributors list update - * Merge branch 'refs/heads/0.6.x-docs' into 0.6.x - * Added guide link to docs. WIP - * Include/contain are now both properties and methods - * Add an alias annotation - * Remove usless function wrapper - * Fix a typo - * A/an are now both properties and methods - * [docs] new site homepage layout / color checkpoint - * Ignore IE-specific error properties. - * Fixing order of error message test. - * New cross-browser `getName` util. - * Fixing up `AssertionError` inheritance. - * backup docs - * Add doctypes - * [bug] was still using `constructor.name` in `throw` assertion - * [bug] flag Object.create(null) instead of new Object - * [test] browser build - * [refactor] all usage of Assertion.prototype.assert now uses template tags and flags - * [refactor] remove Assertion.prototype.inspect for testable object inspection - * [refactor] object to test is now stored in flag, with ssfi and custom message - * [bug] flag util - don't return on `set` - * [docs] comments for getMessage utility - * [feature] getMessage - * [feature] testing utilities - * [refactor] flag doesn't require `call` - * Make order of source files well-defined - * Added support for throw(errorInstance). - * Use a foolproof method of grabbing an error's name. - * Removed constructor.name check from throw. - * disabled stackTrack configuration tests until api is stable again - * first version of line displayed error for node js (unstable) - * refactor core Assertion to use flag utility for negation - * added flag utility - * tests for assert interface negatives. Closed #42 - * added assertion negatives that were missing. #42 - * Support for expected and actual parameters in assert-style error object - * chai as promised - readme - * Added assert.fail. Closes #40 - * better error message for assert.operator. Closes #39 - * [refactor] Assertion#property to use getPathValue property - * added getPathValue utility helper - * removed todo about browser build - * version notes - * version bumb 0.6.0 - * browser build - * [refactor] browser compile function to replace with `require('./error')' with 'require('./browser/error')' - * [feature] browser uses different error.js - * [refactor] error without chai.fail - * Assertion & interfaces use new utils helper export - * [refactor] primary export for new plugin util usage - * added util index.js helper - * added 2012 to copyright headers - * Added DeepEqual assertions - -0.5.3 / 2012-04-21 -================== - - * Merge branch 'refs/heads/jgonera-oldbrowsers' - * browser build - * fixed reserved names for old browsers in interface/assert - * fixed reserved names for old browsers in interface/should - * fixed: chai.js no longer contains fail() - * fixed reserved names for old browsers in Assertion - * Merge pull request #49 from joliss/build-order - * Make order of source files well-defined - * Merge pull request #43 from zzen/patch-1 - * Support for expected and actual parameters in assert-style error object - * chai as promised - readme - -0.5.2 / 2012-03-21 -================== - - * browser build - * Merge branch 'feature/assert-fail' - * Added assert.fail. Closes #40 - * Merge branch 'bug/operator-msg' - * better error message for assert.operator. Closes #39 - * version notes - -0.5.1 / 2012-03-14 -================== - - * chai.fail no longer exists - * Merge branch 'feature/assertdefined' - * Added asset#isDefined. Closes #37. - * dev docs update for Assertion#assert - -0.5.0 / 2012-03-07 -================== - - * [bug] on inspect of reg on n 0.4.12 - * Merge branch 'bug/33-throws' - * Merge pull request #35 from logicalparadox/empty-object - * browser build - * updated #throw docs - * Assertion#throw `should` tests updated - * Assertion#throw `expect` tests - * Should interface supports multiple throw parameters - * Update Assertion#throw to support strings and type checks. - * Add more tests for `empty` in `should`. - * Add more tests for `empty` in `expect`. - * Merge branch 'master' into empty-object - * don't switch act/exp - * Merge pull request #34 from logicalparadox/assert-operator - * Update the compiled verison. - * Add `assert.operator`. - * Notes on messages. #22 - * browser build - * have been test - * below tests - * Merge branch 'feature/actexp' - * browser build - * remove unnecessary fail export - * full support for actual/expected where relevant - * Assertion.assert support expected value - * clean up error - * Update the compiled version. - * Add object & sane arguments support to `Assertion#empty`. - -0.4.2 / 2012-02-28 -================== - - * fix for `process` not available in browser when used via browserify. Closes #28 - * Merge pull request #31 from joliss/doc - * Document that "should" works in browsers other than IE - * Merge pull request #30 from logicalparadox/assert-tests - * Update the browser version of chai. - * Update `assert.doesNotThrow` test in order to check the use case when type is a string. - * Add test for `assert.ifError`. - * Falsey -> falsy. - * Full coverage for `assert.throws` and `assert.doesNotThrow`. - * Add test for `assert.doesNotThrow`. - * Add test for `assert.throws`. - * Add test for `assert.length`. - * Add test for `assert.include`. - * Add test for `assert.isBoolean`. - * Fix the implementation of `assert.isNumber`. - * Add test for `assert.isNumber`. - * Add test for `assert.isString`. - * Add test for `assert.isArray`. - * Add test for `assert.isUndefined`. - * Add test for `assert.isNotNull`. - * Fix `assert.isNotNull` implementation. - * Fix `assert.isNull` implementation. - * Add test for `assert.isNull`. - * Add test for `assert.notDeepEqual`. - * Add test for `assert.deepEqual`. - * Add test for `assert.notStrictEqual`. - * Add test for `assert.strictEqual`. - * Add test for `assert.notEqual`. - -0.4.1 / 2012-02-26 -================== - - * Merge pull request #27 from logicalparadox/type-fix - * Update the browser version. - * Add should tests for type checks. - * Add function type check test. - * Add more type checks tests. - * Add test for `new Number` type check. - * Fix type of actual checks. - -0.4.0 / 2012-02-25 -================== - - * docs and readme for upcoming 0.4.0 - * docs generated - * putting coverage and tests for docs in docs/out/support - * make docs - * makefile copy necessary resources for tests in docs - * rename configuration test - * Merge pull request #21 from logicalparadox/close-to - * Update the browser version. - * Update `closeTo()` docs. - * Add `Assertion.closeTo()` method. - * Add `.closeTo()` should test. - * Add `.closeTo()` expect test. - * Merge pull request #20 from logicalparadox/satisfy - * Update the browser version. - * `..` -> `()` in `.satisfy()` should test. - * Update example for `.satisfy()`. - * Update the compiled browser version. - * Add `Assertion.satisfy()` method. - * Add `.satisfy()` should test. - * Add `.satisfy()` expect test. - * Merge pull request #19 from logicalparadox/respond-to - * Update the compiled browser version. - * Add `respondTo` Assertion. - * Add `respondTo` should test. - * Add `respondTo` expect test. - * Merge branch 'feature/coverage' - * mocha coverage support - * doc contributors - * README contributors - -0.3.4 / 2012-02-23 -================== - - * inline comment typos for #15 - * Merge branch 'refs/heads/jeffbski-configErrorStackCompat' - * includeStack documentation for all interfaces - * suite name more generic - * Update test to be compatible with browsers that do not support err.stack - * udpated compiled chai.js and added to browser tests - * Allow inclusion of stack trace for Assert error messages to be configurable - * docs sharing buttons - * sinon-chai link - * doc updates - * read me updates include plugins - -0.3.3 / 2012-02-12 -================== - - * Merge pull request #14 from jfirebaugh/configurable_properties - * Make Assertion.prototype properties configurable - -0.3.2 / 2012-02-10 -================== - - * codex version - * docs - * docs cleanup - -0.3.1 / 2012-02-07 -================== - - * node 0.4.x compat - -0.3.0 / 2012-02-07 -================== - - * Merge branch 'feature/03x' - * browser build - * remove html/json/headers testign - * regex error.message testing - * tests for using plugins - * Merge pull request #11 from domenic/master - * Make `chai.use` a no-op if the function has already been used. - -0.2.4 / 2012-02-02 -================== - - * added in past tense switch for `been` - -0.2.3 / 2012-02-01 -================== - - * try that again - -0.2.2 / 2012-02-01 -================== - - * added `been` (past of `be`) alias - -0.2.1 / 2012-01-29 -================== - - * added Throw, with a capital T, as an alias to `throw` (#7) - -0.2.0 / 2012-01-26 -================== - - * update gitignore for vim *.swp - * Merge branch 'feature/plugins' - * browser build - * interfaces now work with use - * simple .use function. See #9. - * readme notice on browser compat - -0.1.7 / 2012-01-25 -================== - - * added assert tests to browser test runner - * browser update - * `should` interface patch for primitives support in FF - * fix isObject() Thanks @milewise - * travis only on branch `master` - * add instanceof alias `instanceOf`. #6 - * some tests for assert module - -0.1.6 / 2012-01-02 -================== - - * commenting for assert interface - * updated codex dep - -0.1.5 / 2012-01-02 -================== - - * browser tests pass - * type in should.not.equal - * test for should (not) exist - * added should.exist and should.not.exist - * browser uses tdd - * convert tests to tdd - -0.1.4 / 2011-12-26 -================== - - * browser lib update for new assert interface compatiblitiy - * inspect typos - * added strict equal + negatives and ifError - * interface assert had doesNotThrow - * added should tests to browser - * new expect empty tests - * should test browser compat - * Fix typo for instanceof docs. Closes #3 [ci skip] - -0.1.3 / 2011-12-18 -================== - - * much cleaner reporting string on error. - -0.1.2 / 2011-12-18 -================== - - * [docs] for upcoming 0.1.2 - * browser version built with pre/suffix … all tests passing - * make / compile now use prefix/suffix correctly - * code clean - * prefix/suffix to wrap browser output to prevent conflicts with other `require` methods. - * Merge branch 'feature/should4xcompatibility' - * compile for browser tests.. all pass - * added header/status/html/json - * throw tests - * should.throw & should.not.throw shortcuts - * improved `throw` type detection and messaging - * contain is now `include` … keys modifier is now `contain` - * removed object() test - * removed #respondTo - * Merge branch 'bug/2' - * replaced __defineGetter__ with defineProperty for all uses - * [docs] change mp tracking code - * docs site updated with assert (TDD) interface - * updated doc comments for assert interface - -0.1.1 / 2011-12-16 -================== - - * docs ready for upcoming 0.1.1 - * readme image fixed [ci skip] - * more readme tweaks [ci skip] - * réadmet image fixed [ci skip] - * documentation - * codex locked in version 0.0.5 - * more comments to assertions for docs - * assertions fully commented, browser library updated - * adding codex as doc dependancy - * prepping for docs - * assertion component completely commented for documentation - * added exist test - * var expect outside of browser if check - * added keywords to package.json - -0.1.0 / 2011-12-15 -================== - - * failing on purpose successful .. back to normal - * testing travis failure - * assert#arguments getter - * readme typo - * updated README - * added travis and npmignore - * copyright notices … think i got them all - * moved expect interface to own file for consistency - * assert ui deepEqual - * browser tests expect (all working) - * browser version built - * chai.fail (should ui) - * expect tests browser compatible - * tests for should and expect (all pass) - * moved fail to primary export - * should compatibility testing - * within, greaterThan, object, keys, - * Aliases - * Assertion#property now correctly works with negate and undefined values - * error message language matches should - * Assertion#respondTo - * Assertion now uses inspect util - * git ignore node modules - * should is exported - * AssertionError __proto__ from Error.prototype - * add should interface for should.js compatibility - * moved eql to until folder and added inspect from (joyent/node) - * added mocha for testing - * browser build for current api - * multiple .property assertions - * added deep equal from node - -0.0.2 / 2011-12-07 -================== - - * cleaner output on error - * improved exists detection - * package remnant artifact - * empty deep equal - * test browser build - * assertion cleanup - * client compile script - * makefile - * most of the basic assertions - * allow no parameters to assertion error - * name change - * assertion error instance - * main exports: assert() & expect() - * initialize diff --git a/node_modules/chai/LICENSE b/node_modules/chai/LICENSE deleted file mode 100644 index eedbe23..0000000 --- a/node_modules/chai/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2017 Chai.js Assertion Library - -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. diff --git a/node_modules/chai/README.md b/node_modules/chai/README.md deleted file mode 100644 index 78e4d2d..0000000 --- a/node_modules/chai/README.md +++ /dev/null @@ -1,212 +0,0 @@ -

- - ChaiJS - -
- chai -

- -

- Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework. -

- -

- - license:mit - - - tag:? - - - node:? - -
- - Selenium Test Status - -
- - downloads:? - - - build:? - - - coverage:? - - - devDependencies:? - -
- - Join the Slack chat - - - Join the Gitter chat - - - OpenCollective Backers - -

- -For more information or to download plugins, view the [documentation](http://chaijs.com). - -## What is Chai? - -Chai is an _assertion library_, similar to Node's built-in `assert`. It makes testing much easier by giving you lots of assertions you can run against your code. - -## Installation - -### Node.js - -`chai` is available on [npm](http://npmjs.org). To install it, type: - - $ npm install --save-dev chai - -### Browsers - -You can also use it within the browser; install via npm and use the `chai.js` file found within the download. For example: - -```html - -``` - -## Usage - -Import the library in your code, and then pick one of the styles you'd like to use - either `assert`, `expect` or `should`: - -```js -var chai = require('chai'); -var assert = chai.assert; // Using Assert style -var expect = chai.expect; // Using Expect style -var should = chai.should(); // Using Should style -``` - -### Pre-Native Modules Usage (_registers the chai testing style globally_) - -```js -require('chai/register-assert'); // Using Assert style -require('chai/register-expect'); // Using Expect style -require('chai/register-should'); // Using Should style -``` - -### Pre-Native Modules Usage (_as local variables_) - -```js -const { assert } = require('chai'); // Using Assert style -const { expect } = require('chai'); // Using Expect style -const { should } = require('chai'); // Using Should style -should(); // Modifies `Object.prototype` - -const { expect, use } = require('chai'); // Creates local variables `expect` and `use`; useful for plugin use -``` - -### Native Modules Usage (_registers the chai testing style globally_) - -```js -import 'chai/register-assert'; // Using Assert style -import 'chai/register-expect'; // Using Expect style -import 'chai/register-should'; // Using Should style -``` - -### Native Modules Usage (_local import only_) - -```js -import { assert } from 'chai'; // Using Assert style -import { expect } from 'chai'; // Using Expect style -import { should } from 'chai'; // Using Should style -should(); // Modifies `Object.prototype` -``` - -### Usage with Mocha - -```bash -mocha spec.js -r chai/register-assert # Using Assert style -mocha spec.js -r chai/register-expect # Using Expect style -mocha spec.js -r chai/register-should # Using Should style -``` - -[Read more about these styles in our docs](http://chaijs.com/guide/styles/). - -## Plugins - -Chai offers a robust Plugin architecture for extending Chai's assertions and interfaces. - -- Need a plugin? View the [official plugin list](http://chaijs.com/plugins). -- Want to build a plugin? Read the [plugin api documentation](http://chaijs.com/guide/plugins/). -- Have a plugin and want it listed? Simply add the following keywords to your package.json: - - `chai-plugin` - - `browser` if your plugin works in the browser as well as Node.js - - `browser-only` if your plugin does not work with Node.js - -### Related Projects - -- [chaijs / chai-docs](https://github.com/chaijs/chai-docs): The chaijs.com website source code. -- [chaijs / assertion-error](https://github.com/chaijs/assertion-error): Custom `Error` constructor thrown upon an assertion failing. -- [chaijs / deep-eql](https://github.com/chaijs/deep-eql): Improved deep equality testing for Node.js and the browser. -- [chaijs / type-detect](https://github.com/chaijs/type-detect): Improved typeof detection for Node.js and the browser. -- [chaijs / check-error](https://github.com/chaijs/check-error): Error comparison and information related utility for Node.js and the browser. -- [chaijs / loupe](https://github.com/chaijs/loupe): Inspect utility for Node.js and browsers. -- [chaijs / pathval](https://github.com/chaijs/pathval): Object value retrieval given a string path. -- [chaijs / get-func-name](https://github.com/chaijs/get-func-name): Utility for getting a function's name for node and the browser. - -### Contributing - -Thank you very much for considering to contribute! - -Please make sure you follow our [Code Of Conduct](https://github.com/chaijs/chai/blob/master/CODE_OF_CONDUCT.md) and we also strongly recommend reading our [Contributing Guide](https://github.com/chaijs/chai/blob/master/CONTRIBUTING.md). - -Here are a few issues other contributors frequently ran into when opening pull requests: - -- Please do not commit changes to the `chai.js` build. We do it once per release. -- Before pushing your commits, please make sure you [rebase](https://github.com/chaijs/chai/blob/master/CONTRIBUTING.md#pull-requests) them. - -### Contributors - -Please see the full -[Contributors Graph](https://github.com/chaijs/chai/graphs/contributors) for our -list of contributors. - -### Core Contributors - -Feel free to reach out to any of the core contributors with your questions or -concerns. We will do our best to respond in a timely manner. - -[![Jake Luer](https://avatars3.githubusercontent.com/u/58988?v=3&s=50)](https://github.com/logicalparadox) -[![Veselin Todorov](https://avatars3.githubusercontent.com/u/330048?v=3&s=50)](https://github.com/vesln) -[![Keith Cirkel](https://avatars3.githubusercontent.com/u/118266?v=3&s=50)](https://github.com/keithamus) -[![Lucas Fernandes da Costa](https://avatars3.githubusercontent.com/u/6868147?v=3&s=50)](https://github.com/lucasfcosta) -[![Grant Snodgrass](https://avatars3.githubusercontent.com/u/17260989?v=3&s=50)](https://github.com/meeber) diff --git a/node_modules/chai/ReleaseNotes.md b/node_modules/chai/ReleaseNotes.md deleted file mode 100644 index 2a80d5c..0000000 --- a/node_modules/chai/ReleaseNotes.md +++ /dev/null @@ -1,737 +0,0 @@ -# Release Notes - -## Note - -As of 3.0.0, the ReleaseNotes.md file has been deprecated. [Please refer to the release notes available on Github](https://github.com/chaijs/chai/releases). Or -[the release notes on the chaijs.com website](https://chaijs.com/releases). - ---- - -## 2.3.0 / 2015-04-26 - -Added `ownPropertyDescriptor` assertion: - -```js -expect('test').to.have.ownPropertyDescriptor('length'); -expect('test').to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 4 }); -expect('test').not.to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 3 }); -expect('test').ownPropertyDescriptor('length').to.have.property('enumerable', false); -expect('test').ownPropertyDescriptor('length').to.have.keys('value'); -``` - -### Community Contributions - -#### Code Features & Fixes - - * [#408](https://github.com/chaijs/chai/pull/408) Add `ownPropertyDescriptor` - assertion. - By [@ljharb](https://github.com/ljharb) - * [#422](https://github.com/chaijs/chai/pull/422) Improve ownPropertyDescriptor - tests. - By [@ljharb](https://github.com/ljharb) - -#### Documentation fixes - - * [#417](https://github.com/chaijs/chai/pull/417) Fix documentation typo - By [@astorije](https://github.com/astorije) - * [#423](https://github.com/chaijs/chai/pull/423) Fix inconsistency in docs. - By [@ehntoo](https://github.com/ehntoo) - - -## 2.2.0 / 2015-03-26 - -Deep property strings can now be escaped using `\\` - for example: - -```js -var deepCss = { '.link': { '[target]': 42 }}; -expect(deepCss).to.have.deep.property('\\.link.\\[target\\]', 42) -``` - -### Community Contributions - -#### Code Features & Fixes - - * [#402](https://github.com/chaijs/chai/pull/402) Allow escaping of deep - property keys. - By [@umireon](https://github.com/umireon) - -#### Documentation fixes - - * [#405](https://github.com/chaijs/chai/pull/405) Tweak documentation around - deep property escaping. - By [@keithamus](https://github.com/keithamus) - - -## 2.1.2 / 2015-03-15 - -A minor bug fix. No new features. - -### Community Contributions - -#### Code Features & Fixes - - * [#395](https://github.com/chaijs/chai/pull/395) Fix eval-related bugs with - assert.operator ([#386](https://github.com/chaijs/chai/pull/386)). - By [@cjqed](https://github.com/cjqed) - -## 2.1.1 / 2015-03-04 - -Two minor bugfixes. No new features. - -### Community Contributions - -#### Code Features & Fixes - - * [#385](https://github.com/chaijs/chai/pull/385) Fix a bug (also described in - [#387](https://github.com/chaijs/chai/pull/385)) where `deep.property` would not work with single - key names. By [@eldritch-fossicker](https://github.com/eldritch-fossicker) - * [#379](https://github.com/chaijs/chai/pull/379) Fix bug where tools which overwrite - primitive prototypes, such as Babel or core-js would fail. - By [@dcneiner](https://github.com/dcneiner) - -#### Documentation fixes - - * [#382](https://github.com/chaijs/chai/pull/382) Add doc for showDiff argument in assert. - By [@astorije](https://github.com/astorije) - * [#383](https://github.com/chaijs/chai/pull/383) Improve wording for truncateTreshold docs - By [@gurdiga](https://github.com/gurdiga) - * [#381](https://github.com/chaijs/chai/pull/381) Improve wording for assert.empty docs - By [@astorije](https://github.com/astorije) - -## 2.1.0 / 2015-02-23 - -Small release; fixes an issue where the Chai lib was incorrectly reporting the -version number. - -Adds new `should.fail()` and `expect.fail()` methods, which are convinience -methods to throw Assertion Errors. - -### Community Contributions - -#### Code Features & Fixes - - * [#356](https://github.com/chaijs/chai/pull/356) Add should.fail(), expect.fail(). By [@Soviut](https://github.com/Soviut) - * [#374](https://github.com/chaijs/chai/pull/374) Increment version. By [@jmm](https://github.com/jmm) - -## 2.0.0 / 2015-02-09 - -Unfortunately with 1.10.0 - compatibility broke with older versions because of -the `addChainableNoop`. This change has been reverted. - -Any plugins using `addChainableNoop` should cease to do so. - -Any developers wishing for this behaviour can use [dirty-chai](https://www.npmjs.com/package/dirty-chai) -by [@joshperry](https://github.com/joshperry) - -### Community Contributions - -#### Code Features & Fixes - - * [#361](https://github.com/chaijs/chai/pull/361) `.keys()` now accepts Objects, extracting keys from them. By [@gregglind](https://github.com/gregglind) - * [#359](https://github.com/chaijs/chai/pull/359) `.keys()` no longer mutates passed arrays. By [@gregglind](https://github.com/gregglind) - * [#349](https://github.com/chaijs/chai/pull/349) Add a new chainable keyword - `.which`. By [@toastynerd](https://github.com/toastynerd) - * [#333](https://github.com/chaijs/chai/pull/333) Add `.change`, `.increase` and `.decrease` assertions. By [@cmpolis](https://github.com/cmpolis) - * [#335](https://github.com/chaijs/chai/pull/335) `chai.util` is now exposed [@DingoEatingFuzz](https://github.com/DingoEatingFuzz) - * [#328](https://github.com/chaijs/chai/pull/328) Add `.includes` and `.contains` aliases (for `.include` and `.contain`). By [@lo1tuma](https://github.com/lo1tuma) - * [#313](https://github.com/chaijs/chai/pull/313) Add `.any.keys()` and `.all.keys()` qualifiers. By [@cjqed](https://github.com/cjqed) - * [#312](https://github.com/chaijs/chai/pull/312) Add `assert.sameDeepMembers()`. By [@cjqed](https://github.com/cjqed) - * [#311](https://github.com/chaijs/chai/pull/311) Add `assert.isAbove()` and `assert.isBelow()`. By [@cjqed](https://github.com/cjqed) - * [#308](https://github.com/chaijs/chai/pull/308) `property` and `deep.property` now pass if a value is set to `undefined`. By [@prodatakey](https://github.com/prodatakey) - * [#309](https://github.com/chaijs/chai/pull/309) optimize deep equal in Arrays. By [@ericdouglas](https://github.com/ericdouglas) - * [#306](https://github.com/chaijs/chai/pull/306) revert #297 - allowing lint-friendly tests. By [@keithamus](https://github.com/keithamus) - -#### Documentation fixes - - * [#357](https://github.com/chaijs/chai/pull/357) Copyright year updated in docs. By [@danilovaz](https://github.com/danilovaz) - * [#325](https://github.com/chaijs/chai/pull/325) Fix documentation for overwriteChainableMethod. By [@chasenlehara](https://github.com/chasenlehara) - * [#334](https://github.com/chaijs/chai/pull/334) Typo fix. By [@hurrymaplelad](https://github.com/hurrymaplelad) - * [#317](https://github.com/chaijs/chai/pull/317) Typo fix. By [@jasonkarns](https://github.com/jasonkarns) - * [#318](https://github.com/chaijs/chai/pull/318) Typo fix. By [@jasonkarns](https://github.com/jasonkarns) - * [#316](https://github.com/chaijs/chai/pull/316) Typo fix. By [@jasonkarns](https://github.com/jasonkarns) - - -## 1.10.0 / 2014-11-10 - -The following changes are required if you are upgrading from the previous version: - -- **Users:** - - No changes required -- **Plugin Developers:** - - Review `addChainableNoop` notes below. -- **Core Contributors:** - - Refresh `node_modules` folder for updated dependencies. - -### Noop Function for Terminating Assertion Properties - -The following assertions can now also be used in the function-call form: - -* ok -* true -* false -* null -* undefined -* exist -* empty -* arguments -* Arguments - -The above list of assertions are property getters that assert immediately on -access. Because of that, they were written to be used by terminating the assertion -chain with a property access. - -```js -expect(true).to.be.true; -foo.should.be.ok; -``` - -This syntax is definitely aesthetically pleasing but, if you are linting your -test code, your linter will complain with an error something like "Expected an -assignment or function call and instead saw an expression." Since the linter -doesn't know about the property getter it assumes this line has no side-effects, -and throws a warning in case you made a mistake. - -Squelching these errors is not a good solution as test code is getting to be -just as important as, if not more than, production code. Catching syntactical -errors in tests using static analysis is a great tool to help make sure that your -tests are well-defined and free of typos. - -A better option was to provide a function-call form for these assertions so that -the code's intent is more clear and the linters stop complaining about something -looking off. This form is added in addition to the existing property access form -and does not impact existing test code. - -```js -expect(true).to.be.true(); -foo.should.be.ok(); -``` - -These forms can also be mixed in any way, these are all functionally identical: - -```js -expect(true).to.be.true.and.not.false(); -expect(true).to.be.true().and.not.false; -expect(true).to.be.true.and.not.false; -``` - -#### Plugin Authors - -If you would like to provide this function-call form for your terminating assertion -properties, there is a new function to register these types of asserts. Instead -of using `addProperty` to register terminating assertions, simply use `addChainableNoop` -instead; the arguments to both are identical. The latter will make the assertion -available in both the attribute and function-call forms and should have no impact -on existing users of your plugin. - -### Community Contributions - -- [#297](https://github.com/chaijs/chai/pull/297) Allow writing lint-friendly tests. [@joshperry](https://github.com/joshperry) -- [#298](https://github.com/chaijs/chai/pull/298) Add check for logging `-0`. [@dasilvacontin](https://github.com/dasilvacontin) -- [#300](https://github.com/chaijs/chai/pull/300) Fix #299: the test is defining global variables [@julienw](https://github.com/julienw) - -Thank you to all who took time to contribute! - -## 1.9.2 / 2014-09-29 - -The following changes are required if you are upgrading from the previous version: - -- **Users:** - - No changes required -- **Plugin Developers:** - - No changes required -- **Core Contributors:** - - Refresh `node_modules` folder for updated dependencies. - -### Community Contributions - -- [#264](https://github.com/chaijs/chai/pull/264) Show diff for keys assertions [@cjthompson](https://github.com/cjthompson) -- [#267](https://github.com/chaijs/chai/pull/267) Use SVG badges [@shinnn](https://github.com/shinnn) -- [#268](https://github.com/chaijs/chai/pull/268) Allow messages to be functions (sinon-compat) [@charlierudolph](https://github.com/charlierudolph) -- [#269](https://github.com/chaijs/chai/pull/269) Remove unused argument for #lengthOf [@charlierudolph](https://github.com/charlierudolph) -- [#275](https://github.com/chaijs/chai/pull/275) Rewrite pretty-printing HTML elements to prevent throwing internal errors [@DrRataplan](https://github.com/DrRataplan) -- [#277](https://github.com/chaijs/chai/pull/277) Fix assert documentation for #sameMembers [@charlierudolph](https://github.com/charlierudolph) -- [#279](https://github.com/chaijs/chai/pull/279) closeTo should check value's type before assertion [@mohayonao](https://github.com/mohayonao) -- [#289](https://github.com/chaijs/chai/pull/289) satisfy is called twice [@charlierudolph](https://github.com/charlierudolph) -- [#292](https://github.com/chaijs/chai/pull/292) resolve conflicts with node-webkit and global usage [@boneskull](https://github.com/boneskull) - -Thank you to all who took time to contribute! - -## 1.9.1 / 2014-03-19 - -The following changes are required if you are upgrading from the previous version: - -- **Users:** - - Migrate configuration options to new interface. (see notes) -- **Plugin Developers:** - - No changes required -- **Core Contributors:** - - Refresh `node_modules` folder for updated dependencies. - -### Configuration - -There have been requests for changes and additions to the configuration mechanisms -and their impact in the Chai architecture. As such, we have decoupled the -configuration from the `Assertion` constructor. This not only allows for centralized -configuration, but will allow us to shift the responsibility from the `Assertion` -constructor to the `assert` interface in future releases. - -These changes have been implemented in a non-breaking way, but a depretiation -warning will be presented to users until they migrate. The old config method will -be removed in either `v1.11.0` or `v2.0.0`, whichever comes first. - -#### Quick Migration - -```js -// change this: -chai.Assertion.includeStack = true; -chai.Assertion.showDiff = false; - -// ... to this: -chai.config.includeStack = true; -chai.config.showDiff = false; -``` - -#### All Config Options - -##### config.includeStack - -- **@param** _{Boolean}_ -- **@default** `false` - -User configurable property, influences whether stack trace is included in -Assertion error message. Default of `false` suppresses stack trace in the error -message. - -##### config.showDiff - -- **@param** _{Boolean}_ -- **@default** `true` - -User configurable property, influences whether or not the `showDiff` flag -should be included in the thrown AssertionErrors. `false` will always be `false`; -`true` will be true when the assertion has requested a diff be shown. - -##### config.truncateThreshold **(NEW)** - -- **@param** _{Number}_ -- **@default** `40` - -User configurable property, sets length threshold for actual and expected values -in assertion errors. If this threshold is exceeded, the value is truncated. - -Set it to zero if you want to disable truncating altogether. - -```js -chai.config.truncateThreshold = 0; // disable truncating -``` - -### Community Contributions - -- [#228](https://github.com/chaijs/chai/pull/228) Deep equality check for memebers. [@duncanbeevers](https://github.com/duncanbeevers) -- [#247](https://github.com/chaijs/chai/pull/247) Proofreading. [@didorellano](https://github.com/didoarellano) -- [#244](https://github.com/chaijs/chai/pull/244) Fix `contain`/`include` 1.9.0 regression. [@leider](https://github.com/leider) -- [#233](https://github.com/chaijs/chai/pull/233) Improvements to `ssfi` for `assert` interface. [@refack](https://github.com/refack) -- [#251](https://github.com/chaijs/chai/pull/251) New config option: object display threshold. [@romario333](https://github.com/romario333) - -Thank you to all who took time to contribute! - -### Other Bug Fixes - -- [#183](https://github.com/chaijs/chai/issues/183) Allow `undefined` for actual. (internal api) -- Update Karam(+plugins)/Istanbul to most recent versions. - -## 1.9.0 / 2014-01-29 - -The following changes are required if you are upgrading from the previous version: - -- **Users:** - - No changes required -- **Plugin Developers:** - - Review [#219](https://github.com/chaijs/chai/pull/219). -- **Core Contributors:** - - Refresh `node_modules` folder for updated dependencies. - -### Community Contributions - -- [#202](https://github.com/chaijs/chai/pull/201) Improve error message for .throw(). [@andreineculau](https://github.com/andreineculau) -- [#217](https://github.com/chaijs/chai/pull/217) Chai tests can be run with `--watch`. [@demands](https://github.com/demands) -- [#219](https://github.com/chaijs/chai/pull/219) Add overwriteChainableMethod utility. [@demands](https://github.com/demands) -- [#224](https://github.com/chaijs/chai/pull/224) Return error on throw method to chain on error properties. [@vbardales](https://github.com/vbardales) -- [#226](https://github.com/chaijs/chai/pull/226) Add `has` to language chains. [@duncanbeevers](https://github.com/duncanbeevers) -- [#230](https://github.com/chaijs/chai/pull/230) Support `{a:1,b:2}.should.include({a:1})` [@jkroso](https://github.com/jkroso) -- [#231](https://github.com/chaijs/chai/pull/231) Update Copyright notices to 2014 [@duncanbeevers](https://github.com/duncanbeevers) -- [#232](https://github.com/chaijs/chai/pull/232) Avoid error instantiation if possible on assert.throws. [@laconbass](https://github.com/laconbass) - -Thank you to all who took time to contribute! - -### Other Bug Fixes - -- [#225](https://github.com/chaijs/chai/pull/225) Improved AMD wrapper provided by upstream `component(1)`. -- [#185](https://github.com/chaijs/chai/issues/185) `assert.throws()` returns thrown error for further assertions. -- [#237](https://github.com/chaijs/chai/pull/237) Remove coveralls/jscoverage, include istanbul coverage report in travis test. -- Update Karma and Sauce runner versions for consistent CI results. No more karma@canary. - -## 1.8.1 / 2013-10-10 - -The following changes are required if you are upgrading from the previous version: - -- **Users:** - - Refresh `node_modules` folder for updated dependencies. -- **Plugin Developers:** - - No changes required -- **Core Contributors:** - - Refresh `node_modules` folder for updated dependencies. - -### Browserify - -This is a small patch that updates the dependency tree so browserify users can install -chai. (Remove conditional requires) - -## 1.8.0 / 2013-09-18 - -The following changes are required if you are upgrading from the previous version: - -- **Users:** - - See `deep.equal` notes. -- **Plugin Developers:** - - No changes required -- **Core Contributors:** - - Refresh `node_modules` folder for updated dependencies. - -### Deep Equals - -This version of Chai focused on a overhaul to the deep equal utility. The code for this -tool has been removed from the core lib and can now be found at: -[chai / deep-eql](https://github.com/chaijs/deep-eql). As stated in previous releases, -this is part of a larger initiative to provide transparency, independent testing, and coverage for -some of the more complicated internal tools. - -For the most part `.deep.equal` will behave the same as it has. However, in order to provide a -consistent ruleset across all types being tested, the following changes have been made and _might_ -require changes to your tests. - -**1.** Strict equality for non-traversable nodes according to [egal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). - -_Previously:_ Non-traversable equal via `===`. - -```js -expect(NaN).to.deep.equal(NaN); -expect(-0).to.not.deep.equal(+0); -``` - -**2.** Arguments are not Arrays (and all types must be equal): - -_Previously:_ Some crazy nonsense that led to empty arrays deep equaling empty objects deep equaling dates. - -```js -expect(arguments).to.not.deep.equal([]); -expect(Array.prototype.slice.call(arguments)).to.deep.equal([]); -``` - -- [#156](https://github.com/chaijs/chai/issues/156) Empty object is eql to empty array -- [#192](https://github.com/chaijs/chai/issues/192) empty object is eql to a Date object -- [#194](https://github.com/chaijs/chai/issues/194) refactor deep-equal utility - -### CI and Browser Testing - -Chai now runs the browser CI suite using [Karma](http://karma-runner.github.io/) directed at -[SauceLabs](https://saucelabs.com/). This means we get to know where our browser support stands... -and we get a cool badge: - -[![Selenium Test Status](https://saucelabs.com/browser-matrix/logicalparadox.svg)](https://saucelabs.com/u/logicalparadox) - -Look for the list of browsers/versions to expand over the coming releases. - -- [#195](https://github.com/chaijs/chai/issues/195) karma test framework - -## 1.7.2 / 2013-06-27 - -The following changes are required if you are upgrading from the previous version: - -- **Users:** - - No changes required. -- **Plugin Developers:** - - No changes required -- **Core Contributors:** - - Refresh `node_modules` folder for updated dependencies. - -### Coverage Reporting - -Coverage reporting has always been available for core-developers but the data has never been published -for our end users. In our ongoing effort to improve accountability this data will now be published via -the [coveralls.io](https://coveralls.io/) service. A badge has been added to the README and the full report -can be viewed online at the [chai coveralls project](https://coveralls.io/r/chaijs/chai). Furthermore, PRs -will receive automated messages indicating how their PR impacts test coverage. This service is tied to TravisCI. - -### Other Fixes - -- [#175](https://github.com/chaijs/chai/issues/175) Add `bower.json`. (Fix ignore all) - -## 1.7.1 / 2013-06-24 - -The following changes are required if you are upgrading from the previous version: - -- **Users:** - - No changes required. -- **Plugin Developers:** - - No changes required -- **Core Contributors:** - - Refresh `node_modules` folder for updated dependencies. - -### Official Bower Support - -Support has been added for the Bower Package Manager ([bower.io])(http://bower.io/). Though -Chai could be installed via Bower in the past, this update adds official support via the `bower.json` -specification file. - -- [#175](https://github.com/chaijs/chai/issues/175) Add `bower.json`. - -## 1.7.0 / 2013-06-17 - -The following changes are required if you are upgrading from the previous version: - -- **Users:** - - No changes required. -- **Plugin Developers:** - - Review AssertionError update notice. -- **Core Contributors:** - - Refresh `node_modules` folder for updated dependencies. - -### AssertionError Update Notice - -Chai now uses [chaijs/assertion-error](https://github.com/chaijs/assertion-error) instead an internal -constructor. This will allow for further iteration/experimentation of the AssertionError constructor -independant of Chai. Future plans include stack parsing for callsite support. - -This update constructor has a different constructor param signature that conforms more with the standard -`Error` object. If your plugin throws and `AssertionError` directly you will need to update your plugin -with the new signature. - -```js -var AssertionError = require('chai').AssertionError; - -/** - * previous - * - * @param {Object} options - */ - -throw new AssertionError({ - message: 'An assertion error occurred' - , actual: actual - , expect: expect - , startStackFunction: arguments.callee - , showStack: true -}); - -/** - * new - * - * @param {String} message - * @param {Object} options - * @param {Function} start stack function - */ - -throw new AssertionError('An assertion error occurred', { - actual: actual - , expect: expect - , showStack: true -}, arguments.callee); - -// other signatures -throw new AssertionError('An assertion error occurred'); -throw new AssertionError('An assertion error occurred', null, arguments.callee); -``` - -#### External Dependencies - -This is the first non-developement dependency for Chai. As Chai continues to evolve we will begin adding -more; the next will likely be improved type detection and deep equality. With Chai's userbase continually growing -there is an higher need for accountability and documentation. External dependencies will allow us to iterate and -test on features independent from our interfaces. - -Note: The browser packaged version `chai.js` will ALWAYS contain all dependencies needed to run Chai. - -### Community Contributions - -- [#169](https://github.com/chaijs/chai/pull/169) Fix deep equal comparison for Date/Regexp types. [@katsgeorgeek](https://github.com/katsgeorgeek) -- [#171](https://github.com/chaijs/chai/pull/171) Add `assert.notOk()`. [@Bartvds](https://github.com/Bartvds) -- [#173](https://github.com/chaijs/chai/pull/173) Fix `inspect` utility. [@domenic](https://github.com/domenic) - -Thank you to all who took the time to contribute! - -## 1.6.1 / 2013-06-05 - -The following changes are required if you are upgrading from the previous version: - -- **Users:** - - No changes required. -- **Plugin Developers:** - - No changes required. -- **Core Contributors:** - - Refresh `node_modules` folder for updated developement dependencies. - -### Deep Equality - -Regular Expressions are now tested as part of all deep equality assertions. In previous versions -they silently passed for all scenarios. Thanks to [@katsgeorgeek](https://github.com/katsgeorgeek) for the contribution. - -### Community Contributions - -- [#161](https://github.com/chaijs/chai/pull/161) Fix documented name for assert interface's isDefined method. [@brandonpayton](https://github.com/brandonpayton) -- [#168](https://github.com/chaijs/chai/pull/168) Fix comparison equality of two regexps for when using deep equality. [@katsgeorgeek](https://github.com/katsgeorgeek) - -Thank you to all who took the time to contribute! - -### Additional Notes - -- Mocha has been locked at version `1.8.x` to ensure `mocha-phantomjs` compatibility. - -## 1.6.0 / 2013-04-29 - -The following changes are required if you are upgrading from the previous version: - -- **Users:** - - No changes required. -- **Plugin Developers:** - - No changes required. -- **Core Contributors:** - - Refresh `node_modules` folder for updated developement dependencies. - -### New Assertions - -#### Array Members Inclusion - -Asserts that the target is a superset of `set`, or that the target and `set` have the same members. -Order is not taken into account. Thanks to [@NickHeiner](https://github.com/NickHeiner) for the contribution. - -```js -// (expect/should) full set -expect([4, 2]).to.have.members([2, 4]); -expect([5, 2]).to.not.have.members([5, 2, 1]); - -// (expect/should) inclusion -expect([1, 2, 3]).to.include.members([3, 2]); -expect([1, 2, 3]).to.not.include.members([3, 2, 8]); - -// (assert) full set -assert.sameMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'same members'); - -// (assert) inclusion -assert.includeMembers([ 1, 2, 3 ], [ 2, 1 ], 'include members'); - -``` - -#### Non-inclusion for Assert Interface - -Most `assert` functions have a negative version, like `instanceOf()` has a corresponding `notInstaceOf()`. -However `include()` did not have a corresponding `notInclude()`. This has been added. - -```js -assert.notInclude([ 1, 2, 3 ], 8); -assert.notInclude('foobar', 'baz'); -``` - -### Community Contributions - -- [#140](https://github.com/chaijs/chai/pull/140) Restore `call`/`apply` methods for plugin interface. [@RubenVerborgh](https://github.com/RubenVerborgh) -- [#148](https://github.com/chaijs/chai/issues/148)/[#153](https://github.com/chaijs/chai/pull/153) Add `members` and `include.members` assertions. [#NickHeiner](https://github.com/NickHeiner) - -Thank you to all who took time to contribute! - -### Other Bug Fixes - -- [#142](https://github.com/chaijs/chai/issues/142) `assert#include` will no longer silently pass on wrong-type haystack. -- [#158](https://github.com/chaijs/chai/issues/158) `assert#notInclude` has been added. -- Travis-CI now tests Node.js `v0.10.x`. Support for `v0.6.x` has been removed. `v0.8.x` is still tested as before. - -## 1.5.0 / 2013-02-03 - -### Migration Requirements - -The following changes are required if you are upgrading from the previous version: - -- **Users:** - - _Update [2013-02-04]:_ Some users may notice a small subset of deep equality assertions will no longer pass. This is the result of - [#120](https://github.com/chaijs/chai/issues/120), an improvement to our deep equality algorithm. Users will need to revise their assertions - to be more granular should this occur. Further information: [#139](https://github.com/chaijs/chai/issues/139). -- **Plugin Developers:** - - No changes required. -- **Core Contributors:** - - Refresh `node_modules` folder for updated developement dependencies. - -### Community Contributions - -- [#126](https://github.com/chaijs/chai/pull/126): Add `eqls` alias for `eql`. [@RubenVerborgh](https://github.com/RubenVerborgh) -- [#127](https://github.com/chaijs/chai/issues/127): Performance refactor for chainable methods. [@RubenVerborgh](https://github.com/RubenVerborgh) -- [#133](https://github.com/chaijs/chai/pull/133): Assertion `.throw` support for primitives. [@RubenVerborgh](https://github.com/RubenVerborgh) -- [#137](https://github.com/chaijs/chai/issues/137): Assertion `.throw` support for empty messages. [@timnew](https://github.com/timnew) -- [#136](https://github.com/chaijs/chai/pull/136): Fix backward negation messages when using `.above()` and `.below()`. [@whatthejeff](https://github.com/whatthejeff) - -Thank you to all who took time to contribute! - -### Other Bug Fixes - -- Improve type detection of `.a()`/`.an()` to work in cross-browser scenarios. -- [#116](https://github.com/chaijs/chai/issues/116): `.throw()` has cleaner display of errors when WebKit browsers. -- [#120](https://github.com/chaijs/chai/issues/120): `.eql()` now works to compare dom nodes in browsers. - - -### Usage Updates - -#### For Users - -**1. Component Support:** Chai now included the proper configuration to be installed as a -[component](https://github.com/component/component). Component users are encouraged to consult -[chaijs.com](http://chaijs.com) for the latest version number as using the master branch -does not gaurantee stability. - -```js -// relevant component.json - devDependencies: { - "chaijs/chai": "1.5.0" - } -``` - -Alternatively, bleeding-edge is available: - - $ component install chaijs/chai - -**2. Configurable showDiff:** Some test runners (such as [mocha](http://visionmedia.github.com/mocha/)) -include support for showing the diff of strings and objects when an equality error occurs. Chai has -already included support for this, however some users may not prefer this display behavior. To revert to -no diff display, the following configuration is available: - -```js -chai.Assertion.showDiff = false; // diff output disabled -chai.Assertion.showDiff = true; // default, diff output enabled -``` - -#### For Plugin Developers - -**1. New Utility - type**: The new utility `.type()` is available as a better implementation of `typeof` -that can be used cross-browser. It handles the inconsistencies of Array, `null`, and `undefined` detection. - -- **@param** _{Mixed}_ object to detect type of -- **@return** _{String}_ object type - -```js -chai.use(function (c, utils) { - // some examples - utils.type({}); // 'object' - utils.type(null); // `null' - utils.type(undefined); // `undefined` - utils.type([]); // `array` -}); -``` - -#### For Core Contributors - -**1. Browser Testing**: Browser testing of the `./chai.js` file is now available in the command line -via PhantomJS. `make test` and Travis-CI will now also rebuild and test `./chai.js`. Consequently, all -pull requests will now be browser tested in this way. - -_Note: Contributors opening pull requests should still NOT include the browser build._ - -**2. SauceLabs Testing**: Early SauceLab support has been enabled with the file `./support/mocha-cloud.js`. -Those interested in trying it out should create a free [Open Sauce](https://saucelabs.com/signup/plan) account -and include their credentials in `./test/auth/sauce.json`. diff --git a/node_modules/chai/bower.json b/node_modules/chai/bower.json deleted file mode 100644 index af2ee02..0000000 --- a/node_modules/chai/bower.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "chai", - "description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.", - "license": "MIT", - "keywords": [ - "test", - "assertion", - "assert", - "testing", - "chai" - ], - "main": "chai.js", - "ignore": [ - "build", - "components", - "lib", - "node_modules", - "support", - "test", - "index.js", - "Makefile", - ".*" - ], - "dependencies": {}, - "devDependencies": {} -} diff --git a/node_modules/chai/chai.js b/node_modules/chai/chai.js deleted file mode 100644 index b961ff7..0000000 --- a/node_modules/chai/chai.js +++ /dev/null @@ -1,11464 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.chai = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i - * MIT Licensed - */ - -var used = []; - -/*! - * Chai version - */ - -exports.version = '4.3.3'; - -/*! - * Assertion Error - */ - -exports.AssertionError = require('assertion-error'); - -/*! - * Utils for plugins (not exported) - */ - -var util = require('./chai/utils'); - -/** - * # .use(function) - * - * Provides a way to extend the internals of Chai. - * - * @param {Function} - * @returns {this} for chaining - * @api public - */ - -exports.use = function (fn) { - if (!~used.indexOf(fn)) { - fn(exports, util); - used.push(fn); - } - - return exports; -}; - -/*! - * Utility Functions - */ - -exports.util = util; - -/*! - * Configuration - */ - -var config = require('./chai/config'); -exports.config = config; - -/*! - * Primary `Assertion` prototype - */ - -var assertion = require('./chai/assertion'); -exports.use(assertion); - -/*! - * Core Assertions - */ - -var core = require('./chai/core/assertions'); -exports.use(core); - -/*! - * Expect interface - */ - -var expect = require('./chai/interface/expect'); -exports.use(expect); - -/*! - * Should interface - */ - -var should = require('./chai/interface/should'); -exports.use(should); - -/*! - * Assert interface - */ - -var assert = require('./chai/interface/assert'); -exports.use(assert); - -},{"./chai/assertion":3,"./chai/config":4,"./chai/core/assertions":5,"./chai/interface/assert":6,"./chai/interface/expect":7,"./chai/interface/should":8,"./chai/utils":22,"assertion-error":33}],3:[function(require,module,exports){ -/*! - * chai - * http://chaijs.com - * Copyright(c) 2011-2014 Jake Luer - * MIT Licensed - */ - -var config = require('./config'); - -module.exports = function (_chai, util) { - /*! - * Module dependencies. - */ - - var AssertionError = _chai.AssertionError - , flag = util.flag; - - /*! - * Module export. - */ - - _chai.Assertion = Assertion; - - /*! - * Assertion Constructor - * - * Creates object for chaining. - * - * `Assertion` objects contain metadata in the form of flags. Three flags can - * be assigned during instantiation by passing arguments to this constructor: - * - * - `object`: This flag contains the target of the assertion. For example, in - * the assertion `expect(numKittens).to.equal(7);`, the `object` flag will - * contain `numKittens` so that the `equal` assertion can reference it when - * needed. - * - * - `message`: This flag contains an optional custom error message to be - * prepended to the error message that's generated by the assertion when it - * fails. - * - * - `ssfi`: This flag stands for "start stack function indicator". It - * contains a function reference that serves as the starting point for - * removing frames from the stack trace of the error that's created by the - * assertion when it fails. The goal is to provide a cleaner stack trace to - * end users by removing Chai's internal functions. Note that it only works - * in environments that support `Error.captureStackTrace`, and only when - * `Chai.config.includeStack` hasn't been set to `false`. - * - * - `lockSsfi`: This flag controls whether or not the given `ssfi` flag - * should retain its current value, even as assertions are chained off of - * this object. This is usually set to `true` when creating a new assertion - * from within another assertion. It's also temporarily set to `true` before - * an overwritten assertion gets called by the overwriting assertion. - * - * @param {Mixed} obj target of the assertion - * @param {String} msg (optional) custom error message - * @param {Function} ssfi (optional) starting point for removing stack frames - * @param {Boolean} lockSsfi (optional) whether or not the ssfi flag is locked - * @api private - */ - - function Assertion (obj, msg, ssfi, lockSsfi) { - flag(this, 'ssfi', ssfi || Assertion); - flag(this, 'lockSsfi', lockSsfi); - flag(this, 'object', obj); - flag(this, 'message', msg); - - return util.proxify(this); - } - - Object.defineProperty(Assertion, 'includeStack', { - get: function() { - console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.'); - return config.includeStack; - }, - set: function(value) { - console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.'); - config.includeStack = value; - } - }); - - Object.defineProperty(Assertion, 'showDiff', { - get: function() { - console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.'); - return config.showDiff; - }, - set: function(value) { - console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.'); - config.showDiff = value; - } - }); - - Assertion.addProperty = function (name, fn) { - util.addProperty(this.prototype, name, fn); - }; - - Assertion.addMethod = function (name, fn) { - util.addMethod(this.prototype, name, fn); - }; - - Assertion.addChainableMethod = function (name, fn, chainingBehavior) { - util.addChainableMethod(this.prototype, name, fn, chainingBehavior); - }; - - Assertion.overwriteProperty = function (name, fn) { - util.overwriteProperty(this.prototype, name, fn); - }; - - Assertion.overwriteMethod = function (name, fn) { - util.overwriteMethod(this.prototype, name, fn); - }; - - Assertion.overwriteChainableMethod = function (name, fn, chainingBehavior) { - util.overwriteChainableMethod(this.prototype, name, fn, chainingBehavior); - }; - - /** - * ### .assert(expression, message, negateMessage, expected, actual, showDiff) - * - * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass. - * - * @name assert - * @param {Philosophical} expression to be tested - * @param {String|Function} message or function that returns message to display if expression fails - * @param {String|Function} negatedMessage or function that returns negatedMessage to display if negated expression fails - * @param {Mixed} expected value (remember to check for negation) - * @param {Mixed} actual (optional) will default to `this.obj` - * @param {Boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails - * @api private - */ - - Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) { - var ok = util.test(this, arguments); - if (false !== showDiff) showDiff = true; - if (undefined === expected && undefined === _actual) showDiff = false; - if (true !== config.showDiff) showDiff = false; - - if (!ok) { - msg = util.getMessage(this, arguments); - var actual = util.getActual(this, arguments); - var assertionErrorObjectProperties = { - actual: actual - , expected: expected - , showDiff: showDiff - }; - - var operator = util.getOperator(this, arguments); - if (operator) { - assertionErrorObjectProperties.operator = operator; - } - - throw new AssertionError( - msg, - assertionErrorObjectProperties, - (config.includeStack) ? this.assert : flag(this, 'ssfi')); - } - }; - - /*! - * ### ._obj - * - * Quick reference to stored `actual` value for plugin developers. - * - * @api private - */ - - Object.defineProperty(Assertion.prototype, '_obj', - { get: function () { - return flag(this, 'object'); - } - , set: function (val) { - flag(this, 'object', val); - } - }); -}; - -},{"./config":4}],4:[function(require,module,exports){ -module.exports = { - - /** - * ### config.includeStack - * - * User configurable property, influences whether stack trace - * is included in Assertion error message. Default of false - * suppresses stack trace in the error message. - * - * chai.config.includeStack = true; // enable stack on error - * - * @param {Boolean} - * @api public - */ - - includeStack: false, - - /** - * ### config.showDiff - * - * User configurable property, influences whether or not - * the `showDiff` flag should be included in the thrown - * AssertionErrors. `false` will always be `false`; `true` - * will be true when the assertion has requested a diff - * be shown. - * - * @param {Boolean} - * @api public - */ - - showDiff: true, - - /** - * ### config.truncateThreshold - * - * User configurable property, sets length threshold for actual and - * expected values in assertion errors. If this threshold is exceeded, for - * example for large data structures, the value is replaced with something - * like `[ Array(3) ]` or `{ Object (prop1, prop2) }`. - * - * Set it to zero if you want to disable truncating altogether. - * - * This is especially userful when doing assertions on arrays: having this - * set to a reasonable large value makes the failure messages readily - * inspectable. - * - * chai.config.truncateThreshold = 0; // disable truncating - * - * @param {Number} - * @api public - */ - - truncateThreshold: 40, - - /** - * ### config.useProxy - * - * User configurable property, defines if chai will use a Proxy to throw - * an error when a non-existent property is read, which protects users - * from typos when using property-based assertions. - * - * Set it to false if you want to disable this feature. - * - * chai.config.useProxy = false; // disable use of Proxy - * - * This feature is automatically disabled regardless of this config value - * in environments that don't support proxies. - * - * @param {Boolean} - * @api public - */ - - useProxy: true, - - /** - * ### config.proxyExcludedKeys - * - * User configurable property, defines which properties should be ignored - * instead of throwing an error if they do not exist on the assertion. - * This is only applied if the environment Chai is running in supports proxies and - * if the `useProxy` configuration setting is enabled. - * By default, `then` and `inspect` will not throw an error if they do not exist on the - * assertion object because the `.inspect` property is read by `util.inspect` (for example, when - * using `console.log` on the assertion object) and `.then` is necessary for promise type-checking. - * - * // By default these keys will not throw an error if they do not exist on the assertion object - * chai.config.proxyExcludedKeys = ['then', 'inspect']; - * - * @param {Array} - * @api public - */ - - proxyExcludedKeys: ['then', 'catch', 'inspect', 'toJSON'] -}; - -},{}],5:[function(require,module,exports){ -/*! - * chai - * http://chaijs.com - * Copyright(c) 2011-2014 Jake Luer - * MIT Licensed - */ - -module.exports = function (chai, _) { - var Assertion = chai.Assertion - , AssertionError = chai.AssertionError - , flag = _.flag; - - /** - * ### Language Chains - * - * The following are provided as chainable getters to improve the readability - * of your assertions. - * - * **Chains** - * - * - to - * - be - * - been - * - is - * - that - * - which - * - and - * - has - * - have - * - with - * - at - * - of - * - same - * - but - * - does - * - still - * - also - * - * @name language chains - * @namespace BDD - * @api public - */ - - [ 'to', 'be', 'been', 'is' - , 'and', 'has', 'have', 'with' - , 'that', 'which', 'at', 'of' - , 'same', 'but', 'does', 'still', "also" ].forEach(function (chain) { - Assertion.addProperty(chain); - }); - - /** - * ### .not - * - * Negates all assertions that follow in the chain. - * - * expect(function () {}).to.not.throw(); - * expect({a: 1}).to.not.have.property('b'); - * expect([1, 2]).to.be.an('array').that.does.not.include(3); - * - * Just because you can negate any assertion with `.not` doesn't mean you - * should. With great power comes great responsibility. It's often best to - * assert that the one expected output was produced, rather than asserting - * that one of countless unexpected outputs wasn't produced. See individual - * assertions for specific guidance. - * - * expect(2).to.equal(2); // Recommended - * expect(2).to.not.equal(1); // Not recommended - * - * @name not - * @namespace BDD - * @api public - */ - - Assertion.addProperty('not', function () { - flag(this, 'negate', true); - }); - - /** - * ### .deep - * - * Causes all `.equal`, `.include`, `.members`, `.keys`, and `.property` - * assertions that follow in the chain to use deep equality instead of strict - * (`===`) equality. See the `deep-eql` project page for info on the deep - * equality algorithm: https://github.com/chaijs/deep-eql. - * - * // Target object deeply (but not strictly) equals `{a: 1}` - * expect({a: 1}).to.deep.equal({a: 1}); - * expect({a: 1}).to.not.equal({a: 1}); - * - * // Target array deeply (but not strictly) includes `{a: 1}` - * expect([{a: 1}]).to.deep.include({a: 1}); - * expect([{a: 1}]).to.not.include({a: 1}); - * - * // Target object deeply (but not strictly) includes `x: {a: 1}` - * expect({x: {a: 1}}).to.deep.include({x: {a: 1}}); - * expect({x: {a: 1}}).to.not.include({x: {a: 1}}); - * - * // Target array deeply (but not strictly) has member `{a: 1}` - * expect([{a: 1}]).to.have.deep.members([{a: 1}]); - * expect([{a: 1}]).to.not.have.members([{a: 1}]); - * - * // Target set deeply (but not strictly) has key `{a: 1}` - * expect(new Set([{a: 1}])).to.have.deep.keys([{a: 1}]); - * expect(new Set([{a: 1}])).to.not.have.keys([{a: 1}]); - * - * // Target object deeply (but not strictly) has property `x: {a: 1}` - * expect({x: {a: 1}}).to.have.deep.property('x', {a: 1}); - * expect({x: {a: 1}}).to.not.have.property('x', {a: 1}); - * - * @name deep - * @namespace BDD - * @api public - */ - - Assertion.addProperty('deep', function () { - flag(this, 'deep', true); - }); - - /** - * ### .nested - * - * Enables dot- and bracket-notation in all `.property` and `.include` - * assertions that follow in the chain. - * - * expect({a: {b: ['x', 'y']}}).to.have.nested.property('a.b[1]'); - * expect({a: {b: ['x', 'y']}}).to.nested.include({'a.b[1]': 'y'}); - * - * If `.` or `[]` are part of an actual property name, they can be escaped by - * adding two backslashes before them. - * - * expect({'.a': {'[b]': 'x'}}).to.have.nested.property('\\.a.\\[b\\]'); - * expect({'.a': {'[b]': 'x'}}).to.nested.include({'\\.a.\\[b\\]': 'x'}); - * - * `.nested` cannot be combined with `.own`. - * - * @name nested - * @namespace BDD - * @api public - */ - - Assertion.addProperty('nested', function () { - flag(this, 'nested', true); - }); - - /** - * ### .own - * - * Causes all `.property` and `.include` assertions that follow in the chain - * to ignore inherited properties. - * - * Object.prototype.b = 2; - * - * expect({a: 1}).to.have.own.property('a'); - * expect({a: 1}).to.have.property('b'); - * expect({a: 1}).to.not.have.own.property('b'); - * - * expect({a: 1}).to.own.include({a: 1}); - * expect({a: 1}).to.include({b: 2}).but.not.own.include({b: 2}); - * - * `.own` cannot be combined with `.nested`. - * - * @name own - * @namespace BDD - * @api public - */ - - Assertion.addProperty('own', function () { - flag(this, 'own', true); - }); - - /** - * ### .ordered - * - * Causes all `.members` assertions that follow in the chain to require that - * members be in the same order. - * - * expect([1, 2]).to.have.ordered.members([1, 2]) - * .but.not.have.ordered.members([2, 1]); - * - * When `.include` and `.ordered` are combined, the ordering begins at the - * start of both arrays. - * - * expect([1, 2, 3]).to.include.ordered.members([1, 2]) - * .but.not.include.ordered.members([2, 3]); - * - * @name ordered - * @namespace BDD - * @api public - */ - - Assertion.addProperty('ordered', function () { - flag(this, 'ordered', true); - }); - - /** - * ### .any - * - * Causes all `.keys` assertions that follow in the chain to only require that - * the target have at least one of the given keys. This is the opposite of - * `.all`, which requires that the target have all of the given keys. - * - * expect({a: 1, b: 2}).to.not.have.any.keys('c', 'd'); - * - * See the `.keys` doc for guidance on when to use `.any` or `.all`. - * - * @name any - * @namespace BDD - * @api public - */ - - Assertion.addProperty('any', function () { - flag(this, 'any', true); - flag(this, 'all', false); - }); - - /** - * ### .all - * - * Causes all `.keys` assertions that follow in the chain to require that the - * target have all of the given keys. This is the opposite of `.any`, which - * only requires that the target have at least one of the given keys. - * - * expect({a: 1, b: 2}).to.have.all.keys('a', 'b'); - * - * Note that `.all` is used by default when neither `.all` nor `.any` are - * added earlier in the chain. However, it's often best to add `.all` anyway - * because it improves readability. - * - * See the `.keys` doc for guidance on when to use `.any` or `.all`. - * - * @name all - * @namespace BDD - * @api public - */ - - Assertion.addProperty('all', function () { - flag(this, 'all', true); - flag(this, 'any', false); - }); - - /** - * ### .a(type[, msg]) - * - * Asserts that the target's type is equal to the given string `type`. Types - * are case insensitive. See the `type-detect` project page for info on the - * type detection algorithm: https://github.com/chaijs/type-detect. - * - * expect('foo').to.be.a('string'); - * expect({a: 1}).to.be.an('object'); - * expect(null).to.be.a('null'); - * expect(undefined).to.be.an('undefined'); - * expect(new Error).to.be.an('error'); - * expect(Promise.resolve()).to.be.a('promise'); - * expect(new Float32Array).to.be.a('float32array'); - * expect(Symbol()).to.be.a('symbol'); - * - * `.a` supports objects that have a custom type set via `Symbol.toStringTag`. - * - * var myObj = { - * [Symbol.toStringTag]: 'myCustomType' - * }; - * - * expect(myObj).to.be.a('myCustomType').but.not.an('object'); - * - * It's often best to use `.a` to check a target's type before making more - * assertions on the same target. That way, you avoid unexpected behavior from - * any assertion that does different things based on the target's type. - * - * expect([1, 2, 3]).to.be.an('array').that.includes(2); - * expect([]).to.be.an('array').that.is.empty; - * - * Add `.not` earlier in the chain to negate `.a`. However, it's often best to - * assert that the target is the expected type, rather than asserting that it - * isn't one of many unexpected types. - * - * expect('foo').to.be.a('string'); // Recommended - * expect('foo').to.not.be.an('array'); // Not recommended - * - * `.a` accepts an optional `msg` argument which is a custom error message to - * show when the assertion fails. The message can also be given as the second - * argument to `expect`. - * - * expect(1).to.be.a('string', 'nooo why fail??'); - * expect(1, 'nooo why fail??').to.be.a('string'); - * - * `.a` can also be used as a language chain to improve the readability of - * your assertions. - * - * expect({b: 2}).to.have.a.property('b'); - * - * The alias `.an` can be used interchangeably with `.a`. - * - * @name a - * @alias an - * @param {String} type - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function an (type, msg) { - if (msg) flag(this, 'message', msg); - type = type.toLowerCase(); - var obj = flag(this, 'object') - , article = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(type.charAt(0)) ? 'an ' : 'a '; - - this.assert( - type === _.type(obj).toLowerCase() - , 'expected #{this} to be ' + article + type - , 'expected #{this} not to be ' + article + type - ); - } - - Assertion.addChainableMethod('an', an); - Assertion.addChainableMethod('a', an); - - /** - * ### .include(val[, msg]) - * - * When the target is a string, `.include` asserts that the given string `val` - * is a substring of the target. - * - * expect('foobar').to.include('foo'); - * - * When the target is an array, `.include` asserts that the given `val` is a - * member of the target. - * - * expect([1, 2, 3]).to.include(2); - * - * When the target is an object, `.include` asserts that the given object - * `val`'s properties are a subset of the target's properties. - * - * expect({a: 1, b: 2, c: 3}).to.include({a: 1, b: 2}); - * - * When the target is a Set or WeakSet, `.include` asserts that the given `val` is a - * member of the target. SameValueZero equality algorithm is used. - * - * expect(new Set([1, 2])).to.include(2); - * - * When the target is a Map, `.include` asserts that the given `val` is one of - * the values of the target. SameValueZero equality algorithm is used. - * - * expect(new Map([['a', 1], ['b', 2]])).to.include(2); - * - * Because `.include` does different things based on the target's type, it's - * important to check the target's type before using `.include`. See the `.a` - * doc for info on testing a target's type. - * - * expect([1, 2, 3]).to.be.an('array').that.includes(2); - * - * By default, strict (`===`) equality is used to compare array members and - * object properties. Add `.deep` earlier in the chain to use deep equality - * instead (WeakSet targets are not supported). See the `deep-eql` project - * page for info on the deep equality algorithm: https://github.com/chaijs/deep-eql. - * - * // Target array deeply (but not strictly) includes `{a: 1}` - * expect([{a: 1}]).to.deep.include({a: 1}); - * expect([{a: 1}]).to.not.include({a: 1}); - * - * // Target object deeply (but not strictly) includes `x: {a: 1}` - * expect({x: {a: 1}}).to.deep.include({x: {a: 1}}); - * expect({x: {a: 1}}).to.not.include({x: {a: 1}}); - * - * By default, all of the target's properties are searched when working with - * objects. This includes properties that are inherited and/or non-enumerable. - * Add `.own` earlier in the chain to exclude the target's inherited - * properties from the search. - * - * Object.prototype.b = 2; - * - * expect({a: 1}).to.own.include({a: 1}); - * expect({a: 1}).to.include({b: 2}).but.not.own.include({b: 2}); - * - * Note that a target object is always only searched for `val`'s own - * enumerable properties. - * - * `.deep` and `.own` can be combined. - * - * expect({a: {b: 2}}).to.deep.own.include({a: {b: 2}}); - * - * Add `.nested` earlier in the chain to enable dot- and bracket-notation when - * referencing nested properties. - * - * expect({a: {b: ['x', 'y']}}).to.nested.include({'a.b[1]': 'y'}); - * - * If `.` or `[]` are part of an actual property name, they can be escaped by - * adding two backslashes before them. - * - * expect({'.a': {'[b]': 2}}).to.nested.include({'\\.a.\\[b\\]': 2}); - * - * `.deep` and `.nested` can be combined. - * - * expect({a: {b: [{c: 3}]}}).to.deep.nested.include({'a.b[0]': {c: 3}}); - * - * `.own` and `.nested` cannot be combined. - * - * Add `.not` earlier in the chain to negate `.include`. - * - * expect('foobar').to.not.include('taco'); - * expect([1, 2, 3]).to.not.include(4); - * - * However, it's dangerous to negate `.include` when the target is an object. - * The problem is that it creates uncertain expectations by asserting that the - * target object doesn't have all of `val`'s key/value pairs but may or may - * not have some of them. It's often best to identify the exact output that's - * expected, and then write an assertion that only accepts that exact output. - * - * When the target object isn't even expected to have `val`'s keys, it's - * often best to assert exactly that. - * - * expect({c: 3}).to.not.have.any.keys('a', 'b'); // Recommended - * expect({c: 3}).to.not.include({a: 1, b: 2}); // Not recommended - * - * When the target object is expected to have `val`'s keys, it's often best to - * assert that each of the properties has its expected value, rather than - * asserting that each property doesn't have one of many unexpected values. - * - * expect({a: 3, b: 4}).to.include({a: 3, b: 4}); // Recommended - * expect({a: 3, b: 4}).to.not.include({a: 1, b: 2}); // Not recommended - * - * `.include` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect([1, 2, 3]).to.include(4, 'nooo why fail??'); - * expect([1, 2, 3], 'nooo why fail??').to.include(4); - * - * `.include` can also be used as a language chain, causing all `.members` and - * `.keys` assertions that follow in the chain to require the target to be a - * superset of the expected set, rather than an identical set. Note that - * `.members` ignores duplicates in the subset when `.include` is added. - * - * // Target object's keys are a superset of ['a', 'b'] but not identical - * expect({a: 1, b: 2, c: 3}).to.include.all.keys('a', 'b'); - * expect({a: 1, b: 2, c: 3}).to.not.have.all.keys('a', 'b'); - * - * // Target array is a superset of [1, 2] but not identical - * expect([1, 2, 3]).to.include.members([1, 2]); - * expect([1, 2, 3]).to.not.have.members([1, 2]); - * - * // Duplicates in the subset are ignored - * expect([1, 2, 3]).to.include.members([1, 2, 2, 2]); - * - * Note that adding `.any` earlier in the chain causes the `.keys` assertion - * to ignore `.include`. - * - * // Both assertions are identical - * expect({a: 1}).to.include.any.keys('a', 'b'); - * expect({a: 1}).to.have.any.keys('a', 'b'); - * - * The aliases `.includes`, `.contain`, and `.contains` can be used - * interchangeably with `.include`. - * - * @name include - * @alias contain - * @alias includes - * @alias contains - * @param {Mixed} val - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function SameValueZero(a, b) { - return (_.isNaN(a) && _.isNaN(b)) || a === b; - } - - function includeChainingBehavior () { - flag(this, 'contains', true); - } - - function include (val, msg) { - if (msg) flag(this, 'message', msg); - - var obj = flag(this, 'object') - , objType = _.type(obj).toLowerCase() - , flagMsg = flag(this, 'message') - , negate = flag(this, 'negate') - , ssfi = flag(this, 'ssfi') - , isDeep = flag(this, 'deep') - , descriptor = isDeep ? 'deep ' : ''; - - flagMsg = flagMsg ? flagMsg + ': ' : ''; - - var included = false; - - switch (objType) { - case 'string': - included = obj.indexOf(val) !== -1; - break; - - case 'weakset': - if (isDeep) { - throw new AssertionError( - flagMsg + 'unable to use .deep.include with WeakSet', - undefined, - ssfi - ); - } - - included = obj.has(val); - break; - - case 'map': - var isEql = isDeep ? _.eql : SameValueZero; - obj.forEach(function (item) { - included = included || isEql(item, val); - }); - break; - - case 'set': - if (isDeep) { - obj.forEach(function (item) { - included = included || _.eql(item, val); - }); - } else { - included = obj.has(val); - } - break; - - case 'array': - if (isDeep) { - included = obj.some(function (item) { - return _.eql(item, val); - }) - } else { - included = obj.indexOf(val) !== -1; - } - break; - - default: - // This block is for asserting a subset of properties in an object. - // `_.expectTypes` isn't used here because `.include` should work with - // objects with a custom `@@toStringTag`. - if (val !== Object(val)) { - throw new AssertionError( - flagMsg + 'the given combination of arguments (' - + objType + ' and ' - + _.type(val).toLowerCase() + ')' - + ' is invalid for this assertion. ' - + 'You can use an array, a map, an object, a set, a string, ' - + 'or a weakset instead of a ' - + _.type(val).toLowerCase(), - undefined, - ssfi - ); - } - - var props = Object.keys(val) - , firstErr = null - , numErrs = 0; - - props.forEach(function (prop) { - var propAssertion = new Assertion(obj); - _.transferFlags(this, propAssertion, true); - flag(propAssertion, 'lockSsfi', true); - - if (!negate || props.length === 1) { - propAssertion.property(prop, val[prop]); - return; - } - - try { - propAssertion.property(prop, val[prop]); - } catch (err) { - if (!_.checkError.compatibleConstructor(err, AssertionError)) { - throw err; - } - if (firstErr === null) firstErr = err; - numErrs++; - } - }, this); - - // When validating .not.include with multiple properties, we only want - // to throw an assertion error if all of the properties are included, - // in which case we throw the first property assertion error that we - // encountered. - if (negate && props.length > 1 && numErrs === props.length) { - throw firstErr; - } - return; - } - - // Assert inclusion in collection or substring in a string. - this.assert( - included - , 'expected #{this} to ' + descriptor + 'include ' + _.inspect(val) - , 'expected #{this} to not ' + descriptor + 'include ' + _.inspect(val)); - } - - Assertion.addChainableMethod('include', include, includeChainingBehavior); - Assertion.addChainableMethod('contain', include, includeChainingBehavior); - Assertion.addChainableMethod('contains', include, includeChainingBehavior); - Assertion.addChainableMethod('includes', include, includeChainingBehavior); - - /** - * ### .ok - * - * Asserts that the target is a truthy value (considered `true` in boolean context). - * However, it's often best to assert that the target is strictly (`===`) or - * deeply equal to its expected value. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.be.ok; // Not recommended - * - * expect(true).to.be.true; // Recommended - * expect(true).to.be.ok; // Not recommended - * - * Add `.not` earlier in the chain to negate `.ok`. - * - * expect(0).to.equal(0); // Recommended - * expect(0).to.not.be.ok; // Not recommended - * - * expect(false).to.be.false; // Recommended - * expect(false).to.not.be.ok; // Not recommended - * - * expect(null).to.be.null; // Recommended - * expect(null).to.not.be.ok; // Not recommended - * - * expect(undefined).to.be.undefined; // Recommended - * expect(undefined).to.not.be.ok; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(false, 'nooo why fail??').to.be.ok; - * - * @name ok - * @namespace BDD - * @api public - */ - - Assertion.addProperty('ok', function () { - this.assert( - flag(this, 'object') - , 'expected #{this} to be truthy' - , 'expected #{this} to be falsy'); - }); - - /** - * ### .true - * - * Asserts that the target is strictly (`===`) equal to `true`. - * - * expect(true).to.be.true; - * - * Add `.not` earlier in the chain to negate `.true`. However, it's often best - * to assert that the target is equal to its expected value, rather than not - * equal to `true`. - * - * expect(false).to.be.false; // Recommended - * expect(false).to.not.be.true; // Not recommended - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.true; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(false, 'nooo why fail??').to.be.true; - * - * @name true - * @namespace BDD - * @api public - */ - - Assertion.addProperty('true', function () { - this.assert( - true === flag(this, 'object') - , 'expected #{this} to be true' - , 'expected #{this} to be false' - , flag(this, 'negate') ? false : true - ); - }); - - /** - * ### .false - * - * Asserts that the target is strictly (`===`) equal to `false`. - * - * expect(false).to.be.false; - * - * Add `.not` earlier in the chain to negate `.false`. However, it's often - * best to assert that the target is equal to its expected value, rather than - * not equal to `false`. - * - * expect(true).to.be.true; // Recommended - * expect(true).to.not.be.false; // Not recommended - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.false; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(true, 'nooo why fail??').to.be.false; - * - * @name false - * @namespace BDD - * @api public - */ - - Assertion.addProperty('false', function () { - this.assert( - false === flag(this, 'object') - , 'expected #{this} to be false' - , 'expected #{this} to be true' - , flag(this, 'negate') ? true : false - ); - }); - - /** - * ### .null - * - * Asserts that the target is strictly (`===`) equal to `null`. - * - * expect(null).to.be.null; - * - * Add `.not` earlier in the chain to negate `.null`. However, it's often best - * to assert that the target is equal to its expected value, rather than not - * equal to `null`. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.null; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(42, 'nooo why fail??').to.be.null; - * - * @name null - * @namespace BDD - * @api public - */ - - Assertion.addProperty('null', function () { - this.assert( - null === flag(this, 'object') - , 'expected #{this} to be null' - , 'expected #{this} not to be null' - ); - }); - - /** - * ### .undefined - * - * Asserts that the target is strictly (`===`) equal to `undefined`. - * - * expect(undefined).to.be.undefined; - * - * Add `.not` earlier in the chain to negate `.undefined`. However, it's often - * best to assert that the target is equal to its expected value, rather than - * not equal to `undefined`. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.undefined; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(42, 'nooo why fail??').to.be.undefined; - * - * @name undefined - * @namespace BDD - * @api public - */ - - Assertion.addProperty('undefined', function () { - this.assert( - undefined === flag(this, 'object') - , 'expected #{this} to be undefined' - , 'expected #{this} not to be undefined' - ); - }); - - /** - * ### .NaN - * - * Asserts that the target is exactly `NaN`. - * - * expect(NaN).to.be.NaN; - * - * Add `.not` earlier in the chain to negate `.NaN`. However, it's often best - * to assert that the target is equal to its expected value, rather than not - * equal to `NaN`. - * - * expect('foo').to.equal('foo'); // Recommended - * expect('foo').to.not.be.NaN; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(42, 'nooo why fail??').to.be.NaN; - * - * @name NaN - * @namespace BDD - * @api public - */ - - Assertion.addProperty('NaN', function () { - this.assert( - _.isNaN(flag(this, 'object')) - , 'expected #{this} to be NaN' - , 'expected #{this} not to be NaN' - ); - }); - - /** - * ### .exist - * - * Asserts that the target is not strictly (`===`) equal to either `null` or - * `undefined`. However, it's often best to assert that the target is equal to - * its expected value. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.exist; // Not recommended - * - * expect(0).to.equal(0); // Recommended - * expect(0).to.exist; // Not recommended - * - * Add `.not` earlier in the chain to negate `.exist`. - * - * expect(null).to.be.null; // Recommended - * expect(null).to.not.exist; // Not recommended - * - * expect(undefined).to.be.undefined; // Recommended - * expect(undefined).to.not.exist; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(null, 'nooo why fail??').to.exist; - * - * The alias `.exists` can be used interchangeably with `.exist`. - * - * @name exist - * @alias exists - * @namespace BDD - * @api public - */ - - function assertExist () { - var val = flag(this, 'object'); - this.assert( - val !== null && val !== undefined - , 'expected #{this} to exist' - , 'expected #{this} to not exist' - ); - } - - Assertion.addProperty('exist', assertExist); - Assertion.addProperty('exists', assertExist); - - /** - * ### .empty - * - * When the target is a string or array, `.empty` asserts that the target's - * `length` property is strictly (`===`) equal to `0`. - * - * expect([]).to.be.empty; - * expect('').to.be.empty; - * - * When the target is a map or set, `.empty` asserts that the target's `size` - * property is strictly equal to `0`. - * - * expect(new Set()).to.be.empty; - * expect(new Map()).to.be.empty; - * - * When the target is a non-function object, `.empty` asserts that the target - * doesn't have any own enumerable properties. Properties with Symbol-based - * keys are excluded from the count. - * - * expect({}).to.be.empty; - * - * Because `.empty` does different things based on the target's type, it's - * important to check the target's type before using `.empty`. See the `.a` - * doc for info on testing a target's type. - * - * expect([]).to.be.an('array').that.is.empty; - * - * Add `.not` earlier in the chain to negate `.empty`. However, it's often - * best to assert that the target contains its expected number of values, - * rather than asserting that it's not empty. - * - * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended - * expect([1, 2, 3]).to.not.be.empty; // Not recommended - * - * expect(new Set([1, 2, 3])).to.have.property('size', 3); // Recommended - * expect(new Set([1, 2, 3])).to.not.be.empty; // Not recommended - * - * expect(Object.keys({a: 1})).to.have.lengthOf(1); // Recommended - * expect({a: 1}).to.not.be.empty; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect([1, 2, 3], 'nooo why fail??').to.be.empty; - * - * @name empty - * @namespace BDD - * @api public - */ - - Assertion.addProperty('empty', function () { - var val = flag(this, 'object') - , ssfi = flag(this, 'ssfi') - , flagMsg = flag(this, 'message') - , itemsCount; - - flagMsg = flagMsg ? flagMsg + ': ' : ''; - - switch (_.type(val).toLowerCase()) { - case 'array': - case 'string': - itemsCount = val.length; - break; - case 'map': - case 'set': - itemsCount = val.size; - break; - case 'weakmap': - case 'weakset': - throw new AssertionError( - flagMsg + '.empty was passed a weak collection', - undefined, - ssfi - ); - case 'function': - var msg = flagMsg + '.empty was passed a function ' + _.getName(val); - throw new AssertionError(msg.trim(), undefined, ssfi); - default: - if (val !== Object(val)) { - throw new AssertionError( - flagMsg + '.empty was passed non-string primitive ' + _.inspect(val), - undefined, - ssfi - ); - } - itemsCount = Object.keys(val).length; - } - - this.assert( - 0 === itemsCount - , 'expected #{this} to be empty' - , 'expected #{this} not to be empty' - ); - }); - - /** - * ### .arguments - * - * Asserts that the target is an `arguments` object. - * - * function test () { - * expect(arguments).to.be.arguments; - * } - * - * test(); - * - * Add `.not` earlier in the chain to negate `.arguments`. However, it's often - * best to assert which type the target is expected to be, rather than - * asserting that it’s not an `arguments` object. - * - * expect('foo').to.be.a('string'); // Recommended - * expect('foo').to.not.be.arguments; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect({}, 'nooo why fail??').to.be.arguments; - * - * The alias `.Arguments` can be used interchangeably with `.arguments`. - * - * @name arguments - * @alias Arguments - * @namespace BDD - * @api public - */ - - function checkArguments () { - var obj = flag(this, 'object') - , type = _.type(obj); - this.assert( - 'Arguments' === type - , 'expected #{this} to be arguments but got ' + type - , 'expected #{this} to not be arguments' - ); - } - - Assertion.addProperty('arguments', checkArguments); - Assertion.addProperty('Arguments', checkArguments); - - /** - * ### .equal(val[, msg]) - * - * Asserts that the target is strictly (`===`) equal to the given `val`. - * - * expect(1).to.equal(1); - * expect('foo').to.equal('foo'); - * - * Add `.deep` earlier in the chain to use deep equality instead. See the - * `deep-eql` project page for info on the deep equality algorithm: - * https://github.com/chaijs/deep-eql. - * - * // Target object deeply (but not strictly) equals `{a: 1}` - * expect({a: 1}).to.deep.equal({a: 1}); - * expect({a: 1}).to.not.equal({a: 1}); - * - * // Target array deeply (but not strictly) equals `[1, 2]` - * expect([1, 2]).to.deep.equal([1, 2]); - * expect([1, 2]).to.not.equal([1, 2]); - * - * Add `.not` earlier in the chain to negate `.equal`. However, it's often - * best to assert that the target is equal to its expected value, rather than - * not equal to one of countless unexpected values. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.equal(2); // Not recommended - * - * `.equal` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect(1).to.equal(2, 'nooo why fail??'); - * expect(1, 'nooo why fail??').to.equal(2); - * - * The aliases `.equals` and `eq` can be used interchangeably with `.equal`. - * - * @name equal - * @alias equals - * @alias eq - * @param {Mixed} val - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertEqual (val, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - if (flag(this, 'deep')) { - var prevLockSsfi = flag(this, 'lockSsfi'); - flag(this, 'lockSsfi', true); - this.eql(val); - flag(this, 'lockSsfi', prevLockSsfi); - } else { - this.assert( - val === obj - , 'expected #{this} to equal #{exp}' - , 'expected #{this} to not equal #{exp}' - , val - , this._obj - , true - ); - } - } - - Assertion.addMethod('equal', assertEqual); - Assertion.addMethod('equals', assertEqual); - Assertion.addMethod('eq', assertEqual); - - /** - * ### .eql(obj[, msg]) - * - * Asserts that the target is deeply equal to the given `obj`. See the - * `deep-eql` project page for info on the deep equality algorithm: - * https://github.com/chaijs/deep-eql. - * - * // Target object is deeply (but not strictly) equal to {a: 1} - * expect({a: 1}).to.eql({a: 1}).but.not.equal({a: 1}); - * - * // Target array is deeply (but not strictly) equal to [1, 2] - * expect([1, 2]).to.eql([1, 2]).but.not.equal([1, 2]); - * - * Add `.not` earlier in the chain to negate `.eql`. However, it's often best - * to assert that the target is deeply equal to its expected value, rather - * than not deeply equal to one of countless unexpected values. - * - * expect({a: 1}).to.eql({a: 1}); // Recommended - * expect({a: 1}).to.not.eql({b: 2}); // Not recommended - * - * `.eql` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect({a: 1}).to.eql({b: 2}, 'nooo why fail??'); - * expect({a: 1}, 'nooo why fail??').to.eql({b: 2}); - * - * The alias `.eqls` can be used interchangeably with `.eql`. - * - * The `.deep.equal` assertion is almost identical to `.eql` but with one - * difference: `.deep.equal` causes deep equality comparisons to also be used - * for any other assertions that follow in the chain. - * - * @name eql - * @alias eqls - * @param {Mixed} obj - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertEql(obj, msg) { - if (msg) flag(this, 'message', msg); - this.assert( - _.eql(obj, flag(this, 'object')) - , 'expected #{this} to deeply equal #{exp}' - , 'expected #{this} to not deeply equal #{exp}' - , obj - , this._obj - , true - ); - } - - Assertion.addMethod('eql', assertEql); - Assertion.addMethod('eqls', assertEql); - - /** - * ### .above(n[, msg]) - * - * Asserts that the target is a number or a date greater than the given number or date `n` respectively. - * However, it's often best to assert that the target is equal to its expected - * value. - * - * expect(2).to.equal(2); // Recommended - * expect(2).to.be.above(1); // Not recommended - * - * Add `.lengthOf` earlier in the chain to assert that the target's `length` - * or `size` is greater than the given number `n`. - * - * expect('foo').to.have.lengthOf(3); // Recommended - * expect('foo').to.have.lengthOf.above(2); // Not recommended - * - * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended - * expect([1, 2, 3]).to.have.lengthOf.above(2); // Not recommended - * - * Add `.not` earlier in the chain to negate `.above`. - * - * expect(2).to.equal(2); // Recommended - * expect(1).to.not.be.above(2); // Not recommended - * - * `.above` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect(1).to.be.above(2, 'nooo why fail??'); - * expect(1, 'nooo why fail??').to.be.above(2); - * - * The aliases `.gt` and `.greaterThan` can be used interchangeably with - * `.above`. - * - * @name above - * @alias gt - * @alias greaterThan - * @param {Number} n - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertAbove (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , doLength = flag(this, 'doLength') - , flagMsg = flag(this, 'message') - , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '') - , ssfi = flag(this, 'ssfi') - , objType = _.type(obj).toLowerCase() - , nType = _.type(n).toLowerCase() - , errorMessage - , shouldThrow = true; - - if (doLength && objType !== 'map' && objType !== 'set') { - new Assertion(obj, flagMsg, ssfi, true).to.have.property('length'); - } - - if (!doLength && (objType === 'date' && nType !== 'date')) { - errorMessage = msgPrefix + 'the argument to above must be a date'; - } else if (nType !== 'number' && (doLength || objType === 'number')) { - errorMessage = msgPrefix + 'the argument to above must be a number'; - } else if (!doLength && (objType !== 'date' && objType !== 'number')) { - var printObj = (objType === 'string') ? "'" + obj + "'" : obj; - errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date'; - } else { - shouldThrow = false; - } - - if (shouldThrow) { - throw new AssertionError(errorMessage, undefined, ssfi); - } - - if (doLength) { - var descriptor = 'length' - , itemsCount; - if (objType === 'map' || objType === 'set') { - descriptor = 'size'; - itemsCount = obj.size; - } else { - itemsCount = obj.length; - } - this.assert( - itemsCount > n - , 'expected #{this} to have a ' + descriptor + ' above #{exp} but got #{act}' - , 'expected #{this} to not have a ' + descriptor + ' above #{exp}' - , n - , itemsCount - ); - } else { - this.assert( - obj > n - , 'expected #{this} to be above #{exp}' - , 'expected #{this} to be at most #{exp}' - , n - ); - } - } - - Assertion.addMethod('above', assertAbove); - Assertion.addMethod('gt', assertAbove); - Assertion.addMethod('greaterThan', assertAbove); - - /** - * ### .least(n[, msg]) - * - * Asserts that the target is a number or a date greater than or equal to the given - * number or date `n` respectively. However, it's often best to assert that the target is equal to - * its expected value. - * - * expect(2).to.equal(2); // Recommended - * expect(2).to.be.at.least(1); // Not recommended - * expect(2).to.be.at.least(2); // Not recommended - * - * Add `.lengthOf` earlier in the chain to assert that the target's `length` - * or `size` is greater than or equal to the given number `n`. - * - * expect('foo').to.have.lengthOf(3); // Recommended - * expect('foo').to.have.lengthOf.at.least(2); // Not recommended - * - * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended - * expect([1, 2, 3]).to.have.lengthOf.at.least(2); // Not recommended - * - * Add `.not` earlier in the chain to negate `.least`. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.at.least(2); // Not recommended - * - * `.least` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect(1).to.be.at.least(2, 'nooo why fail??'); - * expect(1, 'nooo why fail??').to.be.at.least(2); - * - * The aliases `.gte` and `.greaterThanOrEqual` can be used interchangeably with - * `.least`. - * - * @name least - * @alias gte - * @alias greaterThanOrEqual - * @param {Number} n - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertLeast (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , doLength = flag(this, 'doLength') - , flagMsg = flag(this, 'message') - , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '') - , ssfi = flag(this, 'ssfi') - , objType = _.type(obj).toLowerCase() - , nType = _.type(n).toLowerCase() - , errorMessage - , shouldThrow = true; - - if (doLength && objType !== 'map' && objType !== 'set') { - new Assertion(obj, flagMsg, ssfi, true).to.have.property('length'); - } - - if (!doLength && (objType === 'date' && nType !== 'date')) { - errorMessage = msgPrefix + 'the argument to least must be a date'; - } else if (nType !== 'number' && (doLength || objType === 'number')) { - errorMessage = msgPrefix + 'the argument to least must be a number'; - } else if (!doLength && (objType !== 'date' && objType !== 'number')) { - var printObj = (objType === 'string') ? "'" + obj + "'" : obj; - errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date'; - } else { - shouldThrow = false; - } - - if (shouldThrow) { - throw new AssertionError(errorMessage, undefined, ssfi); - } - - if (doLength) { - var descriptor = 'length' - , itemsCount; - if (objType === 'map' || objType === 'set') { - descriptor = 'size'; - itemsCount = obj.size; - } else { - itemsCount = obj.length; - } - this.assert( - itemsCount >= n - , 'expected #{this} to have a ' + descriptor + ' at least #{exp} but got #{act}' - , 'expected #{this} to have a ' + descriptor + ' below #{exp}' - , n - , itemsCount - ); - } else { - this.assert( - obj >= n - , 'expected #{this} to be at least #{exp}' - , 'expected #{this} to be below #{exp}' - , n - ); - } - } - - Assertion.addMethod('least', assertLeast); - Assertion.addMethod('gte', assertLeast); - Assertion.addMethod('greaterThanOrEqual', assertLeast); - - /** - * ### .below(n[, msg]) - * - * Asserts that the target is a number or a date less than the given number or date `n` respectively. - * However, it's often best to assert that the target is equal to its expected - * value. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.be.below(2); // Not recommended - * - * Add `.lengthOf` earlier in the chain to assert that the target's `length` - * or `size` is less than the given number `n`. - * - * expect('foo').to.have.lengthOf(3); // Recommended - * expect('foo').to.have.lengthOf.below(4); // Not recommended - * - * expect([1, 2, 3]).to.have.length(3); // Recommended - * expect([1, 2, 3]).to.have.lengthOf.below(4); // Not recommended - * - * Add `.not` earlier in the chain to negate `.below`. - * - * expect(2).to.equal(2); // Recommended - * expect(2).to.not.be.below(1); // Not recommended - * - * `.below` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect(2).to.be.below(1, 'nooo why fail??'); - * expect(2, 'nooo why fail??').to.be.below(1); - * - * The aliases `.lt` and `.lessThan` can be used interchangeably with - * `.below`. - * - * @name below - * @alias lt - * @alias lessThan - * @param {Number} n - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertBelow (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , doLength = flag(this, 'doLength') - , flagMsg = flag(this, 'message') - , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '') - , ssfi = flag(this, 'ssfi') - , objType = _.type(obj).toLowerCase() - , nType = _.type(n).toLowerCase() - , errorMessage - , shouldThrow = true; - - if (doLength && objType !== 'map' && objType !== 'set') { - new Assertion(obj, flagMsg, ssfi, true).to.have.property('length'); - } - - if (!doLength && (objType === 'date' && nType !== 'date')) { - errorMessage = msgPrefix + 'the argument to below must be a date'; - } else if (nType !== 'number' && (doLength || objType === 'number')) { - errorMessage = msgPrefix + 'the argument to below must be a number'; - } else if (!doLength && (objType !== 'date' && objType !== 'number')) { - var printObj = (objType === 'string') ? "'" + obj + "'" : obj; - errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date'; - } else { - shouldThrow = false; - } - - if (shouldThrow) { - throw new AssertionError(errorMessage, undefined, ssfi); - } - - if (doLength) { - var descriptor = 'length' - , itemsCount; - if (objType === 'map' || objType === 'set') { - descriptor = 'size'; - itemsCount = obj.size; - } else { - itemsCount = obj.length; - } - this.assert( - itemsCount < n - , 'expected #{this} to have a ' + descriptor + ' below #{exp} but got #{act}' - , 'expected #{this} to not have a ' + descriptor + ' below #{exp}' - , n - , itemsCount - ); - } else { - this.assert( - obj < n - , 'expected #{this} to be below #{exp}' - , 'expected #{this} to be at least #{exp}' - , n - ); - } - } - - Assertion.addMethod('below', assertBelow); - Assertion.addMethod('lt', assertBelow); - Assertion.addMethod('lessThan', assertBelow); - - /** - * ### .most(n[, msg]) - * - * Asserts that the target is a number or a date less than or equal to the given number - * or date `n` respectively. However, it's often best to assert that the target is equal to its - * expected value. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.be.at.most(2); // Not recommended - * expect(1).to.be.at.most(1); // Not recommended - * - * Add `.lengthOf` earlier in the chain to assert that the target's `length` - * or `size` is less than or equal to the given number `n`. - * - * expect('foo').to.have.lengthOf(3); // Recommended - * expect('foo').to.have.lengthOf.at.most(4); // Not recommended - * - * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended - * expect([1, 2, 3]).to.have.lengthOf.at.most(4); // Not recommended - * - * Add `.not` earlier in the chain to negate `.most`. - * - * expect(2).to.equal(2); // Recommended - * expect(2).to.not.be.at.most(1); // Not recommended - * - * `.most` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect(2).to.be.at.most(1, 'nooo why fail??'); - * expect(2, 'nooo why fail??').to.be.at.most(1); - * - * The aliases `.lte` and `.lessThanOrEqual` can be used interchangeably with - * `.most`. - * - * @name most - * @alias lte - * @alias lessThanOrEqual - * @param {Number} n - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertMost (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , doLength = flag(this, 'doLength') - , flagMsg = flag(this, 'message') - , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '') - , ssfi = flag(this, 'ssfi') - , objType = _.type(obj).toLowerCase() - , nType = _.type(n).toLowerCase() - , errorMessage - , shouldThrow = true; - - if (doLength && objType !== 'map' && objType !== 'set') { - new Assertion(obj, flagMsg, ssfi, true).to.have.property('length'); - } - - if (!doLength && (objType === 'date' && nType !== 'date')) { - errorMessage = msgPrefix + 'the argument to most must be a date'; - } else if (nType !== 'number' && (doLength || objType === 'number')) { - errorMessage = msgPrefix + 'the argument to most must be a number'; - } else if (!doLength && (objType !== 'date' && objType !== 'number')) { - var printObj = (objType === 'string') ? "'" + obj + "'" : obj; - errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date'; - } else { - shouldThrow = false; - } - - if (shouldThrow) { - throw new AssertionError(errorMessage, undefined, ssfi); - } - - if (doLength) { - var descriptor = 'length' - , itemsCount; - if (objType === 'map' || objType === 'set') { - descriptor = 'size'; - itemsCount = obj.size; - } else { - itemsCount = obj.length; - } - this.assert( - itemsCount <= n - , 'expected #{this} to have a ' + descriptor + ' at most #{exp} but got #{act}' - , 'expected #{this} to have a ' + descriptor + ' above #{exp}' - , n - , itemsCount - ); - } else { - this.assert( - obj <= n - , 'expected #{this} to be at most #{exp}' - , 'expected #{this} to be above #{exp}' - , n - ); - } - } - - Assertion.addMethod('most', assertMost); - Assertion.addMethod('lte', assertMost); - Assertion.addMethod('lessThanOrEqual', assertMost); - - /** - * ### .within(start, finish[, msg]) - * - * Asserts that the target is a number or a date greater than or equal to the given - * number or date `start`, and less than or equal to the given number or date `finish` respectively. - * However, it's often best to assert that the target is equal to its expected - * value. - * - * expect(2).to.equal(2); // Recommended - * expect(2).to.be.within(1, 3); // Not recommended - * expect(2).to.be.within(2, 3); // Not recommended - * expect(2).to.be.within(1, 2); // Not recommended - * - * Add `.lengthOf` earlier in the chain to assert that the target's `length` - * or `size` is greater than or equal to the given number `start`, and less - * than or equal to the given number `finish`. - * - * expect('foo').to.have.lengthOf(3); // Recommended - * expect('foo').to.have.lengthOf.within(2, 4); // Not recommended - * - * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended - * expect([1, 2, 3]).to.have.lengthOf.within(2, 4); // Not recommended - * - * Add `.not` earlier in the chain to negate `.within`. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.within(2, 4); // Not recommended - * - * `.within` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect(4).to.be.within(1, 3, 'nooo why fail??'); - * expect(4, 'nooo why fail??').to.be.within(1, 3); - * - * @name within - * @param {Number} start lower bound inclusive - * @param {Number} finish upper bound inclusive - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - Assertion.addMethod('within', function (start, finish, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , doLength = flag(this, 'doLength') - , flagMsg = flag(this, 'message') - , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '') - , ssfi = flag(this, 'ssfi') - , objType = _.type(obj).toLowerCase() - , startType = _.type(start).toLowerCase() - , finishType = _.type(finish).toLowerCase() - , errorMessage - , shouldThrow = true - , range = (startType === 'date' && finishType === 'date') - ? start.toISOString() + '..' + finish.toISOString() - : start + '..' + finish; - - if (doLength && objType !== 'map' && objType !== 'set') { - new Assertion(obj, flagMsg, ssfi, true).to.have.property('length'); - } - - if (!doLength && (objType === 'date' && (startType !== 'date' || finishType !== 'date'))) { - errorMessage = msgPrefix + 'the arguments to within must be dates'; - } else if ((startType !== 'number' || finishType !== 'number') && (doLength || objType === 'number')) { - errorMessage = msgPrefix + 'the arguments to within must be numbers'; - } else if (!doLength && (objType !== 'date' && objType !== 'number')) { - var printObj = (objType === 'string') ? "'" + obj + "'" : obj; - errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date'; - } else { - shouldThrow = false; - } - - if (shouldThrow) { - throw new AssertionError(errorMessage, undefined, ssfi); - } - - if (doLength) { - var descriptor = 'length' - , itemsCount; - if (objType === 'map' || objType === 'set') { - descriptor = 'size'; - itemsCount = obj.size; - } else { - itemsCount = obj.length; - } - this.assert( - itemsCount >= start && itemsCount <= finish - , 'expected #{this} to have a ' + descriptor + ' within ' + range - , 'expected #{this} to not have a ' + descriptor + ' within ' + range - ); - } else { - this.assert( - obj >= start && obj <= finish - , 'expected #{this} to be within ' + range - , 'expected #{this} to not be within ' + range - ); - } - }); - - /** - * ### .instanceof(constructor[, msg]) - * - * Asserts that the target is an instance of the given `constructor`. - * - * function Cat () { } - * - * expect(new Cat()).to.be.an.instanceof(Cat); - * expect([1, 2]).to.be.an.instanceof(Array); - * - * Add `.not` earlier in the chain to negate `.instanceof`. - * - * expect({a: 1}).to.not.be.an.instanceof(Array); - * - * `.instanceof` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect(1).to.be.an.instanceof(Array, 'nooo why fail??'); - * expect(1, 'nooo why fail??').to.be.an.instanceof(Array); - * - * Due to limitations in ES5, `.instanceof` may not always work as expected - * when using a transpiler such as Babel or TypeScript. In particular, it may - * produce unexpected results when subclassing built-in object such as - * `Array`, `Error`, and `Map`. See your transpiler's docs for details: - * - * - ([Babel](https://babeljs.io/docs/usage/caveats/#classes)) - * - ([TypeScript](https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work)) - * - * The alias `.instanceOf` can be used interchangeably with `.instanceof`. - * - * @name instanceof - * @param {Constructor} constructor - * @param {String} msg _optional_ - * @alias instanceOf - * @namespace BDD - * @api public - */ - - function assertInstanceOf (constructor, msg) { - if (msg) flag(this, 'message', msg); - - var target = flag(this, 'object') - var ssfi = flag(this, 'ssfi'); - var flagMsg = flag(this, 'message'); - - try { - var isInstanceOf = target instanceof constructor; - } catch (err) { - if (err instanceof TypeError) { - flagMsg = flagMsg ? flagMsg + ': ' : ''; - throw new AssertionError( - flagMsg + 'The instanceof assertion needs a constructor but ' - + _.type(constructor) + ' was given.', - undefined, - ssfi - ); - } - throw err; - } - - var name = _.getName(constructor); - if (name === null) { - name = 'an unnamed constructor'; - } - - this.assert( - isInstanceOf - , 'expected #{this} to be an instance of ' + name - , 'expected #{this} to not be an instance of ' + name - ); - }; - - Assertion.addMethod('instanceof', assertInstanceOf); - Assertion.addMethod('instanceOf', assertInstanceOf); - - /** - * ### .property(name[, val[, msg]]) - * - * Asserts that the target has a property with the given key `name`. - * - * expect({a: 1}).to.have.property('a'); - * - * When `val` is provided, `.property` also asserts that the property's value - * is equal to the given `val`. - * - * expect({a: 1}).to.have.property('a', 1); - * - * By default, strict (`===`) equality is used. Add `.deep` earlier in the - * chain to use deep equality instead. See the `deep-eql` project page for - * info on the deep equality algorithm: https://github.com/chaijs/deep-eql. - * - * // Target object deeply (but not strictly) has property `x: {a: 1}` - * expect({x: {a: 1}}).to.have.deep.property('x', {a: 1}); - * expect({x: {a: 1}}).to.not.have.property('x', {a: 1}); - * - * The target's enumerable and non-enumerable properties are always included - * in the search. By default, both own and inherited properties are included. - * Add `.own` earlier in the chain to exclude inherited properties from the - * search. - * - * Object.prototype.b = 2; - * - * expect({a: 1}).to.have.own.property('a'); - * expect({a: 1}).to.have.own.property('a', 1); - * expect({a: 1}).to.have.property('b'); - * expect({a: 1}).to.not.have.own.property('b'); - * - * `.deep` and `.own` can be combined. - * - * expect({x: {a: 1}}).to.have.deep.own.property('x', {a: 1}); - * - * Add `.nested` earlier in the chain to enable dot- and bracket-notation when - * referencing nested properties. - * - * expect({a: {b: ['x', 'y']}}).to.have.nested.property('a.b[1]'); - * expect({a: {b: ['x', 'y']}}).to.have.nested.property('a.b[1]', 'y'); - * - * If `.` or `[]` are part of an actual property name, they can be escaped by - * adding two backslashes before them. - * - * expect({'.a': {'[b]': 'x'}}).to.have.nested.property('\\.a.\\[b\\]'); - * - * `.deep` and `.nested` can be combined. - * - * expect({a: {b: [{c: 3}]}}) - * .to.have.deep.nested.property('a.b[0]', {c: 3}); - * - * `.own` and `.nested` cannot be combined. - * - * Add `.not` earlier in the chain to negate `.property`. - * - * expect({a: 1}).to.not.have.property('b'); - * - * However, it's dangerous to negate `.property` when providing `val`. The - * problem is that it creates uncertain expectations by asserting that the - * target either doesn't have a property with the given key `name`, or that it - * does have a property with the given key `name` but its value isn't equal to - * the given `val`. It's often best to identify the exact output that's - * expected, and then write an assertion that only accepts that exact output. - * - * When the target isn't expected to have a property with the given key - * `name`, it's often best to assert exactly that. - * - * expect({b: 2}).to.not.have.property('a'); // Recommended - * expect({b: 2}).to.not.have.property('a', 1); // Not recommended - * - * When the target is expected to have a property with the given key `name`, - * it's often best to assert that the property has its expected value, rather - * than asserting that it doesn't have one of many unexpected values. - * - * expect({a: 3}).to.have.property('a', 3); // Recommended - * expect({a: 3}).to.not.have.property('a', 1); // Not recommended - * - * `.property` changes the target of any assertions that follow in the chain - * to be the value of the property from the original target object. - * - * expect({a: 1}).to.have.property('a').that.is.a('number'); - * - * `.property` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. When not providing `val`, only use the - * second form. - * - * // Recommended - * expect({a: 1}).to.have.property('a', 2, 'nooo why fail??'); - * expect({a: 1}, 'nooo why fail??').to.have.property('a', 2); - * expect({a: 1}, 'nooo why fail??').to.have.property('b'); - * - * // Not recommended - * expect({a: 1}).to.have.property('b', undefined, 'nooo why fail??'); - * - * The above assertion isn't the same thing as not providing `val`. Instead, - * it's asserting that the target object has a `b` property that's equal to - * `undefined`. - * - * The assertions `.ownProperty` and `.haveOwnProperty` can be used - * interchangeably with `.own.property`. - * - * @name property - * @param {String} name - * @param {Mixed} val (optional) - * @param {String} msg _optional_ - * @returns value of property for chaining - * @namespace BDD - * @api public - */ - - function assertProperty (name, val, msg) { - if (msg) flag(this, 'message', msg); - - var isNested = flag(this, 'nested') - , isOwn = flag(this, 'own') - , flagMsg = flag(this, 'message') - , obj = flag(this, 'object') - , ssfi = flag(this, 'ssfi') - , nameType = typeof name; - - flagMsg = flagMsg ? flagMsg + ': ' : ''; - - if (isNested) { - if (nameType !== 'string') { - throw new AssertionError( - flagMsg + 'the argument to property must be a string when using nested syntax', - undefined, - ssfi - ); - } - } else { - if (nameType !== 'string' && nameType !== 'number' && nameType !== 'symbol') { - throw new AssertionError( - flagMsg + 'the argument to property must be a string, number, or symbol', - undefined, - ssfi - ); - } - } - - if (isNested && isOwn) { - throw new AssertionError( - flagMsg + 'The "nested" and "own" flags cannot be combined.', - undefined, - ssfi - ); - } - - if (obj === null || obj === undefined) { - throw new AssertionError( - flagMsg + 'Target cannot be null or undefined.', - undefined, - ssfi - ); - } - - var isDeep = flag(this, 'deep') - , negate = flag(this, 'negate') - , pathInfo = isNested ? _.getPathInfo(obj, name) : null - , value = isNested ? pathInfo.value : obj[name]; - - var descriptor = ''; - if (isDeep) descriptor += 'deep '; - if (isOwn) descriptor += 'own '; - if (isNested) descriptor += 'nested '; - descriptor += 'property '; - - var hasProperty; - if (isOwn) hasProperty = Object.prototype.hasOwnProperty.call(obj, name); - else if (isNested) hasProperty = pathInfo.exists; - else hasProperty = _.hasProperty(obj, name); - - // When performing a negated assertion for both name and val, merely having - // a property with the given name isn't enough to cause the assertion to - // fail. It must both have a property with the given name, and the value of - // that property must equal the given val. Therefore, skip this assertion in - // favor of the next. - if (!negate || arguments.length === 1) { - this.assert( - hasProperty - , 'expected #{this} to have ' + descriptor + _.inspect(name) - , 'expected #{this} to not have ' + descriptor + _.inspect(name)); - } - - if (arguments.length > 1) { - this.assert( - hasProperty && (isDeep ? _.eql(val, value) : val === value) - , 'expected #{this} to have ' + descriptor + _.inspect(name) + ' of #{exp}, but got #{act}' - , 'expected #{this} to not have ' + descriptor + _.inspect(name) + ' of #{act}' - , val - , value - ); - } - - flag(this, 'object', value); - } - - Assertion.addMethod('property', assertProperty); - - function assertOwnProperty (name, value, msg) { - flag(this, 'own', true); - assertProperty.apply(this, arguments); - } - - Assertion.addMethod('ownProperty', assertOwnProperty); - Assertion.addMethod('haveOwnProperty', assertOwnProperty); - - /** - * ### .ownPropertyDescriptor(name[, descriptor[, msg]]) - * - * Asserts that the target has its own property descriptor with the given key - * `name`. Enumerable and non-enumerable properties are included in the - * search. - * - * expect({a: 1}).to.have.ownPropertyDescriptor('a'); - * - * When `descriptor` is provided, `.ownPropertyDescriptor` also asserts that - * the property's descriptor is deeply equal to the given `descriptor`. See - * the `deep-eql` project page for info on the deep equality algorithm: - * https://github.com/chaijs/deep-eql. - * - * expect({a: 1}).to.have.ownPropertyDescriptor('a', { - * configurable: true, - * enumerable: true, - * writable: true, - * value: 1, - * }); - * - * Add `.not` earlier in the chain to negate `.ownPropertyDescriptor`. - * - * expect({a: 1}).to.not.have.ownPropertyDescriptor('b'); - * - * However, it's dangerous to negate `.ownPropertyDescriptor` when providing - * a `descriptor`. The problem is that it creates uncertain expectations by - * asserting that the target either doesn't have a property descriptor with - * the given key `name`, or that it does have a property descriptor with the - * given key `name` but it’s not deeply equal to the given `descriptor`. It's - * often best to identify the exact output that's expected, and then write an - * assertion that only accepts that exact output. - * - * When the target isn't expected to have a property descriptor with the given - * key `name`, it's often best to assert exactly that. - * - * // Recommended - * expect({b: 2}).to.not.have.ownPropertyDescriptor('a'); - * - * // Not recommended - * expect({b: 2}).to.not.have.ownPropertyDescriptor('a', { - * configurable: true, - * enumerable: true, - * writable: true, - * value: 1, - * }); - * - * When the target is expected to have a property descriptor with the given - * key `name`, it's often best to assert that the property has its expected - * descriptor, rather than asserting that it doesn't have one of many - * unexpected descriptors. - * - * // Recommended - * expect({a: 3}).to.have.ownPropertyDescriptor('a', { - * configurable: true, - * enumerable: true, - * writable: true, - * value: 3, - * }); - * - * // Not recommended - * expect({a: 3}).to.not.have.ownPropertyDescriptor('a', { - * configurable: true, - * enumerable: true, - * writable: true, - * value: 1, - * }); - * - * `.ownPropertyDescriptor` changes the target of any assertions that follow - * in the chain to be the value of the property descriptor from the original - * target object. - * - * expect({a: 1}).to.have.ownPropertyDescriptor('a') - * .that.has.property('enumerable', true); - * - * `.ownPropertyDescriptor` accepts an optional `msg` argument which is a - * custom error message to show when the assertion fails. The message can also - * be given as the second argument to `expect`. When not providing - * `descriptor`, only use the second form. - * - * // Recommended - * expect({a: 1}).to.have.ownPropertyDescriptor('a', { - * configurable: true, - * enumerable: true, - * writable: true, - * value: 2, - * }, 'nooo why fail??'); - * - * // Recommended - * expect({a: 1}, 'nooo why fail??').to.have.ownPropertyDescriptor('a', { - * configurable: true, - * enumerable: true, - * writable: true, - * value: 2, - * }); - * - * // Recommended - * expect({a: 1}, 'nooo why fail??').to.have.ownPropertyDescriptor('b'); - * - * // Not recommended - * expect({a: 1}) - * .to.have.ownPropertyDescriptor('b', undefined, 'nooo why fail??'); - * - * The above assertion isn't the same thing as not providing `descriptor`. - * Instead, it's asserting that the target object has a `b` property - * descriptor that's deeply equal to `undefined`. - * - * The alias `.haveOwnPropertyDescriptor` can be used interchangeably with - * `.ownPropertyDescriptor`. - * - * @name ownPropertyDescriptor - * @alias haveOwnPropertyDescriptor - * @param {String} name - * @param {Object} descriptor _optional_ - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertOwnPropertyDescriptor (name, descriptor, msg) { - if (typeof descriptor === 'string') { - msg = descriptor; - descriptor = null; - } - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - var actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name); - if (actualDescriptor && descriptor) { - this.assert( - _.eql(descriptor, actualDescriptor) - , 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to match ' + _.inspect(descriptor) + ', got ' + _.inspect(actualDescriptor) - , 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to not match ' + _.inspect(descriptor) - , descriptor - , actualDescriptor - , true - ); - } else { - this.assert( - actualDescriptor - , 'expected #{this} to have an own property descriptor for ' + _.inspect(name) - , 'expected #{this} to not have an own property descriptor for ' + _.inspect(name) - ); - } - flag(this, 'object', actualDescriptor); - } - - Assertion.addMethod('ownPropertyDescriptor', assertOwnPropertyDescriptor); - Assertion.addMethod('haveOwnPropertyDescriptor', assertOwnPropertyDescriptor); - - /** - * ### .lengthOf(n[, msg]) - * - * Asserts that the target's `length` or `size` is equal to the given number - * `n`. - * - * expect([1, 2, 3]).to.have.lengthOf(3); - * expect('foo').to.have.lengthOf(3); - * expect(new Set([1, 2, 3])).to.have.lengthOf(3); - * expect(new Map([['a', 1], ['b', 2], ['c', 3]])).to.have.lengthOf(3); - * - * Add `.not` earlier in the chain to negate `.lengthOf`. However, it's often - * best to assert that the target's `length` property is equal to its expected - * value, rather than not equal to one of many unexpected values. - * - * expect('foo').to.have.lengthOf(3); // Recommended - * expect('foo').to.not.have.lengthOf(4); // Not recommended - * - * `.lengthOf` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect([1, 2, 3]).to.have.lengthOf(2, 'nooo why fail??'); - * expect([1, 2, 3], 'nooo why fail??').to.have.lengthOf(2); - * - * `.lengthOf` can also be used as a language chain, causing all `.above`, - * `.below`, `.least`, `.most`, and `.within` assertions that follow in the - * chain to use the target's `length` property as the target. However, it's - * often best to assert that the target's `length` property is equal to its - * expected length, rather than asserting that its `length` property falls - * within some range of values. - * - * // Recommended - * expect([1, 2, 3]).to.have.lengthOf(3); - * - * // Not recommended - * expect([1, 2, 3]).to.have.lengthOf.above(2); - * expect([1, 2, 3]).to.have.lengthOf.below(4); - * expect([1, 2, 3]).to.have.lengthOf.at.least(3); - * expect([1, 2, 3]).to.have.lengthOf.at.most(3); - * expect([1, 2, 3]).to.have.lengthOf.within(2,4); - * - * Due to a compatibility issue, the alias `.length` can't be chained directly - * off of an uninvoked method such as `.a`. Therefore, `.length` can't be used - * interchangeably with `.lengthOf` in every situation. It's recommended to - * always use `.lengthOf` instead of `.length`. - * - * expect([1, 2, 3]).to.have.a.length(3); // incompatible; throws error - * expect([1, 2, 3]).to.have.a.lengthOf(3); // passes as expected - * - * @name lengthOf - * @alias length - * @param {Number} n - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertLengthChain () { - flag(this, 'doLength', true); - } - - function assertLength (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , objType = _.type(obj).toLowerCase() - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi') - , descriptor = 'length' - , itemsCount; - - switch (objType) { - case 'map': - case 'set': - descriptor = 'size'; - itemsCount = obj.size; - break; - default: - new Assertion(obj, flagMsg, ssfi, true).to.have.property('length'); - itemsCount = obj.length; - } - - this.assert( - itemsCount == n - , 'expected #{this} to have a ' + descriptor + ' of #{exp} but got #{act}' - , 'expected #{this} to not have a ' + descriptor + ' of #{act}' - , n - , itemsCount - ); - } - - Assertion.addChainableMethod('length', assertLength, assertLengthChain); - Assertion.addChainableMethod('lengthOf', assertLength, assertLengthChain); - - /** - * ### .match(re[, msg]) - * - * Asserts that the target matches the given regular expression `re`. - * - * expect('foobar').to.match(/^foo/); - * - * Add `.not` earlier in the chain to negate `.match`. - * - * expect('foobar').to.not.match(/taco/); - * - * `.match` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect('foobar').to.match(/taco/, 'nooo why fail??'); - * expect('foobar', 'nooo why fail??').to.match(/taco/); - * - * The alias `.matches` can be used interchangeably with `.match`. - * - * @name match - * @alias matches - * @param {RegExp} re - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - function assertMatch(re, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - this.assert( - re.exec(obj) - , 'expected #{this} to match ' + re - , 'expected #{this} not to match ' + re - ); - } - - Assertion.addMethod('match', assertMatch); - Assertion.addMethod('matches', assertMatch); - - /** - * ### .string(str[, msg]) - * - * Asserts that the target string contains the given substring `str`. - * - * expect('foobar').to.have.string('bar'); - * - * Add `.not` earlier in the chain to negate `.string`. - * - * expect('foobar').to.not.have.string('taco'); - * - * `.string` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect('foobar').to.have.string('taco', 'nooo why fail??'); - * expect('foobar', 'nooo why fail??').to.have.string('taco'); - * - * @name string - * @param {String} str - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - Assertion.addMethod('string', function (str, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi'); - new Assertion(obj, flagMsg, ssfi, true).is.a('string'); - - this.assert( - ~obj.indexOf(str) - , 'expected #{this} to contain ' + _.inspect(str) - , 'expected #{this} to not contain ' + _.inspect(str) - ); - }); - - /** - * ### .keys(key1[, key2[, ...]]) - * - * Asserts that the target object, array, map, or set has the given keys. Only - * the target's own inherited properties are included in the search. - * - * When the target is an object or array, keys can be provided as one or more - * string arguments, a single array argument, or a single object argument. In - * the latter case, only the keys in the given object matter; the values are - * ignored. - * - * expect({a: 1, b: 2}).to.have.all.keys('a', 'b'); - * expect(['x', 'y']).to.have.all.keys(0, 1); - * - * expect({a: 1, b: 2}).to.have.all.keys(['a', 'b']); - * expect(['x', 'y']).to.have.all.keys([0, 1]); - * - * expect({a: 1, b: 2}).to.have.all.keys({a: 4, b: 5}); // ignore 4 and 5 - * expect(['x', 'y']).to.have.all.keys({0: 4, 1: 5}); // ignore 4 and 5 - * - * When the target is a map or set, each key must be provided as a separate - * argument. - * - * expect(new Map([['a', 1], ['b', 2]])).to.have.all.keys('a', 'b'); - * expect(new Set(['a', 'b'])).to.have.all.keys('a', 'b'); - * - * Because `.keys` does different things based on the target's type, it's - * important to check the target's type before using `.keys`. See the `.a` doc - * for info on testing a target's type. - * - * expect({a: 1, b: 2}).to.be.an('object').that.has.all.keys('a', 'b'); - * - * By default, strict (`===`) equality is used to compare keys of maps and - * sets. Add `.deep` earlier in the chain to use deep equality instead. See - * the `deep-eql` project page for info on the deep equality algorithm: - * https://github.com/chaijs/deep-eql. - * - * // Target set deeply (but not strictly) has key `{a: 1}` - * expect(new Set([{a: 1}])).to.have.all.deep.keys([{a: 1}]); - * expect(new Set([{a: 1}])).to.not.have.all.keys([{a: 1}]); - * - * By default, the target must have all of the given keys and no more. Add - * `.any` earlier in the chain to only require that the target have at least - * one of the given keys. Also, add `.not` earlier in the chain to negate - * `.keys`. It's often best to add `.any` when negating `.keys`, and to use - * `.all` when asserting `.keys` without negation. - * - * When negating `.keys`, `.any` is preferred because `.not.any.keys` asserts - * exactly what's expected of the output, whereas `.not.all.keys` creates - * uncertain expectations. - * - * // Recommended; asserts that target doesn't have any of the given keys - * expect({a: 1, b: 2}).to.not.have.any.keys('c', 'd'); - * - * // Not recommended; asserts that target doesn't have all of the given - * // keys but may or may not have some of them - * expect({a: 1, b: 2}).to.not.have.all.keys('c', 'd'); - * - * When asserting `.keys` without negation, `.all` is preferred because - * `.all.keys` asserts exactly what's expected of the output, whereas - * `.any.keys` creates uncertain expectations. - * - * // Recommended; asserts that target has all the given keys - * expect({a: 1, b: 2}).to.have.all.keys('a', 'b'); - * - * // Not recommended; asserts that target has at least one of the given - * // keys but may or may not have more of them - * expect({a: 1, b: 2}).to.have.any.keys('a', 'b'); - * - * Note that `.all` is used by default when neither `.all` nor `.any` appear - * earlier in the chain. However, it's often best to add `.all` anyway because - * it improves readability. - * - * // Both assertions are identical - * expect({a: 1, b: 2}).to.have.all.keys('a', 'b'); // Recommended - * expect({a: 1, b: 2}).to.have.keys('a', 'b'); // Not recommended - * - * Add `.include` earlier in the chain to require that the target's keys be a - * superset of the expected keys, rather than identical sets. - * - * // Target object's keys are a superset of ['a', 'b'] but not identical - * expect({a: 1, b: 2, c: 3}).to.include.all.keys('a', 'b'); - * expect({a: 1, b: 2, c: 3}).to.not.have.all.keys('a', 'b'); - * - * However, if `.any` and `.include` are combined, only the `.any` takes - * effect. The `.include` is ignored in this case. - * - * // Both assertions are identical - * expect({a: 1}).to.have.any.keys('a', 'b'); - * expect({a: 1}).to.include.any.keys('a', 'b'); - * - * A custom error message can be given as the second argument to `expect`. - * - * expect({a: 1}, 'nooo why fail??').to.have.key('b'); - * - * The alias `.key` can be used interchangeably with `.keys`. - * - * @name keys - * @alias key - * @param {...String|Array|Object} keys - * @namespace BDD - * @api public - */ - - function assertKeys (keys) { - var obj = flag(this, 'object') - , objType = _.type(obj) - , keysType = _.type(keys) - , ssfi = flag(this, 'ssfi') - , isDeep = flag(this, 'deep') - , str - , deepStr = '' - , actual - , ok = true - , flagMsg = flag(this, 'message'); - - flagMsg = flagMsg ? flagMsg + ': ' : ''; - var mixedArgsMsg = flagMsg + 'when testing keys against an object or an array you must give a single Array|Object|String argument or multiple String arguments'; - - if (objType === 'Map' || objType === 'Set') { - deepStr = isDeep ? 'deeply ' : ''; - actual = []; - - // Map and Set '.keys' aren't supported in IE 11. Therefore, use .forEach. - obj.forEach(function (val, key) { actual.push(key) }); - - if (keysType !== 'Array') { - keys = Array.prototype.slice.call(arguments); - } - } else { - actual = _.getOwnEnumerableProperties(obj); - - switch (keysType) { - case 'Array': - if (arguments.length > 1) { - throw new AssertionError(mixedArgsMsg, undefined, ssfi); - } - break; - case 'Object': - if (arguments.length > 1) { - throw new AssertionError(mixedArgsMsg, undefined, ssfi); - } - keys = Object.keys(keys); - break; - default: - keys = Array.prototype.slice.call(arguments); - } - - // Only stringify non-Symbols because Symbols would become "Symbol()" - keys = keys.map(function (val) { - return typeof val === 'symbol' ? val : String(val); - }); - } - - if (!keys.length) { - throw new AssertionError(flagMsg + 'keys required', undefined, ssfi); - } - - var len = keys.length - , any = flag(this, 'any') - , all = flag(this, 'all') - , expected = keys; - - if (!any && !all) { - all = true; - } - - // Has any - if (any) { - ok = expected.some(function(expectedKey) { - return actual.some(function(actualKey) { - if (isDeep) { - return _.eql(expectedKey, actualKey); - } else { - return expectedKey === actualKey; - } - }); - }); - } - - // Has all - if (all) { - ok = expected.every(function(expectedKey) { - return actual.some(function(actualKey) { - if (isDeep) { - return _.eql(expectedKey, actualKey); - } else { - return expectedKey === actualKey; - } - }); - }); - - if (!flag(this, 'contains')) { - ok = ok && keys.length == actual.length; - } - } - - // Key string - if (len > 1) { - keys = keys.map(function(key) { - return _.inspect(key); - }); - var last = keys.pop(); - if (all) { - str = keys.join(', ') + ', and ' + last; - } - if (any) { - str = keys.join(', ') + ', or ' + last; - } - } else { - str = _.inspect(keys[0]); - } - - // Form - str = (len > 1 ? 'keys ' : 'key ') + str; - - // Have / include - str = (flag(this, 'contains') ? 'contain ' : 'have ') + str; - - // Assertion - this.assert( - ok - , 'expected #{this} to ' + deepStr + str - , 'expected #{this} to not ' + deepStr + str - , expected.slice(0).sort(_.compareByInspect) - , actual.sort(_.compareByInspect) - , true - ); - } - - Assertion.addMethod('keys', assertKeys); - Assertion.addMethod('key', assertKeys); - - /** - * ### .throw([errorLike], [errMsgMatcher], [msg]) - * - * When no arguments are provided, `.throw` invokes the target function and - * asserts that an error is thrown. - * - * var badFn = function () { throw new TypeError('Illegal salmon!'); }; - * - * expect(badFn).to.throw(); - * - * When one argument is provided, and it's an error constructor, `.throw` - * invokes the target function and asserts that an error is thrown that's an - * instance of that error constructor. - * - * var badFn = function () { throw new TypeError('Illegal salmon!'); }; - * - * expect(badFn).to.throw(TypeError); - * - * When one argument is provided, and it's an error instance, `.throw` invokes - * the target function and asserts that an error is thrown that's strictly - * (`===`) equal to that error instance. - * - * var err = new TypeError('Illegal salmon!'); - * var badFn = function () { throw err; }; - * - * expect(badFn).to.throw(err); - * - * When one argument is provided, and it's a string, `.throw` invokes the - * target function and asserts that an error is thrown with a message that - * contains that string. - * - * var badFn = function () { throw new TypeError('Illegal salmon!'); }; - * - * expect(badFn).to.throw('salmon'); - * - * When one argument is provided, and it's a regular expression, `.throw` - * invokes the target function and asserts that an error is thrown with a - * message that matches that regular expression. - * - * var badFn = function () { throw new TypeError('Illegal salmon!'); }; - * - * expect(badFn).to.throw(/salmon/); - * - * When two arguments are provided, and the first is an error instance or - * constructor, and the second is a string or regular expression, `.throw` - * invokes the function and asserts that an error is thrown that fulfills both - * conditions as described above. - * - * var err = new TypeError('Illegal salmon!'); - * var badFn = function () { throw err; }; - * - * expect(badFn).to.throw(TypeError, 'salmon'); - * expect(badFn).to.throw(TypeError, /salmon/); - * expect(badFn).to.throw(err, 'salmon'); - * expect(badFn).to.throw(err, /salmon/); - * - * Add `.not` earlier in the chain to negate `.throw`. - * - * var goodFn = function () {}; - * - * expect(goodFn).to.not.throw(); - * - * However, it's dangerous to negate `.throw` when providing any arguments. - * The problem is that it creates uncertain expectations by asserting that the - * target either doesn't throw an error, or that it throws an error but of a - * different type than the given type, or that it throws an error of the given - * type but with a message that doesn't include the given string. It's often - * best to identify the exact output that's expected, and then write an - * assertion that only accepts that exact output. - * - * When the target isn't expected to throw an error, it's often best to assert - * exactly that. - * - * var goodFn = function () {}; - * - * expect(goodFn).to.not.throw(); // Recommended - * expect(goodFn).to.not.throw(ReferenceError, 'x'); // Not recommended - * - * When the target is expected to throw an error, it's often best to assert - * that the error is of its expected type, and has a message that includes an - * expected string, rather than asserting that it doesn't have one of many - * unexpected types, and doesn't have a message that includes some string. - * - * var badFn = function () { throw new TypeError('Illegal salmon!'); }; - * - * expect(badFn).to.throw(TypeError, 'salmon'); // Recommended - * expect(badFn).to.not.throw(ReferenceError, 'x'); // Not recommended - * - * `.throw` changes the target of any assertions that follow in the chain to - * be the error object that's thrown. - * - * var err = new TypeError('Illegal salmon!'); - * err.code = 42; - * var badFn = function () { throw err; }; - * - * expect(badFn).to.throw(TypeError).with.property('code', 42); - * - * `.throw` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. When not providing two arguments, always use - * the second form. - * - * var goodFn = function () {}; - * - * expect(goodFn).to.throw(TypeError, 'x', 'nooo why fail??'); - * expect(goodFn, 'nooo why fail??').to.throw(); - * - * Due to limitations in ES5, `.throw` may not always work as expected when - * using a transpiler such as Babel or TypeScript. In particular, it may - * produce unexpected results when subclassing the built-in `Error` object and - * then passing the subclassed constructor to `.throw`. See your transpiler's - * docs for details: - * - * - ([Babel](https://babeljs.io/docs/usage/caveats/#classes)) - * - ([TypeScript](https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work)) - * - * Beware of some common mistakes when using the `throw` assertion. One common - * mistake is to accidentally invoke the function yourself instead of letting - * the `throw` assertion invoke the function for you. For example, when - * testing if a function named `fn` throws, provide `fn` instead of `fn()` as - * the target for the assertion. - * - * expect(fn).to.throw(); // Good! Tests `fn` as desired - * expect(fn()).to.throw(); // Bad! Tests result of `fn()`, not `fn` - * - * If you need to assert that your function `fn` throws when passed certain - * arguments, then wrap a call to `fn` inside of another function. - * - * expect(function () { fn(42); }).to.throw(); // Function expression - * expect(() => fn(42)).to.throw(); // ES6 arrow function - * - * Another common mistake is to provide an object method (or any stand-alone - * function that relies on `this`) as the target of the assertion. Doing so is - * problematic because the `this` context will be lost when the function is - * invoked by `.throw`; there's no way for it to know what `this` is supposed - * to be. There are two ways around this problem. One solution is to wrap the - * method or function call inside of another function. Another solution is to - * use `bind`. - * - * expect(function () { cat.meow(); }).to.throw(); // Function expression - * expect(() => cat.meow()).to.throw(); // ES6 arrow function - * expect(cat.meow.bind(cat)).to.throw(); // Bind - * - * Finally, it's worth mentioning that it's a best practice in JavaScript to - * only throw `Error` and derivatives of `Error` such as `ReferenceError`, - * `TypeError`, and user-defined objects that extend `Error`. No other type of - * value will generate a stack trace when initialized. With that said, the - * `throw` assertion does technically support any type of value being thrown, - * not just `Error` and its derivatives. - * - * The aliases `.throws` and `.Throw` can be used interchangeably with - * `.throw`. - * - * @name throw - * @alias throws - * @alias Throw - * @param {Error|ErrorConstructor} errorLike - * @param {String|RegExp} errMsgMatcher error message - * @param {String} msg _optional_ - * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types - * @returns error for chaining (null if no error) - * @namespace BDD - * @api public - */ - - function assertThrows (errorLike, errMsgMatcher, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , ssfi = flag(this, 'ssfi') - , flagMsg = flag(this, 'message') - , negate = flag(this, 'negate') || false; - new Assertion(obj, flagMsg, ssfi, true).is.a('function'); - - if (errorLike instanceof RegExp || typeof errorLike === 'string') { - errMsgMatcher = errorLike; - errorLike = null; - } - - var caughtErr; - try { - obj(); - } catch (err) { - caughtErr = err; - } - - // If we have the negate flag enabled and at least one valid argument it means we do expect an error - // but we want it to match a given set of criteria - var everyArgIsUndefined = errorLike === undefined && errMsgMatcher === undefined; - - // If we've got the negate flag enabled and both args, we should only fail if both aren't compatible - // See Issue #551 and PR #683@GitHub - var everyArgIsDefined = Boolean(errorLike && errMsgMatcher); - var errorLikeFail = false; - var errMsgMatcherFail = false; - - // Checking if error was thrown - if (everyArgIsUndefined || !everyArgIsUndefined && !negate) { - // We need this to display results correctly according to their types - var errorLikeString = 'an error'; - if (errorLike instanceof Error) { - errorLikeString = '#{exp}'; - } else if (errorLike) { - errorLikeString = _.checkError.getConstructorName(errorLike); - } - - this.assert( - caughtErr - , 'expected #{this} to throw ' + errorLikeString - , 'expected #{this} to not throw an error but #{act} was thrown' - , errorLike && errorLike.toString() - , (caughtErr instanceof Error ? - caughtErr.toString() : (typeof caughtErr === 'string' ? caughtErr : caughtErr && - _.checkError.getConstructorName(caughtErr))) - ); - } - - if (errorLike && caughtErr) { - // We should compare instances only if `errorLike` is an instance of `Error` - if (errorLike instanceof Error) { - var isCompatibleInstance = _.checkError.compatibleInstance(caughtErr, errorLike); - - if (isCompatibleInstance === negate) { - // These checks were created to ensure we won't fail too soon when we've got both args and a negate - // See Issue #551 and PR #683@GitHub - if (everyArgIsDefined && negate) { - errorLikeFail = true; - } else { - this.assert( - negate - , 'expected #{this} to throw #{exp} but #{act} was thrown' - , 'expected #{this} to not throw #{exp}' + (caughtErr && !negate ? ' but #{act} was thrown' : '') - , errorLike.toString() - , caughtErr.toString() - ); - } - } - } - - var isCompatibleConstructor = _.checkError.compatibleConstructor(caughtErr, errorLike); - if (isCompatibleConstructor === negate) { - if (everyArgIsDefined && negate) { - errorLikeFail = true; - } else { - this.assert( - negate - , 'expected #{this} to throw #{exp} but #{act} was thrown' - , 'expected #{this} to not throw #{exp}' + (caughtErr ? ' but #{act} was thrown' : '') - , (errorLike instanceof Error ? errorLike.toString() : errorLike && _.checkError.getConstructorName(errorLike)) - , (caughtErr instanceof Error ? caughtErr.toString() : caughtErr && _.checkError.getConstructorName(caughtErr)) - ); - } - } - } - - if (caughtErr && errMsgMatcher !== undefined && errMsgMatcher !== null) { - // Here we check compatible messages - var placeholder = 'including'; - if (errMsgMatcher instanceof RegExp) { - placeholder = 'matching' - } - - var isCompatibleMessage = _.checkError.compatibleMessage(caughtErr, errMsgMatcher); - if (isCompatibleMessage === negate) { - if (everyArgIsDefined && negate) { - errMsgMatcherFail = true; - } else { - this.assert( - negate - , 'expected #{this} to throw error ' + placeholder + ' #{exp} but got #{act}' - , 'expected #{this} to throw error not ' + placeholder + ' #{exp}' - , errMsgMatcher - , _.checkError.getMessage(caughtErr) - ); - } - } - } - - // If both assertions failed and both should've matched we throw an error - if (errorLikeFail && errMsgMatcherFail) { - this.assert( - negate - , 'expected #{this} to throw #{exp} but #{act} was thrown' - , 'expected #{this} to not throw #{exp}' + (caughtErr ? ' but #{act} was thrown' : '') - , (errorLike instanceof Error ? errorLike.toString() : errorLike && _.checkError.getConstructorName(errorLike)) - , (caughtErr instanceof Error ? caughtErr.toString() : caughtErr && _.checkError.getConstructorName(caughtErr)) - ); - } - - flag(this, 'object', caughtErr); - }; - - Assertion.addMethod('throw', assertThrows); - Assertion.addMethod('throws', assertThrows); - Assertion.addMethod('Throw', assertThrows); - - /** - * ### .respondTo(method[, msg]) - * - * When the target is a non-function object, `.respondTo` asserts that the - * target has a method with the given name `method`. The method can be own or - * inherited, and it can be enumerable or non-enumerable. - * - * function Cat () {} - * Cat.prototype.meow = function () {}; - * - * expect(new Cat()).to.respondTo('meow'); - * - * When the target is a function, `.respondTo` asserts that the target's - * `prototype` property has a method with the given name `method`. Again, the - * method can be own or inherited, and it can be enumerable or non-enumerable. - * - * function Cat () {} - * Cat.prototype.meow = function () {}; - * - * expect(Cat).to.respondTo('meow'); - * - * Add `.itself` earlier in the chain to force `.respondTo` to treat the - * target as a non-function object, even if it's a function. Thus, it asserts - * that the target has a method with the given name `method`, rather than - * asserting that the target's `prototype` property has a method with the - * given name `method`. - * - * function Cat () {} - * Cat.prototype.meow = function () {}; - * Cat.hiss = function () {}; - * - * expect(Cat).itself.to.respondTo('hiss').but.not.respondTo('meow'); - * - * When not adding `.itself`, it's important to check the target's type before - * using `.respondTo`. See the `.a` doc for info on checking a target's type. - * - * function Cat () {} - * Cat.prototype.meow = function () {}; - * - * expect(new Cat()).to.be.an('object').that.respondsTo('meow'); - * - * Add `.not` earlier in the chain to negate `.respondTo`. - * - * function Dog () {} - * Dog.prototype.bark = function () {}; - * - * expect(new Dog()).to.not.respondTo('meow'); - * - * `.respondTo` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect({}).to.respondTo('meow', 'nooo why fail??'); - * expect({}, 'nooo why fail??').to.respondTo('meow'); - * - * The alias `.respondsTo` can be used interchangeably with `.respondTo`. - * - * @name respondTo - * @alias respondsTo - * @param {String} method - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function respondTo (method, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , itself = flag(this, 'itself') - , context = ('function' === typeof obj && !itself) - ? obj.prototype[method] - : obj[method]; - - this.assert( - 'function' === typeof context - , 'expected #{this} to respond to ' + _.inspect(method) - , 'expected #{this} to not respond to ' + _.inspect(method) - ); - } - - Assertion.addMethod('respondTo', respondTo); - Assertion.addMethod('respondsTo', respondTo); - - /** - * ### .itself - * - * Forces all `.respondTo` assertions that follow in the chain to behave as if - * the target is a non-function object, even if it's a function. Thus, it - * causes `.respondTo` to assert that the target has a method with the given - * name, rather than asserting that the target's `prototype` property has a - * method with the given name. - * - * function Cat () {} - * Cat.prototype.meow = function () {}; - * Cat.hiss = function () {}; - * - * expect(Cat).itself.to.respondTo('hiss').but.not.respondTo('meow'); - * - * @name itself - * @namespace BDD - * @api public - */ - - Assertion.addProperty('itself', function () { - flag(this, 'itself', true); - }); - - /** - * ### .satisfy(matcher[, msg]) - * - * Invokes the given `matcher` function with the target being passed as the - * first argument, and asserts that the value returned is truthy. - * - * expect(1).to.satisfy(function(num) { - * return num > 0; - * }); - * - * Add `.not` earlier in the chain to negate `.satisfy`. - * - * expect(1).to.not.satisfy(function(num) { - * return num > 2; - * }); - * - * `.satisfy` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect(1).to.satisfy(function(num) { - * return num > 2; - * }, 'nooo why fail??'); - * - * expect(1, 'nooo why fail??').to.satisfy(function(num) { - * return num > 2; - * }); - * - * The alias `.satisfies` can be used interchangeably with `.satisfy`. - * - * @name satisfy - * @alias satisfies - * @param {Function} matcher - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function satisfy (matcher, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - var result = matcher(obj); - this.assert( - result - , 'expected #{this} to satisfy ' + _.objDisplay(matcher) - , 'expected #{this} to not satisfy' + _.objDisplay(matcher) - , flag(this, 'negate') ? false : true - , result - ); - } - - Assertion.addMethod('satisfy', satisfy); - Assertion.addMethod('satisfies', satisfy); - - /** - * ### .closeTo(expected, delta[, msg]) - * - * Asserts that the target is a number that's within a given +/- `delta` range - * of the given number `expected`. However, it's often best to assert that the - * target is equal to its expected value. - * - * // Recommended - * expect(1.5).to.equal(1.5); - * - * // Not recommended - * expect(1.5).to.be.closeTo(1, 0.5); - * expect(1.5).to.be.closeTo(2, 0.5); - * expect(1.5).to.be.closeTo(1, 1); - * - * Add `.not` earlier in the chain to negate `.closeTo`. - * - * expect(1.5).to.equal(1.5); // Recommended - * expect(1.5).to.not.be.closeTo(3, 1); // Not recommended - * - * `.closeTo` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect(1.5).to.be.closeTo(3, 1, 'nooo why fail??'); - * expect(1.5, 'nooo why fail??').to.be.closeTo(3, 1); - * - * The alias `.approximately` can be used interchangeably with `.closeTo`. - * - * @name closeTo - * @alias approximately - * @param {Number} expected - * @param {Number} delta - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function closeTo(expected, delta, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi'); - - new Assertion(obj, flagMsg, ssfi, true).is.a('number'); - if (typeof expected !== 'number' || typeof delta !== 'number') { - flagMsg = flagMsg ? flagMsg + ': ' : ''; - var deltaMessage = delta === undefined ? ", and a delta is required" : ""; - throw new AssertionError( - flagMsg + 'the arguments to closeTo or approximately must be numbers' + deltaMessage, - undefined, - ssfi - ); - } - - this.assert( - Math.abs(obj - expected) <= delta - , 'expected #{this} to be close to ' + expected + ' +/- ' + delta - , 'expected #{this} not to be close to ' + expected + ' +/- ' + delta - ); - } - - Assertion.addMethod('closeTo', closeTo); - Assertion.addMethod('approximately', closeTo); - - // Note: Duplicates are ignored if testing for inclusion instead of sameness. - function isSubsetOf(subset, superset, cmp, contains, ordered) { - if (!contains) { - if (subset.length !== superset.length) return false; - superset = superset.slice(); - } - - return subset.every(function(elem, idx) { - if (ordered) return cmp ? cmp(elem, superset[idx]) : elem === superset[idx]; - - if (!cmp) { - var matchIdx = superset.indexOf(elem); - if (matchIdx === -1) return false; - - // Remove match from superset so not counted twice if duplicate in subset. - if (!contains) superset.splice(matchIdx, 1); - return true; - } - - return superset.some(function(elem2, matchIdx) { - if (!cmp(elem, elem2)) return false; - - // Remove match from superset so not counted twice if duplicate in subset. - if (!contains) superset.splice(matchIdx, 1); - return true; - }); - }); - } - - /** - * ### .members(set[, msg]) - * - * Asserts that the target array has the same members as the given array - * `set`. - * - * expect([1, 2, 3]).to.have.members([2, 1, 3]); - * expect([1, 2, 2]).to.have.members([2, 1, 2]); - * - * By default, members are compared using strict (`===`) equality. Add `.deep` - * earlier in the chain to use deep equality instead. See the `deep-eql` - * project page for info on the deep equality algorithm: - * https://github.com/chaijs/deep-eql. - * - * // Target array deeply (but not strictly) has member `{a: 1}` - * expect([{a: 1}]).to.have.deep.members([{a: 1}]); - * expect([{a: 1}]).to.not.have.members([{a: 1}]); - * - * By default, order doesn't matter. Add `.ordered` earlier in the chain to - * require that members appear in the same order. - * - * expect([1, 2, 3]).to.have.ordered.members([1, 2, 3]); - * expect([1, 2, 3]).to.have.members([2, 1, 3]) - * .but.not.ordered.members([2, 1, 3]); - * - * By default, both arrays must be the same size. Add `.include` earlier in - * the chain to require that the target's members be a superset of the - * expected members. Note that duplicates are ignored in the subset when - * `.include` is added. - * - * // Target array is a superset of [1, 2] but not identical - * expect([1, 2, 3]).to.include.members([1, 2]); - * expect([1, 2, 3]).to.not.have.members([1, 2]); - * - * // Duplicates in the subset are ignored - * expect([1, 2, 3]).to.include.members([1, 2, 2, 2]); - * - * `.deep`, `.ordered`, and `.include` can all be combined. However, if - * `.include` and `.ordered` are combined, the ordering begins at the start of - * both arrays. - * - * expect([{a: 1}, {b: 2}, {c: 3}]) - * .to.include.deep.ordered.members([{a: 1}, {b: 2}]) - * .but.not.include.deep.ordered.members([{b: 2}, {c: 3}]); - * - * Add `.not` earlier in the chain to negate `.members`. However, it's - * dangerous to do so. The problem is that it creates uncertain expectations - * by asserting that the target array doesn't have all of the same members as - * the given array `set` but may or may not have some of them. It's often best - * to identify the exact output that's expected, and then write an assertion - * that only accepts that exact output. - * - * expect([1, 2]).to.not.include(3).and.not.include(4); // Recommended - * expect([1, 2]).to.not.have.members([3, 4]); // Not recommended - * - * `.members` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect([1, 2]).to.have.members([1, 2, 3], 'nooo why fail??'); - * expect([1, 2], 'nooo why fail??').to.have.members([1, 2, 3]); - * - * @name members - * @param {Array} set - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - Assertion.addMethod('members', function (subset, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi'); - - new Assertion(obj, flagMsg, ssfi, true).to.be.an('array'); - new Assertion(subset, flagMsg, ssfi, true).to.be.an('array'); - - var contains = flag(this, 'contains'); - var ordered = flag(this, 'ordered'); - - var subject, failMsg, failNegateMsg; - - if (contains) { - subject = ordered ? 'an ordered superset' : 'a superset'; - failMsg = 'expected #{this} to be ' + subject + ' of #{exp}'; - failNegateMsg = 'expected #{this} to not be ' + subject + ' of #{exp}'; - } else { - subject = ordered ? 'ordered members' : 'members'; - failMsg = 'expected #{this} to have the same ' + subject + ' as #{exp}'; - failNegateMsg = 'expected #{this} to not have the same ' + subject + ' as #{exp}'; - } - - var cmp = flag(this, 'deep') ? _.eql : undefined; - - this.assert( - isSubsetOf(subset, obj, cmp, contains, ordered) - , failMsg - , failNegateMsg - , subset - , obj - , true - ); - }); - - /** - * ### .oneOf(list[, msg]) - * - * Asserts that the target is a member of the given array `list`. However, - * it's often best to assert that the target is equal to its expected value. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.be.oneOf([1, 2, 3]); // Not recommended - * - * Comparisons are performed using strict (`===`) equality. - * - * Add `.not` earlier in the chain to negate `.oneOf`. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.oneOf([2, 3, 4]); // Not recommended - * - * It can also be chained with `.contain` or `.include`, which will work with - * both arrays and strings: - * - * expect('Today is sunny').to.contain.oneOf(['sunny', 'cloudy']) - * expect('Today is rainy').to.not.contain.oneOf(['sunny', 'cloudy']) - * expect([1,2,3]).to.contain.oneOf([3,4,5]) - * expect([1,2,3]).to.not.contain.oneOf([4,5,6]) - * - * `.oneOf` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect(1).to.be.oneOf([2, 3, 4], 'nooo why fail??'); - * expect(1, 'nooo why fail??').to.be.oneOf([2, 3, 4]); - * - * @name oneOf - * @param {Array<*>} list - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function oneOf (list, msg) { - if (msg) flag(this, 'message', msg); - var expected = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi') - , contains = flag(this, 'contains') - , isDeep = flag(this, 'deep'); - new Assertion(list, flagMsg, ssfi, true).to.be.an('array'); - - if (contains) { - this.assert( - list.some(function(possibility) { return expected.indexOf(possibility) > -1 }) - , 'expected #{this} to contain one of #{exp}' - , 'expected #{this} to not contain one of #{exp}' - , list - , expected - ); - } else { - if (isDeep) { - this.assert( - list.some(function(possibility) { return _.eql(expected, possibility) }) - , 'expected #{this} to deeply equal one of #{exp}' - , 'expected #{this} to deeply equal one of #{exp}' - , list - , expected - ); - } else { - this.assert( - list.indexOf(expected) > -1 - , 'expected #{this} to be one of #{exp}' - , 'expected #{this} to not be one of #{exp}' - , list - , expected - ); - } - } - } - - Assertion.addMethod('oneOf', oneOf); - - /** - * ### .change(subject[, prop[, msg]]) - * - * When one argument is provided, `.change` asserts that the given function - * `subject` returns a different value when it's invoked before the target - * function compared to when it's invoked afterward. However, it's often best - * to assert that `subject` is equal to its expected value. - * - * var dots = '' - * , addDot = function () { dots += '.'; } - * , getDots = function () { return dots; }; - * - * // Recommended - * expect(getDots()).to.equal(''); - * addDot(); - * expect(getDots()).to.equal('.'); - * - * // Not recommended - * expect(addDot).to.change(getDots); - * - * When two arguments are provided, `.change` asserts that the value of the - * given object `subject`'s `prop` property is different before invoking the - * target function compared to afterward. - * - * var myObj = {dots: ''} - * , addDot = function () { myObj.dots += '.'; }; - * - * // Recommended - * expect(myObj).to.have.property('dots', ''); - * addDot(); - * expect(myObj).to.have.property('dots', '.'); - * - * // Not recommended - * expect(addDot).to.change(myObj, 'dots'); - * - * Strict (`===`) equality is used to compare before and after values. - * - * Add `.not` earlier in the chain to negate `.change`. - * - * var dots = '' - * , noop = function () {} - * , getDots = function () { return dots; }; - * - * expect(noop).to.not.change(getDots); - * - * var myObj = {dots: ''} - * , noop = function () {}; - * - * expect(noop).to.not.change(myObj, 'dots'); - * - * `.change` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. When not providing two arguments, always - * use the second form. - * - * var myObj = {dots: ''} - * , addDot = function () { myObj.dots += '.'; }; - * - * expect(addDot).to.not.change(myObj, 'dots', 'nooo why fail??'); - * - * var dots = '' - * , addDot = function () { dots += '.'; } - * , getDots = function () { return dots; }; - * - * expect(addDot, 'nooo why fail??').to.not.change(getDots); - * - * `.change` also causes all `.by` assertions that follow in the chain to - * assert how much a numeric subject was increased or decreased by. However, - * it's dangerous to use `.change.by`. The problem is that it creates - * uncertain expectations by asserting that the subject either increases by - * the given delta, or that it decreases by the given delta. It's often best - * to identify the exact output that's expected, and then write an assertion - * that only accepts that exact output. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; } - * , subtractTwo = function () { myObj.val -= 2; }; - * - * expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended - * expect(addTwo).to.change(myObj, 'val').by(2); // Not recommended - * - * expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended - * expect(subtractTwo).to.change(myObj, 'val').by(2); // Not recommended - * - * The alias `.changes` can be used interchangeably with `.change`. - * - * @name change - * @alias changes - * @param {String} subject - * @param {String} prop name _optional_ - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertChanges (subject, prop, msg) { - if (msg) flag(this, 'message', msg); - var fn = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi'); - new Assertion(fn, flagMsg, ssfi, true).is.a('function'); - - var initial; - if (!prop) { - new Assertion(subject, flagMsg, ssfi, true).is.a('function'); - initial = subject(); - } else { - new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop); - initial = subject[prop]; - } - - fn(); - - var final = prop === undefined || prop === null ? subject() : subject[prop]; - var msgObj = prop === undefined || prop === null ? initial : '.' + prop; - - // This gets flagged because of the .by(delta) assertion - flag(this, 'deltaMsgObj', msgObj); - flag(this, 'initialDeltaValue', initial); - flag(this, 'finalDeltaValue', final); - flag(this, 'deltaBehavior', 'change'); - flag(this, 'realDelta', final !== initial); - - this.assert( - initial !== final - , 'expected ' + msgObj + ' to change' - , 'expected ' + msgObj + ' to not change' - ); - } - - Assertion.addMethod('change', assertChanges); - Assertion.addMethod('changes', assertChanges); - - /** - * ### .increase(subject[, prop[, msg]]) - * - * When one argument is provided, `.increase` asserts that the given function - * `subject` returns a greater number when it's invoked after invoking the - * target function compared to when it's invoked beforehand. `.increase` also - * causes all `.by` assertions that follow in the chain to assert how much - * greater of a number is returned. It's often best to assert that the return - * value increased by the expected amount, rather than asserting it increased - * by any amount. - * - * var val = 1 - * , addTwo = function () { val += 2; } - * , getVal = function () { return val; }; - * - * expect(addTwo).to.increase(getVal).by(2); // Recommended - * expect(addTwo).to.increase(getVal); // Not recommended - * - * When two arguments are provided, `.increase` asserts that the value of the - * given object `subject`'s `prop` property is greater after invoking the - * target function compared to beforehand. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; }; - * - * expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended - * expect(addTwo).to.increase(myObj, 'val'); // Not recommended - * - * Add `.not` earlier in the chain to negate `.increase`. However, it's - * dangerous to do so. The problem is that it creates uncertain expectations - * by asserting that the subject either decreases, or that it stays the same. - * It's often best to identify the exact output that's expected, and then - * write an assertion that only accepts that exact output. - * - * When the subject is expected to decrease, it's often best to assert that it - * decreased by the expected amount. - * - * var myObj = {val: 1} - * , subtractTwo = function () { myObj.val -= 2; }; - * - * expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended - * expect(subtractTwo).to.not.increase(myObj, 'val'); // Not recommended - * - * When the subject is expected to stay the same, it's often best to assert - * exactly that. - * - * var myObj = {val: 1} - * , noop = function () {}; - * - * expect(noop).to.not.change(myObj, 'val'); // Recommended - * expect(noop).to.not.increase(myObj, 'val'); // Not recommended - * - * `.increase` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. When not providing two arguments, always - * use the second form. - * - * var myObj = {val: 1} - * , noop = function () {}; - * - * expect(noop).to.increase(myObj, 'val', 'nooo why fail??'); - * - * var val = 1 - * , noop = function () {} - * , getVal = function () { return val; }; - * - * expect(noop, 'nooo why fail??').to.increase(getVal); - * - * The alias `.increases` can be used interchangeably with `.increase`. - * - * @name increase - * @alias increases - * @param {String|Function} subject - * @param {String} prop name _optional_ - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertIncreases (subject, prop, msg) { - if (msg) flag(this, 'message', msg); - var fn = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi'); - new Assertion(fn, flagMsg, ssfi, true).is.a('function'); - - var initial; - if (!prop) { - new Assertion(subject, flagMsg, ssfi, true).is.a('function'); - initial = subject(); - } else { - new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop); - initial = subject[prop]; - } - - // Make sure that the target is a number - new Assertion(initial, flagMsg, ssfi, true).is.a('number'); - - fn(); - - var final = prop === undefined || prop === null ? subject() : subject[prop]; - var msgObj = prop === undefined || prop === null ? initial : '.' + prop; - - flag(this, 'deltaMsgObj', msgObj); - flag(this, 'initialDeltaValue', initial); - flag(this, 'finalDeltaValue', final); - flag(this, 'deltaBehavior', 'increase'); - flag(this, 'realDelta', final - initial); - - this.assert( - final - initial > 0 - , 'expected ' + msgObj + ' to increase' - , 'expected ' + msgObj + ' to not increase' - ); - } - - Assertion.addMethod('increase', assertIncreases); - Assertion.addMethod('increases', assertIncreases); - - /** - * ### .decrease(subject[, prop[, msg]]) - * - * When one argument is provided, `.decrease` asserts that the given function - * `subject` returns a lesser number when it's invoked after invoking the - * target function compared to when it's invoked beforehand. `.decrease` also - * causes all `.by` assertions that follow in the chain to assert how much - * lesser of a number is returned. It's often best to assert that the return - * value decreased by the expected amount, rather than asserting it decreased - * by any amount. - * - * var val = 1 - * , subtractTwo = function () { val -= 2; } - * , getVal = function () { return val; }; - * - * expect(subtractTwo).to.decrease(getVal).by(2); // Recommended - * expect(subtractTwo).to.decrease(getVal); // Not recommended - * - * When two arguments are provided, `.decrease` asserts that the value of the - * given object `subject`'s `prop` property is lesser after invoking the - * target function compared to beforehand. - * - * var myObj = {val: 1} - * , subtractTwo = function () { myObj.val -= 2; }; - * - * expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended - * expect(subtractTwo).to.decrease(myObj, 'val'); // Not recommended - * - * Add `.not` earlier in the chain to negate `.decrease`. However, it's - * dangerous to do so. The problem is that it creates uncertain expectations - * by asserting that the subject either increases, or that it stays the same. - * It's often best to identify the exact output that's expected, and then - * write an assertion that only accepts that exact output. - * - * When the subject is expected to increase, it's often best to assert that it - * increased by the expected amount. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; }; - * - * expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended - * expect(addTwo).to.not.decrease(myObj, 'val'); // Not recommended - * - * When the subject is expected to stay the same, it's often best to assert - * exactly that. - * - * var myObj = {val: 1} - * , noop = function () {}; - * - * expect(noop).to.not.change(myObj, 'val'); // Recommended - * expect(noop).to.not.decrease(myObj, 'val'); // Not recommended - * - * `.decrease` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. When not providing two arguments, always - * use the second form. - * - * var myObj = {val: 1} - * , noop = function () {}; - * - * expect(noop).to.decrease(myObj, 'val', 'nooo why fail??'); - * - * var val = 1 - * , noop = function () {} - * , getVal = function () { return val; }; - * - * expect(noop, 'nooo why fail??').to.decrease(getVal); - * - * The alias `.decreases` can be used interchangeably with `.decrease`. - * - * @name decrease - * @alias decreases - * @param {String|Function} subject - * @param {String} prop name _optional_ - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertDecreases (subject, prop, msg) { - if (msg) flag(this, 'message', msg); - var fn = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi'); - new Assertion(fn, flagMsg, ssfi, true).is.a('function'); - - var initial; - if (!prop) { - new Assertion(subject, flagMsg, ssfi, true).is.a('function'); - initial = subject(); - } else { - new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop); - initial = subject[prop]; - } - - // Make sure that the target is a number - new Assertion(initial, flagMsg, ssfi, true).is.a('number'); - - fn(); - - var final = prop === undefined || prop === null ? subject() : subject[prop]; - var msgObj = prop === undefined || prop === null ? initial : '.' + prop; - - flag(this, 'deltaMsgObj', msgObj); - flag(this, 'initialDeltaValue', initial); - flag(this, 'finalDeltaValue', final); - flag(this, 'deltaBehavior', 'decrease'); - flag(this, 'realDelta', initial - final); - - this.assert( - final - initial < 0 - , 'expected ' + msgObj + ' to decrease' - , 'expected ' + msgObj + ' to not decrease' - ); - } - - Assertion.addMethod('decrease', assertDecreases); - Assertion.addMethod('decreases', assertDecreases); - - /** - * ### .by(delta[, msg]) - * - * When following an `.increase` assertion in the chain, `.by` asserts that - * the subject of the `.increase` assertion increased by the given `delta`. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; }; - * - * expect(addTwo).to.increase(myObj, 'val').by(2); - * - * When following a `.decrease` assertion in the chain, `.by` asserts that the - * subject of the `.decrease` assertion decreased by the given `delta`. - * - * var myObj = {val: 1} - * , subtractTwo = function () { myObj.val -= 2; }; - * - * expect(subtractTwo).to.decrease(myObj, 'val').by(2); - * - * When following a `.change` assertion in the chain, `.by` asserts that the - * subject of the `.change` assertion either increased or decreased by the - * given `delta`. However, it's dangerous to use `.change.by`. The problem is - * that it creates uncertain expectations. It's often best to identify the - * exact output that's expected, and then write an assertion that only accepts - * that exact output. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; } - * , subtractTwo = function () { myObj.val -= 2; }; - * - * expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended - * expect(addTwo).to.change(myObj, 'val').by(2); // Not recommended - * - * expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended - * expect(subtractTwo).to.change(myObj, 'val').by(2); // Not recommended - * - * Add `.not` earlier in the chain to negate `.by`. However, it's often best - * to assert that the subject changed by its expected delta, rather than - * asserting that it didn't change by one of countless unexpected deltas. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; }; - * - * // Recommended - * expect(addTwo).to.increase(myObj, 'val').by(2); - * - * // Not recommended - * expect(addTwo).to.increase(myObj, 'val').but.not.by(3); - * - * `.by` accepts an optional `msg` argument which is a custom error message to - * show when the assertion fails. The message can also be given as the second - * argument to `expect`. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; }; - * - * expect(addTwo).to.increase(myObj, 'val').by(3, 'nooo why fail??'); - * expect(addTwo, 'nooo why fail??').to.increase(myObj, 'val').by(3); - * - * @name by - * @param {Number} delta - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertDelta(delta, msg) { - if (msg) flag(this, 'message', msg); - - var msgObj = flag(this, 'deltaMsgObj'); - var initial = flag(this, 'initialDeltaValue'); - var final = flag(this, 'finalDeltaValue'); - var behavior = flag(this, 'deltaBehavior'); - var realDelta = flag(this, 'realDelta'); - - var expression; - if (behavior === 'change') { - expression = Math.abs(final - initial) === Math.abs(delta); - } else { - expression = realDelta === Math.abs(delta); - } - - this.assert( - expression - , 'expected ' + msgObj + ' to ' + behavior + ' by ' + delta - , 'expected ' + msgObj + ' to not ' + behavior + ' by ' + delta - ); - } - - Assertion.addMethod('by', assertDelta); - - /** - * ### .extensible - * - * Asserts that the target is extensible, which means that new properties can - * be added to it. Primitives are never extensible. - * - * expect({a: 1}).to.be.extensible; - * - * Add `.not` earlier in the chain to negate `.extensible`. - * - * var nonExtensibleObject = Object.preventExtensions({}) - * , sealedObject = Object.seal({}) - * , frozenObject = Object.freeze({}); - * - * expect(nonExtensibleObject).to.not.be.extensible; - * expect(sealedObject).to.not.be.extensible; - * expect(frozenObject).to.not.be.extensible; - * expect(1).to.not.be.extensible; - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(1, 'nooo why fail??').to.be.extensible; - * - * @name extensible - * @namespace BDD - * @api public - */ - - Assertion.addProperty('extensible', function() { - var obj = flag(this, 'object'); - - // In ES5, if the argument to this method is a primitive, then it will cause a TypeError. - // In ES6, a non-object argument will be treated as if it was a non-extensible ordinary object, simply return false. - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible - // The following provides ES6 behavior for ES5 environments. - - var isExtensible = obj === Object(obj) && Object.isExtensible(obj); - - this.assert( - isExtensible - , 'expected #{this} to be extensible' - , 'expected #{this} to not be extensible' - ); - }); - - /** - * ### .sealed - * - * Asserts that the target is sealed, which means that new properties can't be - * added to it, and its existing properties can't be reconfigured or deleted. - * However, it's possible that its existing properties can still be reassigned - * to different values. Primitives are always sealed. - * - * var sealedObject = Object.seal({}); - * var frozenObject = Object.freeze({}); - * - * expect(sealedObject).to.be.sealed; - * expect(frozenObject).to.be.sealed; - * expect(1).to.be.sealed; - * - * Add `.not` earlier in the chain to negate `.sealed`. - * - * expect({a: 1}).to.not.be.sealed; - * - * A custom error message can be given as the second argument to `expect`. - * - * expect({a: 1}, 'nooo why fail??').to.be.sealed; - * - * @name sealed - * @namespace BDD - * @api public - */ - - Assertion.addProperty('sealed', function() { - var obj = flag(this, 'object'); - - // In ES5, if the argument to this method is a primitive, then it will cause a TypeError. - // In ES6, a non-object argument will be treated as if it was a sealed ordinary object, simply return true. - // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed - // The following provides ES6 behavior for ES5 environments. - - var isSealed = obj === Object(obj) ? Object.isSealed(obj) : true; - - this.assert( - isSealed - , 'expected #{this} to be sealed' - , 'expected #{this} to not be sealed' - ); - }); - - /** - * ### .frozen - * - * Asserts that the target is frozen, which means that new properties can't be - * added to it, and its existing properties can't be reassigned to different - * values, reconfigured, or deleted. Primitives are always frozen. - * - * var frozenObject = Object.freeze({}); - * - * expect(frozenObject).to.be.frozen; - * expect(1).to.be.frozen; - * - * Add `.not` earlier in the chain to negate `.frozen`. - * - * expect({a: 1}).to.not.be.frozen; - * - * A custom error message can be given as the second argument to `expect`. - * - * expect({a: 1}, 'nooo why fail??').to.be.frozen; - * - * @name frozen - * @namespace BDD - * @api public - */ - - Assertion.addProperty('frozen', function() { - var obj = flag(this, 'object'); - - // In ES5, if the argument to this method is a primitive, then it will cause a TypeError. - // In ES6, a non-object argument will be treated as if it was a frozen ordinary object, simply return true. - // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen - // The following provides ES6 behavior for ES5 environments. - - var isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true; - - this.assert( - isFrozen - , 'expected #{this} to be frozen' - , 'expected #{this} to not be frozen' - ); - }); - - /** - * ### .finite - * - * Asserts that the target is a number, and isn't `NaN` or positive/negative - * `Infinity`. - * - * expect(1).to.be.finite; - * - * Add `.not` earlier in the chain to negate `.finite`. However, it's - * dangerous to do so. The problem is that it creates uncertain expectations - * by asserting that the subject either isn't a number, or that it's `NaN`, or - * that it's positive `Infinity`, or that it's negative `Infinity`. It's often - * best to identify the exact output that's expected, and then write an - * assertion that only accepts that exact output. - * - * When the target isn't expected to be a number, it's often best to assert - * that it's the expected type, rather than asserting that it isn't one of - * many unexpected types. - * - * expect('foo').to.be.a('string'); // Recommended - * expect('foo').to.not.be.finite; // Not recommended - * - * When the target is expected to be `NaN`, it's often best to assert exactly - * that. - * - * expect(NaN).to.be.NaN; // Recommended - * expect(NaN).to.not.be.finite; // Not recommended - * - * When the target is expected to be positive infinity, it's often best to - * assert exactly that. - * - * expect(Infinity).to.equal(Infinity); // Recommended - * expect(Infinity).to.not.be.finite; // Not recommended - * - * When the target is expected to be negative infinity, it's often best to - * assert exactly that. - * - * expect(-Infinity).to.equal(-Infinity); // Recommended - * expect(-Infinity).to.not.be.finite; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect('foo', 'nooo why fail??').to.be.finite; - * - * @name finite - * @namespace BDD - * @api public - */ - - Assertion.addProperty('finite', function(msg) { - var obj = flag(this, 'object'); - - this.assert( - typeof obj === 'number' && isFinite(obj) - , 'expected #{this} to be a finite number' - , 'expected #{this} to not be a finite number' - ); - }); -}; - -},{}],6:[function(require,module,exports){ -/*! - * chai - * Copyright(c) 2011-2014 Jake Luer - * MIT Licensed - */ - -module.exports = function (chai, util) { - /*! - * Chai dependencies. - */ - - var Assertion = chai.Assertion - , flag = util.flag; - - /*! - * Module export. - */ - - /** - * ### assert(expression, message) - * - * Write your own test expressions. - * - * assert('foo' !== 'bar', 'foo is not bar'); - * assert(Array.isArray([]), 'empty arrays are arrays'); - * - * @param {Mixed} expression to test for truthiness - * @param {String} message to display on error - * @name assert - * @namespace Assert - * @api public - */ - - var assert = chai.assert = function (express, errmsg) { - var test = new Assertion(null, null, chai.assert, true); - test.assert( - express - , errmsg - , '[ negation message unavailable ]' - ); - }; - - /** - * ### .fail([message]) - * ### .fail(actual, expected, [message], [operator]) - * - * Throw a failure. Node.js `assert` module-compatible. - * - * assert.fail(); - * assert.fail("custom error message"); - * assert.fail(1, 2); - * assert.fail(1, 2, "custom error message"); - * assert.fail(1, 2, "custom error message", ">"); - * assert.fail(1, 2, undefined, ">"); - * - * @name fail - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @param {String} operator - * @namespace Assert - * @api public - */ - - assert.fail = function (actual, expected, message, operator) { - if (arguments.length < 2) { - // Comply with Node's fail([message]) interface - - message = actual; - actual = undefined; - } - - message = message || 'assert.fail()'; - throw new chai.AssertionError(message, { - actual: actual - , expected: expected - , operator: operator - }, assert.fail); - }; - - /** - * ### .isOk(object, [message]) - * - * Asserts that `object` is truthy. - * - * assert.isOk('everything', 'everything is ok'); - * assert.isOk(false, 'this will fail'); - * - * @name isOk - * @alias ok - * @param {Mixed} object to test - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isOk = function (val, msg) { - new Assertion(val, msg, assert.isOk, true).is.ok; - }; - - /** - * ### .isNotOk(object, [message]) - * - * Asserts that `object` is falsy. - * - * assert.isNotOk('everything', 'this will fail'); - * assert.isNotOk(false, 'this will pass'); - * - * @name isNotOk - * @alias notOk - * @param {Mixed} object to test - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotOk = function (val, msg) { - new Assertion(val, msg, assert.isNotOk, true).is.not.ok; - }; - - /** - * ### .equal(actual, expected, [message]) - * - * Asserts non-strict equality (`==`) of `actual` and `expected`. - * - * assert.equal(3, '3', '== coerces values to strings'); - * - * @name equal - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.equal = function (act, exp, msg) { - var test = new Assertion(act, msg, assert.equal, true); - - test.assert( - exp == flag(test, 'object') - , 'expected #{this} to equal #{exp}' - , 'expected #{this} to not equal #{act}' - , exp - , act - , true - ); - }; - - /** - * ### .notEqual(actual, expected, [message]) - * - * Asserts non-strict inequality (`!=`) of `actual` and `expected`. - * - * assert.notEqual(3, 4, 'these numbers are not equal'); - * - * @name notEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notEqual = function (act, exp, msg) { - var test = new Assertion(act, msg, assert.notEqual, true); - - test.assert( - exp != flag(test, 'object') - , 'expected #{this} to not equal #{exp}' - , 'expected #{this} to equal #{act}' - , exp - , act - , true - ); - }; - - /** - * ### .strictEqual(actual, expected, [message]) - * - * Asserts strict equality (`===`) of `actual` and `expected`. - * - * assert.strictEqual(true, true, 'these booleans are strictly equal'); - * - * @name strictEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.strictEqual = function (act, exp, msg) { - new Assertion(act, msg, assert.strictEqual, true).to.equal(exp); - }; - - /** - * ### .notStrictEqual(actual, expected, [message]) - * - * Asserts strict inequality (`!==`) of `actual` and `expected`. - * - * assert.notStrictEqual(3, '3', 'no coercion for strict equality'); - * - * @name notStrictEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notStrictEqual = function (act, exp, msg) { - new Assertion(act, msg, assert.notStrictEqual, true).to.not.equal(exp); - }; - - /** - * ### .deepEqual(actual, expected, [message]) - * - * Asserts that `actual` is deeply equal to `expected`. - * - * assert.deepEqual({ tea: 'green' }, { tea: 'green' }); - * - * @name deepEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @alias deepStrictEqual - * @namespace Assert - * @api public - */ - - assert.deepEqual = assert.deepStrictEqual = function (act, exp, msg) { - new Assertion(act, msg, assert.deepEqual, true).to.eql(exp); - }; - - /** - * ### .notDeepEqual(actual, expected, [message]) - * - * Assert that `actual` is not deeply equal to `expected`. - * - * assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' }); - * - * @name notDeepEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notDeepEqual = function (act, exp, msg) { - new Assertion(act, msg, assert.notDeepEqual, true).to.not.eql(exp); - }; - - /** - * ### .isAbove(valueToCheck, valueToBeAbove, [message]) - * - * Asserts `valueToCheck` is strictly greater than (>) `valueToBeAbove`. - * - * assert.isAbove(5, 2, '5 is strictly greater than 2'); - * - * @name isAbove - * @param {Mixed} valueToCheck - * @param {Mixed} valueToBeAbove - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isAbove = function (val, abv, msg) { - new Assertion(val, msg, assert.isAbove, true).to.be.above(abv); - }; - - /** - * ### .isAtLeast(valueToCheck, valueToBeAtLeast, [message]) - * - * Asserts `valueToCheck` is greater than or equal to (>=) `valueToBeAtLeast`. - * - * assert.isAtLeast(5, 2, '5 is greater or equal to 2'); - * assert.isAtLeast(3, 3, '3 is greater or equal to 3'); - * - * @name isAtLeast - * @param {Mixed} valueToCheck - * @param {Mixed} valueToBeAtLeast - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isAtLeast = function (val, atlst, msg) { - new Assertion(val, msg, assert.isAtLeast, true).to.be.least(atlst); - }; - - /** - * ### .isBelow(valueToCheck, valueToBeBelow, [message]) - * - * Asserts `valueToCheck` is strictly less than (<) `valueToBeBelow`. - * - * assert.isBelow(3, 6, '3 is strictly less than 6'); - * - * @name isBelow - * @param {Mixed} valueToCheck - * @param {Mixed} valueToBeBelow - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isBelow = function (val, blw, msg) { - new Assertion(val, msg, assert.isBelow, true).to.be.below(blw); - }; - - /** - * ### .isAtMost(valueToCheck, valueToBeAtMost, [message]) - * - * Asserts `valueToCheck` is less than or equal to (<=) `valueToBeAtMost`. - * - * assert.isAtMost(3, 6, '3 is less than or equal to 6'); - * assert.isAtMost(4, 4, '4 is less than or equal to 4'); - * - * @name isAtMost - * @param {Mixed} valueToCheck - * @param {Mixed} valueToBeAtMost - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isAtMost = function (val, atmst, msg) { - new Assertion(val, msg, assert.isAtMost, true).to.be.most(atmst); - }; - - /** - * ### .isTrue(value, [message]) - * - * Asserts that `value` is true. - * - * var teaServed = true; - * assert.isTrue(teaServed, 'the tea has been served'); - * - * @name isTrue - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isTrue = function (val, msg) { - new Assertion(val, msg, assert.isTrue, true).is['true']; - }; - - /** - * ### .isNotTrue(value, [message]) - * - * Asserts that `value` is not true. - * - * var tea = 'tasty chai'; - * assert.isNotTrue(tea, 'great, time for tea!'); - * - * @name isNotTrue - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotTrue = function (val, msg) { - new Assertion(val, msg, assert.isNotTrue, true).to.not.equal(true); - }; - - /** - * ### .isFalse(value, [message]) - * - * Asserts that `value` is false. - * - * var teaServed = false; - * assert.isFalse(teaServed, 'no tea yet? hmm...'); - * - * @name isFalse - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isFalse = function (val, msg) { - new Assertion(val, msg, assert.isFalse, true).is['false']; - }; - - /** - * ### .isNotFalse(value, [message]) - * - * Asserts that `value` is not false. - * - * var tea = 'tasty chai'; - * assert.isNotFalse(tea, 'great, time for tea!'); - * - * @name isNotFalse - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotFalse = function (val, msg) { - new Assertion(val, msg, assert.isNotFalse, true).to.not.equal(false); - }; - - /** - * ### .isNull(value, [message]) - * - * Asserts that `value` is null. - * - * assert.isNull(err, 'there was no error'); - * - * @name isNull - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNull = function (val, msg) { - new Assertion(val, msg, assert.isNull, true).to.equal(null); - }; - - /** - * ### .isNotNull(value, [message]) - * - * Asserts that `value` is not null. - * - * var tea = 'tasty chai'; - * assert.isNotNull(tea, 'great, time for tea!'); - * - * @name isNotNull - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotNull = function (val, msg) { - new Assertion(val, msg, assert.isNotNull, true).to.not.equal(null); - }; - - /** - * ### .isNaN - * - * Asserts that value is NaN. - * - * assert.isNaN(NaN, 'NaN is NaN'); - * - * @name isNaN - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNaN = function (val, msg) { - new Assertion(val, msg, assert.isNaN, true).to.be.NaN; - }; - - /** - * ### .isNotNaN - * - * Asserts that value is not NaN. - * - * assert.isNotNaN(4, '4 is not NaN'); - * - * @name isNotNaN - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - assert.isNotNaN = function (val, msg) { - new Assertion(val, msg, assert.isNotNaN, true).not.to.be.NaN; - }; - - /** - * ### .exists - * - * Asserts that the target is neither `null` nor `undefined`. - * - * var foo = 'hi'; - * - * assert.exists(foo, 'foo is neither `null` nor `undefined`'); - * - * @name exists - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.exists = function (val, msg) { - new Assertion(val, msg, assert.exists, true).to.exist; - }; - - /** - * ### .notExists - * - * Asserts that the target is either `null` or `undefined`. - * - * var bar = null - * , baz; - * - * assert.notExists(bar); - * assert.notExists(baz, 'baz is either null or undefined'); - * - * @name notExists - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notExists = function (val, msg) { - new Assertion(val, msg, assert.notExists, true).to.not.exist; - }; - - /** - * ### .isUndefined(value, [message]) - * - * Asserts that `value` is `undefined`. - * - * var tea; - * assert.isUndefined(tea, 'no tea defined'); - * - * @name isUndefined - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isUndefined = function (val, msg) { - new Assertion(val, msg, assert.isUndefined, true).to.equal(undefined); - }; - - /** - * ### .isDefined(value, [message]) - * - * Asserts that `value` is not `undefined`. - * - * var tea = 'cup of chai'; - * assert.isDefined(tea, 'tea has been defined'); - * - * @name isDefined - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isDefined = function (val, msg) { - new Assertion(val, msg, assert.isDefined, true).to.not.equal(undefined); - }; - - /** - * ### .isFunction(value, [message]) - * - * Asserts that `value` is a function. - * - * function serveTea() { return 'cup of tea'; }; - * assert.isFunction(serveTea, 'great, we can have tea now'); - * - * @name isFunction - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isFunction = function (val, msg) { - new Assertion(val, msg, assert.isFunction, true).to.be.a('function'); - }; - - /** - * ### .isNotFunction(value, [message]) - * - * Asserts that `value` is _not_ a function. - * - * var serveTea = [ 'heat', 'pour', 'sip' ]; - * assert.isNotFunction(serveTea, 'great, we have listed the steps'); - * - * @name isNotFunction - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotFunction = function (val, msg) { - new Assertion(val, msg, assert.isNotFunction, true).to.not.be.a('function'); - }; - - /** - * ### .isObject(value, [message]) - * - * Asserts that `value` is an object of type 'Object' (as revealed by `Object.prototype.toString`). - * _The assertion does not match subclassed objects._ - * - * var selection = { name: 'Chai', serve: 'with spices' }; - * assert.isObject(selection, 'tea selection is an object'); - * - * @name isObject - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isObject = function (val, msg) { - new Assertion(val, msg, assert.isObject, true).to.be.a('object'); - }; - - /** - * ### .isNotObject(value, [message]) - * - * Asserts that `value` is _not_ an object of type 'Object' (as revealed by `Object.prototype.toString`). - * - * var selection = 'chai' - * assert.isNotObject(selection, 'tea selection is not an object'); - * assert.isNotObject(null, 'null is not an object'); - * - * @name isNotObject - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotObject = function (val, msg) { - new Assertion(val, msg, assert.isNotObject, true).to.not.be.a('object'); - }; - - /** - * ### .isArray(value, [message]) - * - * Asserts that `value` is an array. - * - * var menu = [ 'green', 'chai', 'oolong' ]; - * assert.isArray(menu, 'what kind of tea do we want?'); - * - * @name isArray - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isArray = function (val, msg) { - new Assertion(val, msg, assert.isArray, true).to.be.an('array'); - }; - - /** - * ### .isNotArray(value, [message]) - * - * Asserts that `value` is _not_ an array. - * - * var menu = 'green|chai|oolong'; - * assert.isNotArray(menu, 'what kind of tea do we want?'); - * - * @name isNotArray - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotArray = function (val, msg) { - new Assertion(val, msg, assert.isNotArray, true).to.not.be.an('array'); - }; - - /** - * ### .isString(value, [message]) - * - * Asserts that `value` is a string. - * - * var teaOrder = 'chai'; - * assert.isString(teaOrder, 'order placed'); - * - * @name isString - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isString = function (val, msg) { - new Assertion(val, msg, assert.isString, true).to.be.a('string'); - }; - - /** - * ### .isNotString(value, [message]) - * - * Asserts that `value` is _not_ a string. - * - * var teaOrder = 4; - * assert.isNotString(teaOrder, 'order placed'); - * - * @name isNotString - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotString = function (val, msg) { - new Assertion(val, msg, assert.isNotString, true).to.not.be.a('string'); - }; - - /** - * ### .isNumber(value, [message]) - * - * Asserts that `value` is a number. - * - * var cups = 2; - * assert.isNumber(cups, 'how many cups'); - * - * @name isNumber - * @param {Number} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNumber = function (val, msg) { - new Assertion(val, msg, assert.isNumber, true).to.be.a('number'); - }; - - /** - * ### .isNotNumber(value, [message]) - * - * Asserts that `value` is _not_ a number. - * - * var cups = '2 cups please'; - * assert.isNotNumber(cups, 'how many cups'); - * - * @name isNotNumber - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotNumber = function (val, msg) { - new Assertion(val, msg, assert.isNotNumber, true).to.not.be.a('number'); - }; - - /** - * ### .isFinite(value, [message]) - * - * Asserts that `value` is a finite number. Unlike `.isNumber`, this will fail for `NaN` and `Infinity`. - * - * var cups = 2; - * assert.isFinite(cups, 'how many cups'); - * - * assert.isFinite(NaN); // throws - * - * @name isFinite - * @param {Number} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isFinite = function (val, msg) { - new Assertion(val, msg, assert.isFinite, true).to.be.finite; - }; - - /** - * ### .isBoolean(value, [message]) - * - * Asserts that `value` is a boolean. - * - * var teaReady = true - * , teaServed = false; - * - * assert.isBoolean(teaReady, 'is the tea ready'); - * assert.isBoolean(teaServed, 'has tea been served'); - * - * @name isBoolean - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isBoolean = function (val, msg) { - new Assertion(val, msg, assert.isBoolean, true).to.be.a('boolean'); - }; - - /** - * ### .isNotBoolean(value, [message]) - * - * Asserts that `value` is _not_ a boolean. - * - * var teaReady = 'yep' - * , teaServed = 'nope'; - * - * assert.isNotBoolean(teaReady, 'is the tea ready'); - * assert.isNotBoolean(teaServed, 'has tea been served'); - * - * @name isNotBoolean - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotBoolean = function (val, msg) { - new Assertion(val, msg, assert.isNotBoolean, true).to.not.be.a('boolean'); - }; - - /** - * ### .typeOf(value, name, [message]) - * - * Asserts that `value`'s type is `name`, as determined by - * `Object.prototype.toString`. - * - * assert.typeOf({ tea: 'chai' }, 'object', 'we have an object'); - * assert.typeOf(['chai', 'jasmine'], 'array', 'we have an array'); - * assert.typeOf('tea', 'string', 'we have a string'); - * assert.typeOf(/tea/, 'regexp', 'we have a regular expression'); - * assert.typeOf(null, 'null', 'we have a null'); - * assert.typeOf(undefined, 'undefined', 'we have an undefined'); - * - * @name typeOf - * @param {Mixed} value - * @param {String} name - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.typeOf = function (val, type, msg) { - new Assertion(val, msg, assert.typeOf, true).to.be.a(type); - }; - - /** - * ### .notTypeOf(value, name, [message]) - * - * Asserts that `value`'s type is _not_ `name`, as determined by - * `Object.prototype.toString`. - * - * assert.notTypeOf('tea', 'number', 'strings are not numbers'); - * - * @name notTypeOf - * @param {Mixed} value - * @param {String} typeof name - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notTypeOf = function (val, type, msg) { - new Assertion(val, msg, assert.notTypeOf, true).to.not.be.a(type); - }; - - /** - * ### .instanceOf(object, constructor, [message]) - * - * Asserts that `value` is an instance of `constructor`. - * - * var Tea = function (name) { this.name = name; } - * , chai = new Tea('chai'); - * - * assert.instanceOf(chai, Tea, 'chai is an instance of tea'); - * - * @name instanceOf - * @param {Object} object - * @param {Constructor} constructor - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.instanceOf = function (val, type, msg) { - new Assertion(val, msg, assert.instanceOf, true).to.be.instanceOf(type); - }; - - /** - * ### .notInstanceOf(object, constructor, [message]) - * - * Asserts `value` is not an instance of `constructor`. - * - * var Tea = function (name) { this.name = name; } - * , chai = new String('chai'); - * - * assert.notInstanceOf(chai, Tea, 'chai is not an instance of tea'); - * - * @name notInstanceOf - * @param {Object} object - * @param {Constructor} constructor - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notInstanceOf = function (val, type, msg) { - new Assertion(val, msg, assert.notInstanceOf, true) - .to.not.be.instanceOf(type); - }; - - /** - * ### .include(haystack, needle, [message]) - * - * Asserts that `haystack` includes `needle`. Can be used to assert the - * inclusion of a value in an array, a substring in a string, or a subset of - * properties in an object. - * - * assert.include([1,2,3], 2, 'array contains value'); - * assert.include('foobar', 'foo', 'string contains substring'); - * assert.include({ foo: 'bar', hello: 'universe' }, { foo: 'bar' }, 'object contains property'); - * - * Strict equality (===) is used. When asserting the inclusion of a value in - * an array, the array is searched for an element that's strictly equal to the - * given value. When asserting a subset of properties in an object, the object - * is searched for the given property keys, checking that each one is present - * and strictly equal to the given property value. For instance: - * - * var obj1 = {a: 1} - * , obj2 = {b: 2}; - * assert.include([obj1, obj2], obj1); - * assert.include({foo: obj1, bar: obj2}, {foo: obj1}); - * assert.include({foo: obj1, bar: obj2}, {foo: obj1, bar: obj2}); - * - * @name include - * @param {Array|String} haystack - * @param {Mixed} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.include = function (exp, inc, msg) { - new Assertion(exp, msg, assert.include, true).include(inc); - }; - - /** - * ### .notInclude(haystack, needle, [message]) - * - * Asserts that `haystack` does not include `needle`. Can be used to assert - * the absence of a value in an array, a substring in a string, or a subset of - * properties in an object. - * - * assert.notInclude([1,2,3], 4, "array doesn't contain value"); - * assert.notInclude('foobar', 'baz', "string doesn't contain substring"); - * assert.notInclude({ foo: 'bar', hello: 'universe' }, { foo: 'baz' }, 'object doesn't contain property'); - * - * Strict equality (===) is used. When asserting the absence of a value in an - * array, the array is searched to confirm the absence of an element that's - * strictly equal to the given value. When asserting a subset of properties in - * an object, the object is searched to confirm that at least one of the given - * property keys is either not present or not strictly equal to the given - * property value. For instance: - * - * var obj1 = {a: 1} - * , obj2 = {b: 2}; - * assert.notInclude([obj1, obj2], {a: 1}); - * assert.notInclude({foo: obj1, bar: obj2}, {foo: {a: 1}}); - * assert.notInclude({foo: obj1, bar: obj2}, {foo: obj1, bar: {b: 2}}); - * - * @name notInclude - * @param {Array|String} haystack - * @param {Mixed} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notInclude = function (exp, inc, msg) { - new Assertion(exp, msg, assert.notInclude, true).not.include(inc); - }; - - /** - * ### .deepInclude(haystack, needle, [message]) - * - * Asserts that `haystack` includes `needle`. Can be used to assert the - * inclusion of a value in an array or a subset of properties in an object. - * Deep equality is used. - * - * var obj1 = {a: 1} - * , obj2 = {b: 2}; - * assert.deepInclude([obj1, obj2], {a: 1}); - * assert.deepInclude({foo: obj1, bar: obj2}, {foo: {a: 1}}); - * assert.deepInclude({foo: obj1, bar: obj2}, {foo: {a: 1}, bar: {b: 2}}); - * - * @name deepInclude - * @param {Array|String} haystack - * @param {Mixed} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.deepInclude = function (exp, inc, msg) { - new Assertion(exp, msg, assert.deepInclude, true).deep.include(inc); - }; - - /** - * ### .notDeepInclude(haystack, needle, [message]) - * - * Asserts that `haystack` does not include `needle`. Can be used to assert - * the absence of a value in an array or a subset of properties in an object. - * Deep equality is used. - * - * var obj1 = {a: 1} - * , obj2 = {b: 2}; - * assert.notDeepInclude([obj1, obj2], {a: 9}); - * assert.notDeepInclude({foo: obj1, bar: obj2}, {foo: {a: 9}}); - * assert.notDeepInclude({foo: obj1, bar: obj2}, {foo: {a: 1}, bar: {b: 9}}); - * - * @name notDeepInclude - * @param {Array|String} haystack - * @param {Mixed} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notDeepInclude = function (exp, inc, msg) { - new Assertion(exp, msg, assert.notDeepInclude, true).not.deep.include(inc); - }; - - /** - * ### .nestedInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' includes 'needle'. - * Can be used to assert the inclusion of a subset of properties in an - * object. - * Enables the use of dot- and bracket-notation for referencing nested - * properties. - * '[]' and '.' in property names can be escaped using double backslashes. - * - * assert.nestedInclude({'.a': {'b': 'x'}}, {'\\.a.[b]': 'x'}); - * assert.nestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'x'}); - * - * @name nestedInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.nestedInclude = function (exp, inc, msg) { - new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc); - }; - - /** - * ### .notNestedInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' does not include 'needle'. - * Can be used to assert the absence of a subset of properties in an - * object. - * Enables the use of dot- and bracket-notation for referencing nested - * properties. - * '[]' and '.' in property names can be escaped using double backslashes. - * - * assert.notNestedInclude({'.a': {'b': 'x'}}, {'\\.a.b': 'y'}); - * assert.notNestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'y'}); - * - * @name notNestedInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notNestedInclude = function (exp, inc, msg) { - new Assertion(exp, msg, assert.notNestedInclude, true) - .not.nested.include(inc); - }; - - /** - * ### .deepNestedInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' includes 'needle'. - * Can be used to assert the inclusion of a subset of properties in an - * object while checking for deep equality. - * Enables the use of dot- and bracket-notation for referencing nested - * properties. - * '[]' and '.' in property names can be escaped using double backslashes. - * - * assert.deepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {x: 1}}); - * assert.deepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {x: 1}}); - * - * @name deepNestedInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.deepNestedInclude = function(exp, inc, msg) { - new Assertion(exp, msg, assert.deepNestedInclude, true) - .deep.nested.include(inc); - }; - - /** - * ### .notDeepNestedInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' does not include 'needle'. - * Can be used to assert the absence of a subset of properties in an - * object while checking for deep equality. - * Enables the use of dot- and bracket-notation for referencing nested - * properties. - * '[]' and '.' in property names can be escaped using double backslashes. - * - * assert.notDeepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {y: 1}}) - * assert.notDeepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {y: 2}}); - * - * @name notDeepNestedInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notDeepNestedInclude = function(exp, inc, msg) { - new Assertion(exp, msg, assert.notDeepNestedInclude, true) - .not.deep.nested.include(inc); - }; - - /** - * ### .ownInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' includes 'needle'. - * Can be used to assert the inclusion of a subset of properties in an - * object while ignoring inherited properties. - * - * assert.ownInclude({ a: 1 }, { a: 1 }); - * - * @name ownInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.ownInclude = function(exp, inc, msg) { - new Assertion(exp, msg, assert.ownInclude, true).own.include(inc); - }; - - /** - * ### .notOwnInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' includes 'needle'. - * Can be used to assert the absence of a subset of properties in an - * object while ignoring inherited properties. - * - * Object.prototype.b = 2; - * - * assert.notOwnInclude({ a: 1 }, { b: 2 }); - * - * @name notOwnInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notOwnInclude = function(exp, inc, msg) { - new Assertion(exp, msg, assert.notOwnInclude, true).not.own.include(inc); - }; - - /** - * ### .deepOwnInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' includes 'needle'. - * Can be used to assert the inclusion of a subset of properties in an - * object while ignoring inherited properties and checking for deep equality. - * - * assert.deepOwnInclude({a: {b: 2}}, {a: {b: 2}}); - * - * @name deepOwnInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.deepOwnInclude = function(exp, inc, msg) { - new Assertion(exp, msg, assert.deepOwnInclude, true) - .deep.own.include(inc); - }; - - /** - * ### .notDeepOwnInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' includes 'needle'. - * Can be used to assert the absence of a subset of properties in an - * object while ignoring inherited properties and checking for deep equality. - * - * assert.notDeepOwnInclude({a: {b: 2}}, {a: {c: 3}}); - * - * @name notDeepOwnInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notDeepOwnInclude = function(exp, inc, msg) { - new Assertion(exp, msg, assert.notDeepOwnInclude, true) - .not.deep.own.include(inc); - }; - - /** - * ### .match(value, regexp, [message]) - * - * Asserts that `value` matches the regular expression `regexp`. - * - * assert.match('foobar', /^foo/, 'regexp matches'); - * - * @name match - * @param {Mixed} value - * @param {RegExp} regexp - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.match = function (exp, re, msg) { - new Assertion(exp, msg, assert.match, true).to.match(re); - }; - - /** - * ### .notMatch(value, regexp, [message]) - * - * Asserts that `value` does not match the regular expression `regexp`. - * - * assert.notMatch('foobar', /^foo/, 'regexp does not match'); - * - * @name notMatch - * @param {Mixed} value - * @param {RegExp} regexp - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notMatch = function (exp, re, msg) { - new Assertion(exp, msg, assert.notMatch, true).to.not.match(re); - }; - - /** - * ### .property(object, property, [message]) - * - * Asserts that `object` has a direct or inherited property named by - * `property`. - * - * assert.property({ tea: { green: 'matcha' }}, 'tea'); - * assert.property({ tea: { green: 'matcha' }}, 'toString'); - * - * @name property - * @param {Object} object - * @param {String} property - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.property = function (obj, prop, msg) { - new Assertion(obj, msg, assert.property, true).to.have.property(prop); - }; - - /** - * ### .notProperty(object, property, [message]) - * - * Asserts that `object` does _not_ have a direct or inherited property named - * by `property`. - * - * assert.notProperty({ tea: { green: 'matcha' }}, 'coffee'); - * - * @name notProperty - * @param {Object} object - * @param {String} property - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notProperty = function (obj, prop, msg) { - new Assertion(obj, msg, assert.notProperty, true) - .to.not.have.property(prop); - }; - - /** - * ### .propertyVal(object, property, value, [message]) - * - * Asserts that `object` has a direct or inherited property named by - * `property` with a value given by `value`. Uses a strict equality check - * (===). - * - * assert.propertyVal({ tea: 'is good' }, 'tea', 'is good'); - * - * @name propertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.propertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.propertyVal, true) - .to.have.property(prop, val); - }; - - /** - * ### .notPropertyVal(object, property, value, [message]) - * - * Asserts that `object` does _not_ have a direct or inherited property named - * by `property` with value given by `value`. Uses a strict equality check - * (===). - * - * assert.notPropertyVal({ tea: 'is good' }, 'tea', 'is bad'); - * assert.notPropertyVal({ tea: 'is good' }, 'coffee', 'is good'); - * - * @name notPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.notPropertyVal, true) - .to.not.have.property(prop, val); - }; - - /** - * ### .deepPropertyVal(object, property, value, [message]) - * - * Asserts that `object` has a direct or inherited property named by - * `property` with a value given by `value`. Uses a deep equality check. - * - * assert.deepPropertyVal({ tea: { green: 'matcha' } }, 'tea', { green: 'matcha' }); - * - * @name deepPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.deepPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.deepPropertyVal, true) - .to.have.deep.property(prop, val); - }; - - /** - * ### .notDeepPropertyVal(object, property, value, [message]) - * - * Asserts that `object` does _not_ have a direct or inherited property named - * by `property` with value given by `value`. Uses a deep equality check. - * - * assert.notDeepPropertyVal({ tea: { green: 'matcha' } }, 'tea', { black: 'matcha' }); - * assert.notDeepPropertyVal({ tea: { green: 'matcha' } }, 'tea', { green: 'oolong' }); - * assert.notDeepPropertyVal({ tea: { green: 'matcha' } }, 'coffee', { green: 'matcha' }); - * - * @name notDeepPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notDeepPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.notDeepPropertyVal, true) - .to.not.have.deep.property(prop, val); - }; - - /** - * ### .ownProperty(object, property, [message]) - * - * Asserts that `object` has a direct property named by `property`. Inherited - * properties aren't checked. - * - * assert.ownProperty({ tea: { green: 'matcha' }}, 'tea'); - * - * @name ownProperty - * @param {Object} object - * @param {String} property - * @param {String} message - * @api public - */ - - assert.ownProperty = function (obj, prop, msg) { - new Assertion(obj, msg, assert.ownProperty, true) - .to.have.own.property(prop); - }; - - /** - * ### .notOwnProperty(object, property, [message]) - * - * Asserts that `object` does _not_ have a direct property named by - * `property`. Inherited properties aren't checked. - * - * assert.notOwnProperty({ tea: { green: 'matcha' }}, 'coffee'); - * assert.notOwnProperty({}, 'toString'); - * - * @name notOwnProperty - * @param {Object} object - * @param {String} property - * @param {String} message - * @api public - */ - - assert.notOwnProperty = function (obj, prop, msg) { - new Assertion(obj, msg, assert.notOwnProperty, true) - .to.not.have.own.property(prop); - }; - - /** - * ### .ownPropertyVal(object, property, value, [message]) - * - * Asserts that `object` has a direct property named by `property` and a value - * equal to the provided `value`. Uses a strict equality check (===). - * Inherited properties aren't checked. - * - * assert.ownPropertyVal({ coffee: 'is good'}, 'coffee', 'is good'); - * - * @name ownPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.ownPropertyVal = function (obj, prop, value, msg) { - new Assertion(obj, msg, assert.ownPropertyVal, true) - .to.have.own.property(prop, value); - }; - - /** - * ### .notOwnPropertyVal(object, property, value, [message]) - * - * Asserts that `object` does _not_ have a direct property named by `property` - * with a value equal to the provided `value`. Uses a strict equality check - * (===). Inherited properties aren't checked. - * - * assert.notOwnPropertyVal({ tea: 'is better'}, 'tea', 'is worse'); - * assert.notOwnPropertyVal({}, 'toString', Object.prototype.toString); - * - * @name notOwnPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.notOwnPropertyVal = function (obj, prop, value, msg) { - new Assertion(obj, msg, assert.notOwnPropertyVal, true) - .to.not.have.own.property(prop, value); - }; - - /** - * ### .deepOwnPropertyVal(object, property, value, [message]) - * - * Asserts that `object` has a direct property named by `property` and a value - * equal to the provided `value`. Uses a deep equality check. Inherited - * properties aren't checked. - * - * assert.deepOwnPropertyVal({ tea: { green: 'matcha' } }, 'tea', { green: 'matcha' }); - * - * @name deepOwnPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.deepOwnPropertyVal = function (obj, prop, value, msg) { - new Assertion(obj, msg, assert.deepOwnPropertyVal, true) - .to.have.deep.own.property(prop, value); - }; - - /** - * ### .notDeepOwnPropertyVal(object, property, value, [message]) - * - * Asserts that `object` does _not_ have a direct property named by `property` - * with a value equal to the provided `value`. Uses a deep equality check. - * Inherited properties aren't checked. - * - * assert.notDeepOwnPropertyVal({ tea: { green: 'matcha' } }, 'tea', { black: 'matcha' }); - * assert.notDeepOwnPropertyVal({ tea: { green: 'matcha' } }, 'tea', { green: 'oolong' }); - * assert.notDeepOwnPropertyVal({ tea: { green: 'matcha' } }, 'coffee', { green: 'matcha' }); - * assert.notDeepOwnPropertyVal({}, 'toString', Object.prototype.toString); - * - * @name notDeepOwnPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.notDeepOwnPropertyVal = function (obj, prop, value, msg) { - new Assertion(obj, msg, assert.notDeepOwnPropertyVal, true) - .to.not.have.deep.own.property(prop, value); - }; - - /** - * ### .nestedProperty(object, property, [message]) - * - * Asserts that `object` has a direct or inherited property named by - * `property`, which can be a string using dot- and bracket-notation for - * nested reference. - * - * assert.nestedProperty({ tea: { green: 'matcha' }}, 'tea.green'); - * - * @name nestedProperty - * @param {Object} object - * @param {String} property - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.nestedProperty = function (obj, prop, msg) { - new Assertion(obj, msg, assert.nestedProperty, true) - .to.have.nested.property(prop); - }; - - /** - * ### .notNestedProperty(object, property, [message]) - * - * Asserts that `object` does _not_ have a property named by `property`, which - * can be a string using dot- and bracket-notation for nested reference. The - * property cannot exist on the object nor anywhere in its prototype chain. - * - * assert.notNestedProperty({ tea: { green: 'matcha' }}, 'tea.oolong'); - * - * @name notNestedProperty - * @param {Object} object - * @param {String} property - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notNestedProperty = function (obj, prop, msg) { - new Assertion(obj, msg, assert.notNestedProperty, true) - .to.not.have.nested.property(prop); - }; - - /** - * ### .nestedPropertyVal(object, property, value, [message]) - * - * Asserts that `object` has a property named by `property` with value given - * by `value`. `property` can use dot- and bracket-notation for nested - * reference. Uses a strict equality check (===). - * - * assert.nestedPropertyVal({ tea: { green: 'matcha' }}, 'tea.green', 'matcha'); - * - * @name nestedPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.nestedPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.nestedPropertyVal, true) - .to.have.nested.property(prop, val); - }; - - /** - * ### .notNestedPropertyVal(object, property, value, [message]) - * - * Asserts that `object` does _not_ have a property named by `property` with - * value given by `value`. `property` can use dot- and bracket-notation for - * nested reference. Uses a strict equality check (===). - * - * assert.notNestedPropertyVal({ tea: { green: 'matcha' }}, 'tea.green', 'konacha'); - * assert.notNestedPropertyVal({ tea: { green: 'matcha' }}, 'coffee.green', 'matcha'); - * - * @name notNestedPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notNestedPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.notNestedPropertyVal, true) - .to.not.have.nested.property(prop, val); - }; - - /** - * ### .deepNestedPropertyVal(object, property, value, [message]) - * - * Asserts that `object` has a property named by `property` with a value given - * by `value`. `property` can use dot- and bracket-notation for nested - * reference. Uses a deep equality check. - * - * assert.deepNestedPropertyVal({ tea: { green: { matcha: 'yum' } } }, 'tea.green', { matcha: 'yum' }); - * - * @name deepNestedPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.deepNestedPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.deepNestedPropertyVal, true) - .to.have.deep.nested.property(prop, val); - }; - - /** - * ### .notDeepNestedPropertyVal(object, property, value, [message]) - * - * Asserts that `object` does _not_ have a property named by `property` with - * value given by `value`. `property` can use dot- and bracket-notation for - * nested reference. Uses a deep equality check. - * - * assert.notDeepNestedPropertyVal({ tea: { green: { matcha: 'yum' } } }, 'tea.green', { oolong: 'yum' }); - * assert.notDeepNestedPropertyVal({ tea: { green: { matcha: 'yum' } } }, 'tea.green', { matcha: 'yuck' }); - * assert.notDeepNestedPropertyVal({ tea: { green: { matcha: 'yum' } } }, 'tea.black', { matcha: 'yum' }); - * - * @name notDeepNestedPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notDeepNestedPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.notDeepNestedPropertyVal, true) - .to.not.have.deep.nested.property(prop, val); - } - - /** - * ### .lengthOf(object, length, [message]) - * - * Asserts that `object` has a `length` or `size` with the expected value. - * - * assert.lengthOf([1,2,3], 3, 'array has length of 3'); - * assert.lengthOf('foobar', 6, 'string has length of 6'); - * assert.lengthOf(new Set([1,2,3]), 3, 'set has size of 3'); - * assert.lengthOf(new Map([['a',1],['b',2],['c',3]]), 3, 'map has size of 3'); - * - * @name lengthOf - * @param {Mixed} object - * @param {Number} length - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.lengthOf = function (exp, len, msg) { - new Assertion(exp, msg, assert.lengthOf, true).to.have.lengthOf(len); - }; - - /** - * ### .hasAnyKeys(object, [keys], [message]) - * - * Asserts that `object` has at least one of the `keys` provided. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.hasAnyKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'iDontExist', 'baz']); - * assert.hasAnyKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, iDontExist: 99, baz: 1337}); - * assert.hasAnyKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']); - * assert.hasAnyKeys(new Set([{foo: 'bar'}, 'anotherKey']), [{foo: 'bar'}, 'anotherKey']); - * - * @name hasAnyKeys - * @param {Mixed} object - * @param {Array|Object} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.hasAnyKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.hasAnyKeys, true).to.have.any.keys(keys); - } - - /** - * ### .hasAllKeys(object, [keys], [message]) - * - * Asserts that `object` has all and only all of the `keys` provided. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.hasAllKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'bar', 'baz']); - * assert.hasAllKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, bar: 99, baz: 1337]); - * assert.hasAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']); - * assert.hasAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{foo: 'bar'}, 'anotherKey']); - * - * @name hasAllKeys - * @param {Mixed} object - * @param {String[]} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.hasAllKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.hasAllKeys, true).to.have.all.keys(keys); - } - - /** - * ### .containsAllKeys(object, [keys], [message]) - * - * Asserts that `object` has all of the `keys` provided but may have more keys not listed. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'baz']); - * assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'bar', 'baz']); - * assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, baz: 1337}); - * assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, bar: 99, baz: 1337}); - * assert.containsAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}]); - * assert.containsAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']); - * assert.containsAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{foo: 'bar'}]); - * assert.containsAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{foo: 'bar'}, 'anotherKey']); - * - * @name containsAllKeys - * @param {Mixed} object - * @param {String[]} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.containsAllKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.containsAllKeys, true) - .to.contain.all.keys(keys); - } - - /** - * ### .doesNotHaveAnyKeys(object, [keys], [message]) - * - * Asserts that `object` has none of the `keys` provided. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.doesNotHaveAnyKeys({foo: 1, bar: 2, baz: 3}, ['one', 'two', 'example']); - * assert.doesNotHaveAnyKeys({foo: 1, bar: 2, baz: 3}, {one: 1, two: 2, example: 'foo'}); - * assert.doesNotHaveAnyKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{one: 'two'}, 'example']); - * assert.doesNotHaveAnyKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{one: 'two'}, 'example']); - * - * @name doesNotHaveAnyKeys - * @param {Mixed} object - * @param {String[]} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.doesNotHaveAnyKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true) - .to.not.have.any.keys(keys); - } - - /** - * ### .doesNotHaveAllKeys(object, [keys], [message]) - * - * Asserts that `object` does not have at least one of the `keys` provided. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.doesNotHaveAllKeys({foo: 1, bar: 2, baz: 3}, ['one', 'two', 'example']); - * assert.doesNotHaveAllKeys({foo: 1, bar: 2, baz: 3}, {one: 1, two: 2, example: 'foo'}); - * assert.doesNotHaveAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{one: 'two'}, 'example']); - * assert.doesNotHaveAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{one: 'two'}, 'example']); - * - * @name doesNotHaveAllKeys - * @param {Mixed} object - * @param {String[]} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.doesNotHaveAllKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.doesNotHaveAllKeys, true) - .to.not.have.all.keys(keys); - } - - /** - * ### .hasAnyDeepKeys(object, [keys], [message]) - * - * Asserts that `object` has at least one of the `keys` provided. - * Since Sets and Maps can have objects as keys you can use this assertion to perform - * a deep comparison. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {one: 'one'}); - * assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), [{one: 'one'}, {two: 'two'}]); - * assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]); - * assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {one: 'one'}); - * assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {three: 'three'}]); - * assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]); - * - * @name hasAnyDeepKeys - * @param {Mixed} object - * @param {Array|Object} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.hasAnyDeepKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.hasAnyDeepKeys, true) - .to.have.any.deep.keys(keys); - } - - /** - * ### .hasAllDeepKeys(object, [keys], [message]) - * - * Asserts that `object` has all and only all of the `keys` provided. - * Since Sets and Maps can have objects as keys you can use this assertion to perform - * a deep comparison. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.hasAllDeepKeys(new Map([[{one: 'one'}, 'valueOne']]), {one: 'one'}); - * assert.hasAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]); - * assert.hasAllDeepKeys(new Set([{one: 'one'}]), {one: 'one'}); - * assert.hasAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]); - * - * @name hasAllDeepKeys - * @param {Mixed} object - * @param {Array|Object} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.hasAllDeepKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.hasAllDeepKeys, true) - .to.have.all.deep.keys(keys); - } - - /** - * ### .containsAllDeepKeys(object, [keys], [message]) - * - * Asserts that `object` contains all of the `keys` provided. - * Since Sets and Maps can have objects as keys you can use this assertion to perform - * a deep comparison. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.containsAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {one: 'one'}); - * assert.containsAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]); - * assert.containsAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {one: 'one'}); - * assert.containsAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]); - * - * @name containsAllDeepKeys - * @param {Mixed} object - * @param {Array|Object} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.containsAllDeepKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.containsAllDeepKeys, true) - .to.contain.all.deep.keys(keys); - } - - /** - * ### .doesNotHaveAnyDeepKeys(object, [keys], [message]) - * - * Asserts that `object` has none of the `keys` provided. - * Since Sets and Maps can have objects as keys you can use this assertion to perform - * a deep comparison. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.doesNotHaveAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {thisDoesNot: 'exist'}); - * assert.doesNotHaveAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{twenty: 'twenty'}, {fifty: 'fifty'}]); - * assert.doesNotHaveAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {twenty: 'twenty'}); - * assert.doesNotHaveAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{twenty: 'twenty'}, {fifty: 'fifty'}]); - * - * @name doesNotHaveAnyDeepKeys - * @param {Mixed} object - * @param {Array|Object} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.doesNotHaveAnyDeepKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.doesNotHaveAnyDeepKeys, true) - .to.not.have.any.deep.keys(keys); - } - - /** - * ### .doesNotHaveAllDeepKeys(object, [keys], [message]) - * - * Asserts that `object` does not have at least one of the `keys` provided. - * Since Sets and Maps can have objects as keys you can use this assertion to perform - * a deep comparison. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.doesNotHaveAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {thisDoesNot: 'exist'}); - * assert.doesNotHaveAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{twenty: 'twenty'}, {one: 'one'}]); - * assert.doesNotHaveAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {twenty: 'twenty'}); - * assert.doesNotHaveAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {fifty: 'fifty'}]); - * - * @name doesNotHaveAllDeepKeys - * @param {Mixed} object - * @param {Array|Object} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.doesNotHaveAllDeepKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.doesNotHaveAllDeepKeys, true) - .to.not.have.all.deep.keys(keys); - } - - /** - * ### .throws(fn, [errorLike/string/regexp], [string/regexp], [message]) - * - * If `errorLike` is an `Error` constructor, asserts that `fn` will throw an error that is an - * instance of `errorLike`. - * If `errorLike` is an `Error` instance, asserts that the error thrown is the same - * instance as `errorLike`. - * If `errMsgMatcher` is provided, it also asserts that the error thrown will have a - * message matching `errMsgMatcher`. - * - * assert.throws(fn, 'Error thrown must have this msg'); - * assert.throws(fn, /Error thrown must have a msg that matches this/); - * assert.throws(fn, ReferenceError); - * assert.throws(fn, errorInstance); - * assert.throws(fn, ReferenceError, 'Error thrown must be a ReferenceError and have this msg'); - * assert.throws(fn, errorInstance, 'Error thrown must be the same errorInstance and have this msg'); - * assert.throws(fn, ReferenceError, /Error thrown must be a ReferenceError and match this/); - * assert.throws(fn, errorInstance, /Error thrown must be the same errorInstance and match this/); - * - * @name throws - * @alias throw - * @alias Throw - * @param {Function} fn - * @param {ErrorConstructor|Error} errorLike - * @param {RegExp|String} errMsgMatcher - * @param {String} message - * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types - * @namespace Assert - * @api public - */ - - assert.throws = function (fn, errorLike, errMsgMatcher, msg) { - if ('string' === typeof errorLike || errorLike instanceof RegExp) { - errMsgMatcher = errorLike; - errorLike = null; - } - - var assertErr = new Assertion(fn, msg, assert.throws, true) - .to.throw(errorLike, errMsgMatcher); - return flag(assertErr, 'object'); - }; - - /** - * ### .doesNotThrow(fn, [errorLike/string/regexp], [string/regexp], [message]) - * - * If `errorLike` is an `Error` constructor, asserts that `fn` will _not_ throw an error that is an - * instance of `errorLike`. - * If `errorLike` is an `Error` instance, asserts that the error thrown is _not_ the same - * instance as `errorLike`. - * If `errMsgMatcher` is provided, it also asserts that the error thrown will _not_ have a - * message matching `errMsgMatcher`. - * - * assert.doesNotThrow(fn, 'Any Error thrown must not have this message'); - * assert.doesNotThrow(fn, /Any Error thrown must not match this/); - * assert.doesNotThrow(fn, Error); - * assert.doesNotThrow(fn, errorInstance); - * assert.doesNotThrow(fn, Error, 'Error must not have this message'); - * assert.doesNotThrow(fn, errorInstance, 'Error must not have this message'); - * assert.doesNotThrow(fn, Error, /Error must not match this/); - * assert.doesNotThrow(fn, errorInstance, /Error must not match this/); - * - * @name doesNotThrow - * @param {Function} fn - * @param {ErrorConstructor} errorLike - * @param {RegExp|String} errMsgMatcher - * @param {String} message - * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types - * @namespace Assert - * @api public - */ - - assert.doesNotThrow = function (fn, errorLike, errMsgMatcher, msg) { - if ('string' === typeof errorLike || errorLike instanceof RegExp) { - errMsgMatcher = errorLike; - errorLike = null; - } - - new Assertion(fn, msg, assert.doesNotThrow, true) - .to.not.throw(errorLike, errMsgMatcher); - }; - - /** - * ### .operator(val1, operator, val2, [message]) - * - * Compares two values using `operator`. - * - * assert.operator(1, '<', 2, 'everything is ok'); - * assert.operator(1, '>', 2, 'this will fail'); - * - * @name operator - * @param {Mixed} val1 - * @param {String} operator - * @param {Mixed} val2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.operator = function (val, operator, val2, msg) { - var ok; - switch(operator) { - case '==': - ok = val == val2; - break; - case '===': - ok = val === val2; - break; - case '>': - ok = val > val2; - break; - case '>=': - ok = val >= val2; - break; - case '<': - ok = val < val2; - break; - case '<=': - ok = val <= val2; - break; - case '!=': - ok = val != val2; - break; - case '!==': - ok = val !== val2; - break; - default: - msg = msg ? msg + ': ' : msg; - throw new chai.AssertionError( - msg + 'Invalid operator "' + operator + '"', - undefined, - assert.operator - ); - } - var test = new Assertion(ok, msg, assert.operator, true); - test.assert( - true === flag(test, 'object') - , 'expected ' + util.inspect(val) + ' to be ' + operator + ' ' + util.inspect(val2) - , 'expected ' + util.inspect(val) + ' to not be ' + operator + ' ' + util.inspect(val2) ); - }; - - /** - * ### .closeTo(actual, expected, delta, [message]) - * - * Asserts that the target is equal `expected`, to within a +/- `delta` range. - * - * assert.closeTo(1.5, 1, 0.5, 'numbers are close'); - * - * @name closeTo - * @param {Number} actual - * @param {Number} expected - * @param {Number} delta - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.closeTo = function (act, exp, delta, msg) { - new Assertion(act, msg, assert.closeTo, true).to.be.closeTo(exp, delta); - }; - - /** - * ### .approximately(actual, expected, delta, [message]) - * - * Asserts that the target is equal `expected`, to within a +/- `delta` range. - * - * assert.approximately(1.5, 1, 0.5, 'numbers are close'); - * - * @name approximately - * @param {Number} actual - * @param {Number} expected - * @param {Number} delta - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.approximately = function (act, exp, delta, msg) { - new Assertion(act, msg, assert.approximately, true) - .to.be.approximately(exp, delta); - }; - - /** - * ### .sameMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` have the same members in any order. Uses a - * strict equality check (===). - * - * assert.sameMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'same members'); - * - * @name sameMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.sameMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.sameMembers, true) - .to.have.same.members(set2); - } - - /** - * ### .notSameMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` don't have the same members in any order. - * Uses a strict equality check (===). - * - * assert.notSameMembers([ 1, 2, 3 ], [ 5, 1, 3 ], 'not same members'); - * - * @name notSameMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notSameMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.notSameMembers, true) - .to.not.have.same.members(set2); - } - - /** - * ### .sameDeepMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` have the same members in any order. Uses a - * deep equality check. - * - * assert.sameDeepMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [{ b: 2 }, { a: 1 }, { c: 3 }], 'same deep members'); - * - * @name sameDeepMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.sameDeepMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.sameDeepMembers, true) - .to.have.same.deep.members(set2); - } - - /** - * ### .notSameDeepMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` don't have the same members in any order. - * Uses a deep equality check. - * - * assert.notSameDeepMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [{ b: 2 }, { a: 1 }, { f: 5 }], 'not same deep members'); - * - * @name notSameDeepMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notSameDeepMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.notSameDeepMembers, true) - .to.not.have.same.deep.members(set2); - } - - /** - * ### .sameOrderedMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` have the same members in the same order. - * Uses a strict equality check (===). - * - * assert.sameOrderedMembers([ 1, 2, 3 ], [ 1, 2, 3 ], 'same ordered members'); - * - * @name sameOrderedMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.sameOrderedMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.sameOrderedMembers, true) - .to.have.same.ordered.members(set2); - } - - /** - * ### .notSameOrderedMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` don't have the same members in the same - * order. Uses a strict equality check (===). - * - * assert.notSameOrderedMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'not same ordered members'); - * - * @name notSameOrderedMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notSameOrderedMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.notSameOrderedMembers, true) - .to.not.have.same.ordered.members(set2); - } - - /** - * ### .sameDeepOrderedMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` have the same members in the same order. - * Uses a deep equality check. - * - * assert.sameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { c: 3 } ], 'same deep ordered members'); - * - * @name sameDeepOrderedMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.sameDeepOrderedMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.sameDeepOrderedMembers, true) - .to.have.same.deep.ordered.members(set2); - } - - /** - * ### .notSameDeepOrderedMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` don't have the same members in the same - * order. Uses a deep equality check. - * - * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { z: 5 } ], 'not same deep ordered members'); - * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { c: 3 } ], 'not same deep ordered members'); - * - * @name notSameDeepOrderedMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notSameDeepOrderedMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.notSameDeepOrderedMembers, true) - .to.not.have.same.deep.ordered.members(set2); - } - - /** - * ### .includeMembers(superset, subset, [message]) - * - * Asserts that `subset` is included in `superset` in any order. Uses a - * strict equality check (===). Duplicates are ignored. - * - * assert.includeMembers([ 1, 2, 3 ], [ 2, 1, 2 ], 'include members'); - * - * @name includeMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.includeMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.includeMembers, true) - .to.include.members(subset); - } - - /** - * ### .notIncludeMembers(superset, subset, [message]) - * - * Asserts that `subset` isn't included in `superset` in any order. Uses a - * strict equality check (===). Duplicates are ignored. - * - * assert.notIncludeMembers([ 1, 2, 3 ], [ 5, 1 ], 'not include members'); - * - * @name notIncludeMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notIncludeMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.notIncludeMembers, true) - .to.not.include.members(subset); - } - - /** - * ### .includeDeepMembers(superset, subset, [message]) - * - * Asserts that `subset` is included in `superset` in any order. Uses a deep - * equality check. Duplicates are ignored. - * - * assert.includeDeepMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { b: 2 } ], 'include deep members'); - * - * @name includeDeepMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.includeDeepMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.includeDeepMembers, true) - .to.include.deep.members(subset); - } - - /** - * ### .notIncludeDeepMembers(superset, subset, [message]) - * - * Asserts that `subset` isn't included in `superset` in any order. Uses a - * deep equality check. Duplicates are ignored. - * - * assert.notIncludeDeepMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { f: 5 } ], 'not include deep members'); - * - * @name notIncludeDeepMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notIncludeDeepMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.notIncludeDeepMembers, true) - .to.not.include.deep.members(subset); - } - - /** - * ### .includeOrderedMembers(superset, subset, [message]) - * - * Asserts that `subset` is included in `superset` in the same order - * beginning with the first element in `superset`. Uses a strict equality - * check (===). - * - * assert.includeOrderedMembers([ 1, 2, 3 ], [ 1, 2 ], 'include ordered members'); - * - * @name includeOrderedMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.includeOrderedMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.includeOrderedMembers, true) - .to.include.ordered.members(subset); - } - - /** - * ### .notIncludeOrderedMembers(superset, subset, [message]) - * - * Asserts that `subset` isn't included in `superset` in the same order - * beginning with the first element in `superset`. Uses a strict equality - * check (===). - * - * assert.notIncludeOrderedMembers([ 1, 2, 3 ], [ 2, 1 ], 'not include ordered members'); - * assert.notIncludeOrderedMembers([ 1, 2, 3 ], [ 2, 3 ], 'not include ordered members'); - * - * @name notIncludeOrderedMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notIncludeOrderedMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.notIncludeOrderedMembers, true) - .to.not.include.ordered.members(subset); - } - - /** - * ### .includeDeepOrderedMembers(superset, subset, [message]) - * - * Asserts that `subset` is included in `superset` in the same order - * beginning with the first element in `superset`. Uses a deep equality - * check. - * - * assert.includeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 } ], 'include deep ordered members'); - * - * @name includeDeepOrderedMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.includeDeepOrderedMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.includeDeepOrderedMembers, true) - .to.include.deep.ordered.members(subset); - } - - /** - * ### .notIncludeDeepOrderedMembers(superset, subset, [message]) - * - * Asserts that `subset` isn't included in `superset` in the same order - * beginning with the first element in `superset`. Uses a deep equality - * check. - * - * assert.notIncludeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { f: 5 } ], 'not include deep ordered members'); - * assert.notIncludeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 } ], 'not include deep ordered members'); - * assert.notIncludeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { c: 3 } ], 'not include deep ordered members'); - * - * @name notIncludeDeepOrderedMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notIncludeDeepOrderedMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.notIncludeDeepOrderedMembers, true) - .to.not.include.deep.ordered.members(subset); - } - - /** - * ### .oneOf(inList, list, [message]) - * - * Asserts that non-object, non-array value `inList` appears in the flat array `list`. - * - * assert.oneOf(1, [ 2, 1 ], 'Not found in list'); - * - * @name oneOf - * @param {*} inList - * @param {Array<*>} list - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.oneOf = function (inList, list, msg) { - new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list); - } - - /** - * ### .changes(function, object, property, [message]) - * - * Asserts that a function changes the value of a property. - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 22 }; - * assert.changes(fn, obj, 'val'); - * - * @name changes - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.changes = function (fn, obj, prop, msg) { - if (arguments.length === 3 && typeof obj === 'function') { - msg = prop; - prop = null; - } - - new Assertion(fn, msg, assert.changes, true).to.change(obj, prop); - } - - /** - * ### .changesBy(function, object, property, delta, [message]) - * - * Asserts that a function changes the value of a property by an amount (delta). - * - * var obj = { val: 10 }; - * var fn = function() { obj.val += 2 }; - * assert.changesBy(fn, obj, 'val', 2); - * - * @name changesBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.changesBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - new Assertion(fn, msg, assert.changesBy, true) - .to.change(obj, prop).by(delta); - } - - /** - * ### .doesNotChange(function, object, property, [message]) - * - * Asserts that a function does not change the value of a property. - * - * var obj = { val: 10 }; - * var fn = function() { console.log('foo'); }; - * assert.doesNotChange(fn, obj, 'val'); - * - * @name doesNotChange - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.doesNotChange = function (fn, obj, prop, msg) { - if (arguments.length === 3 && typeof obj === 'function') { - msg = prop; - prop = null; - } - - return new Assertion(fn, msg, assert.doesNotChange, true) - .to.not.change(obj, prop); - } - - /** - * ### .changesButNotBy(function, object, property, delta, [message]) - * - * Asserts that a function does not change the value of a property or of a function's return value by an amount (delta) - * - * var obj = { val: 10 }; - * var fn = function() { obj.val += 10 }; - * assert.changesButNotBy(fn, obj, 'val', 5); - * - * @name changesButNotBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.changesButNotBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - new Assertion(fn, msg, assert.changesButNotBy, true) - .to.change(obj, prop).but.not.by(delta); - } - - /** - * ### .increases(function, object, property, [message]) - * - * Asserts that a function increases a numeric object property. - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 13 }; - * assert.increases(fn, obj, 'val'); - * - * @name increases - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.increases = function (fn, obj, prop, msg) { - if (arguments.length === 3 && typeof obj === 'function') { - msg = prop; - prop = null; - } - - return new Assertion(fn, msg, assert.increases, true) - .to.increase(obj, prop); - } - - /** - * ### .increasesBy(function, object, property, delta, [message]) - * - * Asserts that a function increases a numeric object property or a function's return value by an amount (delta). - * - * var obj = { val: 10 }; - * var fn = function() { obj.val += 10 }; - * assert.increasesBy(fn, obj, 'val', 10); - * - * @name increasesBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.increasesBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - new Assertion(fn, msg, assert.increasesBy, true) - .to.increase(obj, prop).by(delta); - } - - /** - * ### .doesNotIncrease(function, object, property, [message]) - * - * Asserts that a function does not increase a numeric object property. - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 8 }; - * assert.doesNotIncrease(fn, obj, 'val'); - * - * @name doesNotIncrease - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.doesNotIncrease = function (fn, obj, prop, msg) { - if (arguments.length === 3 && typeof obj === 'function') { - msg = prop; - prop = null; - } - - return new Assertion(fn, msg, assert.doesNotIncrease, true) - .to.not.increase(obj, prop); - } - - /** - * ### .increasesButNotBy(function, object, property, delta, [message]) - * - * Asserts that a function does not increase a numeric object property or function's return value by an amount (delta). - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 15 }; - * assert.increasesButNotBy(fn, obj, 'val', 10); - * - * @name increasesButNotBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.increasesButNotBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - new Assertion(fn, msg, assert.increasesButNotBy, true) - .to.increase(obj, prop).but.not.by(delta); - } - - /** - * ### .decreases(function, object, property, [message]) - * - * Asserts that a function decreases a numeric object property. - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 5 }; - * assert.decreases(fn, obj, 'val'); - * - * @name decreases - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.decreases = function (fn, obj, prop, msg) { - if (arguments.length === 3 && typeof obj === 'function') { - msg = prop; - prop = null; - } - - return new Assertion(fn, msg, assert.decreases, true) - .to.decrease(obj, prop); - } - - /** - * ### .decreasesBy(function, object, property, delta, [message]) - * - * Asserts that a function decreases a numeric object property or a function's return value by an amount (delta) - * - * var obj = { val: 10 }; - * var fn = function() { obj.val -= 5 }; - * assert.decreasesBy(fn, obj, 'val', 5); - * - * @name decreasesBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.decreasesBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - new Assertion(fn, msg, assert.decreasesBy, true) - .to.decrease(obj, prop).by(delta); - } - - /** - * ### .doesNotDecrease(function, object, property, [message]) - * - * Asserts that a function does not decreases a numeric object property. - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 15 }; - * assert.doesNotDecrease(fn, obj, 'val'); - * - * @name doesNotDecrease - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.doesNotDecrease = function (fn, obj, prop, msg) { - if (arguments.length === 3 && typeof obj === 'function') { - msg = prop; - prop = null; - } - - return new Assertion(fn, msg, assert.doesNotDecrease, true) - .to.not.decrease(obj, prop); - } - - /** - * ### .doesNotDecreaseBy(function, object, property, delta, [message]) - * - * Asserts that a function does not decreases a numeric object property or a function's return value by an amount (delta) - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 5 }; - * assert.doesNotDecreaseBy(fn, obj, 'val', 1); - * - * @name doesNotDecreaseBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.doesNotDecreaseBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - return new Assertion(fn, msg, assert.doesNotDecreaseBy, true) - .to.not.decrease(obj, prop).by(delta); - } - - /** - * ### .decreasesButNotBy(function, object, property, delta, [message]) - * - * Asserts that a function does not decreases a numeric object property or a function's return value by an amount (delta) - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 5 }; - * assert.decreasesButNotBy(fn, obj, 'val', 1); - * - * @name decreasesButNotBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.decreasesButNotBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - new Assertion(fn, msg, assert.decreasesButNotBy, true) - .to.decrease(obj, prop).but.not.by(delta); - } - - /*! - * ### .ifError(object) - * - * Asserts if value is not a false value, and throws if it is a true value. - * This is added to allow for chai to be a drop-in replacement for Node's - * assert class. - * - * var err = new Error('I am a custom error'); - * assert.ifError(err); // Rethrows err! - * - * @name ifError - * @param {Object} object - * @namespace Assert - * @api public - */ - - assert.ifError = function (val) { - if (val) { - throw(val); - } - }; - - /** - * ### .isExtensible(object) - * - * Asserts that `object` is extensible (can have new properties added to it). - * - * assert.isExtensible({}); - * - * @name isExtensible - * @alias extensible - * @param {Object} object - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isExtensible = function (obj, msg) { - new Assertion(obj, msg, assert.isExtensible, true).to.be.extensible; - }; - - /** - * ### .isNotExtensible(object) - * - * Asserts that `object` is _not_ extensible. - * - * var nonExtensibleObject = Object.preventExtensions({}); - * var sealedObject = Object.seal({}); - * var frozenObject = Object.freeze({}); - * - * assert.isNotExtensible(nonExtensibleObject); - * assert.isNotExtensible(sealedObject); - * assert.isNotExtensible(frozenObject); - * - * @name isNotExtensible - * @alias notExtensible - * @param {Object} object - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isNotExtensible = function (obj, msg) { - new Assertion(obj, msg, assert.isNotExtensible, true).to.not.be.extensible; - }; - - /** - * ### .isSealed(object) - * - * Asserts that `object` is sealed (cannot have new properties added to it - * and its existing properties cannot be removed). - * - * var sealedObject = Object.seal({}); - * var frozenObject = Object.seal({}); - * - * assert.isSealed(sealedObject); - * assert.isSealed(frozenObject); - * - * @name isSealed - * @alias sealed - * @param {Object} object - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isSealed = function (obj, msg) { - new Assertion(obj, msg, assert.isSealed, true).to.be.sealed; - }; - - /** - * ### .isNotSealed(object) - * - * Asserts that `object` is _not_ sealed. - * - * assert.isNotSealed({}); - * - * @name isNotSealed - * @alias notSealed - * @param {Object} object - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isNotSealed = function (obj, msg) { - new Assertion(obj, msg, assert.isNotSealed, true).to.not.be.sealed; - }; - - /** - * ### .isFrozen(object) - * - * Asserts that `object` is frozen (cannot have new properties added to it - * and its existing properties cannot be modified). - * - * var frozenObject = Object.freeze({}); - * assert.frozen(frozenObject); - * - * @name isFrozen - * @alias frozen - * @param {Object} object - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isFrozen = function (obj, msg) { - new Assertion(obj, msg, assert.isFrozen, true).to.be.frozen; - }; - - /** - * ### .isNotFrozen(object) - * - * Asserts that `object` is _not_ frozen. - * - * assert.isNotFrozen({}); - * - * @name isNotFrozen - * @alias notFrozen - * @param {Object} object - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isNotFrozen = function (obj, msg) { - new Assertion(obj, msg, assert.isNotFrozen, true).to.not.be.frozen; - }; - - /** - * ### .isEmpty(target) - * - * Asserts that the target does not contain any values. - * For arrays and strings, it checks the `length` property. - * For `Map` and `Set` instances, it checks the `size` property. - * For non-function objects, it gets the count of own - * enumerable string keys. - * - * assert.isEmpty([]); - * assert.isEmpty(''); - * assert.isEmpty(new Map); - * assert.isEmpty({}); - * - * @name isEmpty - * @alias empty - * @param {Object|Array|String|Map|Set} target - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isEmpty = function(val, msg) { - new Assertion(val, msg, assert.isEmpty, true).to.be.empty; - }; - - /** - * ### .isNotEmpty(target) - * - * Asserts that the target contains values. - * For arrays and strings, it checks the `length` property. - * For `Map` and `Set` instances, it checks the `size` property. - * For non-function objects, it gets the count of own - * enumerable string keys. - * - * assert.isNotEmpty([1, 2]); - * assert.isNotEmpty('34'); - * assert.isNotEmpty(new Set([5, 6])); - * assert.isNotEmpty({ key: 7 }); - * - * @name isNotEmpty - * @alias notEmpty - * @param {Object|Array|String|Map|Set} target - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isNotEmpty = function(val, msg) { - new Assertion(val, msg, assert.isNotEmpty, true).to.not.be.empty; - }; - - /*! - * Aliases. - */ - - (function alias(name, as){ - assert[as] = assert[name]; - return alias; - }) - ('isOk', 'ok') - ('isNotOk', 'notOk') - ('throws', 'throw') - ('throws', 'Throw') - ('isExtensible', 'extensible') - ('isNotExtensible', 'notExtensible') - ('isSealed', 'sealed') - ('isNotSealed', 'notSealed') - ('isFrozen', 'frozen') - ('isNotFrozen', 'notFrozen') - ('isEmpty', 'empty') - ('isNotEmpty', 'notEmpty'); -}; - -},{}],7:[function(require,module,exports){ -/*! - * chai - * Copyright(c) 2011-2014 Jake Luer - * MIT Licensed - */ - -module.exports = function (chai, util) { - chai.expect = function (val, message) { - return new chai.Assertion(val, message); - }; - - /** - * ### .fail([message]) - * ### .fail(actual, expected, [message], [operator]) - * - * Throw a failure. - * - * expect.fail(); - * expect.fail("custom error message"); - * expect.fail(1, 2); - * expect.fail(1, 2, "custom error message"); - * expect.fail(1, 2, "custom error message", ">"); - * expect.fail(1, 2, undefined, ">"); - * - * @name fail - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @param {String} operator - * @namespace BDD - * @api public - */ - - chai.expect.fail = function (actual, expected, message, operator) { - if (arguments.length < 2) { - message = actual; - actual = undefined; - } - - message = message || 'expect.fail()'; - throw new chai.AssertionError(message, { - actual: actual - , expected: expected - , operator: operator - }, chai.expect.fail); - }; -}; - -},{}],8:[function(require,module,exports){ -/*! - * chai - * Copyright(c) 2011-2014 Jake Luer - * MIT Licensed - */ - -module.exports = function (chai, util) { - var Assertion = chai.Assertion; - - function loadShould () { - // explicitly define this method as function as to have it's name to include as `ssfi` - function shouldGetter() { - if (this instanceof String - || this instanceof Number - || this instanceof Boolean - || typeof Symbol === 'function' && this instanceof Symbol - || typeof BigInt === 'function' && this instanceof BigInt) { - return new Assertion(this.valueOf(), null, shouldGetter); - } - return new Assertion(this, null, shouldGetter); - } - function shouldSetter(value) { - // See https://github.com/chaijs/chai/issues/86: this makes - // `whatever.should = someValue` actually set `someValue`, which is - // especially useful for `global.should = require('chai').should()`. - // - // Note that we have to use [[DefineProperty]] instead of [[Put]] - // since otherwise we would trigger this very setter! - Object.defineProperty(this, 'should', { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } - // modify Object.prototype to have `should` - Object.defineProperty(Object.prototype, 'should', { - set: shouldSetter - , get: shouldGetter - , configurable: true - }); - - var should = {}; - - /** - * ### .fail([message]) - * ### .fail(actual, expected, [message], [operator]) - * - * Throw a failure. - * - * should.fail(); - * should.fail("custom error message"); - * should.fail(1, 2); - * should.fail(1, 2, "custom error message"); - * should.fail(1, 2, "custom error message", ">"); - * should.fail(1, 2, undefined, ">"); - * - * - * @name fail - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @param {String} operator - * @namespace BDD - * @api public - */ - - should.fail = function (actual, expected, message, operator) { - if (arguments.length < 2) { - message = actual; - actual = undefined; - } - - message = message || 'should.fail()'; - throw new chai.AssertionError(message, { - actual: actual - , expected: expected - , operator: operator - }, should.fail); - }; - - /** - * ### .equal(actual, expected, [message]) - * - * Asserts non-strict equality (`==`) of `actual` and `expected`. - * - * should.equal(3, '3', '== coerces values to strings'); - * - * @name equal - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Should - * @api public - */ - - should.equal = function (val1, val2, msg) { - new Assertion(val1, msg).to.equal(val2); - }; - - /** - * ### .throw(function, [constructor/string/regexp], [string/regexp], [message]) - * - * Asserts that `function` will throw an error that is an instance of - * `constructor`, or alternately that it will throw an error with message - * matching `regexp`. - * - * should.throw(fn, 'function throws a reference error'); - * should.throw(fn, /function throws a reference error/); - * should.throw(fn, ReferenceError); - * should.throw(fn, ReferenceError, 'function throws a reference error'); - * should.throw(fn, ReferenceError, /function throws a reference error/); - * - * @name throw - * @alias Throw - * @param {Function} function - * @param {ErrorConstructor} constructor - * @param {RegExp} regexp - * @param {String} message - * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types - * @namespace Should - * @api public - */ - - should.Throw = function (fn, errt, errs, msg) { - new Assertion(fn, msg).to.Throw(errt, errs); - }; - - /** - * ### .exist - * - * Asserts that the target is neither `null` nor `undefined`. - * - * var foo = 'hi'; - * - * should.exist(foo, 'foo exists'); - * - * @name exist - * @namespace Should - * @api public - */ - - should.exist = function (val, msg) { - new Assertion(val, msg).to.exist; - } - - // negation - should.not = {} - - /** - * ### .not.equal(actual, expected, [message]) - * - * Asserts non-strict inequality (`!=`) of `actual` and `expected`. - * - * should.not.equal(3, 4, 'these numbers are not equal'); - * - * @name not.equal - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Should - * @api public - */ - - should.not.equal = function (val1, val2, msg) { - new Assertion(val1, msg).to.not.equal(val2); - }; - - /** - * ### .throw(function, [constructor/regexp], [message]) - * - * Asserts that `function` will _not_ throw an error that is an instance of - * `constructor`, or alternately that it will not throw an error with message - * matching `regexp`. - * - * should.not.throw(fn, Error, 'function does not throw'); - * - * @name not.throw - * @alias not.Throw - * @param {Function} function - * @param {ErrorConstructor} constructor - * @param {RegExp} regexp - * @param {String} message - * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types - * @namespace Should - * @api public - */ - - should.not.Throw = function (fn, errt, errs, msg) { - new Assertion(fn, msg).to.not.Throw(errt, errs); - }; - - /** - * ### .not.exist - * - * Asserts that the target is neither `null` nor `undefined`. - * - * var bar = null; - * - * should.not.exist(bar, 'bar does not exist'); - * - * @name not.exist - * @namespace Should - * @api public - */ - - should.not.exist = function (val, msg) { - new Assertion(val, msg).to.not.exist; - } - - should['throw'] = should['Throw']; - should.not['throw'] = should.not['Throw']; - - return should; - }; - - chai.should = loadShould; - chai.Should = loadShould; -}; - -},{}],9:[function(require,module,exports){ -/*! - * Chai - addChainingMethod utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies - */ - -var addLengthGuard = require('./addLengthGuard'); -var chai = require('../../chai'); -var flag = require('./flag'); -var proxify = require('./proxify'); -var transferFlags = require('./transferFlags'); - -/*! - * Module variables - */ - -// Check whether `Object.setPrototypeOf` is supported -var canSetPrototype = typeof Object.setPrototypeOf === 'function'; - -// Without `Object.setPrototypeOf` support, this module will need to add properties to a function. -// However, some of functions' own props are not configurable and should be skipped. -var testFn = function() {}; -var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) { - var propDesc = Object.getOwnPropertyDescriptor(testFn, name); - - // Note: PhantomJS 1.x includes `callee` as one of `testFn`'s own properties, - // but then returns `undefined` as the property descriptor for `callee`. As a - // workaround, we perform an otherwise unnecessary type-check for `propDesc`, - // and then filter it out if it's not an object as it should be. - if (typeof propDesc !== 'object') - return true; - - return !propDesc.configurable; -}); - -// Cache `Function` properties -var call = Function.prototype.call, - apply = Function.prototype.apply; - -/** - * ### .addChainableMethod(ctx, name, method, chainingBehavior) - * - * Adds a method to an object, such that the method can also be chained. - * - * utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) { - * var obj = utils.flag(this, 'object'); - * new chai.Assertion(obj).to.be.equal(str); - * }); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.addChainableMethod('foo', fn, chainingBehavior); - * - * The result can then be used as both a method assertion, executing both `method` and - * `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`. - * - * expect(fooStr).to.be.foo('bar'); - * expect(fooStr).to.be.foo.equal('foo'); - * - * @param {Object} ctx object to which the method is added - * @param {String} name of method to add - * @param {Function} method function to be used for `name`, when called - * @param {Function} chainingBehavior function to be called every time the property is accessed - * @namespace Utils - * @name addChainableMethod - * @api public - */ - -module.exports = function addChainableMethod(ctx, name, method, chainingBehavior) { - if (typeof chainingBehavior !== 'function') { - chainingBehavior = function () { }; - } - - var chainableBehavior = { - method: method - , chainingBehavior: chainingBehavior - }; - - // save the methods so we can overwrite them later, if we need to. - if (!ctx.__methods) { - ctx.__methods = {}; - } - ctx.__methods[name] = chainableBehavior; - - Object.defineProperty(ctx, name, - { get: function chainableMethodGetter() { - chainableBehavior.chainingBehavior.call(this); - - var chainableMethodWrapper = function () { - // Setting the `ssfi` flag to `chainableMethodWrapper` causes this - // function to be the starting point for removing implementation - // frames from the stack trace of a failed assertion. - // - // However, we only want to use this function as the starting point if - // the `lockSsfi` flag isn't set. - // - // If the `lockSsfi` flag is set, then this assertion is being - // invoked from inside of another assertion. In this case, the `ssfi` - // flag has already been set by the outer assertion. - // - // Note that overwriting a chainable method merely replaces the saved - // methods in `ctx.__methods` instead of completely replacing the - // overwritten assertion. Therefore, an overwriting assertion won't - // set the `ssfi` or `lockSsfi` flags. - if (!flag(this, 'lockSsfi')) { - flag(this, 'ssfi', chainableMethodWrapper); - } - - var result = chainableBehavior.method.apply(this, arguments); - if (result !== undefined) { - return result; - } - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - }; - - addLengthGuard(chainableMethodWrapper, name, true); - - // Use `Object.setPrototypeOf` if available - if (canSetPrototype) { - // Inherit all properties from the object by replacing the `Function` prototype - var prototype = Object.create(this); - // Restore the `call` and `apply` methods from `Function` - prototype.call = call; - prototype.apply = apply; - Object.setPrototypeOf(chainableMethodWrapper, prototype); - } - // Otherwise, redefine all properties (slow!) - else { - var asserterNames = Object.getOwnPropertyNames(ctx); - asserterNames.forEach(function (asserterName) { - if (excludeNames.indexOf(asserterName) !== -1) { - return; - } - - var pd = Object.getOwnPropertyDescriptor(ctx, asserterName); - Object.defineProperty(chainableMethodWrapper, asserterName, pd); - }); - } - - transferFlags(this, chainableMethodWrapper); - return proxify(chainableMethodWrapper); - } - , configurable: true - }); -}; - -},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":30,"./transferFlags":32}],10:[function(require,module,exports){ -var fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length'); - -/*! - * Chai - addLengthGuard utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .addLengthGuard(fn, assertionName, isChainable) - * - * Define `length` as a getter on the given uninvoked method assertion. The - * getter acts as a guard against chaining `length` directly off of an uninvoked - * method assertion, which is a problem because it references `function`'s - * built-in `length` property instead of Chai's `length` assertion. When the - * getter catches the user making this mistake, it throws an error with a - * helpful message. - * - * There are two ways in which this mistake can be made. The first way is by - * chaining the `length` assertion directly off of an uninvoked chainable - * method. In this case, Chai suggests that the user use `lengthOf` instead. The - * second way is by chaining the `length` assertion directly off of an uninvoked - * non-chainable method. Non-chainable methods must be invoked prior to - * chaining. In this case, Chai suggests that the user consult the docs for the - * given assertion. - * - * If the `length` property of functions is unconfigurable, then return `fn` - * without modification. - * - * Note that in ES6, the function's `length` property is configurable, so once - * support for legacy environments is dropped, Chai's `length` property can - * replace the built-in function's `length` property, and this length guard will - * no longer be necessary. In the mean time, maintaining consistency across all - * environments is the priority. - * - * @param {Function} fn - * @param {String} assertionName - * @param {Boolean} isChainable - * @namespace Utils - * @name addLengthGuard - */ - -module.exports = function addLengthGuard (fn, assertionName, isChainable) { - if (!fnLengthDesc.configurable) return fn; - - Object.defineProperty(fn, 'length', { - get: function () { - if (isChainable) { - throw Error('Invalid Chai property: ' + assertionName + '.length. Due' + - ' to a compatibility issue, "length" cannot directly follow "' + - assertionName + '". Use "' + assertionName + '.lengthOf" instead.'); - } - - throw Error('Invalid Chai property: ' + assertionName + '.length. See' + - ' docs for proper usage of "' + assertionName + '".'); - } - }); - - return fn; -}; - -},{}],11:[function(require,module,exports){ -/*! - * Chai - addMethod utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -var addLengthGuard = require('./addLengthGuard'); -var chai = require('../../chai'); -var flag = require('./flag'); -var proxify = require('./proxify'); -var transferFlags = require('./transferFlags'); - -/** - * ### .addMethod(ctx, name, method) - * - * Adds a method to the prototype of an object. - * - * utils.addMethod(chai.Assertion.prototype, 'foo', function (str) { - * var obj = utils.flag(this, 'object'); - * new chai.Assertion(obj).to.be.equal(str); - * }); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.addMethod('foo', fn); - * - * Then can be used as any other assertion. - * - * expect(fooStr).to.be.foo('bar'); - * - * @param {Object} ctx object to which the method is added - * @param {String} name of method to add - * @param {Function} method function to be used for name - * @namespace Utils - * @name addMethod - * @api public - */ - -module.exports = function addMethod(ctx, name, method) { - var methodWrapper = function () { - // Setting the `ssfi` flag to `methodWrapper` causes this function to be the - // starting point for removing implementation frames from the stack trace of - // a failed assertion. - // - // However, we only want to use this function as the starting point if the - // `lockSsfi` flag isn't set. - // - // If the `lockSsfi` flag is set, then either this assertion has been - // overwritten by another assertion, or this assertion is being invoked from - // inside of another assertion. In the first case, the `ssfi` flag has - // already been set by the overwriting assertion. In the second case, the - // `ssfi` flag has already been set by the outer assertion. - if (!flag(this, 'lockSsfi')) { - flag(this, 'ssfi', methodWrapper); - } - - var result = method.apply(this, arguments); - if (result !== undefined) - return result; - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - }; - - addLengthGuard(methodWrapper, name, false); - ctx[name] = proxify(methodWrapper, name); -}; - -},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":30,"./transferFlags":32}],12:[function(require,module,exports){ -/*! - * Chai - addProperty utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -var chai = require('../../chai'); -var flag = require('./flag'); -var isProxyEnabled = require('./isProxyEnabled'); -var transferFlags = require('./transferFlags'); - -/** - * ### .addProperty(ctx, name, getter) - * - * Adds a property to the prototype of an object. - * - * utils.addProperty(chai.Assertion.prototype, 'foo', function () { - * var obj = utils.flag(this, 'object'); - * new chai.Assertion(obj).to.be.instanceof(Foo); - * }); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.addProperty('foo', fn); - * - * Then can be used as any other assertion. - * - * expect(myFoo).to.be.foo; - * - * @param {Object} ctx object to which the property is added - * @param {String} name of property to add - * @param {Function} getter function to be used for name - * @namespace Utils - * @name addProperty - * @api public - */ - -module.exports = function addProperty(ctx, name, getter) { - getter = getter === undefined ? function () {} : getter; - - Object.defineProperty(ctx, name, - { get: function propertyGetter() { - // Setting the `ssfi` flag to `propertyGetter` causes this function to - // be the starting point for removing implementation frames from the - // stack trace of a failed assertion. - // - // However, we only want to use this function as the starting point if - // the `lockSsfi` flag isn't set and proxy protection is disabled. - // - // If the `lockSsfi` flag is set, then either this assertion has been - // overwritten by another assertion, or this assertion is being invoked - // from inside of another assertion. In the first case, the `ssfi` flag - // has already been set by the overwriting assertion. In the second - // case, the `ssfi` flag has already been set by the outer assertion. - // - // If proxy protection is enabled, then the `ssfi` flag has already been - // set by the proxy getter. - if (!isProxyEnabled() && !flag(this, 'lockSsfi')) { - flag(this, 'ssfi', propertyGetter); - } - - var result = getter.call(this); - if (result !== undefined) - return result; - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - } - , configurable: true - }); -}; - -},{"../../chai":2,"./flag":15,"./isProxyEnabled":25,"./transferFlags":32}],13:[function(require,module,exports){ -/*! - * Chai - compareByInspect utility - * Copyright(c) 2011-2016 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies - */ - -var inspect = require('./inspect'); - -/** - * ### .compareByInspect(mixed, mixed) - * - * To be used as a compareFunction with Array.prototype.sort. Compares elements - * using inspect instead of default behavior of using toString so that Symbols - * and objects with irregular/missing toString can still be sorted without a - * TypeError. - * - * @param {Mixed} first element to compare - * @param {Mixed} second element to compare - * @returns {Number} -1 if 'a' should come before 'b'; otherwise 1 - * @name compareByInspect - * @namespace Utils - * @api public - */ - -module.exports = function compareByInspect(a, b) { - return inspect(a) < inspect(b) ? -1 : 1; -}; - -},{"./inspect":23}],14:[function(require,module,exports){ -/*! - * Chai - expectTypes utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .expectTypes(obj, types) - * - * Ensures that the object being tested against is of a valid type. - * - * utils.expectTypes(this, ['array', 'object', 'string']); - * - * @param {Mixed} obj constructed Assertion - * @param {Array} type A list of allowed types for this assertion - * @namespace Utils - * @name expectTypes - * @api public - */ - -var AssertionError = require('assertion-error'); -var flag = require('./flag'); -var type = require('type-detect'); - -module.exports = function expectTypes(obj, types) { - var flagMsg = flag(obj, 'message'); - var ssfi = flag(obj, 'ssfi'); - - flagMsg = flagMsg ? flagMsg + ': ' : ''; - - obj = flag(obj, 'object'); - types = types.map(function (t) { return t.toLowerCase(); }); - types.sort(); - - // Transforms ['lorem', 'ipsum'] into 'a lorem, or an ipsum' - var str = types.map(function (t, index) { - var art = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(t.charAt(0)) ? 'an' : 'a'; - var or = types.length > 1 && index === types.length - 1 ? 'or ' : ''; - return or + art + ' ' + t; - }).join(', '); - - var objType = type(obj).toLowerCase(); - - if (!types.some(function (expected) { return objType === expected; })) { - throw new AssertionError( - flagMsg + 'object tested must be ' + str + ', but ' + objType + ' given', - undefined, - ssfi - ); - } -}; - -},{"./flag":15,"assertion-error":33,"type-detect":39}],15:[function(require,module,exports){ -/*! - * Chai - flag utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .flag(object, key, [value]) - * - * Get or set a flag value on an object. If a - * value is provided it will be set, else it will - * return the currently set value or `undefined` if - * the value is not set. - * - * utils.flag(this, 'foo', 'bar'); // setter - * utils.flag(this, 'foo'); // getter, returns `bar` - * - * @param {Object} object constructed Assertion - * @param {String} key - * @param {Mixed} value (optional) - * @namespace Utils - * @name flag - * @api private - */ - -module.exports = function flag(obj, key, value) { - var flags = obj.__flags || (obj.__flags = Object.create(null)); - if (arguments.length === 3) { - flags[key] = value; - } else { - return flags[key]; - } -}; - -},{}],16:[function(require,module,exports){ -/*! - * Chai - getActual utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .getActual(object, [actual]) - * - * Returns the `actual` value for an Assertion. - * - * @param {Object} object (constructed Assertion) - * @param {Arguments} chai.Assertion.prototype.assert arguments - * @namespace Utils - * @name getActual - */ - -module.exports = function getActual(obj, args) { - return args.length > 4 ? args[4] : obj._obj; -}; - -},{}],17:[function(require,module,exports){ -/*! - * Chai - message composition utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies - */ - -var flag = require('./flag') - , getActual = require('./getActual') - , objDisplay = require('./objDisplay'); - -/** - * ### .getMessage(object, message, negateMessage) - * - * Construct the error message based on flags - * and template tags. Template tags will return - * a stringified inspection of the object referenced. - * - * Message template tags: - * - `#{this}` current asserted object - * - `#{act}` actual value - * - `#{exp}` expected value - * - * @param {Object} object (constructed Assertion) - * @param {Arguments} chai.Assertion.prototype.assert arguments - * @namespace Utils - * @name getMessage - * @api public - */ - -module.exports = function getMessage(obj, args) { - var negate = flag(obj, 'negate') - , val = flag(obj, 'object') - , expected = args[3] - , actual = getActual(obj, args) - , msg = negate ? args[2] : args[1] - , flagMsg = flag(obj, 'message'); - - if(typeof msg === "function") msg = msg(); - msg = msg || ''; - msg = msg - .replace(/#\{this\}/g, function () { return objDisplay(val); }) - .replace(/#\{act\}/g, function () { return objDisplay(actual); }) - .replace(/#\{exp\}/g, function () { return objDisplay(expected); }); - - return flagMsg ? flagMsg + ': ' + msg : msg; -}; - -},{"./flag":15,"./getActual":16,"./objDisplay":26}],18:[function(require,module,exports){ -var type = require('type-detect'); - -var flag = require('./flag'); - -function isObjectType(obj) { - var objectType = type(obj); - var objectTypes = ['Array', 'Object', 'function']; - - return objectTypes.indexOf(objectType) !== -1; -} - -/** - * ### .getOperator(message) - * - * Extract the operator from error message. - * Operator defined is based on below link - * https://nodejs.org/api/assert.html#assert_assert. - * - * Returns the `operator` or `undefined` value for an Assertion. - * - * @param {Object} object (constructed Assertion) - * @param {Arguments} chai.Assertion.prototype.assert arguments - * @namespace Utils - * @name getOperator - * @api public - */ - -module.exports = function getOperator(obj, args) { - var operator = flag(obj, 'operator'); - var negate = flag(obj, 'negate'); - var expected = args[3]; - var msg = negate ? args[2] : args[1]; - - if (operator) { - return operator; - } - - if (typeof msg === 'function') msg = msg(); - - msg = msg || ''; - if (!msg) { - return undefined; - } - - if (/\shave\s/.test(msg)) { - return undefined; - } - - var isObject = isObjectType(expected); - if (/\snot\s/.test(msg)) { - return isObject ? 'notDeepStrictEqual' : 'notStrictEqual'; - } - - return isObject ? 'deepStrictEqual' : 'strictEqual'; -}; - -},{"./flag":15,"type-detect":39}],19:[function(require,module,exports){ -/*! - * Chai - getOwnEnumerableProperties utility - * Copyright(c) 2011-2016 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies - */ - -var getOwnEnumerablePropertySymbols = require('./getOwnEnumerablePropertySymbols'); - -/** - * ### .getOwnEnumerableProperties(object) - * - * This allows the retrieval of directly-owned enumerable property names and - * symbols of an object. This function is necessary because Object.keys only - * returns enumerable property names, not enumerable property symbols. - * - * @param {Object} object - * @returns {Array} - * @namespace Utils - * @name getOwnEnumerableProperties - * @api public - */ - -module.exports = function getOwnEnumerableProperties(obj) { - return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj)); -}; - -},{"./getOwnEnumerablePropertySymbols":20}],20:[function(require,module,exports){ -/*! - * Chai - getOwnEnumerablePropertySymbols utility - * Copyright(c) 2011-2016 Jake Luer - * MIT Licensed - */ - -/** - * ### .getOwnEnumerablePropertySymbols(object) - * - * This allows the retrieval of directly-owned enumerable property symbols of an - * object. This function is necessary because Object.getOwnPropertySymbols - * returns both enumerable and non-enumerable property symbols. - * - * @param {Object} object - * @returns {Array} - * @namespace Utils - * @name getOwnEnumerablePropertySymbols - * @api public - */ - -module.exports = function getOwnEnumerablePropertySymbols(obj) { - if (typeof Object.getOwnPropertySymbols !== 'function') return []; - - return Object.getOwnPropertySymbols(obj).filter(function (sym) { - return Object.getOwnPropertyDescriptor(obj, sym).enumerable; - }); -}; - -},{}],21:[function(require,module,exports){ -/*! - * Chai - getProperties utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .getProperties(object) - * - * This allows the retrieval of property names of an object, enumerable or not, - * inherited or not. - * - * @param {Object} object - * @returns {Array} - * @namespace Utils - * @name getProperties - * @api public - */ - -module.exports = function getProperties(object) { - var result = Object.getOwnPropertyNames(object); - - function addProperty(property) { - if (result.indexOf(property) === -1) { - result.push(property); - } - } - - var proto = Object.getPrototypeOf(object); - while (proto !== null) { - Object.getOwnPropertyNames(proto).forEach(addProperty); - proto = Object.getPrototypeOf(proto); - } - - return result; -}; - -},{}],22:[function(require,module,exports){ -/*! - * chai - * Copyright(c) 2011 Jake Luer - * MIT Licensed - */ - -/*! - * Dependencies that are used for multiple exports are required here only once - */ - -var pathval = require('pathval'); - -/*! - * test utility - */ - -exports.test = require('./test'); - -/*! - * type utility - */ - -exports.type = require('type-detect'); - -/*! - * expectTypes utility - */ -exports.expectTypes = require('./expectTypes'); - -/*! - * message utility - */ - -exports.getMessage = require('./getMessage'); - -/*! - * actual utility - */ - -exports.getActual = require('./getActual'); - -/*! - * Inspect util - */ - -exports.inspect = require('./inspect'); - -/*! - * Object Display util - */ - -exports.objDisplay = require('./objDisplay'); - -/*! - * Flag utility - */ - -exports.flag = require('./flag'); - -/*! - * Flag transferring utility - */ - -exports.transferFlags = require('./transferFlags'); - -/*! - * Deep equal utility - */ - -exports.eql = require('deep-eql'); - -/*! - * Deep path info - */ - -exports.getPathInfo = pathval.getPathInfo; - -/*! - * Check if a property exists - */ - -exports.hasProperty = pathval.hasProperty; - -/*! - * Function name - */ - -exports.getName = require('get-func-name'); - -/*! - * add Property - */ - -exports.addProperty = require('./addProperty'); - -/*! - * add Method - */ - -exports.addMethod = require('./addMethod'); - -/*! - * overwrite Property - */ - -exports.overwriteProperty = require('./overwriteProperty'); - -/*! - * overwrite Method - */ - -exports.overwriteMethod = require('./overwriteMethod'); - -/*! - * Add a chainable method - */ - -exports.addChainableMethod = require('./addChainableMethod'); - -/*! - * Overwrite chainable method - */ - -exports.overwriteChainableMethod = require('./overwriteChainableMethod'); - -/*! - * Compare by inspect method - */ - -exports.compareByInspect = require('./compareByInspect'); - -/*! - * Get own enumerable property symbols method - */ - -exports.getOwnEnumerablePropertySymbols = require('./getOwnEnumerablePropertySymbols'); - -/*! - * Get own enumerable properties method - */ - -exports.getOwnEnumerableProperties = require('./getOwnEnumerableProperties'); - -/*! - * Checks error against a given set of criteria - */ - -exports.checkError = require('check-error'); - -/*! - * Proxify util - */ - -exports.proxify = require('./proxify'); - -/*! - * addLengthGuard util - */ - -exports.addLengthGuard = require('./addLengthGuard'); - -/*! - * isProxyEnabled helper - */ - -exports.isProxyEnabled = require('./isProxyEnabled'); - -/*! - * isNaN method - */ - -exports.isNaN = require('./isNaN'); - -/*! - * getOperator method - */ - -exports.getOperator = require('./getOperator'); -},{"./addChainableMethod":9,"./addLengthGuard":10,"./addMethod":11,"./addProperty":12,"./compareByInspect":13,"./expectTypes":14,"./flag":15,"./getActual":16,"./getMessage":17,"./getOperator":18,"./getOwnEnumerableProperties":19,"./getOwnEnumerablePropertySymbols":20,"./inspect":23,"./isNaN":24,"./isProxyEnabled":25,"./objDisplay":26,"./overwriteChainableMethod":27,"./overwriteMethod":28,"./overwriteProperty":29,"./proxify":30,"./test":31,"./transferFlags":32,"check-error":34,"deep-eql":35,"get-func-name":36,"pathval":38,"type-detect":39}],23:[function(require,module,exports){ -// This is (almost) directly from Node.js utils -// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js - -var getName = require('get-func-name'); -var loupe = require('loupe'); -var config = require('../config'); - -module.exports = inspect; - -/** - * ### .inspect(obj, [showHidden], [depth], [colors]) - * - * Echoes the value of a value. Tries to print the value out - * in the best way possible given the different types. - * - * @param {Object} obj The object to print out. - * @param {Boolean} showHidden Flag that shows hidden (not enumerable) - * properties of objects. Default is false. - * @param {Number} depth Depth in which to descend in object. Default is 2. - * @param {Boolean} colors Flag to turn on ANSI escape codes to color the - * output. Default is false (no coloring). - * @namespace Utils - * @name inspect - */ -function inspect(obj, showHidden, depth, colors) { - var options = { - colors: colors, - depth: (typeof depth === 'undefined' ? 2 : depth), - showHidden: showHidden, - truncate: config.truncateThreshold ? config.truncateThreshold : Infinity, - }; - return loupe.inspect(obj, options); -} - -},{"../config":4,"get-func-name":36,"loupe":37}],24:[function(require,module,exports){ -/*! - * Chai - isNaN utility - * Copyright(c) 2012-2015 Sakthipriyan Vairamani - * MIT Licensed - */ - -/** - * ### .isNaN(value) - * - * Checks if the given value is NaN or not. - * - * utils.isNaN(NaN); // true - * - * @param {Value} The value which has to be checked if it is NaN - * @name isNaN - * @api private - */ - -function isNaN(value) { - // Refer http://www.ecma-international.org/ecma-262/6.0/#sec-isnan-number - // section's NOTE. - return value !== value; -} - -// If ECMAScript 6's Number.isNaN is present, prefer that. -module.exports = Number.isNaN || isNaN; - -},{}],25:[function(require,module,exports){ -var config = require('../config'); - -/*! - * Chai - isProxyEnabled helper - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .isProxyEnabled() - * - * Helper function to check if Chai's proxy protection feature is enabled. If - * proxies are unsupported or disabled via the user's Chai config, then return - * false. Otherwise, return true. - * - * @namespace Utils - * @name isProxyEnabled - */ - -module.exports = function isProxyEnabled() { - return config.useProxy && - typeof Proxy !== 'undefined' && - typeof Reflect !== 'undefined'; -}; - -},{"../config":4}],26:[function(require,module,exports){ -/*! - * Chai - flag utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies - */ - -var inspect = require('./inspect'); -var config = require('../config'); - -/** - * ### .objDisplay(object) - * - * Determines if an object or an array matches - * criteria to be inspected in-line for error - * messages or should be truncated. - * - * @param {Mixed} javascript object to inspect - * @name objDisplay - * @namespace Utils - * @api public - */ - -module.exports = function objDisplay(obj) { - var str = inspect(obj) - , type = Object.prototype.toString.call(obj); - - if (config.truncateThreshold && str.length >= config.truncateThreshold) { - if (type === '[object Function]') { - return !obj.name || obj.name === '' - ? '[Function]' - : '[Function: ' + obj.name + ']'; - } else if (type === '[object Array]') { - return '[ Array(' + obj.length + ') ]'; - } else if (type === '[object Object]') { - var keys = Object.keys(obj) - , kstr = keys.length > 2 - ? keys.splice(0, 2).join(', ') + ', ...' - : keys.join(', '); - return '{ Object (' + kstr + ') }'; - } else { - return str; - } - } else { - return str; - } -}; - -},{"../config":4,"./inspect":23}],27:[function(require,module,exports){ -/*! - * Chai - overwriteChainableMethod utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -var chai = require('../../chai'); -var transferFlags = require('./transferFlags'); - -/** - * ### .overwriteChainableMethod(ctx, name, method, chainingBehavior) - * - * Overwrites an already existing chainable method - * and provides access to the previous function or - * property. Must return functions to be used for - * name. - * - * utils.overwriteChainableMethod(chai.Assertion.prototype, 'lengthOf', - * function (_super) { - * } - * , function (_super) { - * } - * ); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.overwriteChainableMethod('foo', fn, fn); - * - * Then can be used as any other assertion. - * - * expect(myFoo).to.have.lengthOf(3); - * expect(myFoo).to.have.lengthOf.above(3); - * - * @param {Object} ctx object whose method / property is to be overwritten - * @param {String} name of method / property to overwrite - * @param {Function} method function that returns a function to be used for name - * @param {Function} chainingBehavior function that returns a function to be used for property - * @namespace Utils - * @name overwriteChainableMethod - * @api public - */ - -module.exports = function overwriteChainableMethod(ctx, name, method, chainingBehavior) { - var chainableBehavior = ctx.__methods[name]; - - var _chainingBehavior = chainableBehavior.chainingBehavior; - chainableBehavior.chainingBehavior = function overwritingChainableMethodGetter() { - var result = chainingBehavior(_chainingBehavior).call(this); - if (result !== undefined) { - return result; - } - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - }; - - var _method = chainableBehavior.method; - chainableBehavior.method = function overwritingChainableMethodWrapper() { - var result = method(_method).apply(this, arguments); - if (result !== undefined) { - return result; - } - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - }; -}; - -},{"../../chai":2,"./transferFlags":32}],28:[function(require,module,exports){ -/*! - * Chai - overwriteMethod utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -var addLengthGuard = require('./addLengthGuard'); -var chai = require('../../chai'); -var flag = require('./flag'); -var proxify = require('./proxify'); -var transferFlags = require('./transferFlags'); - -/** - * ### .overwriteMethod(ctx, name, fn) - * - * Overwrites an already existing method and provides - * access to previous function. Must return function - * to be used for name. - * - * utils.overwriteMethod(chai.Assertion.prototype, 'equal', function (_super) { - * return function (str) { - * var obj = utils.flag(this, 'object'); - * if (obj instanceof Foo) { - * new chai.Assertion(obj.value).to.equal(str); - * } else { - * _super.apply(this, arguments); - * } - * } - * }); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.overwriteMethod('foo', fn); - * - * Then can be used as any other assertion. - * - * expect(myFoo).to.equal('bar'); - * - * @param {Object} ctx object whose method is to be overwritten - * @param {String} name of method to overwrite - * @param {Function} method function that returns a function to be used for name - * @namespace Utils - * @name overwriteMethod - * @api public - */ - -module.exports = function overwriteMethod(ctx, name, method) { - var _method = ctx[name] - , _super = function () { - throw new Error(name + ' is not a function'); - }; - - if (_method && 'function' === typeof _method) - _super = _method; - - var overwritingMethodWrapper = function () { - // Setting the `ssfi` flag to `overwritingMethodWrapper` causes this - // function to be the starting point for removing implementation frames from - // the stack trace of a failed assertion. - // - // However, we only want to use this function as the starting point if the - // `lockSsfi` flag isn't set. - // - // If the `lockSsfi` flag is set, then either this assertion has been - // overwritten by another assertion, or this assertion is being invoked from - // inside of another assertion. In the first case, the `ssfi` flag has - // already been set by the overwriting assertion. In the second case, the - // `ssfi` flag has already been set by the outer assertion. - if (!flag(this, 'lockSsfi')) { - flag(this, 'ssfi', overwritingMethodWrapper); - } - - // Setting the `lockSsfi` flag to `true` prevents the overwritten assertion - // from changing the `ssfi` flag. By this point, the `ssfi` flag is already - // set to the correct starting point for this assertion. - var origLockSsfi = flag(this, 'lockSsfi'); - flag(this, 'lockSsfi', true); - var result = method(_super).apply(this, arguments); - flag(this, 'lockSsfi', origLockSsfi); - - if (result !== undefined) { - return result; - } - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - } - - addLengthGuard(overwritingMethodWrapper, name, false); - ctx[name] = proxify(overwritingMethodWrapper, name); -}; - -},{"../../chai":2,"./addLengthGuard":10,"./flag":15,"./proxify":30,"./transferFlags":32}],29:[function(require,module,exports){ -/*! - * Chai - overwriteProperty utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -var chai = require('../../chai'); -var flag = require('./flag'); -var isProxyEnabled = require('./isProxyEnabled'); -var transferFlags = require('./transferFlags'); - -/** - * ### .overwriteProperty(ctx, name, fn) - * - * Overwrites an already existing property getter and provides - * access to previous value. Must return function to use as getter. - * - * utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) { - * return function () { - * var obj = utils.flag(this, 'object'); - * if (obj instanceof Foo) { - * new chai.Assertion(obj.name).to.equal('bar'); - * } else { - * _super.call(this); - * } - * } - * }); - * - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.overwriteProperty('foo', fn); - * - * Then can be used as any other assertion. - * - * expect(myFoo).to.be.ok; - * - * @param {Object} ctx object whose property is to be overwritten - * @param {String} name of property to overwrite - * @param {Function} getter function that returns a getter function to be used for name - * @namespace Utils - * @name overwriteProperty - * @api public - */ - -module.exports = function overwriteProperty(ctx, name, getter) { - var _get = Object.getOwnPropertyDescriptor(ctx, name) - , _super = function () {}; - - if (_get && 'function' === typeof _get.get) - _super = _get.get - - Object.defineProperty(ctx, name, - { get: function overwritingPropertyGetter() { - // Setting the `ssfi` flag to `overwritingPropertyGetter` causes this - // function to be the starting point for removing implementation frames - // from the stack trace of a failed assertion. - // - // However, we only want to use this function as the starting point if - // the `lockSsfi` flag isn't set and proxy protection is disabled. - // - // If the `lockSsfi` flag is set, then either this assertion has been - // overwritten by another assertion, or this assertion is being invoked - // from inside of another assertion. In the first case, the `ssfi` flag - // has already been set by the overwriting assertion. In the second - // case, the `ssfi` flag has already been set by the outer assertion. - // - // If proxy protection is enabled, then the `ssfi` flag has already been - // set by the proxy getter. - if (!isProxyEnabled() && !flag(this, 'lockSsfi')) { - flag(this, 'ssfi', overwritingPropertyGetter); - } - - // Setting the `lockSsfi` flag to `true` prevents the overwritten - // assertion from changing the `ssfi` flag. By this point, the `ssfi` - // flag is already set to the correct starting point for this assertion. - var origLockSsfi = flag(this, 'lockSsfi'); - flag(this, 'lockSsfi', true); - var result = getter(_super).call(this); - flag(this, 'lockSsfi', origLockSsfi); - - if (result !== undefined) { - return result; - } - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - } - , configurable: true - }); -}; - -},{"../../chai":2,"./flag":15,"./isProxyEnabled":25,"./transferFlags":32}],30:[function(require,module,exports){ -var config = require('../config'); -var flag = require('./flag'); -var getProperties = require('./getProperties'); -var isProxyEnabled = require('./isProxyEnabled'); - -/*! - * Chai - proxify utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .proxify(object) - * - * Return a proxy of given object that throws an error when a non-existent - * property is read. By default, the root cause is assumed to be a misspelled - * property, and thus an attempt is made to offer a reasonable suggestion from - * the list of existing properties. However, if a nonChainableMethodName is - * provided, then the root cause is instead a failure to invoke a non-chainable - * method prior to reading the non-existent property. - * - * If proxies are unsupported or disabled via the user's Chai config, then - * return object without modification. - * - * @param {Object} obj - * @param {String} nonChainableMethodName - * @namespace Utils - * @name proxify - */ - -var builtins = ['__flags', '__methods', '_obj', 'assert']; - -module.exports = function proxify(obj, nonChainableMethodName) { - if (!isProxyEnabled()) return obj; - - return new Proxy(obj, { - get: function proxyGetter(target, property) { - // This check is here because we should not throw errors on Symbol properties - // such as `Symbol.toStringTag`. - // The values for which an error should be thrown can be configured using - // the `config.proxyExcludedKeys` setting. - if (typeof property === 'string' && - config.proxyExcludedKeys.indexOf(property) === -1 && - !Reflect.has(target, property)) { - // Special message for invalid property access of non-chainable methods. - if (nonChainableMethodName) { - throw Error('Invalid Chai property: ' + nonChainableMethodName + '.' + - property + '. See docs for proper usage of "' + - nonChainableMethodName + '".'); - } - - // If the property is reasonably close to an existing Chai property, - // suggest that property to the user. Only suggest properties with a - // distance less than 4. - var suggestion = null; - var suggestionDistance = 4; - getProperties(target).forEach(function(prop) { - if ( - !Object.prototype.hasOwnProperty(prop) && - builtins.indexOf(prop) === -1 - ) { - var dist = stringDistanceCapped( - property, - prop, - suggestionDistance - ); - if (dist < suggestionDistance) { - suggestion = prop; - suggestionDistance = dist; - } - } - }); - - if (suggestion !== null) { - throw Error('Invalid Chai property: ' + property + - '. Did you mean "' + suggestion + '"?'); - } else { - throw Error('Invalid Chai property: ' + property); - } - } - - // Use this proxy getter as the starting point for removing implementation - // frames from the stack trace of a failed assertion. For property - // assertions, this prevents the proxy getter from showing up in the stack - // trace since it's invoked before the property getter. For method and - // chainable method assertions, this flag will end up getting changed to - // the method wrapper, which is good since this frame will no longer be in - // the stack once the method is invoked. Note that Chai builtin assertion - // properties such as `__flags` are skipped since this is only meant to - // capture the starting point of an assertion. This step is also skipped - // if the `lockSsfi` flag is set, thus indicating that this assertion is - // being called from within another assertion. In that case, the `ssfi` - // flag is already set to the outer assertion's starting point. - if (builtins.indexOf(property) === -1 && !flag(target, 'lockSsfi')) { - flag(target, 'ssfi', proxyGetter); - } - - return Reflect.get(target, property); - } - }); -}; - -/** - * # stringDistanceCapped(strA, strB, cap) - * Return the Levenshtein distance between two strings, but no more than cap. - * @param {string} strA - * @param {string} strB - * @param {number} number - * @return {number} min(string distance between strA and strB, cap) - * @api private - */ - -function stringDistanceCapped(strA, strB, cap) { - if (Math.abs(strA.length - strB.length) >= cap) { - return cap; - } - - var memo = []; - // `memo` is a two-dimensional array containing distances. - // memo[i][j] is the distance between strA.slice(0, i) and - // strB.slice(0, j). - for (var i = 0; i <= strA.length; i++) { - memo[i] = Array(strB.length + 1).fill(0); - memo[i][0] = i; - } - for (var j = 0; j < strB.length; j++) { - memo[0][j] = j; - } - - for (var i = 1; i <= strA.length; i++) { - var ch = strA.charCodeAt(i - 1); - for (var j = 1; j <= strB.length; j++) { - if (Math.abs(i - j) >= cap) { - memo[i][j] = cap; - continue; - } - memo[i][j] = Math.min( - memo[i - 1][j] + 1, - memo[i][j - 1] + 1, - memo[i - 1][j - 1] + - (ch === strB.charCodeAt(j - 1) ? 0 : 1) - ); - } - } - - return memo[strA.length][strB.length]; -} - -},{"../config":4,"./flag":15,"./getProperties":21,"./isProxyEnabled":25}],31:[function(require,module,exports){ -/*! - * Chai - test utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies - */ - -var flag = require('./flag'); - -/** - * ### .test(object, expression) - * - * Test and object for expression. - * - * @param {Object} object (constructed Assertion) - * @param {Arguments} chai.Assertion.prototype.assert arguments - * @namespace Utils - * @name test - */ - -module.exports = function test(obj, args) { - var negate = flag(obj, 'negate') - , expr = args[0]; - return negate ? !expr : expr; -}; - -},{"./flag":15}],32:[function(require,module,exports){ -/*! - * Chai - transferFlags utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .transferFlags(assertion, object, includeAll = true) - * - * Transfer all the flags for `assertion` to `object`. If - * `includeAll` is set to `false`, then the base Chai - * assertion flags (namely `object`, `ssfi`, `lockSsfi`, - * and `message`) will not be transferred. - * - * - * var newAssertion = new Assertion(); - * utils.transferFlags(assertion, newAssertion); - * - * var anotherAssertion = new Assertion(myObj); - * utils.transferFlags(assertion, anotherAssertion, false); - * - * @param {Assertion} assertion the assertion to transfer the flags from - * @param {Object} object the object to transfer the flags to; usually a new assertion - * @param {Boolean} includeAll - * @namespace Utils - * @name transferFlags - * @api private - */ - -module.exports = function transferFlags(assertion, object, includeAll) { - var flags = assertion.__flags || (assertion.__flags = Object.create(null)); - - if (!object.__flags) { - object.__flags = Object.create(null); - } - - includeAll = arguments.length === 3 ? includeAll : true; - - for (var flag in flags) { - if (includeAll || - (flag !== 'object' && flag !== 'ssfi' && flag !== 'lockSsfi' && flag != 'message')) { - object.__flags[flag] = flags[flag]; - } - } -}; - -},{}],33:[function(require,module,exports){ -/*! - * assertion-error - * Copyright(c) 2013 Jake Luer - * MIT Licensed - */ - -/*! - * Return a function that will copy properties from - * one object to another excluding any originally - * listed. Returned function will create a new `{}`. - * - * @param {String} excluded properties ... - * @return {Function} - */ - -function exclude () { - var excludes = [].slice.call(arguments); - - function excludeProps (res, obj) { - Object.keys(obj).forEach(function (key) { - if (!~excludes.indexOf(key)) res[key] = obj[key]; - }); - } - - return function extendExclude () { - var args = [].slice.call(arguments) - , i = 0 - , res = {}; - - for (; i < args.length; i++) { - excludeProps(res, args[i]); - } - - return res; - }; -}; - -/*! - * Primary Exports - */ - -module.exports = AssertionError; - -/** - * ### AssertionError - * - * An extension of the JavaScript `Error` constructor for - * assertion and validation scenarios. - * - * @param {String} message - * @param {Object} properties to include (optional) - * @param {callee} start stack function (optional) - */ - -function AssertionError (message, _props, ssf) { - var extend = exclude('name', 'message', 'stack', 'constructor', 'toJSON') - , props = extend(_props || {}); - - // default values - this.message = message || 'Unspecified AssertionError'; - this.showDiff = false; - - // copy from properties - for (var key in props) { - this[key] = props[key]; - } - - // capture stack trace - ssf = ssf || AssertionError; - if (Error.captureStackTrace) { - Error.captureStackTrace(this, ssf); - } else { - try { - throw new Error(); - } catch(e) { - this.stack = e.stack; - } - } -} - -/*! - * Inherit from Error.prototype - */ - -AssertionError.prototype = Object.create(Error.prototype); - -/*! - * Statically set name - */ - -AssertionError.prototype.name = 'AssertionError'; - -/*! - * Ensure correct constructor - */ - -AssertionError.prototype.constructor = AssertionError; - -/** - * Allow errors to be converted to JSON for static transfer. - * - * @param {Boolean} include stack (default: `true`) - * @return {Object} object that can be `JSON.stringify` - */ - -AssertionError.prototype.toJSON = function (stack) { - var extend = exclude('constructor', 'toJSON', 'stack') - , props = extend({ name: this.name }, this); - - // include stack if exists and not turned off - if (false !== stack && this.stack) { - props.stack = this.stack; - } - - return props; -}; - -},{}],34:[function(require,module,exports){ -'use strict'; - -/* ! - * Chai - checkError utility - * Copyright(c) 2012-2016 Jake Luer - * MIT Licensed - */ - -/** - * ### .checkError - * - * Checks that an error conforms to a given set of criteria and/or retrieves information about it. - * - * @api public - */ - -/** - * ### .compatibleInstance(thrown, errorLike) - * - * Checks if two instances are compatible (strict equal). - * Returns false if errorLike is not an instance of Error, because instances - * can only be compatible if they're both error instances. - * - * @name compatibleInstance - * @param {Error} thrown error - * @param {Error|ErrorConstructor} errorLike object to compare against - * @namespace Utils - * @api public - */ - -function compatibleInstance(thrown, errorLike) { - return errorLike instanceof Error && thrown === errorLike; -} - -/** - * ### .compatibleConstructor(thrown, errorLike) - * - * Checks if two constructors are compatible. - * This function can receive either an error constructor or - * an error instance as the `errorLike` argument. - * Constructors are compatible if they're the same or if one is - * an instance of another. - * - * @name compatibleConstructor - * @param {Error} thrown error - * @param {Error|ErrorConstructor} errorLike object to compare against - * @namespace Utils - * @api public - */ - -function compatibleConstructor(thrown, errorLike) { - if (errorLike instanceof Error) { - // If `errorLike` is an instance of any error we compare their constructors - return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor; - } else if (errorLike.prototype instanceof Error || errorLike === Error) { - // If `errorLike` is a constructor that inherits from Error, we compare `thrown` to `errorLike` directly - return thrown.constructor === errorLike || thrown instanceof errorLike; - } - - return false; -} - -/** - * ### .compatibleMessage(thrown, errMatcher) - * - * Checks if an error's message is compatible with a matcher (String or RegExp). - * If the message contains the String or passes the RegExp test, - * it is considered compatible. - * - * @name compatibleMessage - * @param {Error} thrown error - * @param {String|RegExp} errMatcher to look for into the message - * @namespace Utils - * @api public - */ - -function compatibleMessage(thrown, errMatcher) { - var comparisonString = typeof thrown === 'string' ? thrown : thrown.message; - if (errMatcher instanceof RegExp) { - return errMatcher.test(comparisonString); - } else if (typeof errMatcher === 'string') { - return comparisonString.indexOf(errMatcher) !== -1; // eslint-disable-line no-magic-numbers - } - - return false; -} - -/** - * ### .getFunctionName(constructorFn) - * - * Returns the name of a function. - * This also includes a polyfill function if `constructorFn.name` is not defined. - * - * @name getFunctionName - * @param {Function} constructorFn - * @namespace Utils - * @api private - */ - -var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\(\/]+)/; -function getFunctionName(constructorFn) { - var name = ''; - if (typeof constructorFn.name === 'undefined') { - // Here we run a polyfill if constructorFn.name is not defined - var match = String(constructorFn).match(functionNameMatch); - if (match) { - name = match[1]; - } - } else { - name = constructorFn.name; - } - - return name; -} - -/** - * ### .getConstructorName(errorLike) - * - * Gets the constructor name for an Error instance or constructor itself. - * - * @name getConstructorName - * @param {Error|ErrorConstructor} errorLike - * @namespace Utils - * @api public - */ - -function getConstructorName(errorLike) { - var constructorName = errorLike; - if (errorLike instanceof Error) { - constructorName = getFunctionName(errorLike.constructor); - } else if (typeof errorLike === 'function') { - // If `err` is not an instance of Error it is an error constructor itself or another function. - // If we've got a common function we get its name, otherwise we may need to create a new instance - // of the error just in case it's a poorly-constructed error. Please see chaijs/chai/issues/45 to know more. - constructorName = getFunctionName(errorLike).trim() || - getFunctionName(new errorLike()); // eslint-disable-line new-cap - } - - return constructorName; -} - -/** - * ### .getMessage(errorLike) - * - * Gets the error message from an error. - * If `err` is a String itself, we return it. - * If the error has no message, we return an empty string. - * - * @name getMessage - * @param {Error|String} errorLike - * @namespace Utils - * @api public - */ - -function getMessage(errorLike) { - var msg = ''; - if (errorLike && errorLike.message) { - msg = errorLike.message; - } else if (typeof errorLike === 'string') { - msg = errorLike; - } - - return msg; -} - -module.exports = { - compatibleInstance: compatibleInstance, - compatibleConstructor: compatibleConstructor, - compatibleMessage: compatibleMessage, - getMessage: getMessage, - getConstructorName: getConstructorName, -}; - -},{}],35:[function(require,module,exports){ -'use strict'; -/* globals Symbol: false, Uint8Array: false, WeakMap: false */ -/*! - * deep-eql - * Copyright(c) 2013 Jake Luer - * MIT Licensed - */ - -var type = require('type-detect'); -function FakeMap() { - this._key = 'chai/deep-eql__' + Math.random() + Date.now(); -} - -FakeMap.prototype = { - get: function getMap(key) { - return key[this._key]; - }, - set: function setMap(key, value) { - if (Object.isExtensible(key)) { - Object.defineProperty(key, this._key, { - value: value, - configurable: true, - }); - } - }, -}; - -var MemoizeMap = typeof WeakMap === 'function' ? WeakMap : FakeMap; -/*! - * Check to see if the MemoizeMap has recorded a result of the two operands - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {MemoizeMap} memoizeMap - * @returns {Boolean|null} result -*/ -function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) { - // Technically, WeakMap keys can *only* be objects, not primitives. - if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) { - return null; - } - var leftHandMap = memoizeMap.get(leftHandOperand); - if (leftHandMap) { - var result = leftHandMap.get(rightHandOperand); - if (typeof result === 'boolean') { - return result; - } - } - return null; -} - -/*! - * Set the result of the equality into the MemoizeMap - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {MemoizeMap} memoizeMap - * @param {Boolean} result -*/ -function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) { - // Technically, WeakMap keys can *only* be objects, not primitives. - if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) { - return; - } - var leftHandMap = memoizeMap.get(leftHandOperand); - if (leftHandMap) { - leftHandMap.set(rightHandOperand, result); - } else { - leftHandMap = new MemoizeMap(); - leftHandMap.set(rightHandOperand, result); - memoizeMap.set(leftHandOperand, leftHandMap); - } -} - -/*! - * Primary Export - */ - -module.exports = deepEqual; -module.exports.MemoizeMap = MemoizeMap; - -/** - * Assert deeply nested sameValue equality between two objects of any type. - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {Object} [options] (optional) Additional options - * @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality. - * @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of - complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular - references to blow the stack. - * @return {Boolean} equal match - */ -function deepEqual(leftHandOperand, rightHandOperand, options) { - // If we have a comparator, we can't assume anything; so bail to its check first. - if (options && options.comparator) { - return extensiveDeepEqual(leftHandOperand, rightHandOperand, options); - } - - var simpleResult = simpleEqual(leftHandOperand, rightHandOperand); - if (simpleResult !== null) { - return simpleResult; - } - - // Deeper comparisons are pushed through to a larger function - return extensiveDeepEqual(leftHandOperand, rightHandOperand, options); -} - -/** - * Many comparisons can be canceled out early via simple equality or primitive checks. - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @return {Boolean|null} equal match - */ -function simpleEqual(leftHandOperand, rightHandOperand) { - // Equal references (except for Numbers) can be returned early - if (leftHandOperand === rightHandOperand) { - // Handle +-0 cases - return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand; - } - - // handle NaN cases - if ( - leftHandOperand !== leftHandOperand && // eslint-disable-line no-self-compare - rightHandOperand !== rightHandOperand // eslint-disable-line no-self-compare - ) { - return true; - } - - // Anything that is not an 'object', i.e. symbols, functions, booleans, numbers, - // strings, and undefined, can be compared by reference. - if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) { - // Easy out b/c it would have passed the first equality check - return false; - } - return null; -} - -/*! - * The main logic of the `deepEqual` function. - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {Object} [options] (optional) Additional options - * @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality. - * @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of - complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular - references to blow the stack. - * @return {Boolean} equal match -*/ -function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) { - options = options || {}; - options.memoize = options.memoize === false ? false : options.memoize || new MemoizeMap(); - var comparator = options && options.comparator; - - // Check if a memoized result exists. - var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize); - if (memoizeResultLeft !== null) { - return memoizeResultLeft; - } - var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize); - if (memoizeResultRight !== null) { - return memoizeResultRight; - } - - // If a comparator is present, use it. - if (comparator) { - var comparatorResult = comparator(leftHandOperand, rightHandOperand); - // Comparators may return null, in which case we want to go back to default behavior. - if (comparatorResult === false || comparatorResult === true) { - memoizeSet(leftHandOperand, rightHandOperand, options.memoize, comparatorResult); - return comparatorResult; - } - // To allow comparators to override *any* behavior, we ran them first. Since it didn't decide - // what to do, we need to make sure to return the basic tests first before we move on. - var simpleResult = simpleEqual(leftHandOperand, rightHandOperand); - if (simpleResult !== null) { - // Don't memoize this, it takes longer to set/retrieve than to just compare. - return simpleResult; - } - } - - var leftHandType = type(leftHandOperand); - if (leftHandType !== type(rightHandOperand)) { - memoizeSet(leftHandOperand, rightHandOperand, options.memoize, false); - return false; - } - - // Temporarily set the operands in the memoize object to prevent blowing the stack - memoizeSet(leftHandOperand, rightHandOperand, options.memoize, true); - - var result = extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options); - memoizeSet(leftHandOperand, rightHandOperand, options.memoize, result); - return result; -} - -function extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options) { - switch (leftHandType) { - case 'String': - case 'Number': - case 'Boolean': - case 'Date': - // If these types are their instance types (e.g. `new Number`) then re-deepEqual against their values - return deepEqual(leftHandOperand.valueOf(), rightHandOperand.valueOf()); - case 'Promise': - case 'Symbol': - case 'function': - case 'WeakMap': - case 'WeakSet': - case 'Error': - return leftHandOperand === rightHandOperand; - case 'Arguments': - case 'Int8Array': - case 'Uint8Array': - case 'Uint8ClampedArray': - case 'Int16Array': - case 'Uint16Array': - case 'Int32Array': - case 'Uint32Array': - case 'Float32Array': - case 'Float64Array': - case 'Array': - return iterableEqual(leftHandOperand, rightHandOperand, options); - case 'RegExp': - return regexpEqual(leftHandOperand, rightHandOperand); - case 'Generator': - return generatorEqual(leftHandOperand, rightHandOperand, options); - case 'DataView': - return iterableEqual(new Uint8Array(leftHandOperand.buffer), new Uint8Array(rightHandOperand.buffer), options); - case 'ArrayBuffer': - return iterableEqual(new Uint8Array(leftHandOperand), new Uint8Array(rightHandOperand), options); - case 'Set': - return entriesEqual(leftHandOperand, rightHandOperand, options); - case 'Map': - return entriesEqual(leftHandOperand, rightHandOperand, options); - default: - return objectEqual(leftHandOperand, rightHandOperand, options); - } -} - -/*! - * Compare two Regular Expressions for equality. - * - * @param {RegExp} leftHandOperand - * @param {RegExp} rightHandOperand - * @return {Boolean} result - */ - -function regexpEqual(leftHandOperand, rightHandOperand) { - return leftHandOperand.toString() === rightHandOperand.toString(); -} - -/*! - * Compare two Sets/Maps for equality. Faster than other equality functions. - * - * @param {Set} leftHandOperand - * @param {Set} rightHandOperand - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ - -function entriesEqual(leftHandOperand, rightHandOperand, options) { - // IE11 doesn't support Set#entries or Set#@@iterator, so we need manually populate using Set#forEach - if (leftHandOperand.size !== rightHandOperand.size) { - return false; - } - if (leftHandOperand.size === 0) { - return true; - } - var leftHandItems = []; - var rightHandItems = []; - leftHandOperand.forEach(function gatherEntries(key, value) { - leftHandItems.push([ key, value ]); - }); - rightHandOperand.forEach(function gatherEntries(key, value) { - rightHandItems.push([ key, value ]); - }); - return iterableEqual(leftHandItems.sort(), rightHandItems.sort(), options); -} - -/*! - * Simple equality for flat iterable objects such as Arrays, TypedArrays or Node.js buffers. - * - * @param {Iterable} leftHandOperand - * @param {Iterable} rightHandOperand - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ - -function iterableEqual(leftHandOperand, rightHandOperand, options) { - var length = leftHandOperand.length; - if (length !== rightHandOperand.length) { - return false; - } - if (length === 0) { - return true; - } - var index = -1; - while (++index < length) { - if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) { - return false; - } - } - return true; -} - -/*! - * Simple equality for generator objects such as those returned by generator functions. - * - * @param {Iterable} leftHandOperand - * @param {Iterable} rightHandOperand - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ - -function generatorEqual(leftHandOperand, rightHandOperand, options) { - return iterableEqual(getGeneratorEntries(leftHandOperand), getGeneratorEntries(rightHandOperand), options); -} - -/*! - * Determine if the given object has an @@iterator function. - * - * @param {Object} target - * @return {Boolean} `true` if the object has an @@iterator function. - */ -function hasIteratorFunction(target) { - return typeof Symbol !== 'undefined' && - typeof target === 'object' && - typeof Symbol.iterator !== 'undefined' && - typeof target[Symbol.iterator] === 'function'; -} - -/*! - * Gets all iterator entries from the given Object. If the Object has no @@iterator function, returns an empty array. - * This will consume the iterator - which could have side effects depending on the @@iterator implementation. - * - * @param {Object} target - * @returns {Array} an array of entries from the @@iterator function - */ -function getIteratorEntries(target) { - if (hasIteratorFunction(target)) { - try { - return getGeneratorEntries(target[Symbol.iterator]()); - } catch (iteratorError) { - return []; - } - } - return []; -} - -/*! - * Gets all entries from a Generator. This will consume the generator - which could have side effects. - * - * @param {Generator} target - * @returns {Array} an array of entries from the Generator. - */ -function getGeneratorEntries(generator) { - var generatorResult = generator.next(); - var accumulator = [ generatorResult.value ]; - while (generatorResult.done === false) { - generatorResult = generator.next(); - accumulator.push(generatorResult.value); - } - return accumulator; -} - -/*! - * Gets all own and inherited enumerable keys from a target. - * - * @param {Object} target - * @returns {Array} an array of own and inherited enumerable keys from the target. - */ -function getEnumerableKeys(target) { - var keys = []; - for (var key in target) { - keys.push(key); - } - return keys; -} - -/*! - * Determines if two objects have matching values, given a set of keys. Defers to deepEqual for the equality check of - * each key. If any value of the given key is not equal, the function will return false (early). - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {Array} keys An array of keys to compare the values of leftHandOperand and rightHandOperand against - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ -function keysEqual(leftHandOperand, rightHandOperand, keys, options) { - var length = keys.length; - if (length === 0) { - return true; - } - for (var i = 0; i < length; i += 1) { - if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) { - return false; - } - } - return true; -} - -/*! - * 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} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ - -function objectEqual(leftHandOperand, rightHandOperand, options) { - var leftHandKeys = getEnumerableKeys(leftHandOperand); - var rightHandKeys = getEnumerableKeys(rightHandOperand); - if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) { - leftHandKeys.sort(); - rightHandKeys.sort(); - if (iterableEqual(leftHandKeys, rightHandKeys) === false) { - return false; - } - return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options); - } - - var leftHandEntries = getIteratorEntries(leftHandOperand); - var rightHandEntries = getIteratorEntries(rightHandOperand); - if (leftHandEntries.length && leftHandEntries.length === rightHandEntries.length) { - leftHandEntries.sort(); - rightHandEntries.sort(); - return iterableEqual(leftHandEntries, rightHandEntries, options); - } - - if (leftHandKeys.length === 0 && - leftHandEntries.length === 0 && - rightHandKeys.length === 0 && - rightHandEntries.length === 0) { - return true; - } - - return false; -} - -/*! - * Returns true if the argument is a primitive. - * - * This intentionally returns true for all objects that can be compared by reference, - * including functions and symbols. - * - * @param {Mixed} value - * @return {Boolean} result - */ -function isPrimitive(value) { - return value === null || typeof value !== 'object'; -} - -},{"type-detect":39}],36:[function(require,module,exports){ -'use strict'; - -/* ! - * Chai - getFuncName utility - * Copyright(c) 2012-2016 Jake Luer - * MIT Licensed - */ - -/** - * ### .getFuncName(constructorFn) - * - * Returns the name of a function. - * When a non-function instance is passed, returns `null`. - * This also includes a polyfill function if `aFunc.name` is not defined. - * - * @name getFuncName - * @param {Function} funct - * @namespace Utils - * @api public - */ - -var toString = Function.prototype.toString; -var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/; -function getFuncName(aFunc) { - if (typeof aFunc !== 'function') { - return null; - } - - var name = ''; - if (typeof Function.prototype.name === 'undefined' && typeof aFunc.name === 'undefined') { - // Here we run a polyfill if Function does not support the `name` property and if aFunc.name is not defined - var match = toString.call(aFunc).match(functionNameMatch); - if (match) { - name = match[1]; - } - } else { - // If we've got a `name` property we just use it - name = aFunc.name; - } - - return name; -} - -module.exports = getFuncName; - -},{}],37:[function(require,module,exports){ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.loupe = {})); -}(this, (function (exports) { 'use strict'; - - function _typeof(obj) { - "@babel/helpers - typeof"; - - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof = function (obj) { - return typeof obj; - }; - } else { - _typeof = function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - } - - return _typeof(obj); - } - - function _slicedToArray(arr, i) { - return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); - } - - function _arrayWithHoles(arr) { - if (Array.isArray(arr)) return arr; - } - - function _iterableToArrayLimit(arr, i) { - if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; - var _arr = []; - var _n = true; - var _d = false; - var _e = undefined; - - try { - for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { - _arr.push(_s.value); - - if (i && _arr.length === i) break; - } - } catch (err) { - _d = true; - _e = err; - } finally { - try { - if (!_n && _i["return"] != null) _i["return"](); - } finally { - if (_d) throw _e; - } - } - - return _arr; - } - - function _unsupportedIterableToArray(o, minLen) { - if (!o) return; - if (typeof o === "string") return _arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); - } - - function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) len = arr.length; - - for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; - - return arr2; - } - - function _nonIterableRest() { - throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - - var ansiColors = { - bold: ['1', '22'], - dim: ['2', '22'], - italic: ['3', '23'], - underline: ['4', '24'], - // 5 & 6 are blinking - inverse: ['7', '27'], - hidden: ['8', '28'], - strike: ['9', '29'], - // 10-20 are fonts - // 21-29 are resets for 1-9 - black: ['30', '39'], - red: ['31', '39'], - green: ['32', '39'], - yellow: ['33', '39'], - blue: ['34', '39'], - magenta: ['35', '39'], - cyan: ['36', '39'], - white: ['37', '39'], - brightblack: ['30;1', '39'], - brightred: ['31;1', '39'], - brightgreen: ['32;1', '39'], - brightyellow: ['33;1', '39'], - brightblue: ['34;1', '39'], - brightmagenta: ['35;1', '39'], - brightcyan: ['36;1', '39'], - brightwhite: ['37;1', '39'], - grey: ['90', '39'] - }; - var styles = { - special: 'cyan', - number: 'yellow', - bigint: 'yellow', - boolean: 'yellow', - undefined: 'grey', - null: 'bold', - string: 'green', - symbol: 'green', - date: 'magenta', - regexp: 'red' - }; - var truncator = '…'; - - function colorise(value, styleType) { - var color = ansiColors[styles[styleType]] || ansiColors[styleType]; - - if (!color) { - return String(value); - } - - return "\x1B[".concat(color[0], "m").concat(String(value), "\x1B[").concat(color[1], "m"); - } - - function normaliseOptions() { - var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, - _ref$showHidden = _ref.showHidden, - showHidden = _ref$showHidden === void 0 ? false : _ref$showHidden, - _ref$depth = _ref.depth, - depth = _ref$depth === void 0 ? 2 : _ref$depth, - _ref$colors = _ref.colors, - colors = _ref$colors === void 0 ? false : _ref$colors, - _ref$customInspect = _ref.customInspect, - customInspect = _ref$customInspect === void 0 ? true : _ref$customInspect, - _ref$showProxy = _ref.showProxy, - showProxy = _ref$showProxy === void 0 ? false : _ref$showProxy, - _ref$maxArrayLength = _ref.maxArrayLength, - maxArrayLength = _ref$maxArrayLength === void 0 ? Infinity : _ref$maxArrayLength, - _ref$breakLength = _ref.breakLength, - breakLength = _ref$breakLength === void 0 ? Infinity : _ref$breakLength, - _ref$seen = _ref.seen, - seen = _ref$seen === void 0 ? [] : _ref$seen, - _ref$truncate = _ref.truncate, - truncate = _ref$truncate === void 0 ? Infinity : _ref$truncate, - _ref$stylize = _ref.stylize, - stylize = _ref$stylize === void 0 ? String : _ref$stylize; - - var options = { - showHidden: Boolean(showHidden), - depth: Number(depth), - colors: Boolean(colors), - customInspect: Boolean(customInspect), - showProxy: Boolean(showProxy), - maxArrayLength: Number(maxArrayLength), - breakLength: Number(breakLength), - truncate: Number(truncate), - seen: seen, - stylize: stylize - }; - - if (options.colors) { - options.stylize = colorise; - } - - return options; - } - function truncate(string, length) { - var tail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : truncator; - string = String(string); - var tailLength = tail.length; - var stringLength = string.length; - - if (tailLength > length && stringLength > tailLength) { - return tail; - } - - if (stringLength > length && stringLength > tailLength) { - return "".concat(string.slice(0, length - tailLength)).concat(tail); - } - - return string; - } // eslint-disable-next-line complexity - - function inspectList(list, options, inspectItem) { - var separator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ', '; - inspectItem = inspectItem || options.inspect; - var size = list.length; - if (size === 0) return ''; - var originalLength = options.truncate; - var output = ''; - var peek = ''; - var truncated = ''; - - for (var i = 0; i < size; i += 1) { - var last = i + 1 === list.length; - var secondToLast = i + 2 === list.length; - truncated = "".concat(truncator, "(").concat(list.length - i, ")"); - var value = list[i]; // If there is more than one remaining we need to account for a separator of `, ` - - options.truncate = originalLength - output.length - (last ? 0 : separator.length); - var string = peek || inspectItem(value, options) + (last ? '' : separator); - var nextLength = output.length + string.length; - var truncatedLength = nextLength + truncated.length; // If this is the last element, and adding it would - // take us over length, but adding the truncator wouldn't - then break now - - if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) { - break; - } // If this isn't the last or second to last element to scan, - // but the string is already over length then break here - - - if (!last && !secondToLast && truncatedLength > originalLength) { - break; - } // Peek at the next string to determine if we should - // break early before adding this item to the output - - - peek = last ? '' : inspectItem(list[i + 1], options) + (secondToLast ? '' : separator); // If we have one element left, but this element and - // the next takes over length, the break early - - if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) { - break; - } - - output += string; // If the next element takes us to length - - // but there are more after that, then we should truncate now - - if (!last && !secondToLast && nextLength + peek.length >= originalLength) { - truncated = "".concat(truncator, "(").concat(list.length - i - 1, ")"); - break; - } - - truncated = ''; - } - - return "".concat(output).concat(truncated); - } - - function quoteComplexKey(key) { - if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) { - return key; - } - - return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"); - } - - function inspectProperty(_ref2, options) { - var _ref3 = _slicedToArray(_ref2, 2), - key = _ref3[0], - value = _ref3[1]; - - options.truncate -= 2; - - if (typeof key === 'string') { - key = quoteComplexKey(key); - } else if (typeof key !== 'number') { - key = "[".concat(options.inspect(key, options), "]"); - } - - options.truncate -= key.length; - value = options.inspect(value, options); - return "".concat(key, ": ").concat(value); - } - - function inspectArray(array, options) { - // Object.keys will always output the Array indices first, so we can slice by - // `array.length` to get non-index properties - var nonIndexProperties = Object.keys(array).slice(array.length); - if (!array.length && !nonIndexProperties.length) return '[]'; - options.truncate -= 4; - var listContents = inspectList(array, options); - options.truncate -= listContents.length; - var propertyContents = ''; - - if (nonIndexProperties.length) { - propertyContents = inspectList(nonIndexProperties.map(function (key) { - return [key, array[key]]; - }), options, inspectProperty); - } - - return "[ ".concat(listContents).concat(propertyContents ? ", ".concat(propertyContents) : '', " ]"); - } - - /* ! - * Chai - getFuncName utility - * Copyright(c) 2012-2016 Jake Luer - * MIT Licensed - */ - - /** - * ### .getFuncName(constructorFn) - * - * Returns the name of a function. - * When a non-function instance is passed, returns `null`. - * This also includes a polyfill function if `aFunc.name` is not defined. - * - * @name getFuncName - * @param {Function} funct - * @namespace Utils - * @api public - */ - - var toString = Function.prototype.toString; - var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/; - function getFuncName(aFunc) { - if (typeof aFunc !== 'function') { - return null; - } - - var name = ''; - if (typeof Function.prototype.name === 'undefined' && typeof aFunc.name === 'undefined') { - // Here we run a polyfill if Function does not support the `name` property and if aFunc.name is not defined - var match = toString.call(aFunc).match(functionNameMatch); - if (match) { - name = match[1]; - } - } else { - // If we've got a `name` property we just use it - name = aFunc.name; - } - - return name; - } - - var getFuncName_1 = getFuncName; - - var getArrayName = function getArrayName(array) { - // We need to special case Node.js' Buffers, which report to be Uint8Array - if (typeof Buffer === 'function' && array instanceof Buffer) { - return 'Buffer'; - } - - if (array[Symbol.toStringTag]) { - return array[Symbol.toStringTag]; - } - - return getFuncName_1(array.constructor); - }; - - function inspectTypedArray(array, options) { - var name = getArrayName(array); - options.truncate -= name.length + 4; // Object.keys will always output the Array indices first, so we can slice by - // `array.length` to get non-index properties - - var nonIndexProperties = Object.keys(array).slice(array.length); - if (!array.length && !nonIndexProperties.length) return "".concat(name, "[]"); // As we know TypedArrays only contain Unsigned Integers, we can skip inspecting each one and simply - // stylise the toString() value of them - - var output = ''; - - for (var i = 0; i < array.length; i++) { - var string = "".concat(options.stylize(truncate(array[i], options.truncate), 'number')).concat(i === array.length - 1 ? '' : ', '); - options.truncate -= string.length; - - if (array[i] !== array.length && options.truncate <= 3) { - output += "".concat(truncator, "(").concat(array.length - array[i] + 1, ")"); - break; - } - - output += string; - } - - var propertyContents = ''; - - if (nonIndexProperties.length) { - propertyContents = inspectList(nonIndexProperties.map(function (key) { - return [key, array[key]]; - }), options, inspectProperty); - } - - return "".concat(name, "[ ").concat(output).concat(propertyContents ? ", ".concat(propertyContents) : '', " ]"); - } - - function inspectDate(dateObject, options) { - // If we need to - truncate the time portion, but never the date - var split = dateObject.toJSON().split('T'); - var date = split[0]; - return options.stylize("".concat(date, "T").concat(truncate(split[1], options.truncate - date.length - 1)), 'date'); - } - - function inspectFunction(func, options) { - var name = getFuncName_1(func); - - if (!name) { - return options.stylize('[Function]', 'special'); - } - - return options.stylize("[Function ".concat(truncate(name, options.truncate - 11), "]"), 'special'); - } - - function inspectMapEntry(_ref, options) { - var _ref2 = _slicedToArray(_ref, 2), - key = _ref2[0], - value = _ref2[1]; - - options.truncate -= 4; - key = options.inspect(key, options); - options.truncate -= key.length; - value = options.inspect(value, options); - return "".concat(key, " => ").concat(value); - } // IE11 doesn't support `map.entries()` - - - function mapToEntries(map) { - var entries = []; - map.forEach(function (value, key) { - entries.push([key, value]); - }); - return entries; - } - - function inspectMap(map, options) { - var size = map.size - 1; - - if (size <= 0) { - return 'Map{}'; - } - - options.truncate -= 7; - return "Map{ ".concat(inspectList(mapToEntries(map), options, inspectMapEntry), " }"); - } - - var isNaN = Number.isNaN || function (i) { - return i !== i; - }; // eslint-disable-line no-self-compare - - - function inspectNumber(number, options) { - if (isNaN(number)) { - return options.stylize('NaN', 'number'); - } - - if (number === Infinity) { - return options.stylize('Infinity', 'number'); - } - - if (number === -Infinity) { - return options.stylize('-Infinity', 'number'); - } - - if (number === 0) { - return options.stylize(1 / number === Infinity ? '+0' : '-0', 'number'); - } - - return options.stylize(truncate(number, options.truncate), 'number'); - } - - function inspectBigInt(number, options) { - var nums = truncate(number.toString(), options.truncate - 1); - if (nums !== truncator) nums += 'n'; - return options.stylize(nums, 'bigint'); - } - - function inspectRegExp(value, options) { - var flags = value.toString().split('/')[2]; - var sourceLength = options.truncate - (2 + flags.length); - var source = value.source; - return options.stylize("/".concat(truncate(source, sourceLength), "/").concat(flags), 'regexp'); - } - - function arrayFromSet(set) { - var values = []; - set.forEach(function (value) { - values.push(value); - }); - return values; - } - - function inspectSet(set, options) { - if (set.size === 0) return 'Set{}'; - options.truncate -= 7; - return "Set{ ".concat(inspectList(arrayFromSet(set), options), " }"); - } - - var stringEscapeChars = new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5" + "\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", 'g'); - var escapeCharacters = { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - "'": "\\'", - '\\': '\\\\' - }; - var hex = 16; - var unicodeLength = 4; - - function escape(char) { - return escapeCharacters[char] || "\\u".concat("0000".concat(char.charCodeAt(0).toString(hex)).slice(-unicodeLength)); - } - - function inspectString(string, options) { - if (stringEscapeChars.test(string)) { - string = string.replace(stringEscapeChars, escape); - } - - return options.stylize("'".concat(truncate(string, options.truncate - 2), "'"), 'string'); - } - - function inspectSymbol(value) { - if ('description' in Symbol.prototype) { - return value.description ? "Symbol(".concat(value.description, ")") : 'Symbol()'; - } - - return value.toString(); - } - - var getPromiseValue = function getPromiseValue() { - return 'Promise{…}'; - }; - - try { - var _process$binding = process.binding('util'), - getPromiseDetails = _process$binding.getPromiseDetails, - kPending = _process$binding.kPending, - kRejected = _process$binding.kRejected; - - if (Array.isArray(getPromiseDetails(Promise.resolve()))) { - getPromiseValue = function getPromiseValue(value, options) { - var _getPromiseDetails = getPromiseDetails(value), - _getPromiseDetails2 = _slicedToArray(_getPromiseDetails, 2), - state = _getPromiseDetails2[0], - innerValue = _getPromiseDetails2[1]; - - if (state === kPending) { - return 'Promise{}'; - } - - return "Promise".concat(state === kRejected ? '!' : '', "{").concat(options.inspect(innerValue, options), "}"); - }; - } - } catch (notNode) { - /* ignore */ - } - - var inspectPromise = getPromiseValue; - - function inspectObject(object, options) { - var properties = Object.getOwnPropertyNames(object); - var symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : []; - - if (properties.length === 0 && symbols.length === 0) { - return '{}'; - } - - options.truncate -= 4; - options.seen = options.seen || []; - - if (options.seen.indexOf(object) >= 0) { - return '[Circular]'; - } - - options.seen.push(object); - var propertyContents = inspectList(properties.map(function (key) { - return [key, object[key]]; - }), options, inspectProperty); - var symbolContents = inspectList(symbols.map(function (key) { - return [key, object[key]]; - }), options, inspectProperty); - options.seen.pop(); - var sep = ''; - - if (propertyContents && symbolContents) { - sep = ', '; - } - - return "{ ".concat(propertyContents).concat(sep).concat(symbolContents, " }"); - } - - var toStringTag = typeof Symbol !== 'undefined' && Symbol.toStringTag ? Symbol.toStringTag : false; - function inspectClass(value, options) { - var name = ''; - - if (toStringTag && toStringTag in value) { - name = value[toStringTag]; - } - - name = name || getFuncName_1(value.constructor); // Babel transforms anonymous classes to the name `_class` - - if (!name || name === '_class') { - name = ''; - } - - options.truncate -= name.length; - return "".concat(name).concat(inspectObject(value, options)); - } - - function inspectArguments(args, options) { - if (args.length === 0) return 'Arguments[]'; - options.truncate -= 13; - return "Arguments[ ".concat(inspectList(args, options), " ]"); - } - - var errorKeys = ['stack', 'line', 'column', 'name', 'message', 'fileName', 'lineNumber', 'columnNumber', 'number', 'description']; - function inspectObject$1(error, options) { - var properties = Object.getOwnPropertyNames(error).filter(function (key) { - return errorKeys.indexOf(key) === -1; - }); - var name = error.name; - options.truncate -= name.length; - var message = ''; - - if (typeof error.message === 'string') { - message = truncate(error.message, options.truncate); - } else { - properties.unshift('message'); - } - - message = message ? ": ".concat(message) : ''; - options.truncate -= message.length + 5; - var propertyContents = inspectList(properties.map(function (key) { - return [key, error[key]]; - }), options, inspectProperty); - return "".concat(name).concat(message).concat(propertyContents ? " { ".concat(propertyContents, " }") : ''); - } - - function inspectAttribute(_ref, options) { - var _ref2 = _slicedToArray(_ref, 2), - key = _ref2[0], - value = _ref2[1]; - - options.truncate -= 3; - - if (!value) { - return "".concat(options.stylize(key, 'yellow')); - } - - return "".concat(options.stylize(key, 'yellow'), "=").concat(options.stylize("\"".concat(value, "\""), 'string')); - } - function inspectHTMLCollection(collection, options) { - // eslint-disable-next-line no-use-before-define - return inspectList(collection, options, inspectHTML, '\n'); - } - function inspectHTML(element, options) { - var properties = element.getAttributeNames(); - var name = element.tagName.toLowerCase(); - var head = options.stylize("<".concat(name), 'special'); - var headClose = options.stylize(">", 'special'); - var tail = options.stylize(""), 'special'); - options.truncate -= name.length * 2 + 5; - var propertyContents = ''; - - if (properties.length > 0) { - propertyContents += ' '; - propertyContents += inspectList(properties.map(function (key) { - return [key, element.getAttribute(key)]; - }), options, inspectAttribute, ' '); - } - - options.truncate -= propertyContents.length; - var truncate = options.truncate; - var children = inspectHTMLCollection(element.children, options); - - if (children && children.length > truncate) { - children = "".concat(truncator, "(").concat(element.children.length, ")"); - } - - return "".concat(head).concat(propertyContents).concat(headClose).concat(children).concat(tail); - } - - var symbolsSupported = typeof Symbol === 'function' && typeof Symbol.for === 'function'; - var chaiInspect = symbolsSupported ? Symbol.for('chai/inspect') : '@@chai/inspect'; - var nodeInspect = false; - - try { - // eslint-disable-next-line global-require - var nodeUtil = require('util'); - - nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false; - } catch (noNodeInspect) { - nodeInspect = false; - } - - var constructorMap = new WeakMap(); - var stringTagMap = {}; - var baseTypesMap = { - undefined: function undefined$1(value, options) { - return options.stylize('undefined', 'undefined'); - }, - null: function _null(value, options) { - return options.stylize(null, 'null'); - }, - boolean: function boolean(value, options) { - return options.stylize(value, 'boolean'); - }, - Boolean: function Boolean(value, options) { - return options.stylize(value, 'boolean'); - }, - number: inspectNumber, - Number: inspectNumber, - bigint: inspectBigInt, - BigInt: inspectBigInt, - string: inspectString, - String: inspectString, - function: inspectFunction, - Function: inspectFunction, - symbol: inspectSymbol, - // A Symbol polyfill will return `Symbol` not `symbol` from typedetect - Symbol: inspectSymbol, - Array: inspectArray, - Date: inspectDate, - Map: inspectMap, - Set: inspectSet, - RegExp: inspectRegExp, - Promise: inspectPromise, - // WeakSet, WeakMap are totally opaque to us - WeakSet: function WeakSet(value, options) { - return options.stylize('WeakSet{…}', 'special'); - }, - WeakMap: function WeakMap(value, options) { - return options.stylize('WeakMap{…}', 'special'); - }, - Arguments: inspectArguments, - Int8Array: inspectTypedArray, - Uint8Array: inspectTypedArray, - Uint8ClampedArray: inspectTypedArray, - Int16Array: inspectTypedArray, - Uint16Array: inspectTypedArray, - Int32Array: inspectTypedArray, - Uint32Array: inspectTypedArray, - Float32Array: inspectTypedArray, - Float64Array: inspectTypedArray, - Generator: function Generator() { - return ''; - }, - DataView: function DataView() { - return ''; - }, - ArrayBuffer: function ArrayBuffer() { - return ''; - }, - Error: inspectObject$1, - HTMLCollection: inspectHTMLCollection, - NodeList: inspectHTMLCollection - }; // eslint-disable-next-line complexity - - var inspectCustom = function inspectCustom(value, options, type) { - if (chaiInspect in value && typeof value[chaiInspect] === 'function') { - return value[chaiInspect](options); - } - - if (nodeInspect && nodeInspect in value && typeof value[nodeInspect] === 'function') { - return value[nodeInspect](options.depth, options); - } - - if ('inspect' in value && typeof value.inspect === 'function') { - return value.inspect(options.depth, options); - } - - if ('constructor' in value && constructorMap.has(value.constructor)) { - return constructorMap.get(value.constructor)(value, options); - } - - if (stringTagMap[type]) { - return stringTagMap[type](value, options); - } - - return ''; - }; - - var toString$1 = Object.prototype.toString; // eslint-disable-next-line complexity - - function inspect(value, options) { - options = normaliseOptions(options); - options.inspect = inspect; - var _options = options, - customInspect = _options.customInspect; - var type = value === null ? 'null' : _typeof(value); - - if (type === 'object') { - type = toString$1.call(value).slice(8, -1); - } // If it is a base value that we already support, then use Loupe's inspector - - - if (baseTypesMap[type]) { - return baseTypesMap[type](value, options); - } // If `options.customInspect` is set to true then try to use the custom inspector - - - if (customInspect && value) { - var output = inspectCustom(value, options, type); - - if (output) { - if (typeof output === 'string') return output; - return inspect(output, options); - } - } - - var proto = value ? Object.getPrototypeOf(value) : false; // If it's a plain Object then use Loupe's inspector - - if (proto === Object.prototype || proto === null) { - return inspectObject(value, options); - } // Specifically account for HTMLElements - // eslint-disable-next-line no-undef - - - if (value && typeof HTMLElement === 'function' && value instanceof HTMLElement) { - return inspectHTML(value, options); - } - - if ('constructor' in value) { - // If it is a class, inspect it like an object but add the constructor name - if (value.constructor !== Object) { - return inspectClass(value, options); - } // If it is an object with an anonymous prototype, display it as an object. - - - return inspectObject(value, options); - } // We have run out of options! Just stringify the value - - - return options.stylize(String(value), type); - } - function registerConstructor(constructor, inspector) { - if (constructorMap.has(constructor)) { - return false; - } - - constructorMap.add(constructor, inspector); - return true; - } - function registerStringTag(stringTag, inspector) { - if (stringTag in stringTagMap) { - return false; - } - - stringTagMap[stringTag] = inspector; - return true; - } - var custom = chaiInspect; - - exports.custom = custom; - exports.default = inspect; - exports.inspect = inspect; - exports.registerConstructor = registerConstructor; - exports.registerStringTag = registerStringTag; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); - -},{"util":undefined}],38:[function(require,module,exports){ -'use strict'; - -/* ! - * Chai - pathval utility - * Copyright(c) 2012-2014 Jake Luer - * @see https://github.com/logicalparadox/filtr - * MIT Licensed - */ - -/** - * ### .hasProperty(object, name) - * - * This allows checking whether an object has own - * or inherited from prototype chain named property. - * - * Basically does the same thing as the `in` - * operator but works properly with null/undefined values - * and other primitives. - * - * var obj = { - * arr: ['a', 'b', 'c'] - * , str: 'Hello' - * } - * - * The following would be the results. - * - * hasProperty(obj, 'str'); // true - * hasProperty(obj, 'constructor'); // true - * hasProperty(obj, 'bar'); // false - * - * hasProperty(obj.str, 'length'); // true - * hasProperty(obj.str, 1); // true - * hasProperty(obj.str, 5); // false - * - * hasProperty(obj.arr, 'length'); // true - * hasProperty(obj.arr, 2); // true - * hasProperty(obj.arr, 3); // false - * - * @param {Object} object - * @param {String|Symbol} name - * @returns {Boolean} whether it exists - * @namespace Utils - * @name hasProperty - * @api public - */ - -function hasProperty(obj, name) { - if (typeof obj === 'undefined' || obj === null) { - return false; - } - - // The `in` operator does not work with primitives. - return name in Object(obj); -} - -/* ! - * ## parsePath(path) - * - * Helper function used to parse string object - * paths. Use in conjunction with `internalGetPathValue`. - * - * var parsed = parsePath('myobject.property.subprop'); - * - * ### Paths: - * - * * Can be infinitely deep and nested. - * * Arrays are also valid using the formal `myobject.document[3].property`. - * * Literal dots and brackets (not delimiter) must be backslash-escaped. - * - * @param {String} path - * @returns {Object} parsed - * @api private - */ - -function parsePath(path) { - var str = path.replace(/([^\\])\[/g, '$1.['); - var parts = str.match(/(\\\.|[^.]+?)+/g); - return parts.map(function mapMatches(value) { - if ( - value === 'constructor' || - value === '__proto__' || - value === 'prototype' - ) { - return {}; - } - var regexp = /^\[(\d+)\]$/; - var mArr = regexp.exec(value); - var parsed = null; - if (mArr) { - parsed = { i: parseFloat(mArr[1]) }; - } else { - parsed = { p: value.replace(/\\([.[\]])/g, '$1') }; - } - - return parsed; - }); -} - -/* ! - * ## internalGetPathValue(obj, parsed[, pathDepth]) - * - * Helper companion function for `.parsePath` that returns - * the value located at the parsed address. - * - * var value = getPathValue(obj, parsed); - * - * @param {Object} object to search against - * @param {Object} parsed definition from `parsePath`. - * @param {Number} depth (nesting level) of the property we want to retrieve - * @returns {Object|Undefined} value - * @api private - */ - -function internalGetPathValue(obj, parsed, pathDepth) { - var temporaryValue = obj; - var res = null; - pathDepth = typeof pathDepth === 'undefined' ? parsed.length : pathDepth; - - for (var i = 0; i < pathDepth; i++) { - var part = parsed[i]; - if (temporaryValue) { - if (typeof part.p === 'undefined') { - temporaryValue = temporaryValue[part.i]; - } else { - temporaryValue = temporaryValue[part.p]; - } - - if (i === pathDepth - 1) { - res = temporaryValue; - } - } - } - - return res; -} - -/* ! - * ## internalSetPathValue(obj, value, parsed) - * - * Companion function for `parsePath` that sets - * the value located at a parsed address. - * - * internalSetPathValue(obj, 'value', parsed); - * - * @param {Object} object to search and define on - * @param {*} value to use upon set - * @param {Object} parsed definition from `parsePath` - * @api private - */ - -function internalSetPathValue(obj, val, parsed) { - var tempObj = obj; - var pathDepth = parsed.length; - var part = null; - // Here we iterate through every part of the path - for (var i = 0; i < pathDepth; i++) { - var propName = null; - var propVal = null; - part = parsed[i]; - - // If it's the last part of the path, we set the 'propName' value with the property name - if (i === pathDepth - 1) { - propName = typeof part.p === 'undefined' ? part.i : part.p; - // Now we set the property with the name held by 'propName' on object with the desired val - tempObj[propName] = val; - } else if (typeof part.p !== 'undefined' && tempObj[part.p]) { - tempObj = tempObj[part.p]; - } else if (typeof part.i !== 'undefined' && tempObj[part.i]) { - tempObj = tempObj[part.i]; - } else { - // If the obj doesn't have the property we create one with that name to define it - var next = parsed[i + 1]; - // Here we set the name of the property which will be defined - propName = typeof part.p === 'undefined' ? part.i : part.p; - // Here we decide if this property will be an array or a new object - propVal = typeof next.p === 'undefined' ? [] : {}; - tempObj[propName] = propVal; - tempObj = tempObj[propName]; - } - } -} - -/** - * ### .getPathInfo(object, path) - * - * This allows the retrieval of property info in an - * object given a string path. - * - * The path info consists of an object with the - * following properties: - * - * * parent - The parent object of the property referenced by `path` - * * name - The name of the final property, a number if it was an array indexer - * * value - The value of the property, if it exists, otherwise `undefined` - * * exists - Whether the property exists or not - * - * @param {Object} object - * @param {String} path - * @returns {Object} info - * @namespace Utils - * @name getPathInfo - * @api public - */ - -function getPathInfo(obj, path) { - var parsed = parsePath(path); - var last = parsed[parsed.length - 1]; - var info = { - parent: - parsed.length > 1 ? - internalGetPathValue(obj, parsed, parsed.length - 1) : - obj, - name: last.p || last.i, - value: internalGetPathValue(obj, parsed), - }; - info.exists = hasProperty(info.parent, info.name); - - return info; -} - -/** - * ### .getPathValue(object, path) - * - * This allows the retrieval of values in an - * object given a string path. - * - * var obj = { - * prop1: { - * arr: ['a', 'b', 'c'] - * , str: 'Hello' - * } - * , prop2: { - * arr: [ { nested: 'Universe' } ] - * , str: 'Hello again!' - * } - * } - * - * The following would be the results. - * - * getPathValue(obj, 'prop1.str'); // Hello - * getPathValue(obj, 'prop1.att[2]'); // b - * getPathValue(obj, 'prop2.arr[0].nested'); // Universe - * - * @param {Object} object - * @param {String} path - * @returns {Object} value or `undefined` - * @namespace Utils - * @name getPathValue - * @api public - */ - -function getPathValue(obj, path) { - var info = getPathInfo(obj, path); - return info.value; -} - -/** - * ### .setPathValue(object, path, value) - * - * Define the value in an object at a given string path. - * - * ```js - * var obj = { - * prop1: { - * arr: ['a', 'b', 'c'] - * , str: 'Hello' - * } - * , prop2: { - * arr: [ { nested: 'Universe' } ] - * , str: 'Hello again!' - * } - * }; - * ``` - * - * The following would be acceptable. - * - * ```js - * var properties = require('tea-properties'); - * properties.set(obj, 'prop1.str', 'Hello Universe!'); - * properties.set(obj, 'prop1.arr[2]', 'B'); - * properties.set(obj, 'prop2.arr[0].nested.value', { hello: 'universe' }); - * ``` - * - * @param {Object} object - * @param {String} path - * @param {Mixed} value - * @api private - */ - -function setPathValue(obj, path, val) { - var parsed = parsePath(path); - internalSetPathValue(obj, val, parsed); - return obj; -} - -module.exports = { - hasProperty: hasProperty, - getPathInfo: getPathInfo, - getPathValue: getPathValue, - setPathValue: setPathValue, -}; - -},{}],39:[function(require,module,exports){ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global.typeDetect = factory()); -}(this, (function () { 'use strict'; - -/* ! - * type-detect - * Copyright(c) 2013 jake luer - * MIT Licensed - */ -var promiseExists = typeof Promise === 'function'; - -/* eslint-disable no-undef */ -var globalObject = typeof self === 'object' ? self : global; // eslint-disable-line id-blacklist - -var symbolExists = typeof Symbol !== 'undefined'; -var mapExists = typeof Map !== 'undefined'; -var setExists = typeof Set !== 'undefined'; -var weakMapExists = typeof WeakMap !== 'undefined'; -var weakSetExists = typeof WeakSet !== 'undefined'; -var dataViewExists = typeof DataView !== 'undefined'; -var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined'; -var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined'; -var setEntriesExists = setExists && typeof Set.prototype.entries === 'function'; -var mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function'; -var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries()); -var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries()); -var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function'; -var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]()); -var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === 'function'; -var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]()); -var toStringLeftSliceLength = 8; -var toStringRightSliceLength = -1; -/** - * ### typeOf (obj) - * - * Uses `Object.prototype.toString` to determine the type of an object, - * normalising behaviour across engine versions & well optimised. - * - * @param {Mixed} object - * @return {String} object type - * @api public - */ -function typeDetect(obj) { - /* ! Speed optimisation - * Pre: - * string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled) - * boolean literal x 1,424,138 ops/sec ±4.54% (75 runs sampled) - * number literal x 1,653,153 ops/sec ±1.91% (82 runs sampled) - * undefined x 9,978,660 ops/sec ±1.92% (75 runs sampled) - * function x 2,556,769 ops/sec ±1.73% (77 runs sampled) - * Post: - * string literal x 38,564,796 ops/sec ±1.15% (79 runs sampled) - * boolean literal x 31,148,940 ops/sec ±1.10% (79 runs sampled) - * number literal x 32,679,330 ops/sec ±1.90% (78 runs sampled) - * undefined x 32,363,368 ops/sec ±1.07% (82 runs sampled) - * function x 31,296,870 ops/sec ±0.96% (83 runs sampled) - */ - var typeofObj = typeof obj; - if (typeofObj !== 'object') { - return typeofObj; - } - - /* ! Speed optimisation - * Pre: - * null x 28,645,765 ops/sec ±1.17% (82 runs sampled) - * Post: - * null x 36,428,962 ops/sec ±1.37% (84 runs sampled) - */ - if (obj === null) { - return 'null'; - } - - /* ! Spec Conformance - * Test: `Object.prototype.toString.call(window)`` - * - Node === "[object global]" - * - Chrome === "[object global]" - * - Firefox === "[object Window]" - * - PhantomJS === "[object Window]" - * - Safari === "[object Window]" - * - IE 11 === "[object Window]" - * - IE Edge === "[object Window]" - * Test: `Object.prototype.toString.call(this)`` - * - Chrome Worker === "[object global]" - * - Firefox Worker === "[object DedicatedWorkerGlobalScope]" - * - Safari Worker === "[object DedicatedWorkerGlobalScope]" - * - IE 11 Worker === "[object WorkerGlobalScope]" - * - IE Edge Worker === "[object WorkerGlobalScope]" - */ - if (obj === globalObject) { - return 'global'; - } - - /* ! Speed optimisation - * Pre: - * array literal x 2,888,352 ops/sec ±0.67% (82 runs sampled) - * Post: - * array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled) - */ - if ( - Array.isArray(obj) && - (symbolToStringTagExists === false || !(Symbol.toStringTag in obj)) - ) { - return 'Array'; - } - - // Not caching existence of `window` and related properties due to potential - // for `window` to be unset before tests in quasi-browser environments. - if (typeof window === 'object' && window !== null) { - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/browsers.html#location) - * WhatWG HTML$7.7.3 - The `Location` interface - * Test: `Object.prototype.toString.call(window.location)`` - * - IE <=11 === "[object Object]" - * - IE Edge <=13 === "[object Object]" - */ - if (typeof window.location === 'object' && obj === window.location) { - return 'Location'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/#document) - * WhatWG HTML$3.1.1 - The `Document` object - * Note: Most browsers currently adher to the W3C DOM Level 2 spec - * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268) - * which suggests that browsers should use HTMLTableCellElement for - * both TD and TH elements. WhatWG separates these. - * WhatWG HTML states: - * > For historical reasons, Window objects must also have a - * > writable, configurable, non-enumerable property named - * > HTMLDocument whose value is the Document interface object. - * Test: `Object.prototype.toString.call(document)`` - * - Chrome === "[object HTMLDocument]" - * - Firefox === "[object HTMLDocument]" - * - Safari === "[object HTMLDocument]" - * - IE <=10 === "[object Document]" - * - IE 11 === "[object HTMLDocument]" - * - IE Edge <=13 === "[object HTMLDocument]" - */ - if (typeof window.document === 'object' && obj === window.document) { - return 'Document'; - } - - if (typeof window.navigator === 'object') { - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray) - * WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray - * Test: `Object.prototype.toString.call(navigator.mimeTypes)`` - * - IE <=10 === "[object MSMimeTypesCollection]" - */ - if (typeof window.navigator.mimeTypes === 'object' && - obj === window.navigator.mimeTypes) { - return 'MimeTypeArray'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray) - * WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray - * Test: `Object.prototype.toString.call(navigator.plugins)`` - * - IE <=10 === "[object MSPluginsCollection]" - */ - if (typeof window.navigator.plugins === 'object' && - obj === window.navigator.plugins) { - return 'PluginArray'; - } - } - - if ((typeof window.HTMLElement === 'function' || - typeof window.HTMLElement === 'object') && - obj instanceof window.HTMLElement) { - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray) - * WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement` - * Test: `Object.prototype.toString.call(document.createElement('blockquote'))`` - * - IE <=10 === "[object HTMLBlockElement]" - */ - if (obj.tagName === 'BLOCKQUOTE') { - return 'HTMLQuoteElement'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/#htmltabledatacellelement) - * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement` - * Note: Most browsers currently adher to the W3C DOM Level 2 spec - * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075) - * which suggests that browsers should use HTMLTableCellElement for - * both TD and TH elements. WhatWG separates these. - * Test: Object.prototype.toString.call(document.createElement('td')) - * - Chrome === "[object HTMLTableCellElement]" - * - Firefox === "[object HTMLTableCellElement]" - * - Safari === "[object HTMLTableCellElement]" - */ - if (obj.tagName === 'TD') { - return 'HTMLTableDataCellElement'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/#htmltableheadercellelement) - * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement` - * Note: Most browsers currently adher to the W3C DOM Level 2 spec - * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075) - * which suggests that browsers should use HTMLTableCellElement for - * both TD and TH elements. WhatWG separates these. - * Test: Object.prototype.toString.call(document.createElement('th')) - * - Chrome === "[object HTMLTableCellElement]" - * - Firefox === "[object HTMLTableCellElement]" - * - Safari === "[object HTMLTableCellElement]" - */ - if (obj.tagName === 'TH') { - return 'HTMLTableHeaderCellElement'; - } - } - } - - /* ! Speed optimisation - * Pre: - * Float64Array x 625,644 ops/sec ±1.58% (80 runs sampled) - * Float32Array x 1,279,852 ops/sec ±2.91% (77 runs sampled) - * Uint32Array x 1,178,185 ops/sec ±1.95% (83 runs sampled) - * Uint16Array x 1,008,380 ops/sec ±2.25% (80 runs sampled) - * Uint8Array x 1,128,040 ops/sec ±2.11% (81 runs sampled) - * Int32Array x 1,170,119 ops/sec ±2.88% (80 runs sampled) - * Int16Array x 1,176,348 ops/sec ±5.79% (86 runs sampled) - * Int8Array x 1,058,707 ops/sec ±4.94% (77 runs sampled) - * Uint8ClampedArray x 1,110,633 ops/sec ±4.20% (80 runs sampled) - * Post: - * Float64Array x 7,105,671 ops/sec ±13.47% (64 runs sampled) - * Float32Array x 5,887,912 ops/sec ±1.46% (82 runs sampled) - * Uint32Array x 6,491,661 ops/sec ±1.76% (79 runs sampled) - * Uint16Array x 6,559,795 ops/sec ±1.67% (82 runs sampled) - * Uint8Array x 6,463,966 ops/sec ±1.43% (85 runs sampled) - * Int32Array x 5,641,841 ops/sec ±3.49% (81 runs sampled) - * Int16Array x 6,583,511 ops/sec ±1.98% (80 runs sampled) - * Int8Array x 6,606,078 ops/sec ±1.74% (81 runs sampled) - * Uint8ClampedArray x 6,602,224 ops/sec ±1.77% (83 runs sampled) - */ - var stringTag = (symbolToStringTagExists && obj[Symbol.toStringTag]); - if (typeof stringTag === 'string') { - return stringTag; - } - - var objPrototype = Object.getPrototypeOf(obj); - /* ! Speed optimisation - * Pre: - * regex literal x 1,772,385 ops/sec ±1.85% (77 runs sampled) - * regex constructor x 2,143,634 ops/sec ±2.46% (78 runs sampled) - * Post: - * regex literal x 3,928,009 ops/sec ±0.65% (78 runs sampled) - * regex constructor x 3,931,108 ops/sec ±0.58% (84 runs sampled) - */ - if (objPrototype === RegExp.prototype) { - return 'RegExp'; - } - - /* ! Speed optimisation - * Pre: - * date x 2,130,074 ops/sec ±4.42% (68 runs sampled) - * Post: - * date x 3,953,779 ops/sec ±1.35% (77 runs sampled) - */ - if (objPrototype === Date.prototype) { - return 'Date'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag) - * ES6$25.4.5.4 - Promise.prototype[@@toStringTag] should be "Promise": - * Test: `Object.prototype.toString.call(Promise.resolve())`` - * - Chrome <=47 === "[object Object]" - * - Edge <=20 === "[object Object]" - * - Firefox 29-Latest === "[object Promise]" - * - Safari 7.1-Latest === "[object Promise]" - */ - if (promiseExists && objPrototype === Promise.prototype) { - return 'Promise'; - } - - /* ! Speed optimisation - * Pre: - * set x 2,222,186 ops/sec ±1.31% (82 runs sampled) - * Post: - * set x 4,545,879 ops/sec ±1.13% (83 runs sampled) - */ - if (setExists && objPrototype === Set.prototype) { - return 'Set'; - } - - /* ! Speed optimisation - * Pre: - * map x 2,396,842 ops/sec ±1.59% (81 runs sampled) - * Post: - * map x 4,183,945 ops/sec ±6.59% (82 runs sampled) - */ - if (mapExists && objPrototype === Map.prototype) { - return 'Map'; - } - - /* ! Speed optimisation - * Pre: - * weakset x 1,323,220 ops/sec ±2.17% (76 runs sampled) - * Post: - * weakset x 4,237,510 ops/sec ±2.01% (77 runs sampled) - */ - if (weakSetExists && objPrototype === WeakSet.prototype) { - return 'WeakSet'; - } - - /* ! Speed optimisation - * Pre: - * weakmap x 1,500,260 ops/sec ±2.02% (78 runs sampled) - * Post: - * weakmap x 3,881,384 ops/sec ±1.45% (82 runs sampled) - */ - if (weakMapExists && objPrototype === WeakMap.prototype) { - return 'WeakMap'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag) - * ES6$24.2.4.21 - DataView.prototype[@@toStringTag] should be "DataView": - * Test: `Object.prototype.toString.call(new DataView(new ArrayBuffer(1)))`` - * - Edge <=13 === "[object Object]" - */ - if (dataViewExists && objPrototype === DataView.prototype) { - return 'DataView'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag) - * ES6$23.1.5.2.2 - %MapIteratorPrototype%[@@toStringTag] should be "Map Iterator": - * Test: `Object.prototype.toString.call(new Map().entries())`` - * - Edge <=13 === "[object Object]" - */ - if (mapExists && objPrototype === mapIteratorPrototype) { - return 'Map Iterator'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag) - * ES6$23.2.5.2.2 - %SetIteratorPrototype%[@@toStringTag] should be "Set Iterator": - * Test: `Object.prototype.toString.call(new Set().entries())`` - * - Edge <=13 === "[object Object]" - */ - if (setExists && objPrototype === setIteratorPrototype) { - return 'Set Iterator'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag) - * ES6$22.1.5.2.2 - %ArrayIteratorPrototype%[@@toStringTag] should be "Array Iterator": - * Test: `Object.prototype.toString.call([][Symbol.iterator]())`` - * - Edge <=13 === "[object Object]" - */ - if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) { - return 'Array Iterator'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag) - * ES6$21.1.5.2.2 - %StringIteratorPrototype%[@@toStringTag] should be "String Iterator": - * Test: `Object.prototype.toString.call(''[Symbol.iterator]())`` - * - Edge <=13 === "[object Object]" - */ - if (stringIteratorExists && objPrototype === stringIteratorPrototype) { - return 'String Iterator'; - } - - /* ! Speed optimisation - * Pre: - * object from null x 2,424,320 ops/sec ±1.67% (76 runs sampled) - * Post: - * object from null x 5,838,000 ops/sec ±0.99% (84 runs sampled) - */ - if (objPrototype === null) { - return 'Object'; - } - - return Object - .prototype - .toString - .call(obj) - .slice(toStringLeftSliceLength, toStringRightSliceLength); -} - -return typeDetect; - -}))); - -},{}]},{},[1])(1) -}); diff --git a/node_modules/chai/index.js b/node_modules/chai/index.js deleted file mode 100644 index 634483b..0000000 --- a/node_modules/chai/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./lib/chai'); diff --git a/node_modules/chai/index.mjs b/node_modules/chai/index.mjs deleted file mode 100644 index 65b726a..0000000 --- a/node_modules/chai/index.mjs +++ /dev/null @@ -1,14 +0,0 @@ -import chai from './index.js'; - -export const expect = chai.expect; -export const version = chai.version; -export const Assertion = chai.Assertion; -export const AssertionError = chai.AssertionError; -export const util = chai.util; -export const config = chai.config; -export const use = chai.use; -export const should = chai.should; -export const assert = chai.assert; -export const core = chai.core; - -export default chai; diff --git a/node_modules/chai/karma.conf.js b/node_modules/chai/karma.conf.js deleted file mode 100644 index e22923f..0000000 --- a/node_modules/chai/karma.conf.js +++ /dev/null @@ -1,34 +0,0 @@ -module.exports = function(config) { - config.set({ - frameworks: [ 'mocha' ] - , files: [ - 'chai.js' - , 'test/bootstrap/index.js' - , 'test/*.js' - ] - , reporters: [ 'progress' ] - , colors: true - , logLevel: config.LOG_INFO - , autoWatch: false - , browsers: [ 'HeadlessChrome' ] - , customLaunchers: { - HeadlessChrome: { - base: 'ChromeHeadless' - , flags: [ '--no-sandbox',] - , } - , } - , browserDisconnectTimeout: 10000 - , browserDisconnectTolerance: 2 - , browserNoActivityTimeout: 20000 - , singleRun: true - }); - - switch (process.env.CHAI_TEST_ENV) { - case 'sauce': - require('./karma.sauce')(config); - break; - default: - // ... - break; - }; -}; diff --git a/node_modules/chai/karma.sauce.js b/node_modules/chai/karma.sauce.js deleted file mode 100644 index b4f22fe..0000000 --- a/node_modules/chai/karma.sauce.js +++ /dev/null @@ -1,41 +0,0 @@ -var version = require('./package.json').version; -var ts = new Date().getTime(); - -module.exports = function(config) { - var auth; - - try { - auth = require('./test/auth/index'); - } catch(ex) { - auth = {}; - auth.SAUCE_USERNAME = process.env.SAUCE_USERNAME || null; - auth.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY || null; - } - - if (!auth.SAUCE_USERNAME || !auth.SAUCE_ACCESS_KEY) return; - if (process.env.SKIP_SAUCE) return; - - var branch = process.env.TRAVIS_BRANCH || 'local' - var browserConfig = require('./sauce.browsers'); - var browsers = Object.keys(browserConfig); - var tags = [ 'chaijs_' + version, auth.SAUCE_USERNAME + '@' + branch ]; - var tunnel = process.env.TRAVIS_JOB_NUMBER || ts; - - if (process.env.TRAVIS_JOB_NUMBER) { - tags.push('travis@' + process.env.TRAVIS_JOB_NUMBER); - } - - config.browsers = config.browsers.concat(browsers); - Object.assign(config.customLaunchers, browserConfig); - config.reporters.push('saucelabs'); - config.captureTimeout = 300000; - - config.sauceLabs = { - username: auth.SAUCE_USERNAME - , accessKey: auth.SAUCE_ACCESS_KEY - , startConnect: ('TRAVIS' in process.env) === false - , tags: tags - , testName: 'ChaiJS' - , tunnelIdentifier: tunnel - }; -}; diff --git a/node_modules/chai/lib/chai.js b/node_modules/chai/lib/chai.js deleted file mode 100644 index 16d9e62..0000000 --- a/node_modules/chai/lib/chai.js +++ /dev/null @@ -1,92 +0,0 @@ -/*! - * chai - * Copyright(c) 2011-2014 Jake Luer - * MIT Licensed - */ - -var used = []; - -/*! - * Chai version - */ - -exports.version = '4.3.3'; - -/*! - * Assertion Error - */ - -exports.AssertionError = require('assertion-error'); - -/*! - * Utils for plugins (not exported) - */ - -var util = require('./chai/utils'); - -/** - * # .use(function) - * - * Provides a way to extend the internals of Chai. - * - * @param {Function} - * @returns {this} for chaining - * @api public - */ - -exports.use = function (fn) { - if (!~used.indexOf(fn)) { - fn(exports, util); - used.push(fn); - } - - return exports; -}; - -/*! - * Utility Functions - */ - -exports.util = util; - -/*! - * Configuration - */ - -var config = require('./chai/config'); -exports.config = config; - -/*! - * Primary `Assertion` prototype - */ - -var assertion = require('./chai/assertion'); -exports.use(assertion); - -/*! - * Core Assertions - */ - -var core = require('./chai/core/assertions'); -exports.use(core); - -/*! - * Expect interface - */ - -var expect = require('./chai/interface/expect'); -exports.use(expect); - -/*! - * Should interface - */ - -var should = require('./chai/interface/should'); -exports.use(should); - -/*! - * Assert interface - */ - -var assert = require('./chai/interface/assert'); -exports.use(assert); diff --git a/node_modules/chai/lib/chai/assertion.js b/node_modules/chai/lib/chai/assertion.js deleted file mode 100644 index 8ed93ae..0000000 --- a/node_modules/chai/lib/chai/assertion.js +++ /dev/null @@ -1,175 +0,0 @@ -/*! - * chai - * http://chaijs.com - * Copyright(c) 2011-2014 Jake Luer - * MIT Licensed - */ - -var config = require('./config'); - -module.exports = function (_chai, util) { - /*! - * Module dependencies. - */ - - var AssertionError = _chai.AssertionError - , flag = util.flag; - - /*! - * Module export. - */ - - _chai.Assertion = Assertion; - - /*! - * Assertion Constructor - * - * Creates object for chaining. - * - * `Assertion` objects contain metadata in the form of flags. Three flags can - * be assigned during instantiation by passing arguments to this constructor: - * - * - `object`: This flag contains the target of the assertion. For example, in - * the assertion `expect(numKittens).to.equal(7);`, the `object` flag will - * contain `numKittens` so that the `equal` assertion can reference it when - * needed. - * - * - `message`: This flag contains an optional custom error message to be - * prepended to the error message that's generated by the assertion when it - * fails. - * - * - `ssfi`: This flag stands for "start stack function indicator". It - * contains a function reference that serves as the starting point for - * removing frames from the stack trace of the error that's created by the - * assertion when it fails. The goal is to provide a cleaner stack trace to - * end users by removing Chai's internal functions. Note that it only works - * in environments that support `Error.captureStackTrace`, and only when - * `Chai.config.includeStack` hasn't been set to `false`. - * - * - `lockSsfi`: This flag controls whether or not the given `ssfi` flag - * should retain its current value, even as assertions are chained off of - * this object. This is usually set to `true` when creating a new assertion - * from within another assertion. It's also temporarily set to `true` before - * an overwritten assertion gets called by the overwriting assertion. - * - * @param {Mixed} obj target of the assertion - * @param {String} msg (optional) custom error message - * @param {Function} ssfi (optional) starting point for removing stack frames - * @param {Boolean} lockSsfi (optional) whether or not the ssfi flag is locked - * @api private - */ - - function Assertion (obj, msg, ssfi, lockSsfi) { - flag(this, 'ssfi', ssfi || Assertion); - flag(this, 'lockSsfi', lockSsfi); - flag(this, 'object', obj); - flag(this, 'message', msg); - - return util.proxify(this); - } - - Object.defineProperty(Assertion, 'includeStack', { - get: function() { - console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.'); - return config.includeStack; - }, - set: function(value) { - console.warn('Assertion.includeStack is deprecated, use chai.config.includeStack instead.'); - config.includeStack = value; - } - }); - - Object.defineProperty(Assertion, 'showDiff', { - get: function() { - console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.'); - return config.showDiff; - }, - set: function(value) { - console.warn('Assertion.showDiff is deprecated, use chai.config.showDiff instead.'); - config.showDiff = value; - } - }); - - Assertion.addProperty = function (name, fn) { - util.addProperty(this.prototype, name, fn); - }; - - Assertion.addMethod = function (name, fn) { - util.addMethod(this.prototype, name, fn); - }; - - Assertion.addChainableMethod = function (name, fn, chainingBehavior) { - util.addChainableMethod(this.prototype, name, fn, chainingBehavior); - }; - - Assertion.overwriteProperty = function (name, fn) { - util.overwriteProperty(this.prototype, name, fn); - }; - - Assertion.overwriteMethod = function (name, fn) { - util.overwriteMethod(this.prototype, name, fn); - }; - - Assertion.overwriteChainableMethod = function (name, fn, chainingBehavior) { - util.overwriteChainableMethod(this.prototype, name, fn, chainingBehavior); - }; - - /** - * ### .assert(expression, message, negateMessage, expected, actual, showDiff) - * - * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass. - * - * @name assert - * @param {Philosophical} expression to be tested - * @param {String|Function} message or function that returns message to display if expression fails - * @param {String|Function} negatedMessage or function that returns negatedMessage to display if negated expression fails - * @param {Mixed} expected value (remember to check for negation) - * @param {Mixed} actual (optional) will default to `this.obj` - * @param {Boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails - * @api private - */ - - Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, showDiff) { - var ok = util.test(this, arguments); - if (false !== showDiff) showDiff = true; - if (undefined === expected && undefined === _actual) showDiff = false; - if (true !== config.showDiff) showDiff = false; - - if (!ok) { - msg = util.getMessage(this, arguments); - var actual = util.getActual(this, arguments); - var assertionErrorObjectProperties = { - actual: actual - , expected: expected - , showDiff: showDiff - }; - - var operator = util.getOperator(this, arguments); - if (operator) { - assertionErrorObjectProperties.operator = operator; - } - - throw new AssertionError( - msg, - assertionErrorObjectProperties, - (config.includeStack) ? this.assert : flag(this, 'ssfi')); - } - }; - - /*! - * ### ._obj - * - * Quick reference to stored `actual` value for plugin developers. - * - * @api private - */ - - Object.defineProperty(Assertion.prototype, '_obj', - { get: function () { - return flag(this, 'object'); - } - , set: function (val) { - flag(this, 'object', val); - } - }); -}; diff --git a/node_modules/chai/lib/chai/config.js b/node_modules/chai/lib/chai/config.js deleted file mode 100644 index 412a0c8..0000000 --- a/node_modules/chai/lib/chai/config.js +++ /dev/null @@ -1,94 +0,0 @@ -module.exports = { - - /** - * ### config.includeStack - * - * User configurable property, influences whether stack trace - * is included in Assertion error message. Default of false - * suppresses stack trace in the error message. - * - * chai.config.includeStack = true; // enable stack on error - * - * @param {Boolean} - * @api public - */ - - includeStack: false, - - /** - * ### config.showDiff - * - * User configurable property, influences whether or not - * the `showDiff` flag should be included in the thrown - * AssertionErrors. `false` will always be `false`; `true` - * will be true when the assertion has requested a diff - * be shown. - * - * @param {Boolean} - * @api public - */ - - showDiff: true, - - /** - * ### config.truncateThreshold - * - * User configurable property, sets length threshold for actual and - * expected values in assertion errors. If this threshold is exceeded, for - * example for large data structures, the value is replaced with something - * like `[ Array(3) ]` or `{ Object (prop1, prop2) }`. - * - * Set it to zero if you want to disable truncating altogether. - * - * This is especially userful when doing assertions on arrays: having this - * set to a reasonable large value makes the failure messages readily - * inspectable. - * - * chai.config.truncateThreshold = 0; // disable truncating - * - * @param {Number} - * @api public - */ - - truncateThreshold: 40, - - /** - * ### config.useProxy - * - * User configurable property, defines if chai will use a Proxy to throw - * an error when a non-existent property is read, which protects users - * from typos when using property-based assertions. - * - * Set it to false if you want to disable this feature. - * - * chai.config.useProxy = false; // disable use of Proxy - * - * This feature is automatically disabled regardless of this config value - * in environments that don't support proxies. - * - * @param {Boolean} - * @api public - */ - - useProxy: true, - - /** - * ### config.proxyExcludedKeys - * - * User configurable property, defines which properties should be ignored - * instead of throwing an error if they do not exist on the assertion. - * This is only applied if the environment Chai is running in supports proxies and - * if the `useProxy` configuration setting is enabled. - * By default, `then` and `inspect` will not throw an error if they do not exist on the - * assertion object because the `.inspect` property is read by `util.inspect` (for example, when - * using `console.log` on the assertion object) and `.then` is necessary for promise type-checking. - * - * // By default these keys will not throw an error if they do not exist on the assertion object - * chai.config.proxyExcludedKeys = ['then', 'inspect']; - * - * @param {Array} - * @api public - */ - - proxyExcludedKeys: ['then', 'catch', 'inspect', 'toJSON'] -}; diff --git a/node_modules/chai/lib/chai/core/assertions.js b/node_modules/chai/lib/chai/core/assertions.js deleted file mode 100644 index 990664b..0000000 --- a/node_modules/chai/lib/chai/core/assertions.js +++ /dev/null @@ -1,3853 +0,0 @@ -/*! - * chai - * http://chaijs.com - * Copyright(c) 2011-2014 Jake Luer - * MIT Licensed - */ - -module.exports = function (chai, _) { - var Assertion = chai.Assertion - , AssertionError = chai.AssertionError - , flag = _.flag; - - /** - * ### Language Chains - * - * The following are provided as chainable getters to improve the readability - * of your assertions. - * - * **Chains** - * - * - to - * - be - * - been - * - is - * - that - * - which - * - and - * - has - * - have - * - with - * - at - * - of - * - same - * - but - * - does - * - still - * - also - * - * @name language chains - * @namespace BDD - * @api public - */ - - [ 'to', 'be', 'been', 'is' - , 'and', 'has', 'have', 'with' - , 'that', 'which', 'at', 'of' - , 'same', 'but', 'does', 'still', "also" ].forEach(function (chain) { - Assertion.addProperty(chain); - }); - - /** - * ### .not - * - * Negates all assertions that follow in the chain. - * - * expect(function () {}).to.not.throw(); - * expect({a: 1}).to.not.have.property('b'); - * expect([1, 2]).to.be.an('array').that.does.not.include(3); - * - * Just because you can negate any assertion with `.not` doesn't mean you - * should. With great power comes great responsibility. It's often best to - * assert that the one expected output was produced, rather than asserting - * that one of countless unexpected outputs wasn't produced. See individual - * assertions for specific guidance. - * - * expect(2).to.equal(2); // Recommended - * expect(2).to.not.equal(1); // Not recommended - * - * @name not - * @namespace BDD - * @api public - */ - - Assertion.addProperty('not', function () { - flag(this, 'negate', true); - }); - - /** - * ### .deep - * - * Causes all `.equal`, `.include`, `.members`, `.keys`, and `.property` - * assertions that follow in the chain to use deep equality instead of strict - * (`===`) equality. See the `deep-eql` project page for info on the deep - * equality algorithm: https://github.com/chaijs/deep-eql. - * - * // Target object deeply (but not strictly) equals `{a: 1}` - * expect({a: 1}).to.deep.equal({a: 1}); - * expect({a: 1}).to.not.equal({a: 1}); - * - * // Target array deeply (but not strictly) includes `{a: 1}` - * expect([{a: 1}]).to.deep.include({a: 1}); - * expect([{a: 1}]).to.not.include({a: 1}); - * - * // Target object deeply (but not strictly) includes `x: {a: 1}` - * expect({x: {a: 1}}).to.deep.include({x: {a: 1}}); - * expect({x: {a: 1}}).to.not.include({x: {a: 1}}); - * - * // Target array deeply (but not strictly) has member `{a: 1}` - * expect([{a: 1}]).to.have.deep.members([{a: 1}]); - * expect([{a: 1}]).to.not.have.members([{a: 1}]); - * - * // Target set deeply (but not strictly) has key `{a: 1}` - * expect(new Set([{a: 1}])).to.have.deep.keys([{a: 1}]); - * expect(new Set([{a: 1}])).to.not.have.keys([{a: 1}]); - * - * // Target object deeply (but not strictly) has property `x: {a: 1}` - * expect({x: {a: 1}}).to.have.deep.property('x', {a: 1}); - * expect({x: {a: 1}}).to.not.have.property('x', {a: 1}); - * - * @name deep - * @namespace BDD - * @api public - */ - - Assertion.addProperty('deep', function () { - flag(this, 'deep', true); - }); - - /** - * ### .nested - * - * Enables dot- and bracket-notation in all `.property` and `.include` - * assertions that follow in the chain. - * - * expect({a: {b: ['x', 'y']}}).to.have.nested.property('a.b[1]'); - * expect({a: {b: ['x', 'y']}}).to.nested.include({'a.b[1]': 'y'}); - * - * If `.` or `[]` are part of an actual property name, they can be escaped by - * adding two backslashes before them. - * - * expect({'.a': {'[b]': 'x'}}).to.have.nested.property('\\.a.\\[b\\]'); - * expect({'.a': {'[b]': 'x'}}).to.nested.include({'\\.a.\\[b\\]': 'x'}); - * - * `.nested` cannot be combined with `.own`. - * - * @name nested - * @namespace BDD - * @api public - */ - - Assertion.addProperty('nested', function () { - flag(this, 'nested', true); - }); - - /** - * ### .own - * - * Causes all `.property` and `.include` assertions that follow in the chain - * to ignore inherited properties. - * - * Object.prototype.b = 2; - * - * expect({a: 1}).to.have.own.property('a'); - * expect({a: 1}).to.have.property('b'); - * expect({a: 1}).to.not.have.own.property('b'); - * - * expect({a: 1}).to.own.include({a: 1}); - * expect({a: 1}).to.include({b: 2}).but.not.own.include({b: 2}); - * - * `.own` cannot be combined with `.nested`. - * - * @name own - * @namespace BDD - * @api public - */ - - Assertion.addProperty('own', function () { - flag(this, 'own', true); - }); - - /** - * ### .ordered - * - * Causes all `.members` assertions that follow in the chain to require that - * members be in the same order. - * - * expect([1, 2]).to.have.ordered.members([1, 2]) - * .but.not.have.ordered.members([2, 1]); - * - * When `.include` and `.ordered` are combined, the ordering begins at the - * start of both arrays. - * - * expect([1, 2, 3]).to.include.ordered.members([1, 2]) - * .but.not.include.ordered.members([2, 3]); - * - * @name ordered - * @namespace BDD - * @api public - */ - - Assertion.addProperty('ordered', function () { - flag(this, 'ordered', true); - }); - - /** - * ### .any - * - * Causes all `.keys` assertions that follow in the chain to only require that - * the target have at least one of the given keys. This is the opposite of - * `.all`, which requires that the target have all of the given keys. - * - * expect({a: 1, b: 2}).to.not.have.any.keys('c', 'd'); - * - * See the `.keys` doc for guidance on when to use `.any` or `.all`. - * - * @name any - * @namespace BDD - * @api public - */ - - Assertion.addProperty('any', function () { - flag(this, 'any', true); - flag(this, 'all', false); - }); - - /** - * ### .all - * - * Causes all `.keys` assertions that follow in the chain to require that the - * target have all of the given keys. This is the opposite of `.any`, which - * only requires that the target have at least one of the given keys. - * - * expect({a: 1, b: 2}).to.have.all.keys('a', 'b'); - * - * Note that `.all` is used by default when neither `.all` nor `.any` are - * added earlier in the chain. However, it's often best to add `.all` anyway - * because it improves readability. - * - * See the `.keys` doc for guidance on when to use `.any` or `.all`. - * - * @name all - * @namespace BDD - * @api public - */ - - Assertion.addProperty('all', function () { - flag(this, 'all', true); - flag(this, 'any', false); - }); - - /** - * ### .a(type[, msg]) - * - * Asserts that the target's type is equal to the given string `type`. Types - * are case insensitive. See the `type-detect` project page for info on the - * type detection algorithm: https://github.com/chaijs/type-detect. - * - * expect('foo').to.be.a('string'); - * expect({a: 1}).to.be.an('object'); - * expect(null).to.be.a('null'); - * expect(undefined).to.be.an('undefined'); - * expect(new Error).to.be.an('error'); - * expect(Promise.resolve()).to.be.a('promise'); - * expect(new Float32Array).to.be.a('float32array'); - * expect(Symbol()).to.be.a('symbol'); - * - * `.a` supports objects that have a custom type set via `Symbol.toStringTag`. - * - * var myObj = { - * [Symbol.toStringTag]: 'myCustomType' - * }; - * - * expect(myObj).to.be.a('myCustomType').but.not.an('object'); - * - * It's often best to use `.a` to check a target's type before making more - * assertions on the same target. That way, you avoid unexpected behavior from - * any assertion that does different things based on the target's type. - * - * expect([1, 2, 3]).to.be.an('array').that.includes(2); - * expect([]).to.be.an('array').that.is.empty; - * - * Add `.not` earlier in the chain to negate `.a`. However, it's often best to - * assert that the target is the expected type, rather than asserting that it - * isn't one of many unexpected types. - * - * expect('foo').to.be.a('string'); // Recommended - * expect('foo').to.not.be.an('array'); // Not recommended - * - * `.a` accepts an optional `msg` argument which is a custom error message to - * show when the assertion fails. The message can also be given as the second - * argument to `expect`. - * - * expect(1).to.be.a('string', 'nooo why fail??'); - * expect(1, 'nooo why fail??').to.be.a('string'); - * - * `.a` can also be used as a language chain to improve the readability of - * your assertions. - * - * expect({b: 2}).to.have.a.property('b'); - * - * The alias `.an` can be used interchangeably with `.a`. - * - * @name a - * @alias an - * @param {String} type - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function an (type, msg) { - if (msg) flag(this, 'message', msg); - type = type.toLowerCase(); - var obj = flag(this, 'object') - , article = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(type.charAt(0)) ? 'an ' : 'a '; - - this.assert( - type === _.type(obj).toLowerCase() - , 'expected #{this} to be ' + article + type - , 'expected #{this} not to be ' + article + type - ); - } - - Assertion.addChainableMethod('an', an); - Assertion.addChainableMethod('a', an); - - /** - * ### .include(val[, msg]) - * - * When the target is a string, `.include` asserts that the given string `val` - * is a substring of the target. - * - * expect('foobar').to.include('foo'); - * - * When the target is an array, `.include` asserts that the given `val` is a - * member of the target. - * - * expect([1, 2, 3]).to.include(2); - * - * When the target is an object, `.include` asserts that the given object - * `val`'s properties are a subset of the target's properties. - * - * expect({a: 1, b: 2, c: 3}).to.include({a: 1, b: 2}); - * - * When the target is a Set or WeakSet, `.include` asserts that the given `val` is a - * member of the target. SameValueZero equality algorithm is used. - * - * expect(new Set([1, 2])).to.include(2); - * - * When the target is a Map, `.include` asserts that the given `val` is one of - * the values of the target. SameValueZero equality algorithm is used. - * - * expect(new Map([['a', 1], ['b', 2]])).to.include(2); - * - * Because `.include` does different things based on the target's type, it's - * important to check the target's type before using `.include`. See the `.a` - * doc for info on testing a target's type. - * - * expect([1, 2, 3]).to.be.an('array').that.includes(2); - * - * By default, strict (`===`) equality is used to compare array members and - * object properties. Add `.deep` earlier in the chain to use deep equality - * instead (WeakSet targets are not supported). See the `deep-eql` project - * page for info on the deep equality algorithm: https://github.com/chaijs/deep-eql. - * - * // Target array deeply (but not strictly) includes `{a: 1}` - * expect([{a: 1}]).to.deep.include({a: 1}); - * expect([{a: 1}]).to.not.include({a: 1}); - * - * // Target object deeply (but not strictly) includes `x: {a: 1}` - * expect({x: {a: 1}}).to.deep.include({x: {a: 1}}); - * expect({x: {a: 1}}).to.not.include({x: {a: 1}}); - * - * By default, all of the target's properties are searched when working with - * objects. This includes properties that are inherited and/or non-enumerable. - * Add `.own` earlier in the chain to exclude the target's inherited - * properties from the search. - * - * Object.prototype.b = 2; - * - * expect({a: 1}).to.own.include({a: 1}); - * expect({a: 1}).to.include({b: 2}).but.not.own.include({b: 2}); - * - * Note that a target object is always only searched for `val`'s own - * enumerable properties. - * - * `.deep` and `.own` can be combined. - * - * expect({a: {b: 2}}).to.deep.own.include({a: {b: 2}}); - * - * Add `.nested` earlier in the chain to enable dot- and bracket-notation when - * referencing nested properties. - * - * expect({a: {b: ['x', 'y']}}).to.nested.include({'a.b[1]': 'y'}); - * - * If `.` or `[]` are part of an actual property name, they can be escaped by - * adding two backslashes before them. - * - * expect({'.a': {'[b]': 2}}).to.nested.include({'\\.a.\\[b\\]': 2}); - * - * `.deep` and `.nested` can be combined. - * - * expect({a: {b: [{c: 3}]}}).to.deep.nested.include({'a.b[0]': {c: 3}}); - * - * `.own` and `.nested` cannot be combined. - * - * Add `.not` earlier in the chain to negate `.include`. - * - * expect('foobar').to.not.include('taco'); - * expect([1, 2, 3]).to.not.include(4); - * - * However, it's dangerous to negate `.include` when the target is an object. - * The problem is that it creates uncertain expectations by asserting that the - * target object doesn't have all of `val`'s key/value pairs but may or may - * not have some of them. It's often best to identify the exact output that's - * expected, and then write an assertion that only accepts that exact output. - * - * When the target object isn't even expected to have `val`'s keys, it's - * often best to assert exactly that. - * - * expect({c: 3}).to.not.have.any.keys('a', 'b'); // Recommended - * expect({c: 3}).to.not.include({a: 1, b: 2}); // Not recommended - * - * When the target object is expected to have `val`'s keys, it's often best to - * assert that each of the properties has its expected value, rather than - * asserting that each property doesn't have one of many unexpected values. - * - * expect({a: 3, b: 4}).to.include({a: 3, b: 4}); // Recommended - * expect({a: 3, b: 4}).to.not.include({a: 1, b: 2}); // Not recommended - * - * `.include` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect([1, 2, 3]).to.include(4, 'nooo why fail??'); - * expect([1, 2, 3], 'nooo why fail??').to.include(4); - * - * `.include` can also be used as a language chain, causing all `.members` and - * `.keys` assertions that follow in the chain to require the target to be a - * superset of the expected set, rather than an identical set. Note that - * `.members` ignores duplicates in the subset when `.include` is added. - * - * // Target object's keys are a superset of ['a', 'b'] but not identical - * expect({a: 1, b: 2, c: 3}).to.include.all.keys('a', 'b'); - * expect({a: 1, b: 2, c: 3}).to.not.have.all.keys('a', 'b'); - * - * // Target array is a superset of [1, 2] but not identical - * expect([1, 2, 3]).to.include.members([1, 2]); - * expect([1, 2, 3]).to.not.have.members([1, 2]); - * - * // Duplicates in the subset are ignored - * expect([1, 2, 3]).to.include.members([1, 2, 2, 2]); - * - * Note that adding `.any` earlier in the chain causes the `.keys` assertion - * to ignore `.include`. - * - * // Both assertions are identical - * expect({a: 1}).to.include.any.keys('a', 'b'); - * expect({a: 1}).to.have.any.keys('a', 'b'); - * - * The aliases `.includes`, `.contain`, and `.contains` can be used - * interchangeably with `.include`. - * - * @name include - * @alias contain - * @alias includes - * @alias contains - * @param {Mixed} val - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function SameValueZero(a, b) { - return (_.isNaN(a) && _.isNaN(b)) || a === b; - } - - function includeChainingBehavior () { - flag(this, 'contains', true); - } - - function include (val, msg) { - if (msg) flag(this, 'message', msg); - - var obj = flag(this, 'object') - , objType = _.type(obj).toLowerCase() - , flagMsg = flag(this, 'message') - , negate = flag(this, 'negate') - , ssfi = flag(this, 'ssfi') - , isDeep = flag(this, 'deep') - , descriptor = isDeep ? 'deep ' : ''; - - flagMsg = flagMsg ? flagMsg + ': ' : ''; - - var included = false; - - switch (objType) { - case 'string': - included = obj.indexOf(val) !== -1; - break; - - case 'weakset': - if (isDeep) { - throw new AssertionError( - flagMsg + 'unable to use .deep.include with WeakSet', - undefined, - ssfi - ); - } - - included = obj.has(val); - break; - - case 'map': - var isEql = isDeep ? _.eql : SameValueZero; - obj.forEach(function (item) { - included = included || isEql(item, val); - }); - break; - - case 'set': - if (isDeep) { - obj.forEach(function (item) { - included = included || _.eql(item, val); - }); - } else { - included = obj.has(val); - } - break; - - case 'array': - if (isDeep) { - included = obj.some(function (item) { - return _.eql(item, val); - }) - } else { - included = obj.indexOf(val) !== -1; - } - break; - - default: - // This block is for asserting a subset of properties in an object. - // `_.expectTypes` isn't used here because `.include` should work with - // objects with a custom `@@toStringTag`. - if (val !== Object(val)) { - throw new AssertionError( - flagMsg + 'the given combination of arguments (' - + objType + ' and ' - + _.type(val).toLowerCase() + ')' - + ' is invalid for this assertion. ' - + 'You can use an array, a map, an object, a set, a string, ' - + 'or a weakset instead of a ' - + _.type(val).toLowerCase(), - undefined, - ssfi - ); - } - - var props = Object.keys(val) - , firstErr = null - , numErrs = 0; - - props.forEach(function (prop) { - var propAssertion = new Assertion(obj); - _.transferFlags(this, propAssertion, true); - flag(propAssertion, 'lockSsfi', true); - - if (!negate || props.length === 1) { - propAssertion.property(prop, val[prop]); - return; - } - - try { - propAssertion.property(prop, val[prop]); - } catch (err) { - if (!_.checkError.compatibleConstructor(err, AssertionError)) { - throw err; - } - if (firstErr === null) firstErr = err; - numErrs++; - } - }, this); - - // When validating .not.include with multiple properties, we only want - // to throw an assertion error if all of the properties are included, - // in which case we throw the first property assertion error that we - // encountered. - if (negate && props.length > 1 && numErrs === props.length) { - throw firstErr; - } - return; - } - - // Assert inclusion in collection or substring in a string. - this.assert( - included - , 'expected #{this} to ' + descriptor + 'include ' + _.inspect(val) - , 'expected #{this} to not ' + descriptor + 'include ' + _.inspect(val)); - } - - Assertion.addChainableMethod('include', include, includeChainingBehavior); - Assertion.addChainableMethod('contain', include, includeChainingBehavior); - Assertion.addChainableMethod('contains', include, includeChainingBehavior); - Assertion.addChainableMethod('includes', include, includeChainingBehavior); - - /** - * ### .ok - * - * Asserts that the target is a truthy value (considered `true` in boolean context). - * However, it's often best to assert that the target is strictly (`===`) or - * deeply equal to its expected value. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.be.ok; // Not recommended - * - * expect(true).to.be.true; // Recommended - * expect(true).to.be.ok; // Not recommended - * - * Add `.not` earlier in the chain to negate `.ok`. - * - * expect(0).to.equal(0); // Recommended - * expect(0).to.not.be.ok; // Not recommended - * - * expect(false).to.be.false; // Recommended - * expect(false).to.not.be.ok; // Not recommended - * - * expect(null).to.be.null; // Recommended - * expect(null).to.not.be.ok; // Not recommended - * - * expect(undefined).to.be.undefined; // Recommended - * expect(undefined).to.not.be.ok; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(false, 'nooo why fail??').to.be.ok; - * - * @name ok - * @namespace BDD - * @api public - */ - - Assertion.addProperty('ok', function () { - this.assert( - flag(this, 'object') - , 'expected #{this} to be truthy' - , 'expected #{this} to be falsy'); - }); - - /** - * ### .true - * - * Asserts that the target is strictly (`===`) equal to `true`. - * - * expect(true).to.be.true; - * - * Add `.not` earlier in the chain to negate `.true`. However, it's often best - * to assert that the target is equal to its expected value, rather than not - * equal to `true`. - * - * expect(false).to.be.false; // Recommended - * expect(false).to.not.be.true; // Not recommended - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.true; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(false, 'nooo why fail??').to.be.true; - * - * @name true - * @namespace BDD - * @api public - */ - - Assertion.addProperty('true', function () { - this.assert( - true === flag(this, 'object') - , 'expected #{this} to be true' - , 'expected #{this} to be false' - , flag(this, 'negate') ? false : true - ); - }); - - /** - * ### .false - * - * Asserts that the target is strictly (`===`) equal to `false`. - * - * expect(false).to.be.false; - * - * Add `.not` earlier in the chain to negate `.false`. However, it's often - * best to assert that the target is equal to its expected value, rather than - * not equal to `false`. - * - * expect(true).to.be.true; // Recommended - * expect(true).to.not.be.false; // Not recommended - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.false; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(true, 'nooo why fail??').to.be.false; - * - * @name false - * @namespace BDD - * @api public - */ - - Assertion.addProperty('false', function () { - this.assert( - false === flag(this, 'object') - , 'expected #{this} to be false' - , 'expected #{this} to be true' - , flag(this, 'negate') ? true : false - ); - }); - - /** - * ### .null - * - * Asserts that the target is strictly (`===`) equal to `null`. - * - * expect(null).to.be.null; - * - * Add `.not` earlier in the chain to negate `.null`. However, it's often best - * to assert that the target is equal to its expected value, rather than not - * equal to `null`. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.null; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(42, 'nooo why fail??').to.be.null; - * - * @name null - * @namespace BDD - * @api public - */ - - Assertion.addProperty('null', function () { - this.assert( - null === flag(this, 'object') - , 'expected #{this} to be null' - , 'expected #{this} not to be null' - ); - }); - - /** - * ### .undefined - * - * Asserts that the target is strictly (`===`) equal to `undefined`. - * - * expect(undefined).to.be.undefined; - * - * Add `.not` earlier in the chain to negate `.undefined`. However, it's often - * best to assert that the target is equal to its expected value, rather than - * not equal to `undefined`. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.undefined; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(42, 'nooo why fail??').to.be.undefined; - * - * @name undefined - * @namespace BDD - * @api public - */ - - Assertion.addProperty('undefined', function () { - this.assert( - undefined === flag(this, 'object') - , 'expected #{this} to be undefined' - , 'expected #{this} not to be undefined' - ); - }); - - /** - * ### .NaN - * - * Asserts that the target is exactly `NaN`. - * - * expect(NaN).to.be.NaN; - * - * Add `.not` earlier in the chain to negate `.NaN`. However, it's often best - * to assert that the target is equal to its expected value, rather than not - * equal to `NaN`. - * - * expect('foo').to.equal('foo'); // Recommended - * expect('foo').to.not.be.NaN; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(42, 'nooo why fail??').to.be.NaN; - * - * @name NaN - * @namespace BDD - * @api public - */ - - Assertion.addProperty('NaN', function () { - this.assert( - _.isNaN(flag(this, 'object')) - , 'expected #{this} to be NaN' - , 'expected #{this} not to be NaN' - ); - }); - - /** - * ### .exist - * - * Asserts that the target is not strictly (`===`) equal to either `null` or - * `undefined`. However, it's often best to assert that the target is equal to - * its expected value. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.exist; // Not recommended - * - * expect(0).to.equal(0); // Recommended - * expect(0).to.exist; // Not recommended - * - * Add `.not` earlier in the chain to negate `.exist`. - * - * expect(null).to.be.null; // Recommended - * expect(null).to.not.exist; // Not recommended - * - * expect(undefined).to.be.undefined; // Recommended - * expect(undefined).to.not.exist; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(null, 'nooo why fail??').to.exist; - * - * The alias `.exists` can be used interchangeably with `.exist`. - * - * @name exist - * @alias exists - * @namespace BDD - * @api public - */ - - function assertExist () { - var val = flag(this, 'object'); - this.assert( - val !== null && val !== undefined - , 'expected #{this} to exist' - , 'expected #{this} to not exist' - ); - } - - Assertion.addProperty('exist', assertExist); - Assertion.addProperty('exists', assertExist); - - /** - * ### .empty - * - * When the target is a string or array, `.empty` asserts that the target's - * `length` property is strictly (`===`) equal to `0`. - * - * expect([]).to.be.empty; - * expect('').to.be.empty; - * - * When the target is a map or set, `.empty` asserts that the target's `size` - * property is strictly equal to `0`. - * - * expect(new Set()).to.be.empty; - * expect(new Map()).to.be.empty; - * - * When the target is a non-function object, `.empty` asserts that the target - * doesn't have any own enumerable properties. Properties with Symbol-based - * keys are excluded from the count. - * - * expect({}).to.be.empty; - * - * Because `.empty` does different things based on the target's type, it's - * important to check the target's type before using `.empty`. See the `.a` - * doc for info on testing a target's type. - * - * expect([]).to.be.an('array').that.is.empty; - * - * Add `.not` earlier in the chain to negate `.empty`. However, it's often - * best to assert that the target contains its expected number of values, - * rather than asserting that it's not empty. - * - * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended - * expect([1, 2, 3]).to.not.be.empty; // Not recommended - * - * expect(new Set([1, 2, 3])).to.have.property('size', 3); // Recommended - * expect(new Set([1, 2, 3])).to.not.be.empty; // Not recommended - * - * expect(Object.keys({a: 1})).to.have.lengthOf(1); // Recommended - * expect({a: 1}).to.not.be.empty; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect([1, 2, 3], 'nooo why fail??').to.be.empty; - * - * @name empty - * @namespace BDD - * @api public - */ - - Assertion.addProperty('empty', function () { - var val = flag(this, 'object') - , ssfi = flag(this, 'ssfi') - , flagMsg = flag(this, 'message') - , itemsCount; - - flagMsg = flagMsg ? flagMsg + ': ' : ''; - - switch (_.type(val).toLowerCase()) { - case 'array': - case 'string': - itemsCount = val.length; - break; - case 'map': - case 'set': - itemsCount = val.size; - break; - case 'weakmap': - case 'weakset': - throw new AssertionError( - flagMsg + '.empty was passed a weak collection', - undefined, - ssfi - ); - case 'function': - var msg = flagMsg + '.empty was passed a function ' + _.getName(val); - throw new AssertionError(msg.trim(), undefined, ssfi); - default: - if (val !== Object(val)) { - throw new AssertionError( - flagMsg + '.empty was passed non-string primitive ' + _.inspect(val), - undefined, - ssfi - ); - } - itemsCount = Object.keys(val).length; - } - - this.assert( - 0 === itemsCount - , 'expected #{this} to be empty' - , 'expected #{this} not to be empty' - ); - }); - - /** - * ### .arguments - * - * Asserts that the target is an `arguments` object. - * - * function test () { - * expect(arguments).to.be.arguments; - * } - * - * test(); - * - * Add `.not` earlier in the chain to negate `.arguments`. However, it's often - * best to assert which type the target is expected to be, rather than - * asserting that it’s not an `arguments` object. - * - * expect('foo').to.be.a('string'); // Recommended - * expect('foo').to.not.be.arguments; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect({}, 'nooo why fail??').to.be.arguments; - * - * The alias `.Arguments` can be used interchangeably with `.arguments`. - * - * @name arguments - * @alias Arguments - * @namespace BDD - * @api public - */ - - function checkArguments () { - var obj = flag(this, 'object') - , type = _.type(obj); - this.assert( - 'Arguments' === type - , 'expected #{this} to be arguments but got ' + type - , 'expected #{this} to not be arguments' - ); - } - - Assertion.addProperty('arguments', checkArguments); - Assertion.addProperty('Arguments', checkArguments); - - /** - * ### .equal(val[, msg]) - * - * Asserts that the target is strictly (`===`) equal to the given `val`. - * - * expect(1).to.equal(1); - * expect('foo').to.equal('foo'); - * - * Add `.deep` earlier in the chain to use deep equality instead. See the - * `deep-eql` project page for info on the deep equality algorithm: - * https://github.com/chaijs/deep-eql. - * - * // Target object deeply (but not strictly) equals `{a: 1}` - * expect({a: 1}).to.deep.equal({a: 1}); - * expect({a: 1}).to.not.equal({a: 1}); - * - * // Target array deeply (but not strictly) equals `[1, 2]` - * expect([1, 2]).to.deep.equal([1, 2]); - * expect([1, 2]).to.not.equal([1, 2]); - * - * Add `.not` earlier in the chain to negate `.equal`. However, it's often - * best to assert that the target is equal to its expected value, rather than - * not equal to one of countless unexpected values. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.equal(2); // Not recommended - * - * `.equal` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect(1).to.equal(2, 'nooo why fail??'); - * expect(1, 'nooo why fail??').to.equal(2); - * - * The aliases `.equals` and `eq` can be used interchangeably with `.equal`. - * - * @name equal - * @alias equals - * @alias eq - * @param {Mixed} val - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertEqual (val, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - if (flag(this, 'deep')) { - var prevLockSsfi = flag(this, 'lockSsfi'); - flag(this, 'lockSsfi', true); - this.eql(val); - flag(this, 'lockSsfi', prevLockSsfi); - } else { - this.assert( - val === obj - , 'expected #{this} to equal #{exp}' - , 'expected #{this} to not equal #{exp}' - , val - , this._obj - , true - ); - } - } - - Assertion.addMethod('equal', assertEqual); - Assertion.addMethod('equals', assertEqual); - Assertion.addMethod('eq', assertEqual); - - /** - * ### .eql(obj[, msg]) - * - * Asserts that the target is deeply equal to the given `obj`. See the - * `deep-eql` project page for info on the deep equality algorithm: - * https://github.com/chaijs/deep-eql. - * - * // Target object is deeply (but not strictly) equal to {a: 1} - * expect({a: 1}).to.eql({a: 1}).but.not.equal({a: 1}); - * - * // Target array is deeply (but not strictly) equal to [1, 2] - * expect([1, 2]).to.eql([1, 2]).but.not.equal([1, 2]); - * - * Add `.not` earlier in the chain to negate `.eql`. However, it's often best - * to assert that the target is deeply equal to its expected value, rather - * than not deeply equal to one of countless unexpected values. - * - * expect({a: 1}).to.eql({a: 1}); // Recommended - * expect({a: 1}).to.not.eql({b: 2}); // Not recommended - * - * `.eql` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect({a: 1}).to.eql({b: 2}, 'nooo why fail??'); - * expect({a: 1}, 'nooo why fail??').to.eql({b: 2}); - * - * The alias `.eqls` can be used interchangeably with `.eql`. - * - * The `.deep.equal` assertion is almost identical to `.eql` but with one - * difference: `.deep.equal` causes deep equality comparisons to also be used - * for any other assertions that follow in the chain. - * - * @name eql - * @alias eqls - * @param {Mixed} obj - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertEql(obj, msg) { - if (msg) flag(this, 'message', msg); - this.assert( - _.eql(obj, flag(this, 'object')) - , 'expected #{this} to deeply equal #{exp}' - , 'expected #{this} to not deeply equal #{exp}' - , obj - , this._obj - , true - ); - } - - Assertion.addMethod('eql', assertEql); - Assertion.addMethod('eqls', assertEql); - - /** - * ### .above(n[, msg]) - * - * Asserts that the target is a number or a date greater than the given number or date `n` respectively. - * However, it's often best to assert that the target is equal to its expected - * value. - * - * expect(2).to.equal(2); // Recommended - * expect(2).to.be.above(1); // Not recommended - * - * Add `.lengthOf` earlier in the chain to assert that the target's `length` - * or `size` is greater than the given number `n`. - * - * expect('foo').to.have.lengthOf(3); // Recommended - * expect('foo').to.have.lengthOf.above(2); // Not recommended - * - * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended - * expect([1, 2, 3]).to.have.lengthOf.above(2); // Not recommended - * - * Add `.not` earlier in the chain to negate `.above`. - * - * expect(2).to.equal(2); // Recommended - * expect(1).to.not.be.above(2); // Not recommended - * - * `.above` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect(1).to.be.above(2, 'nooo why fail??'); - * expect(1, 'nooo why fail??').to.be.above(2); - * - * The aliases `.gt` and `.greaterThan` can be used interchangeably with - * `.above`. - * - * @name above - * @alias gt - * @alias greaterThan - * @param {Number} n - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertAbove (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , doLength = flag(this, 'doLength') - , flagMsg = flag(this, 'message') - , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '') - , ssfi = flag(this, 'ssfi') - , objType = _.type(obj).toLowerCase() - , nType = _.type(n).toLowerCase() - , errorMessage - , shouldThrow = true; - - if (doLength && objType !== 'map' && objType !== 'set') { - new Assertion(obj, flagMsg, ssfi, true).to.have.property('length'); - } - - if (!doLength && (objType === 'date' && nType !== 'date')) { - errorMessage = msgPrefix + 'the argument to above must be a date'; - } else if (nType !== 'number' && (doLength || objType === 'number')) { - errorMessage = msgPrefix + 'the argument to above must be a number'; - } else if (!doLength && (objType !== 'date' && objType !== 'number')) { - var printObj = (objType === 'string') ? "'" + obj + "'" : obj; - errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date'; - } else { - shouldThrow = false; - } - - if (shouldThrow) { - throw new AssertionError(errorMessage, undefined, ssfi); - } - - if (doLength) { - var descriptor = 'length' - , itemsCount; - if (objType === 'map' || objType === 'set') { - descriptor = 'size'; - itemsCount = obj.size; - } else { - itemsCount = obj.length; - } - this.assert( - itemsCount > n - , 'expected #{this} to have a ' + descriptor + ' above #{exp} but got #{act}' - , 'expected #{this} to not have a ' + descriptor + ' above #{exp}' - , n - , itemsCount - ); - } else { - this.assert( - obj > n - , 'expected #{this} to be above #{exp}' - , 'expected #{this} to be at most #{exp}' - , n - ); - } - } - - Assertion.addMethod('above', assertAbove); - Assertion.addMethod('gt', assertAbove); - Assertion.addMethod('greaterThan', assertAbove); - - /** - * ### .least(n[, msg]) - * - * Asserts that the target is a number or a date greater than or equal to the given - * number or date `n` respectively. However, it's often best to assert that the target is equal to - * its expected value. - * - * expect(2).to.equal(2); // Recommended - * expect(2).to.be.at.least(1); // Not recommended - * expect(2).to.be.at.least(2); // Not recommended - * - * Add `.lengthOf` earlier in the chain to assert that the target's `length` - * or `size` is greater than or equal to the given number `n`. - * - * expect('foo').to.have.lengthOf(3); // Recommended - * expect('foo').to.have.lengthOf.at.least(2); // Not recommended - * - * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended - * expect([1, 2, 3]).to.have.lengthOf.at.least(2); // Not recommended - * - * Add `.not` earlier in the chain to negate `.least`. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.at.least(2); // Not recommended - * - * `.least` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect(1).to.be.at.least(2, 'nooo why fail??'); - * expect(1, 'nooo why fail??').to.be.at.least(2); - * - * The aliases `.gte` and `.greaterThanOrEqual` can be used interchangeably with - * `.least`. - * - * @name least - * @alias gte - * @alias greaterThanOrEqual - * @param {Number} n - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertLeast (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , doLength = flag(this, 'doLength') - , flagMsg = flag(this, 'message') - , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '') - , ssfi = flag(this, 'ssfi') - , objType = _.type(obj).toLowerCase() - , nType = _.type(n).toLowerCase() - , errorMessage - , shouldThrow = true; - - if (doLength && objType !== 'map' && objType !== 'set') { - new Assertion(obj, flagMsg, ssfi, true).to.have.property('length'); - } - - if (!doLength && (objType === 'date' && nType !== 'date')) { - errorMessage = msgPrefix + 'the argument to least must be a date'; - } else if (nType !== 'number' && (doLength || objType === 'number')) { - errorMessage = msgPrefix + 'the argument to least must be a number'; - } else if (!doLength && (objType !== 'date' && objType !== 'number')) { - var printObj = (objType === 'string') ? "'" + obj + "'" : obj; - errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date'; - } else { - shouldThrow = false; - } - - if (shouldThrow) { - throw new AssertionError(errorMessage, undefined, ssfi); - } - - if (doLength) { - var descriptor = 'length' - , itemsCount; - if (objType === 'map' || objType === 'set') { - descriptor = 'size'; - itemsCount = obj.size; - } else { - itemsCount = obj.length; - } - this.assert( - itemsCount >= n - , 'expected #{this} to have a ' + descriptor + ' at least #{exp} but got #{act}' - , 'expected #{this} to have a ' + descriptor + ' below #{exp}' - , n - , itemsCount - ); - } else { - this.assert( - obj >= n - , 'expected #{this} to be at least #{exp}' - , 'expected #{this} to be below #{exp}' - , n - ); - } - } - - Assertion.addMethod('least', assertLeast); - Assertion.addMethod('gte', assertLeast); - Assertion.addMethod('greaterThanOrEqual', assertLeast); - - /** - * ### .below(n[, msg]) - * - * Asserts that the target is a number or a date less than the given number or date `n` respectively. - * However, it's often best to assert that the target is equal to its expected - * value. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.be.below(2); // Not recommended - * - * Add `.lengthOf` earlier in the chain to assert that the target's `length` - * or `size` is less than the given number `n`. - * - * expect('foo').to.have.lengthOf(3); // Recommended - * expect('foo').to.have.lengthOf.below(4); // Not recommended - * - * expect([1, 2, 3]).to.have.length(3); // Recommended - * expect([1, 2, 3]).to.have.lengthOf.below(4); // Not recommended - * - * Add `.not` earlier in the chain to negate `.below`. - * - * expect(2).to.equal(2); // Recommended - * expect(2).to.not.be.below(1); // Not recommended - * - * `.below` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect(2).to.be.below(1, 'nooo why fail??'); - * expect(2, 'nooo why fail??').to.be.below(1); - * - * The aliases `.lt` and `.lessThan` can be used interchangeably with - * `.below`. - * - * @name below - * @alias lt - * @alias lessThan - * @param {Number} n - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertBelow (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , doLength = flag(this, 'doLength') - , flagMsg = flag(this, 'message') - , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '') - , ssfi = flag(this, 'ssfi') - , objType = _.type(obj).toLowerCase() - , nType = _.type(n).toLowerCase() - , errorMessage - , shouldThrow = true; - - if (doLength && objType !== 'map' && objType !== 'set') { - new Assertion(obj, flagMsg, ssfi, true).to.have.property('length'); - } - - if (!doLength && (objType === 'date' && nType !== 'date')) { - errorMessage = msgPrefix + 'the argument to below must be a date'; - } else if (nType !== 'number' && (doLength || objType === 'number')) { - errorMessage = msgPrefix + 'the argument to below must be a number'; - } else if (!doLength && (objType !== 'date' && objType !== 'number')) { - var printObj = (objType === 'string') ? "'" + obj + "'" : obj; - errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date'; - } else { - shouldThrow = false; - } - - if (shouldThrow) { - throw new AssertionError(errorMessage, undefined, ssfi); - } - - if (doLength) { - var descriptor = 'length' - , itemsCount; - if (objType === 'map' || objType === 'set') { - descriptor = 'size'; - itemsCount = obj.size; - } else { - itemsCount = obj.length; - } - this.assert( - itemsCount < n - , 'expected #{this} to have a ' + descriptor + ' below #{exp} but got #{act}' - , 'expected #{this} to not have a ' + descriptor + ' below #{exp}' - , n - , itemsCount - ); - } else { - this.assert( - obj < n - , 'expected #{this} to be below #{exp}' - , 'expected #{this} to be at least #{exp}' - , n - ); - } - } - - Assertion.addMethod('below', assertBelow); - Assertion.addMethod('lt', assertBelow); - Assertion.addMethod('lessThan', assertBelow); - - /** - * ### .most(n[, msg]) - * - * Asserts that the target is a number or a date less than or equal to the given number - * or date `n` respectively. However, it's often best to assert that the target is equal to its - * expected value. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.be.at.most(2); // Not recommended - * expect(1).to.be.at.most(1); // Not recommended - * - * Add `.lengthOf` earlier in the chain to assert that the target's `length` - * or `size` is less than or equal to the given number `n`. - * - * expect('foo').to.have.lengthOf(3); // Recommended - * expect('foo').to.have.lengthOf.at.most(4); // Not recommended - * - * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended - * expect([1, 2, 3]).to.have.lengthOf.at.most(4); // Not recommended - * - * Add `.not` earlier in the chain to negate `.most`. - * - * expect(2).to.equal(2); // Recommended - * expect(2).to.not.be.at.most(1); // Not recommended - * - * `.most` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect(2).to.be.at.most(1, 'nooo why fail??'); - * expect(2, 'nooo why fail??').to.be.at.most(1); - * - * The aliases `.lte` and `.lessThanOrEqual` can be used interchangeably with - * `.most`. - * - * @name most - * @alias lte - * @alias lessThanOrEqual - * @param {Number} n - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertMost (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , doLength = flag(this, 'doLength') - , flagMsg = flag(this, 'message') - , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '') - , ssfi = flag(this, 'ssfi') - , objType = _.type(obj).toLowerCase() - , nType = _.type(n).toLowerCase() - , errorMessage - , shouldThrow = true; - - if (doLength && objType !== 'map' && objType !== 'set') { - new Assertion(obj, flagMsg, ssfi, true).to.have.property('length'); - } - - if (!doLength && (objType === 'date' && nType !== 'date')) { - errorMessage = msgPrefix + 'the argument to most must be a date'; - } else if (nType !== 'number' && (doLength || objType === 'number')) { - errorMessage = msgPrefix + 'the argument to most must be a number'; - } else if (!doLength && (objType !== 'date' && objType !== 'number')) { - var printObj = (objType === 'string') ? "'" + obj + "'" : obj; - errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date'; - } else { - shouldThrow = false; - } - - if (shouldThrow) { - throw new AssertionError(errorMessage, undefined, ssfi); - } - - if (doLength) { - var descriptor = 'length' - , itemsCount; - if (objType === 'map' || objType === 'set') { - descriptor = 'size'; - itemsCount = obj.size; - } else { - itemsCount = obj.length; - } - this.assert( - itemsCount <= n - , 'expected #{this} to have a ' + descriptor + ' at most #{exp} but got #{act}' - , 'expected #{this} to have a ' + descriptor + ' above #{exp}' - , n - , itemsCount - ); - } else { - this.assert( - obj <= n - , 'expected #{this} to be at most #{exp}' - , 'expected #{this} to be above #{exp}' - , n - ); - } - } - - Assertion.addMethod('most', assertMost); - Assertion.addMethod('lte', assertMost); - Assertion.addMethod('lessThanOrEqual', assertMost); - - /** - * ### .within(start, finish[, msg]) - * - * Asserts that the target is a number or a date greater than or equal to the given - * number or date `start`, and less than or equal to the given number or date `finish` respectively. - * However, it's often best to assert that the target is equal to its expected - * value. - * - * expect(2).to.equal(2); // Recommended - * expect(2).to.be.within(1, 3); // Not recommended - * expect(2).to.be.within(2, 3); // Not recommended - * expect(2).to.be.within(1, 2); // Not recommended - * - * Add `.lengthOf` earlier in the chain to assert that the target's `length` - * or `size` is greater than or equal to the given number `start`, and less - * than or equal to the given number `finish`. - * - * expect('foo').to.have.lengthOf(3); // Recommended - * expect('foo').to.have.lengthOf.within(2, 4); // Not recommended - * - * expect([1, 2, 3]).to.have.lengthOf(3); // Recommended - * expect([1, 2, 3]).to.have.lengthOf.within(2, 4); // Not recommended - * - * Add `.not` earlier in the chain to negate `.within`. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.within(2, 4); // Not recommended - * - * `.within` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect(4).to.be.within(1, 3, 'nooo why fail??'); - * expect(4, 'nooo why fail??').to.be.within(1, 3); - * - * @name within - * @param {Number} start lower bound inclusive - * @param {Number} finish upper bound inclusive - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - Assertion.addMethod('within', function (start, finish, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , doLength = flag(this, 'doLength') - , flagMsg = flag(this, 'message') - , msgPrefix = ((flagMsg) ? flagMsg + ': ' : '') - , ssfi = flag(this, 'ssfi') - , objType = _.type(obj).toLowerCase() - , startType = _.type(start).toLowerCase() - , finishType = _.type(finish).toLowerCase() - , errorMessage - , shouldThrow = true - , range = (startType === 'date' && finishType === 'date') - ? start.toISOString() + '..' + finish.toISOString() - : start + '..' + finish; - - if (doLength && objType !== 'map' && objType !== 'set') { - new Assertion(obj, flagMsg, ssfi, true).to.have.property('length'); - } - - if (!doLength && (objType === 'date' && (startType !== 'date' || finishType !== 'date'))) { - errorMessage = msgPrefix + 'the arguments to within must be dates'; - } else if ((startType !== 'number' || finishType !== 'number') && (doLength || objType === 'number')) { - errorMessage = msgPrefix + 'the arguments to within must be numbers'; - } else if (!doLength && (objType !== 'date' && objType !== 'number')) { - var printObj = (objType === 'string') ? "'" + obj + "'" : obj; - errorMessage = msgPrefix + 'expected ' + printObj + ' to be a number or a date'; - } else { - shouldThrow = false; - } - - if (shouldThrow) { - throw new AssertionError(errorMessage, undefined, ssfi); - } - - if (doLength) { - var descriptor = 'length' - , itemsCount; - if (objType === 'map' || objType === 'set') { - descriptor = 'size'; - itemsCount = obj.size; - } else { - itemsCount = obj.length; - } - this.assert( - itemsCount >= start && itemsCount <= finish - , 'expected #{this} to have a ' + descriptor + ' within ' + range - , 'expected #{this} to not have a ' + descriptor + ' within ' + range - ); - } else { - this.assert( - obj >= start && obj <= finish - , 'expected #{this} to be within ' + range - , 'expected #{this} to not be within ' + range - ); - } - }); - - /** - * ### .instanceof(constructor[, msg]) - * - * Asserts that the target is an instance of the given `constructor`. - * - * function Cat () { } - * - * expect(new Cat()).to.be.an.instanceof(Cat); - * expect([1, 2]).to.be.an.instanceof(Array); - * - * Add `.not` earlier in the chain to negate `.instanceof`. - * - * expect({a: 1}).to.not.be.an.instanceof(Array); - * - * `.instanceof` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect(1).to.be.an.instanceof(Array, 'nooo why fail??'); - * expect(1, 'nooo why fail??').to.be.an.instanceof(Array); - * - * Due to limitations in ES5, `.instanceof` may not always work as expected - * when using a transpiler such as Babel or TypeScript. In particular, it may - * produce unexpected results when subclassing built-in object such as - * `Array`, `Error`, and `Map`. See your transpiler's docs for details: - * - * - ([Babel](https://babeljs.io/docs/usage/caveats/#classes)) - * - ([TypeScript](https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work)) - * - * The alias `.instanceOf` can be used interchangeably with `.instanceof`. - * - * @name instanceof - * @param {Constructor} constructor - * @param {String} msg _optional_ - * @alias instanceOf - * @namespace BDD - * @api public - */ - - function assertInstanceOf (constructor, msg) { - if (msg) flag(this, 'message', msg); - - var target = flag(this, 'object') - var ssfi = flag(this, 'ssfi'); - var flagMsg = flag(this, 'message'); - - try { - var isInstanceOf = target instanceof constructor; - } catch (err) { - if (err instanceof TypeError) { - flagMsg = flagMsg ? flagMsg + ': ' : ''; - throw new AssertionError( - flagMsg + 'The instanceof assertion needs a constructor but ' - + _.type(constructor) + ' was given.', - undefined, - ssfi - ); - } - throw err; - } - - var name = _.getName(constructor); - if (name === null) { - name = 'an unnamed constructor'; - } - - this.assert( - isInstanceOf - , 'expected #{this} to be an instance of ' + name - , 'expected #{this} to not be an instance of ' + name - ); - }; - - Assertion.addMethod('instanceof', assertInstanceOf); - Assertion.addMethod('instanceOf', assertInstanceOf); - - /** - * ### .property(name[, val[, msg]]) - * - * Asserts that the target has a property with the given key `name`. - * - * expect({a: 1}).to.have.property('a'); - * - * When `val` is provided, `.property` also asserts that the property's value - * is equal to the given `val`. - * - * expect({a: 1}).to.have.property('a', 1); - * - * By default, strict (`===`) equality is used. Add `.deep` earlier in the - * chain to use deep equality instead. See the `deep-eql` project page for - * info on the deep equality algorithm: https://github.com/chaijs/deep-eql. - * - * // Target object deeply (but not strictly) has property `x: {a: 1}` - * expect({x: {a: 1}}).to.have.deep.property('x', {a: 1}); - * expect({x: {a: 1}}).to.not.have.property('x', {a: 1}); - * - * The target's enumerable and non-enumerable properties are always included - * in the search. By default, both own and inherited properties are included. - * Add `.own` earlier in the chain to exclude inherited properties from the - * search. - * - * Object.prototype.b = 2; - * - * expect({a: 1}).to.have.own.property('a'); - * expect({a: 1}).to.have.own.property('a', 1); - * expect({a: 1}).to.have.property('b'); - * expect({a: 1}).to.not.have.own.property('b'); - * - * `.deep` and `.own` can be combined. - * - * expect({x: {a: 1}}).to.have.deep.own.property('x', {a: 1}); - * - * Add `.nested` earlier in the chain to enable dot- and bracket-notation when - * referencing nested properties. - * - * expect({a: {b: ['x', 'y']}}).to.have.nested.property('a.b[1]'); - * expect({a: {b: ['x', 'y']}}).to.have.nested.property('a.b[1]', 'y'); - * - * If `.` or `[]` are part of an actual property name, they can be escaped by - * adding two backslashes before them. - * - * expect({'.a': {'[b]': 'x'}}).to.have.nested.property('\\.a.\\[b\\]'); - * - * `.deep` and `.nested` can be combined. - * - * expect({a: {b: [{c: 3}]}}) - * .to.have.deep.nested.property('a.b[0]', {c: 3}); - * - * `.own` and `.nested` cannot be combined. - * - * Add `.not` earlier in the chain to negate `.property`. - * - * expect({a: 1}).to.not.have.property('b'); - * - * However, it's dangerous to negate `.property` when providing `val`. The - * problem is that it creates uncertain expectations by asserting that the - * target either doesn't have a property with the given key `name`, or that it - * does have a property with the given key `name` but its value isn't equal to - * the given `val`. It's often best to identify the exact output that's - * expected, and then write an assertion that only accepts that exact output. - * - * When the target isn't expected to have a property with the given key - * `name`, it's often best to assert exactly that. - * - * expect({b: 2}).to.not.have.property('a'); // Recommended - * expect({b: 2}).to.not.have.property('a', 1); // Not recommended - * - * When the target is expected to have a property with the given key `name`, - * it's often best to assert that the property has its expected value, rather - * than asserting that it doesn't have one of many unexpected values. - * - * expect({a: 3}).to.have.property('a', 3); // Recommended - * expect({a: 3}).to.not.have.property('a', 1); // Not recommended - * - * `.property` changes the target of any assertions that follow in the chain - * to be the value of the property from the original target object. - * - * expect({a: 1}).to.have.property('a').that.is.a('number'); - * - * `.property` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. When not providing `val`, only use the - * second form. - * - * // Recommended - * expect({a: 1}).to.have.property('a', 2, 'nooo why fail??'); - * expect({a: 1}, 'nooo why fail??').to.have.property('a', 2); - * expect({a: 1}, 'nooo why fail??').to.have.property('b'); - * - * // Not recommended - * expect({a: 1}).to.have.property('b', undefined, 'nooo why fail??'); - * - * The above assertion isn't the same thing as not providing `val`. Instead, - * it's asserting that the target object has a `b` property that's equal to - * `undefined`. - * - * The assertions `.ownProperty` and `.haveOwnProperty` can be used - * interchangeably with `.own.property`. - * - * @name property - * @param {String} name - * @param {Mixed} val (optional) - * @param {String} msg _optional_ - * @returns value of property for chaining - * @namespace BDD - * @api public - */ - - function assertProperty (name, val, msg) { - if (msg) flag(this, 'message', msg); - - var isNested = flag(this, 'nested') - , isOwn = flag(this, 'own') - , flagMsg = flag(this, 'message') - , obj = flag(this, 'object') - , ssfi = flag(this, 'ssfi') - , nameType = typeof name; - - flagMsg = flagMsg ? flagMsg + ': ' : ''; - - if (isNested) { - if (nameType !== 'string') { - throw new AssertionError( - flagMsg + 'the argument to property must be a string when using nested syntax', - undefined, - ssfi - ); - } - } else { - if (nameType !== 'string' && nameType !== 'number' && nameType !== 'symbol') { - throw new AssertionError( - flagMsg + 'the argument to property must be a string, number, or symbol', - undefined, - ssfi - ); - } - } - - if (isNested && isOwn) { - throw new AssertionError( - flagMsg + 'The "nested" and "own" flags cannot be combined.', - undefined, - ssfi - ); - } - - if (obj === null || obj === undefined) { - throw new AssertionError( - flagMsg + 'Target cannot be null or undefined.', - undefined, - ssfi - ); - } - - var isDeep = flag(this, 'deep') - , negate = flag(this, 'negate') - , pathInfo = isNested ? _.getPathInfo(obj, name) : null - , value = isNested ? pathInfo.value : obj[name]; - - var descriptor = ''; - if (isDeep) descriptor += 'deep '; - if (isOwn) descriptor += 'own '; - if (isNested) descriptor += 'nested '; - descriptor += 'property '; - - var hasProperty; - if (isOwn) hasProperty = Object.prototype.hasOwnProperty.call(obj, name); - else if (isNested) hasProperty = pathInfo.exists; - else hasProperty = _.hasProperty(obj, name); - - // When performing a negated assertion for both name and val, merely having - // a property with the given name isn't enough to cause the assertion to - // fail. It must both have a property with the given name, and the value of - // that property must equal the given val. Therefore, skip this assertion in - // favor of the next. - if (!negate || arguments.length === 1) { - this.assert( - hasProperty - , 'expected #{this} to have ' + descriptor + _.inspect(name) - , 'expected #{this} to not have ' + descriptor + _.inspect(name)); - } - - if (arguments.length > 1) { - this.assert( - hasProperty && (isDeep ? _.eql(val, value) : val === value) - , 'expected #{this} to have ' + descriptor + _.inspect(name) + ' of #{exp}, but got #{act}' - , 'expected #{this} to not have ' + descriptor + _.inspect(name) + ' of #{act}' - , val - , value - ); - } - - flag(this, 'object', value); - } - - Assertion.addMethod('property', assertProperty); - - function assertOwnProperty (name, value, msg) { - flag(this, 'own', true); - assertProperty.apply(this, arguments); - } - - Assertion.addMethod('ownProperty', assertOwnProperty); - Assertion.addMethod('haveOwnProperty', assertOwnProperty); - - /** - * ### .ownPropertyDescriptor(name[, descriptor[, msg]]) - * - * Asserts that the target has its own property descriptor with the given key - * `name`. Enumerable and non-enumerable properties are included in the - * search. - * - * expect({a: 1}).to.have.ownPropertyDescriptor('a'); - * - * When `descriptor` is provided, `.ownPropertyDescriptor` also asserts that - * the property's descriptor is deeply equal to the given `descriptor`. See - * the `deep-eql` project page for info on the deep equality algorithm: - * https://github.com/chaijs/deep-eql. - * - * expect({a: 1}).to.have.ownPropertyDescriptor('a', { - * configurable: true, - * enumerable: true, - * writable: true, - * value: 1, - * }); - * - * Add `.not` earlier in the chain to negate `.ownPropertyDescriptor`. - * - * expect({a: 1}).to.not.have.ownPropertyDescriptor('b'); - * - * However, it's dangerous to negate `.ownPropertyDescriptor` when providing - * a `descriptor`. The problem is that it creates uncertain expectations by - * asserting that the target either doesn't have a property descriptor with - * the given key `name`, or that it does have a property descriptor with the - * given key `name` but it’s not deeply equal to the given `descriptor`. It's - * often best to identify the exact output that's expected, and then write an - * assertion that only accepts that exact output. - * - * When the target isn't expected to have a property descriptor with the given - * key `name`, it's often best to assert exactly that. - * - * // Recommended - * expect({b: 2}).to.not.have.ownPropertyDescriptor('a'); - * - * // Not recommended - * expect({b: 2}).to.not.have.ownPropertyDescriptor('a', { - * configurable: true, - * enumerable: true, - * writable: true, - * value: 1, - * }); - * - * When the target is expected to have a property descriptor with the given - * key `name`, it's often best to assert that the property has its expected - * descriptor, rather than asserting that it doesn't have one of many - * unexpected descriptors. - * - * // Recommended - * expect({a: 3}).to.have.ownPropertyDescriptor('a', { - * configurable: true, - * enumerable: true, - * writable: true, - * value: 3, - * }); - * - * // Not recommended - * expect({a: 3}).to.not.have.ownPropertyDescriptor('a', { - * configurable: true, - * enumerable: true, - * writable: true, - * value: 1, - * }); - * - * `.ownPropertyDescriptor` changes the target of any assertions that follow - * in the chain to be the value of the property descriptor from the original - * target object. - * - * expect({a: 1}).to.have.ownPropertyDescriptor('a') - * .that.has.property('enumerable', true); - * - * `.ownPropertyDescriptor` accepts an optional `msg` argument which is a - * custom error message to show when the assertion fails. The message can also - * be given as the second argument to `expect`. When not providing - * `descriptor`, only use the second form. - * - * // Recommended - * expect({a: 1}).to.have.ownPropertyDescriptor('a', { - * configurable: true, - * enumerable: true, - * writable: true, - * value: 2, - * }, 'nooo why fail??'); - * - * // Recommended - * expect({a: 1}, 'nooo why fail??').to.have.ownPropertyDescriptor('a', { - * configurable: true, - * enumerable: true, - * writable: true, - * value: 2, - * }); - * - * // Recommended - * expect({a: 1}, 'nooo why fail??').to.have.ownPropertyDescriptor('b'); - * - * // Not recommended - * expect({a: 1}) - * .to.have.ownPropertyDescriptor('b', undefined, 'nooo why fail??'); - * - * The above assertion isn't the same thing as not providing `descriptor`. - * Instead, it's asserting that the target object has a `b` property - * descriptor that's deeply equal to `undefined`. - * - * The alias `.haveOwnPropertyDescriptor` can be used interchangeably with - * `.ownPropertyDescriptor`. - * - * @name ownPropertyDescriptor - * @alias haveOwnPropertyDescriptor - * @param {String} name - * @param {Object} descriptor _optional_ - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertOwnPropertyDescriptor (name, descriptor, msg) { - if (typeof descriptor === 'string') { - msg = descriptor; - descriptor = null; - } - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - var actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name); - if (actualDescriptor && descriptor) { - this.assert( - _.eql(descriptor, actualDescriptor) - , 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to match ' + _.inspect(descriptor) + ', got ' + _.inspect(actualDescriptor) - , 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to not match ' + _.inspect(descriptor) - , descriptor - , actualDescriptor - , true - ); - } else { - this.assert( - actualDescriptor - , 'expected #{this} to have an own property descriptor for ' + _.inspect(name) - , 'expected #{this} to not have an own property descriptor for ' + _.inspect(name) - ); - } - flag(this, 'object', actualDescriptor); - } - - Assertion.addMethod('ownPropertyDescriptor', assertOwnPropertyDescriptor); - Assertion.addMethod('haveOwnPropertyDescriptor', assertOwnPropertyDescriptor); - - /** - * ### .lengthOf(n[, msg]) - * - * Asserts that the target's `length` or `size` is equal to the given number - * `n`. - * - * expect([1, 2, 3]).to.have.lengthOf(3); - * expect('foo').to.have.lengthOf(3); - * expect(new Set([1, 2, 3])).to.have.lengthOf(3); - * expect(new Map([['a', 1], ['b', 2], ['c', 3]])).to.have.lengthOf(3); - * - * Add `.not` earlier in the chain to negate `.lengthOf`. However, it's often - * best to assert that the target's `length` property is equal to its expected - * value, rather than not equal to one of many unexpected values. - * - * expect('foo').to.have.lengthOf(3); // Recommended - * expect('foo').to.not.have.lengthOf(4); // Not recommended - * - * `.lengthOf` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect([1, 2, 3]).to.have.lengthOf(2, 'nooo why fail??'); - * expect([1, 2, 3], 'nooo why fail??').to.have.lengthOf(2); - * - * `.lengthOf` can also be used as a language chain, causing all `.above`, - * `.below`, `.least`, `.most`, and `.within` assertions that follow in the - * chain to use the target's `length` property as the target. However, it's - * often best to assert that the target's `length` property is equal to its - * expected length, rather than asserting that its `length` property falls - * within some range of values. - * - * // Recommended - * expect([1, 2, 3]).to.have.lengthOf(3); - * - * // Not recommended - * expect([1, 2, 3]).to.have.lengthOf.above(2); - * expect([1, 2, 3]).to.have.lengthOf.below(4); - * expect([1, 2, 3]).to.have.lengthOf.at.least(3); - * expect([1, 2, 3]).to.have.lengthOf.at.most(3); - * expect([1, 2, 3]).to.have.lengthOf.within(2,4); - * - * Due to a compatibility issue, the alias `.length` can't be chained directly - * off of an uninvoked method such as `.a`. Therefore, `.length` can't be used - * interchangeably with `.lengthOf` in every situation. It's recommended to - * always use `.lengthOf` instead of `.length`. - * - * expect([1, 2, 3]).to.have.a.length(3); // incompatible; throws error - * expect([1, 2, 3]).to.have.a.lengthOf(3); // passes as expected - * - * @name lengthOf - * @alias length - * @param {Number} n - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertLengthChain () { - flag(this, 'doLength', true); - } - - function assertLength (n, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , objType = _.type(obj).toLowerCase() - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi') - , descriptor = 'length' - , itemsCount; - - switch (objType) { - case 'map': - case 'set': - descriptor = 'size'; - itemsCount = obj.size; - break; - default: - new Assertion(obj, flagMsg, ssfi, true).to.have.property('length'); - itemsCount = obj.length; - } - - this.assert( - itemsCount == n - , 'expected #{this} to have a ' + descriptor + ' of #{exp} but got #{act}' - , 'expected #{this} to not have a ' + descriptor + ' of #{act}' - , n - , itemsCount - ); - } - - Assertion.addChainableMethod('length', assertLength, assertLengthChain); - Assertion.addChainableMethod('lengthOf', assertLength, assertLengthChain); - - /** - * ### .match(re[, msg]) - * - * Asserts that the target matches the given regular expression `re`. - * - * expect('foobar').to.match(/^foo/); - * - * Add `.not` earlier in the chain to negate `.match`. - * - * expect('foobar').to.not.match(/taco/); - * - * `.match` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect('foobar').to.match(/taco/, 'nooo why fail??'); - * expect('foobar', 'nooo why fail??').to.match(/taco/); - * - * The alias `.matches` can be used interchangeably with `.match`. - * - * @name match - * @alias matches - * @param {RegExp} re - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - function assertMatch(re, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - this.assert( - re.exec(obj) - , 'expected #{this} to match ' + re - , 'expected #{this} not to match ' + re - ); - } - - Assertion.addMethod('match', assertMatch); - Assertion.addMethod('matches', assertMatch); - - /** - * ### .string(str[, msg]) - * - * Asserts that the target string contains the given substring `str`. - * - * expect('foobar').to.have.string('bar'); - * - * Add `.not` earlier in the chain to negate `.string`. - * - * expect('foobar').to.not.have.string('taco'); - * - * `.string` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect('foobar').to.have.string('taco', 'nooo why fail??'); - * expect('foobar', 'nooo why fail??').to.have.string('taco'); - * - * @name string - * @param {String} str - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - Assertion.addMethod('string', function (str, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi'); - new Assertion(obj, flagMsg, ssfi, true).is.a('string'); - - this.assert( - ~obj.indexOf(str) - , 'expected #{this} to contain ' + _.inspect(str) - , 'expected #{this} to not contain ' + _.inspect(str) - ); - }); - - /** - * ### .keys(key1[, key2[, ...]]) - * - * Asserts that the target object, array, map, or set has the given keys. Only - * the target's own inherited properties are included in the search. - * - * When the target is an object or array, keys can be provided as one or more - * string arguments, a single array argument, or a single object argument. In - * the latter case, only the keys in the given object matter; the values are - * ignored. - * - * expect({a: 1, b: 2}).to.have.all.keys('a', 'b'); - * expect(['x', 'y']).to.have.all.keys(0, 1); - * - * expect({a: 1, b: 2}).to.have.all.keys(['a', 'b']); - * expect(['x', 'y']).to.have.all.keys([0, 1]); - * - * expect({a: 1, b: 2}).to.have.all.keys({a: 4, b: 5}); // ignore 4 and 5 - * expect(['x', 'y']).to.have.all.keys({0: 4, 1: 5}); // ignore 4 and 5 - * - * When the target is a map or set, each key must be provided as a separate - * argument. - * - * expect(new Map([['a', 1], ['b', 2]])).to.have.all.keys('a', 'b'); - * expect(new Set(['a', 'b'])).to.have.all.keys('a', 'b'); - * - * Because `.keys` does different things based on the target's type, it's - * important to check the target's type before using `.keys`. See the `.a` doc - * for info on testing a target's type. - * - * expect({a: 1, b: 2}).to.be.an('object').that.has.all.keys('a', 'b'); - * - * By default, strict (`===`) equality is used to compare keys of maps and - * sets. Add `.deep` earlier in the chain to use deep equality instead. See - * the `deep-eql` project page for info on the deep equality algorithm: - * https://github.com/chaijs/deep-eql. - * - * // Target set deeply (but not strictly) has key `{a: 1}` - * expect(new Set([{a: 1}])).to.have.all.deep.keys([{a: 1}]); - * expect(new Set([{a: 1}])).to.not.have.all.keys([{a: 1}]); - * - * By default, the target must have all of the given keys and no more. Add - * `.any` earlier in the chain to only require that the target have at least - * one of the given keys. Also, add `.not` earlier in the chain to negate - * `.keys`. It's often best to add `.any` when negating `.keys`, and to use - * `.all` when asserting `.keys` without negation. - * - * When negating `.keys`, `.any` is preferred because `.not.any.keys` asserts - * exactly what's expected of the output, whereas `.not.all.keys` creates - * uncertain expectations. - * - * // Recommended; asserts that target doesn't have any of the given keys - * expect({a: 1, b: 2}).to.not.have.any.keys('c', 'd'); - * - * // Not recommended; asserts that target doesn't have all of the given - * // keys but may or may not have some of them - * expect({a: 1, b: 2}).to.not.have.all.keys('c', 'd'); - * - * When asserting `.keys` without negation, `.all` is preferred because - * `.all.keys` asserts exactly what's expected of the output, whereas - * `.any.keys` creates uncertain expectations. - * - * // Recommended; asserts that target has all the given keys - * expect({a: 1, b: 2}).to.have.all.keys('a', 'b'); - * - * // Not recommended; asserts that target has at least one of the given - * // keys but may or may not have more of them - * expect({a: 1, b: 2}).to.have.any.keys('a', 'b'); - * - * Note that `.all` is used by default when neither `.all` nor `.any` appear - * earlier in the chain. However, it's often best to add `.all` anyway because - * it improves readability. - * - * // Both assertions are identical - * expect({a: 1, b: 2}).to.have.all.keys('a', 'b'); // Recommended - * expect({a: 1, b: 2}).to.have.keys('a', 'b'); // Not recommended - * - * Add `.include` earlier in the chain to require that the target's keys be a - * superset of the expected keys, rather than identical sets. - * - * // Target object's keys are a superset of ['a', 'b'] but not identical - * expect({a: 1, b: 2, c: 3}).to.include.all.keys('a', 'b'); - * expect({a: 1, b: 2, c: 3}).to.not.have.all.keys('a', 'b'); - * - * However, if `.any` and `.include` are combined, only the `.any` takes - * effect. The `.include` is ignored in this case. - * - * // Both assertions are identical - * expect({a: 1}).to.have.any.keys('a', 'b'); - * expect({a: 1}).to.include.any.keys('a', 'b'); - * - * A custom error message can be given as the second argument to `expect`. - * - * expect({a: 1}, 'nooo why fail??').to.have.key('b'); - * - * The alias `.key` can be used interchangeably with `.keys`. - * - * @name keys - * @alias key - * @param {...String|Array|Object} keys - * @namespace BDD - * @api public - */ - - function assertKeys (keys) { - var obj = flag(this, 'object') - , objType = _.type(obj) - , keysType = _.type(keys) - , ssfi = flag(this, 'ssfi') - , isDeep = flag(this, 'deep') - , str - , deepStr = '' - , actual - , ok = true - , flagMsg = flag(this, 'message'); - - flagMsg = flagMsg ? flagMsg + ': ' : ''; - var mixedArgsMsg = flagMsg + 'when testing keys against an object or an array you must give a single Array|Object|String argument or multiple String arguments'; - - if (objType === 'Map' || objType === 'Set') { - deepStr = isDeep ? 'deeply ' : ''; - actual = []; - - // Map and Set '.keys' aren't supported in IE 11. Therefore, use .forEach. - obj.forEach(function (val, key) { actual.push(key) }); - - if (keysType !== 'Array') { - keys = Array.prototype.slice.call(arguments); - } - } else { - actual = _.getOwnEnumerableProperties(obj); - - switch (keysType) { - case 'Array': - if (arguments.length > 1) { - throw new AssertionError(mixedArgsMsg, undefined, ssfi); - } - break; - case 'Object': - if (arguments.length > 1) { - throw new AssertionError(mixedArgsMsg, undefined, ssfi); - } - keys = Object.keys(keys); - break; - default: - keys = Array.prototype.slice.call(arguments); - } - - // Only stringify non-Symbols because Symbols would become "Symbol()" - keys = keys.map(function (val) { - return typeof val === 'symbol' ? val : String(val); - }); - } - - if (!keys.length) { - throw new AssertionError(flagMsg + 'keys required', undefined, ssfi); - } - - var len = keys.length - , any = flag(this, 'any') - , all = flag(this, 'all') - , expected = keys; - - if (!any && !all) { - all = true; - } - - // Has any - if (any) { - ok = expected.some(function(expectedKey) { - return actual.some(function(actualKey) { - if (isDeep) { - return _.eql(expectedKey, actualKey); - } else { - return expectedKey === actualKey; - } - }); - }); - } - - // Has all - if (all) { - ok = expected.every(function(expectedKey) { - return actual.some(function(actualKey) { - if (isDeep) { - return _.eql(expectedKey, actualKey); - } else { - return expectedKey === actualKey; - } - }); - }); - - if (!flag(this, 'contains')) { - ok = ok && keys.length == actual.length; - } - } - - // Key string - if (len > 1) { - keys = keys.map(function(key) { - return _.inspect(key); - }); - var last = keys.pop(); - if (all) { - str = keys.join(', ') + ', and ' + last; - } - if (any) { - str = keys.join(', ') + ', or ' + last; - } - } else { - str = _.inspect(keys[0]); - } - - // Form - str = (len > 1 ? 'keys ' : 'key ') + str; - - // Have / include - str = (flag(this, 'contains') ? 'contain ' : 'have ') + str; - - // Assertion - this.assert( - ok - , 'expected #{this} to ' + deepStr + str - , 'expected #{this} to not ' + deepStr + str - , expected.slice(0).sort(_.compareByInspect) - , actual.sort(_.compareByInspect) - , true - ); - } - - Assertion.addMethod('keys', assertKeys); - Assertion.addMethod('key', assertKeys); - - /** - * ### .throw([errorLike], [errMsgMatcher], [msg]) - * - * When no arguments are provided, `.throw` invokes the target function and - * asserts that an error is thrown. - * - * var badFn = function () { throw new TypeError('Illegal salmon!'); }; - * - * expect(badFn).to.throw(); - * - * When one argument is provided, and it's an error constructor, `.throw` - * invokes the target function and asserts that an error is thrown that's an - * instance of that error constructor. - * - * var badFn = function () { throw new TypeError('Illegal salmon!'); }; - * - * expect(badFn).to.throw(TypeError); - * - * When one argument is provided, and it's an error instance, `.throw` invokes - * the target function and asserts that an error is thrown that's strictly - * (`===`) equal to that error instance. - * - * var err = new TypeError('Illegal salmon!'); - * var badFn = function () { throw err; }; - * - * expect(badFn).to.throw(err); - * - * When one argument is provided, and it's a string, `.throw` invokes the - * target function and asserts that an error is thrown with a message that - * contains that string. - * - * var badFn = function () { throw new TypeError('Illegal salmon!'); }; - * - * expect(badFn).to.throw('salmon'); - * - * When one argument is provided, and it's a regular expression, `.throw` - * invokes the target function and asserts that an error is thrown with a - * message that matches that regular expression. - * - * var badFn = function () { throw new TypeError('Illegal salmon!'); }; - * - * expect(badFn).to.throw(/salmon/); - * - * When two arguments are provided, and the first is an error instance or - * constructor, and the second is a string or regular expression, `.throw` - * invokes the function and asserts that an error is thrown that fulfills both - * conditions as described above. - * - * var err = new TypeError('Illegal salmon!'); - * var badFn = function () { throw err; }; - * - * expect(badFn).to.throw(TypeError, 'salmon'); - * expect(badFn).to.throw(TypeError, /salmon/); - * expect(badFn).to.throw(err, 'salmon'); - * expect(badFn).to.throw(err, /salmon/); - * - * Add `.not` earlier in the chain to negate `.throw`. - * - * var goodFn = function () {}; - * - * expect(goodFn).to.not.throw(); - * - * However, it's dangerous to negate `.throw` when providing any arguments. - * The problem is that it creates uncertain expectations by asserting that the - * target either doesn't throw an error, or that it throws an error but of a - * different type than the given type, or that it throws an error of the given - * type but with a message that doesn't include the given string. It's often - * best to identify the exact output that's expected, and then write an - * assertion that only accepts that exact output. - * - * When the target isn't expected to throw an error, it's often best to assert - * exactly that. - * - * var goodFn = function () {}; - * - * expect(goodFn).to.not.throw(); // Recommended - * expect(goodFn).to.not.throw(ReferenceError, 'x'); // Not recommended - * - * When the target is expected to throw an error, it's often best to assert - * that the error is of its expected type, and has a message that includes an - * expected string, rather than asserting that it doesn't have one of many - * unexpected types, and doesn't have a message that includes some string. - * - * var badFn = function () { throw new TypeError('Illegal salmon!'); }; - * - * expect(badFn).to.throw(TypeError, 'salmon'); // Recommended - * expect(badFn).to.not.throw(ReferenceError, 'x'); // Not recommended - * - * `.throw` changes the target of any assertions that follow in the chain to - * be the error object that's thrown. - * - * var err = new TypeError('Illegal salmon!'); - * err.code = 42; - * var badFn = function () { throw err; }; - * - * expect(badFn).to.throw(TypeError).with.property('code', 42); - * - * `.throw` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. When not providing two arguments, always use - * the second form. - * - * var goodFn = function () {}; - * - * expect(goodFn).to.throw(TypeError, 'x', 'nooo why fail??'); - * expect(goodFn, 'nooo why fail??').to.throw(); - * - * Due to limitations in ES5, `.throw` may not always work as expected when - * using a transpiler such as Babel or TypeScript. In particular, it may - * produce unexpected results when subclassing the built-in `Error` object and - * then passing the subclassed constructor to `.throw`. See your transpiler's - * docs for details: - * - * - ([Babel](https://babeljs.io/docs/usage/caveats/#classes)) - * - ([TypeScript](https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work)) - * - * Beware of some common mistakes when using the `throw` assertion. One common - * mistake is to accidentally invoke the function yourself instead of letting - * the `throw` assertion invoke the function for you. For example, when - * testing if a function named `fn` throws, provide `fn` instead of `fn()` as - * the target for the assertion. - * - * expect(fn).to.throw(); // Good! Tests `fn` as desired - * expect(fn()).to.throw(); // Bad! Tests result of `fn()`, not `fn` - * - * If you need to assert that your function `fn` throws when passed certain - * arguments, then wrap a call to `fn` inside of another function. - * - * expect(function () { fn(42); }).to.throw(); // Function expression - * expect(() => fn(42)).to.throw(); // ES6 arrow function - * - * Another common mistake is to provide an object method (or any stand-alone - * function that relies on `this`) as the target of the assertion. Doing so is - * problematic because the `this` context will be lost when the function is - * invoked by `.throw`; there's no way for it to know what `this` is supposed - * to be. There are two ways around this problem. One solution is to wrap the - * method or function call inside of another function. Another solution is to - * use `bind`. - * - * expect(function () { cat.meow(); }).to.throw(); // Function expression - * expect(() => cat.meow()).to.throw(); // ES6 arrow function - * expect(cat.meow.bind(cat)).to.throw(); // Bind - * - * Finally, it's worth mentioning that it's a best practice in JavaScript to - * only throw `Error` and derivatives of `Error` such as `ReferenceError`, - * `TypeError`, and user-defined objects that extend `Error`. No other type of - * value will generate a stack trace when initialized. With that said, the - * `throw` assertion does technically support any type of value being thrown, - * not just `Error` and its derivatives. - * - * The aliases `.throws` and `.Throw` can be used interchangeably with - * `.throw`. - * - * @name throw - * @alias throws - * @alias Throw - * @param {Error|ErrorConstructor} errorLike - * @param {String|RegExp} errMsgMatcher error message - * @param {String} msg _optional_ - * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types - * @returns error for chaining (null if no error) - * @namespace BDD - * @api public - */ - - function assertThrows (errorLike, errMsgMatcher, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , ssfi = flag(this, 'ssfi') - , flagMsg = flag(this, 'message') - , negate = flag(this, 'negate') || false; - new Assertion(obj, flagMsg, ssfi, true).is.a('function'); - - if (errorLike instanceof RegExp || typeof errorLike === 'string') { - errMsgMatcher = errorLike; - errorLike = null; - } - - var caughtErr; - try { - obj(); - } catch (err) { - caughtErr = err; - } - - // If we have the negate flag enabled and at least one valid argument it means we do expect an error - // but we want it to match a given set of criteria - var everyArgIsUndefined = errorLike === undefined && errMsgMatcher === undefined; - - // If we've got the negate flag enabled and both args, we should only fail if both aren't compatible - // See Issue #551 and PR #683@GitHub - var everyArgIsDefined = Boolean(errorLike && errMsgMatcher); - var errorLikeFail = false; - var errMsgMatcherFail = false; - - // Checking if error was thrown - if (everyArgIsUndefined || !everyArgIsUndefined && !negate) { - // We need this to display results correctly according to their types - var errorLikeString = 'an error'; - if (errorLike instanceof Error) { - errorLikeString = '#{exp}'; - } else if (errorLike) { - errorLikeString = _.checkError.getConstructorName(errorLike); - } - - this.assert( - caughtErr - , 'expected #{this} to throw ' + errorLikeString - , 'expected #{this} to not throw an error but #{act} was thrown' - , errorLike && errorLike.toString() - , (caughtErr instanceof Error ? - caughtErr.toString() : (typeof caughtErr === 'string' ? caughtErr : caughtErr && - _.checkError.getConstructorName(caughtErr))) - ); - } - - if (errorLike && caughtErr) { - // We should compare instances only if `errorLike` is an instance of `Error` - if (errorLike instanceof Error) { - var isCompatibleInstance = _.checkError.compatibleInstance(caughtErr, errorLike); - - if (isCompatibleInstance === negate) { - // These checks were created to ensure we won't fail too soon when we've got both args and a negate - // See Issue #551 and PR #683@GitHub - if (everyArgIsDefined && negate) { - errorLikeFail = true; - } else { - this.assert( - negate - , 'expected #{this} to throw #{exp} but #{act} was thrown' - , 'expected #{this} to not throw #{exp}' + (caughtErr && !negate ? ' but #{act} was thrown' : '') - , errorLike.toString() - , caughtErr.toString() - ); - } - } - } - - var isCompatibleConstructor = _.checkError.compatibleConstructor(caughtErr, errorLike); - if (isCompatibleConstructor === negate) { - if (everyArgIsDefined && negate) { - errorLikeFail = true; - } else { - this.assert( - negate - , 'expected #{this} to throw #{exp} but #{act} was thrown' - , 'expected #{this} to not throw #{exp}' + (caughtErr ? ' but #{act} was thrown' : '') - , (errorLike instanceof Error ? errorLike.toString() : errorLike && _.checkError.getConstructorName(errorLike)) - , (caughtErr instanceof Error ? caughtErr.toString() : caughtErr && _.checkError.getConstructorName(caughtErr)) - ); - } - } - } - - if (caughtErr && errMsgMatcher !== undefined && errMsgMatcher !== null) { - // Here we check compatible messages - var placeholder = 'including'; - if (errMsgMatcher instanceof RegExp) { - placeholder = 'matching' - } - - var isCompatibleMessage = _.checkError.compatibleMessage(caughtErr, errMsgMatcher); - if (isCompatibleMessage === negate) { - if (everyArgIsDefined && negate) { - errMsgMatcherFail = true; - } else { - this.assert( - negate - , 'expected #{this} to throw error ' + placeholder + ' #{exp} but got #{act}' - , 'expected #{this} to throw error not ' + placeholder + ' #{exp}' - , errMsgMatcher - , _.checkError.getMessage(caughtErr) - ); - } - } - } - - // If both assertions failed and both should've matched we throw an error - if (errorLikeFail && errMsgMatcherFail) { - this.assert( - negate - , 'expected #{this} to throw #{exp} but #{act} was thrown' - , 'expected #{this} to not throw #{exp}' + (caughtErr ? ' but #{act} was thrown' : '') - , (errorLike instanceof Error ? errorLike.toString() : errorLike && _.checkError.getConstructorName(errorLike)) - , (caughtErr instanceof Error ? caughtErr.toString() : caughtErr && _.checkError.getConstructorName(caughtErr)) - ); - } - - flag(this, 'object', caughtErr); - }; - - Assertion.addMethod('throw', assertThrows); - Assertion.addMethod('throws', assertThrows); - Assertion.addMethod('Throw', assertThrows); - - /** - * ### .respondTo(method[, msg]) - * - * When the target is a non-function object, `.respondTo` asserts that the - * target has a method with the given name `method`. The method can be own or - * inherited, and it can be enumerable or non-enumerable. - * - * function Cat () {} - * Cat.prototype.meow = function () {}; - * - * expect(new Cat()).to.respondTo('meow'); - * - * When the target is a function, `.respondTo` asserts that the target's - * `prototype` property has a method with the given name `method`. Again, the - * method can be own or inherited, and it can be enumerable or non-enumerable. - * - * function Cat () {} - * Cat.prototype.meow = function () {}; - * - * expect(Cat).to.respondTo('meow'); - * - * Add `.itself` earlier in the chain to force `.respondTo` to treat the - * target as a non-function object, even if it's a function. Thus, it asserts - * that the target has a method with the given name `method`, rather than - * asserting that the target's `prototype` property has a method with the - * given name `method`. - * - * function Cat () {} - * Cat.prototype.meow = function () {}; - * Cat.hiss = function () {}; - * - * expect(Cat).itself.to.respondTo('hiss').but.not.respondTo('meow'); - * - * When not adding `.itself`, it's important to check the target's type before - * using `.respondTo`. See the `.a` doc for info on checking a target's type. - * - * function Cat () {} - * Cat.prototype.meow = function () {}; - * - * expect(new Cat()).to.be.an('object').that.respondsTo('meow'); - * - * Add `.not` earlier in the chain to negate `.respondTo`. - * - * function Dog () {} - * Dog.prototype.bark = function () {}; - * - * expect(new Dog()).to.not.respondTo('meow'); - * - * `.respondTo` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect({}).to.respondTo('meow', 'nooo why fail??'); - * expect({}, 'nooo why fail??').to.respondTo('meow'); - * - * The alias `.respondsTo` can be used interchangeably with `.respondTo`. - * - * @name respondTo - * @alias respondsTo - * @param {String} method - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function respondTo (method, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , itself = flag(this, 'itself') - , context = ('function' === typeof obj && !itself) - ? obj.prototype[method] - : obj[method]; - - this.assert( - 'function' === typeof context - , 'expected #{this} to respond to ' + _.inspect(method) - , 'expected #{this} to not respond to ' + _.inspect(method) - ); - } - - Assertion.addMethod('respondTo', respondTo); - Assertion.addMethod('respondsTo', respondTo); - - /** - * ### .itself - * - * Forces all `.respondTo` assertions that follow in the chain to behave as if - * the target is a non-function object, even if it's a function. Thus, it - * causes `.respondTo` to assert that the target has a method with the given - * name, rather than asserting that the target's `prototype` property has a - * method with the given name. - * - * function Cat () {} - * Cat.prototype.meow = function () {}; - * Cat.hiss = function () {}; - * - * expect(Cat).itself.to.respondTo('hiss').but.not.respondTo('meow'); - * - * @name itself - * @namespace BDD - * @api public - */ - - Assertion.addProperty('itself', function () { - flag(this, 'itself', true); - }); - - /** - * ### .satisfy(matcher[, msg]) - * - * Invokes the given `matcher` function with the target being passed as the - * first argument, and asserts that the value returned is truthy. - * - * expect(1).to.satisfy(function(num) { - * return num > 0; - * }); - * - * Add `.not` earlier in the chain to negate `.satisfy`. - * - * expect(1).to.not.satisfy(function(num) { - * return num > 2; - * }); - * - * `.satisfy` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect(1).to.satisfy(function(num) { - * return num > 2; - * }, 'nooo why fail??'); - * - * expect(1, 'nooo why fail??').to.satisfy(function(num) { - * return num > 2; - * }); - * - * The alias `.satisfies` can be used interchangeably with `.satisfy`. - * - * @name satisfy - * @alias satisfies - * @param {Function} matcher - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function satisfy (matcher, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object'); - var result = matcher(obj); - this.assert( - result - , 'expected #{this} to satisfy ' + _.objDisplay(matcher) - , 'expected #{this} to not satisfy' + _.objDisplay(matcher) - , flag(this, 'negate') ? false : true - , result - ); - } - - Assertion.addMethod('satisfy', satisfy); - Assertion.addMethod('satisfies', satisfy); - - /** - * ### .closeTo(expected, delta[, msg]) - * - * Asserts that the target is a number that's within a given +/- `delta` range - * of the given number `expected`. However, it's often best to assert that the - * target is equal to its expected value. - * - * // Recommended - * expect(1.5).to.equal(1.5); - * - * // Not recommended - * expect(1.5).to.be.closeTo(1, 0.5); - * expect(1.5).to.be.closeTo(2, 0.5); - * expect(1.5).to.be.closeTo(1, 1); - * - * Add `.not` earlier in the chain to negate `.closeTo`. - * - * expect(1.5).to.equal(1.5); // Recommended - * expect(1.5).to.not.be.closeTo(3, 1); // Not recommended - * - * `.closeTo` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect(1.5).to.be.closeTo(3, 1, 'nooo why fail??'); - * expect(1.5, 'nooo why fail??').to.be.closeTo(3, 1); - * - * The alias `.approximately` can be used interchangeably with `.closeTo`. - * - * @name closeTo - * @alias approximately - * @param {Number} expected - * @param {Number} delta - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function closeTo(expected, delta, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi'); - - new Assertion(obj, flagMsg, ssfi, true).is.a('number'); - if (typeof expected !== 'number' || typeof delta !== 'number') { - flagMsg = flagMsg ? flagMsg + ': ' : ''; - var deltaMessage = delta === undefined ? ", and a delta is required" : ""; - throw new AssertionError( - flagMsg + 'the arguments to closeTo or approximately must be numbers' + deltaMessage, - undefined, - ssfi - ); - } - - this.assert( - Math.abs(obj - expected) <= delta - , 'expected #{this} to be close to ' + expected + ' +/- ' + delta - , 'expected #{this} not to be close to ' + expected + ' +/- ' + delta - ); - } - - Assertion.addMethod('closeTo', closeTo); - Assertion.addMethod('approximately', closeTo); - - // Note: Duplicates are ignored if testing for inclusion instead of sameness. - function isSubsetOf(subset, superset, cmp, contains, ordered) { - if (!contains) { - if (subset.length !== superset.length) return false; - superset = superset.slice(); - } - - return subset.every(function(elem, idx) { - if (ordered) return cmp ? cmp(elem, superset[idx]) : elem === superset[idx]; - - if (!cmp) { - var matchIdx = superset.indexOf(elem); - if (matchIdx === -1) return false; - - // Remove match from superset so not counted twice if duplicate in subset. - if (!contains) superset.splice(matchIdx, 1); - return true; - } - - return superset.some(function(elem2, matchIdx) { - if (!cmp(elem, elem2)) return false; - - // Remove match from superset so not counted twice if duplicate in subset. - if (!contains) superset.splice(matchIdx, 1); - return true; - }); - }); - } - - /** - * ### .members(set[, msg]) - * - * Asserts that the target array has the same members as the given array - * `set`. - * - * expect([1, 2, 3]).to.have.members([2, 1, 3]); - * expect([1, 2, 2]).to.have.members([2, 1, 2]); - * - * By default, members are compared using strict (`===`) equality. Add `.deep` - * earlier in the chain to use deep equality instead. See the `deep-eql` - * project page for info on the deep equality algorithm: - * https://github.com/chaijs/deep-eql. - * - * // Target array deeply (but not strictly) has member `{a: 1}` - * expect([{a: 1}]).to.have.deep.members([{a: 1}]); - * expect([{a: 1}]).to.not.have.members([{a: 1}]); - * - * By default, order doesn't matter. Add `.ordered` earlier in the chain to - * require that members appear in the same order. - * - * expect([1, 2, 3]).to.have.ordered.members([1, 2, 3]); - * expect([1, 2, 3]).to.have.members([2, 1, 3]) - * .but.not.ordered.members([2, 1, 3]); - * - * By default, both arrays must be the same size. Add `.include` earlier in - * the chain to require that the target's members be a superset of the - * expected members. Note that duplicates are ignored in the subset when - * `.include` is added. - * - * // Target array is a superset of [1, 2] but not identical - * expect([1, 2, 3]).to.include.members([1, 2]); - * expect([1, 2, 3]).to.not.have.members([1, 2]); - * - * // Duplicates in the subset are ignored - * expect([1, 2, 3]).to.include.members([1, 2, 2, 2]); - * - * `.deep`, `.ordered`, and `.include` can all be combined. However, if - * `.include` and `.ordered` are combined, the ordering begins at the start of - * both arrays. - * - * expect([{a: 1}, {b: 2}, {c: 3}]) - * .to.include.deep.ordered.members([{a: 1}, {b: 2}]) - * .but.not.include.deep.ordered.members([{b: 2}, {c: 3}]); - * - * Add `.not` earlier in the chain to negate `.members`. However, it's - * dangerous to do so. The problem is that it creates uncertain expectations - * by asserting that the target array doesn't have all of the same members as - * the given array `set` but may or may not have some of them. It's often best - * to identify the exact output that's expected, and then write an assertion - * that only accepts that exact output. - * - * expect([1, 2]).to.not.include(3).and.not.include(4); // Recommended - * expect([1, 2]).to.not.have.members([3, 4]); // Not recommended - * - * `.members` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. - * - * expect([1, 2]).to.have.members([1, 2, 3], 'nooo why fail??'); - * expect([1, 2], 'nooo why fail??').to.have.members([1, 2, 3]); - * - * @name members - * @param {Array} set - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - Assertion.addMethod('members', function (subset, msg) { - if (msg) flag(this, 'message', msg); - var obj = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi'); - - new Assertion(obj, flagMsg, ssfi, true).to.be.an('array'); - new Assertion(subset, flagMsg, ssfi, true).to.be.an('array'); - - var contains = flag(this, 'contains'); - var ordered = flag(this, 'ordered'); - - var subject, failMsg, failNegateMsg; - - if (contains) { - subject = ordered ? 'an ordered superset' : 'a superset'; - failMsg = 'expected #{this} to be ' + subject + ' of #{exp}'; - failNegateMsg = 'expected #{this} to not be ' + subject + ' of #{exp}'; - } else { - subject = ordered ? 'ordered members' : 'members'; - failMsg = 'expected #{this} to have the same ' + subject + ' as #{exp}'; - failNegateMsg = 'expected #{this} to not have the same ' + subject + ' as #{exp}'; - } - - var cmp = flag(this, 'deep') ? _.eql : undefined; - - this.assert( - isSubsetOf(subset, obj, cmp, contains, ordered) - , failMsg - , failNegateMsg - , subset - , obj - , true - ); - }); - - /** - * ### .oneOf(list[, msg]) - * - * Asserts that the target is a member of the given array `list`. However, - * it's often best to assert that the target is equal to its expected value. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.be.oneOf([1, 2, 3]); // Not recommended - * - * Comparisons are performed using strict (`===`) equality. - * - * Add `.not` earlier in the chain to negate `.oneOf`. - * - * expect(1).to.equal(1); // Recommended - * expect(1).to.not.be.oneOf([2, 3, 4]); // Not recommended - * - * It can also be chained with `.contain` or `.include`, which will work with - * both arrays and strings: - * - * expect('Today is sunny').to.contain.oneOf(['sunny', 'cloudy']) - * expect('Today is rainy').to.not.contain.oneOf(['sunny', 'cloudy']) - * expect([1,2,3]).to.contain.oneOf([3,4,5]) - * expect([1,2,3]).to.not.contain.oneOf([4,5,6]) - * - * `.oneOf` accepts an optional `msg` argument which is a custom error message - * to show when the assertion fails. The message can also be given as the - * second argument to `expect`. - * - * expect(1).to.be.oneOf([2, 3, 4], 'nooo why fail??'); - * expect(1, 'nooo why fail??').to.be.oneOf([2, 3, 4]); - * - * @name oneOf - * @param {Array<*>} list - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function oneOf (list, msg) { - if (msg) flag(this, 'message', msg); - var expected = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi') - , contains = flag(this, 'contains') - , isDeep = flag(this, 'deep'); - new Assertion(list, flagMsg, ssfi, true).to.be.an('array'); - - if (contains) { - this.assert( - list.some(function(possibility) { return expected.indexOf(possibility) > -1 }) - , 'expected #{this} to contain one of #{exp}' - , 'expected #{this} to not contain one of #{exp}' - , list - , expected - ); - } else { - if (isDeep) { - this.assert( - list.some(function(possibility) { return _.eql(expected, possibility) }) - , 'expected #{this} to deeply equal one of #{exp}' - , 'expected #{this} to deeply equal one of #{exp}' - , list - , expected - ); - } else { - this.assert( - list.indexOf(expected) > -1 - , 'expected #{this} to be one of #{exp}' - , 'expected #{this} to not be one of #{exp}' - , list - , expected - ); - } - } - } - - Assertion.addMethod('oneOf', oneOf); - - /** - * ### .change(subject[, prop[, msg]]) - * - * When one argument is provided, `.change` asserts that the given function - * `subject` returns a different value when it's invoked before the target - * function compared to when it's invoked afterward. However, it's often best - * to assert that `subject` is equal to its expected value. - * - * var dots = '' - * , addDot = function () { dots += '.'; } - * , getDots = function () { return dots; }; - * - * // Recommended - * expect(getDots()).to.equal(''); - * addDot(); - * expect(getDots()).to.equal('.'); - * - * // Not recommended - * expect(addDot).to.change(getDots); - * - * When two arguments are provided, `.change` asserts that the value of the - * given object `subject`'s `prop` property is different before invoking the - * target function compared to afterward. - * - * var myObj = {dots: ''} - * , addDot = function () { myObj.dots += '.'; }; - * - * // Recommended - * expect(myObj).to.have.property('dots', ''); - * addDot(); - * expect(myObj).to.have.property('dots', '.'); - * - * // Not recommended - * expect(addDot).to.change(myObj, 'dots'); - * - * Strict (`===`) equality is used to compare before and after values. - * - * Add `.not` earlier in the chain to negate `.change`. - * - * var dots = '' - * , noop = function () {} - * , getDots = function () { return dots; }; - * - * expect(noop).to.not.change(getDots); - * - * var myObj = {dots: ''} - * , noop = function () {}; - * - * expect(noop).to.not.change(myObj, 'dots'); - * - * `.change` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. When not providing two arguments, always - * use the second form. - * - * var myObj = {dots: ''} - * , addDot = function () { myObj.dots += '.'; }; - * - * expect(addDot).to.not.change(myObj, 'dots', 'nooo why fail??'); - * - * var dots = '' - * , addDot = function () { dots += '.'; } - * , getDots = function () { return dots; }; - * - * expect(addDot, 'nooo why fail??').to.not.change(getDots); - * - * `.change` also causes all `.by` assertions that follow in the chain to - * assert how much a numeric subject was increased or decreased by. However, - * it's dangerous to use `.change.by`. The problem is that it creates - * uncertain expectations by asserting that the subject either increases by - * the given delta, or that it decreases by the given delta. It's often best - * to identify the exact output that's expected, and then write an assertion - * that only accepts that exact output. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; } - * , subtractTwo = function () { myObj.val -= 2; }; - * - * expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended - * expect(addTwo).to.change(myObj, 'val').by(2); // Not recommended - * - * expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended - * expect(subtractTwo).to.change(myObj, 'val').by(2); // Not recommended - * - * The alias `.changes` can be used interchangeably with `.change`. - * - * @name change - * @alias changes - * @param {String} subject - * @param {String} prop name _optional_ - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertChanges (subject, prop, msg) { - if (msg) flag(this, 'message', msg); - var fn = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi'); - new Assertion(fn, flagMsg, ssfi, true).is.a('function'); - - var initial; - if (!prop) { - new Assertion(subject, flagMsg, ssfi, true).is.a('function'); - initial = subject(); - } else { - new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop); - initial = subject[prop]; - } - - fn(); - - var final = prop === undefined || prop === null ? subject() : subject[prop]; - var msgObj = prop === undefined || prop === null ? initial : '.' + prop; - - // This gets flagged because of the .by(delta) assertion - flag(this, 'deltaMsgObj', msgObj); - flag(this, 'initialDeltaValue', initial); - flag(this, 'finalDeltaValue', final); - flag(this, 'deltaBehavior', 'change'); - flag(this, 'realDelta', final !== initial); - - this.assert( - initial !== final - , 'expected ' + msgObj + ' to change' - , 'expected ' + msgObj + ' to not change' - ); - } - - Assertion.addMethod('change', assertChanges); - Assertion.addMethod('changes', assertChanges); - - /** - * ### .increase(subject[, prop[, msg]]) - * - * When one argument is provided, `.increase` asserts that the given function - * `subject` returns a greater number when it's invoked after invoking the - * target function compared to when it's invoked beforehand. `.increase` also - * causes all `.by` assertions that follow in the chain to assert how much - * greater of a number is returned. It's often best to assert that the return - * value increased by the expected amount, rather than asserting it increased - * by any amount. - * - * var val = 1 - * , addTwo = function () { val += 2; } - * , getVal = function () { return val; }; - * - * expect(addTwo).to.increase(getVal).by(2); // Recommended - * expect(addTwo).to.increase(getVal); // Not recommended - * - * When two arguments are provided, `.increase` asserts that the value of the - * given object `subject`'s `prop` property is greater after invoking the - * target function compared to beforehand. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; }; - * - * expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended - * expect(addTwo).to.increase(myObj, 'val'); // Not recommended - * - * Add `.not` earlier in the chain to negate `.increase`. However, it's - * dangerous to do so. The problem is that it creates uncertain expectations - * by asserting that the subject either decreases, or that it stays the same. - * It's often best to identify the exact output that's expected, and then - * write an assertion that only accepts that exact output. - * - * When the subject is expected to decrease, it's often best to assert that it - * decreased by the expected amount. - * - * var myObj = {val: 1} - * , subtractTwo = function () { myObj.val -= 2; }; - * - * expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended - * expect(subtractTwo).to.not.increase(myObj, 'val'); // Not recommended - * - * When the subject is expected to stay the same, it's often best to assert - * exactly that. - * - * var myObj = {val: 1} - * , noop = function () {}; - * - * expect(noop).to.not.change(myObj, 'val'); // Recommended - * expect(noop).to.not.increase(myObj, 'val'); // Not recommended - * - * `.increase` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. When not providing two arguments, always - * use the second form. - * - * var myObj = {val: 1} - * , noop = function () {}; - * - * expect(noop).to.increase(myObj, 'val', 'nooo why fail??'); - * - * var val = 1 - * , noop = function () {} - * , getVal = function () { return val; }; - * - * expect(noop, 'nooo why fail??').to.increase(getVal); - * - * The alias `.increases` can be used interchangeably with `.increase`. - * - * @name increase - * @alias increases - * @param {String|Function} subject - * @param {String} prop name _optional_ - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertIncreases (subject, prop, msg) { - if (msg) flag(this, 'message', msg); - var fn = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi'); - new Assertion(fn, flagMsg, ssfi, true).is.a('function'); - - var initial; - if (!prop) { - new Assertion(subject, flagMsg, ssfi, true).is.a('function'); - initial = subject(); - } else { - new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop); - initial = subject[prop]; - } - - // Make sure that the target is a number - new Assertion(initial, flagMsg, ssfi, true).is.a('number'); - - fn(); - - var final = prop === undefined || prop === null ? subject() : subject[prop]; - var msgObj = prop === undefined || prop === null ? initial : '.' + prop; - - flag(this, 'deltaMsgObj', msgObj); - flag(this, 'initialDeltaValue', initial); - flag(this, 'finalDeltaValue', final); - flag(this, 'deltaBehavior', 'increase'); - flag(this, 'realDelta', final - initial); - - this.assert( - final - initial > 0 - , 'expected ' + msgObj + ' to increase' - , 'expected ' + msgObj + ' to not increase' - ); - } - - Assertion.addMethod('increase', assertIncreases); - Assertion.addMethod('increases', assertIncreases); - - /** - * ### .decrease(subject[, prop[, msg]]) - * - * When one argument is provided, `.decrease` asserts that the given function - * `subject` returns a lesser number when it's invoked after invoking the - * target function compared to when it's invoked beforehand. `.decrease` also - * causes all `.by` assertions that follow in the chain to assert how much - * lesser of a number is returned. It's often best to assert that the return - * value decreased by the expected amount, rather than asserting it decreased - * by any amount. - * - * var val = 1 - * , subtractTwo = function () { val -= 2; } - * , getVal = function () { return val; }; - * - * expect(subtractTwo).to.decrease(getVal).by(2); // Recommended - * expect(subtractTwo).to.decrease(getVal); // Not recommended - * - * When two arguments are provided, `.decrease` asserts that the value of the - * given object `subject`'s `prop` property is lesser after invoking the - * target function compared to beforehand. - * - * var myObj = {val: 1} - * , subtractTwo = function () { myObj.val -= 2; }; - * - * expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended - * expect(subtractTwo).to.decrease(myObj, 'val'); // Not recommended - * - * Add `.not` earlier in the chain to negate `.decrease`. However, it's - * dangerous to do so. The problem is that it creates uncertain expectations - * by asserting that the subject either increases, or that it stays the same. - * It's often best to identify the exact output that's expected, and then - * write an assertion that only accepts that exact output. - * - * When the subject is expected to increase, it's often best to assert that it - * increased by the expected amount. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; }; - * - * expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended - * expect(addTwo).to.not.decrease(myObj, 'val'); // Not recommended - * - * When the subject is expected to stay the same, it's often best to assert - * exactly that. - * - * var myObj = {val: 1} - * , noop = function () {}; - * - * expect(noop).to.not.change(myObj, 'val'); // Recommended - * expect(noop).to.not.decrease(myObj, 'val'); // Not recommended - * - * `.decrease` accepts an optional `msg` argument which is a custom error - * message to show when the assertion fails. The message can also be given as - * the second argument to `expect`. When not providing two arguments, always - * use the second form. - * - * var myObj = {val: 1} - * , noop = function () {}; - * - * expect(noop).to.decrease(myObj, 'val', 'nooo why fail??'); - * - * var val = 1 - * , noop = function () {} - * , getVal = function () { return val; }; - * - * expect(noop, 'nooo why fail??').to.decrease(getVal); - * - * The alias `.decreases` can be used interchangeably with `.decrease`. - * - * @name decrease - * @alias decreases - * @param {String|Function} subject - * @param {String} prop name _optional_ - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertDecreases (subject, prop, msg) { - if (msg) flag(this, 'message', msg); - var fn = flag(this, 'object') - , flagMsg = flag(this, 'message') - , ssfi = flag(this, 'ssfi'); - new Assertion(fn, flagMsg, ssfi, true).is.a('function'); - - var initial; - if (!prop) { - new Assertion(subject, flagMsg, ssfi, true).is.a('function'); - initial = subject(); - } else { - new Assertion(subject, flagMsg, ssfi, true).to.have.property(prop); - initial = subject[prop]; - } - - // Make sure that the target is a number - new Assertion(initial, flagMsg, ssfi, true).is.a('number'); - - fn(); - - var final = prop === undefined || prop === null ? subject() : subject[prop]; - var msgObj = prop === undefined || prop === null ? initial : '.' + prop; - - flag(this, 'deltaMsgObj', msgObj); - flag(this, 'initialDeltaValue', initial); - flag(this, 'finalDeltaValue', final); - flag(this, 'deltaBehavior', 'decrease'); - flag(this, 'realDelta', initial - final); - - this.assert( - final - initial < 0 - , 'expected ' + msgObj + ' to decrease' - , 'expected ' + msgObj + ' to not decrease' - ); - } - - Assertion.addMethod('decrease', assertDecreases); - Assertion.addMethod('decreases', assertDecreases); - - /** - * ### .by(delta[, msg]) - * - * When following an `.increase` assertion in the chain, `.by` asserts that - * the subject of the `.increase` assertion increased by the given `delta`. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; }; - * - * expect(addTwo).to.increase(myObj, 'val').by(2); - * - * When following a `.decrease` assertion in the chain, `.by` asserts that the - * subject of the `.decrease` assertion decreased by the given `delta`. - * - * var myObj = {val: 1} - * , subtractTwo = function () { myObj.val -= 2; }; - * - * expect(subtractTwo).to.decrease(myObj, 'val').by(2); - * - * When following a `.change` assertion in the chain, `.by` asserts that the - * subject of the `.change` assertion either increased or decreased by the - * given `delta`. However, it's dangerous to use `.change.by`. The problem is - * that it creates uncertain expectations. It's often best to identify the - * exact output that's expected, and then write an assertion that only accepts - * that exact output. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; } - * , subtractTwo = function () { myObj.val -= 2; }; - * - * expect(addTwo).to.increase(myObj, 'val').by(2); // Recommended - * expect(addTwo).to.change(myObj, 'val').by(2); // Not recommended - * - * expect(subtractTwo).to.decrease(myObj, 'val').by(2); // Recommended - * expect(subtractTwo).to.change(myObj, 'val').by(2); // Not recommended - * - * Add `.not` earlier in the chain to negate `.by`. However, it's often best - * to assert that the subject changed by its expected delta, rather than - * asserting that it didn't change by one of countless unexpected deltas. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; }; - * - * // Recommended - * expect(addTwo).to.increase(myObj, 'val').by(2); - * - * // Not recommended - * expect(addTwo).to.increase(myObj, 'val').but.not.by(3); - * - * `.by` accepts an optional `msg` argument which is a custom error message to - * show when the assertion fails. The message can also be given as the second - * argument to `expect`. - * - * var myObj = {val: 1} - * , addTwo = function () { myObj.val += 2; }; - * - * expect(addTwo).to.increase(myObj, 'val').by(3, 'nooo why fail??'); - * expect(addTwo, 'nooo why fail??').to.increase(myObj, 'val').by(3); - * - * @name by - * @param {Number} delta - * @param {String} msg _optional_ - * @namespace BDD - * @api public - */ - - function assertDelta(delta, msg) { - if (msg) flag(this, 'message', msg); - - var msgObj = flag(this, 'deltaMsgObj'); - var initial = flag(this, 'initialDeltaValue'); - var final = flag(this, 'finalDeltaValue'); - var behavior = flag(this, 'deltaBehavior'); - var realDelta = flag(this, 'realDelta'); - - var expression; - if (behavior === 'change') { - expression = Math.abs(final - initial) === Math.abs(delta); - } else { - expression = realDelta === Math.abs(delta); - } - - this.assert( - expression - , 'expected ' + msgObj + ' to ' + behavior + ' by ' + delta - , 'expected ' + msgObj + ' to not ' + behavior + ' by ' + delta - ); - } - - Assertion.addMethod('by', assertDelta); - - /** - * ### .extensible - * - * Asserts that the target is extensible, which means that new properties can - * be added to it. Primitives are never extensible. - * - * expect({a: 1}).to.be.extensible; - * - * Add `.not` earlier in the chain to negate `.extensible`. - * - * var nonExtensibleObject = Object.preventExtensions({}) - * , sealedObject = Object.seal({}) - * , frozenObject = Object.freeze({}); - * - * expect(nonExtensibleObject).to.not.be.extensible; - * expect(sealedObject).to.not.be.extensible; - * expect(frozenObject).to.not.be.extensible; - * expect(1).to.not.be.extensible; - * - * A custom error message can be given as the second argument to `expect`. - * - * expect(1, 'nooo why fail??').to.be.extensible; - * - * @name extensible - * @namespace BDD - * @api public - */ - - Assertion.addProperty('extensible', function() { - var obj = flag(this, 'object'); - - // In ES5, if the argument to this method is a primitive, then it will cause a TypeError. - // In ES6, a non-object argument will be treated as if it was a non-extensible ordinary object, simply return false. - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible - // The following provides ES6 behavior for ES5 environments. - - var isExtensible = obj === Object(obj) && Object.isExtensible(obj); - - this.assert( - isExtensible - , 'expected #{this} to be extensible' - , 'expected #{this} to not be extensible' - ); - }); - - /** - * ### .sealed - * - * Asserts that the target is sealed, which means that new properties can't be - * added to it, and its existing properties can't be reconfigured or deleted. - * However, it's possible that its existing properties can still be reassigned - * to different values. Primitives are always sealed. - * - * var sealedObject = Object.seal({}); - * var frozenObject = Object.freeze({}); - * - * expect(sealedObject).to.be.sealed; - * expect(frozenObject).to.be.sealed; - * expect(1).to.be.sealed; - * - * Add `.not` earlier in the chain to negate `.sealed`. - * - * expect({a: 1}).to.not.be.sealed; - * - * A custom error message can be given as the second argument to `expect`. - * - * expect({a: 1}, 'nooo why fail??').to.be.sealed; - * - * @name sealed - * @namespace BDD - * @api public - */ - - Assertion.addProperty('sealed', function() { - var obj = flag(this, 'object'); - - // In ES5, if the argument to this method is a primitive, then it will cause a TypeError. - // In ES6, a non-object argument will be treated as if it was a sealed ordinary object, simply return true. - // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isSealed - // The following provides ES6 behavior for ES5 environments. - - var isSealed = obj === Object(obj) ? Object.isSealed(obj) : true; - - this.assert( - isSealed - , 'expected #{this} to be sealed' - , 'expected #{this} to not be sealed' - ); - }); - - /** - * ### .frozen - * - * Asserts that the target is frozen, which means that new properties can't be - * added to it, and its existing properties can't be reassigned to different - * values, reconfigured, or deleted. Primitives are always frozen. - * - * var frozenObject = Object.freeze({}); - * - * expect(frozenObject).to.be.frozen; - * expect(1).to.be.frozen; - * - * Add `.not` earlier in the chain to negate `.frozen`. - * - * expect({a: 1}).to.not.be.frozen; - * - * A custom error message can be given as the second argument to `expect`. - * - * expect({a: 1}, 'nooo why fail??').to.be.frozen; - * - * @name frozen - * @namespace BDD - * @api public - */ - - Assertion.addProperty('frozen', function() { - var obj = flag(this, 'object'); - - // In ES5, if the argument to this method is a primitive, then it will cause a TypeError. - // In ES6, a non-object argument will be treated as if it was a frozen ordinary object, simply return true. - // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isFrozen - // The following provides ES6 behavior for ES5 environments. - - var isFrozen = obj === Object(obj) ? Object.isFrozen(obj) : true; - - this.assert( - isFrozen - , 'expected #{this} to be frozen' - , 'expected #{this} to not be frozen' - ); - }); - - /** - * ### .finite - * - * Asserts that the target is a number, and isn't `NaN` or positive/negative - * `Infinity`. - * - * expect(1).to.be.finite; - * - * Add `.not` earlier in the chain to negate `.finite`. However, it's - * dangerous to do so. The problem is that it creates uncertain expectations - * by asserting that the subject either isn't a number, or that it's `NaN`, or - * that it's positive `Infinity`, or that it's negative `Infinity`. It's often - * best to identify the exact output that's expected, and then write an - * assertion that only accepts that exact output. - * - * When the target isn't expected to be a number, it's often best to assert - * that it's the expected type, rather than asserting that it isn't one of - * many unexpected types. - * - * expect('foo').to.be.a('string'); // Recommended - * expect('foo').to.not.be.finite; // Not recommended - * - * When the target is expected to be `NaN`, it's often best to assert exactly - * that. - * - * expect(NaN).to.be.NaN; // Recommended - * expect(NaN).to.not.be.finite; // Not recommended - * - * When the target is expected to be positive infinity, it's often best to - * assert exactly that. - * - * expect(Infinity).to.equal(Infinity); // Recommended - * expect(Infinity).to.not.be.finite; // Not recommended - * - * When the target is expected to be negative infinity, it's often best to - * assert exactly that. - * - * expect(-Infinity).to.equal(-Infinity); // Recommended - * expect(-Infinity).to.not.be.finite; // Not recommended - * - * A custom error message can be given as the second argument to `expect`. - * - * expect('foo', 'nooo why fail??').to.be.finite; - * - * @name finite - * @namespace BDD - * @api public - */ - - Assertion.addProperty('finite', function(msg) { - var obj = flag(this, 'object'); - - this.assert( - typeof obj === 'number' && isFinite(obj) - , 'expected #{this} to be a finite number' - , 'expected #{this} to not be a finite number' - ); - }); -}; diff --git a/node_modules/chai/lib/chai/interface/assert.js b/node_modules/chai/lib/chai/interface/assert.js deleted file mode 100644 index 11b3c25..0000000 --- a/node_modules/chai/lib/chai/interface/assert.js +++ /dev/null @@ -1,3113 +0,0 @@ -/*! - * chai - * Copyright(c) 2011-2014 Jake Luer - * MIT Licensed - */ - -module.exports = function (chai, util) { - /*! - * Chai dependencies. - */ - - var Assertion = chai.Assertion - , flag = util.flag; - - /*! - * Module export. - */ - - /** - * ### assert(expression, message) - * - * Write your own test expressions. - * - * assert('foo' !== 'bar', 'foo is not bar'); - * assert(Array.isArray([]), 'empty arrays are arrays'); - * - * @param {Mixed} expression to test for truthiness - * @param {String} message to display on error - * @name assert - * @namespace Assert - * @api public - */ - - var assert = chai.assert = function (express, errmsg) { - var test = new Assertion(null, null, chai.assert, true); - test.assert( - express - , errmsg - , '[ negation message unavailable ]' - ); - }; - - /** - * ### .fail([message]) - * ### .fail(actual, expected, [message], [operator]) - * - * Throw a failure. Node.js `assert` module-compatible. - * - * assert.fail(); - * assert.fail("custom error message"); - * assert.fail(1, 2); - * assert.fail(1, 2, "custom error message"); - * assert.fail(1, 2, "custom error message", ">"); - * assert.fail(1, 2, undefined, ">"); - * - * @name fail - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @param {String} operator - * @namespace Assert - * @api public - */ - - assert.fail = function (actual, expected, message, operator) { - if (arguments.length < 2) { - // Comply with Node's fail([message]) interface - - message = actual; - actual = undefined; - } - - message = message || 'assert.fail()'; - throw new chai.AssertionError(message, { - actual: actual - , expected: expected - , operator: operator - }, assert.fail); - }; - - /** - * ### .isOk(object, [message]) - * - * Asserts that `object` is truthy. - * - * assert.isOk('everything', 'everything is ok'); - * assert.isOk(false, 'this will fail'); - * - * @name isOk - * @alias ok - * @param {Mixed} object to test - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isOk = function (val, msg) { - new Assertion(val, msg, assert.isOk, true).is.ok; - }; - - /** - * ### .isNotOk(object, [message]) - * - * Asserts that `object` is falsy. - * - * assert.isNotOk('everything', 'this will fail'); - * assert.isNotOk(false, 'this will pass'); - * - * @name isNotOk - * @alias notOk - * @param {Mixed} object to test - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotOk = function (val, msg) { - new Assertion(val, msg, assert.isNotOk, true).is.not.ok; - }; - - /** - * ### .equal(actual, expected, [message]) - * - * Asserts non-strict equality (`==`) of `actual` and `expected`. - * - * assert.equal(3, '3', '== coerces values to strings'); - * - * @name equal - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.equal = function (act, exp, msg) { - var test = new Assertion(act, msg, assert.equal, true); - - test.assert( - exp == flag(test, 'object') - , 'expected #{this} to equal #{exp}' - , 'expected #{this} to not equal #{act}' - , exp - , act - , true - ); - }; - - /** - * ### .notEqual(actual, expected, [message]) - * - * Asserts non-strict inequality (`!=`) of `actual` and `expected`. - * - * assert.notEqual(3, 4, 'these numbers are not equal'); - * - * @name notEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notEqual = function (act, exp, msg) { - var test = new Assertion(act, msg, assert.notEqual, true); - - test.assert( - exp != flag(test, 'object') - , 'expected #{this} to not equal #{exp}' - , 'expected #{this} to equal #{act}' - , exp - , act - , true - ); - }; - - /** - * ### .strictEqual(actual, expected, [message]) - * - * Asserts strict equality (`===`) of `actual` and `expected`. - * - * assert.strictEqual(true, true, 'these booleans are strictly equal'); - * - * @name strictEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.strictEqual = function (act, exp, msg) { - new Assertion(act, msg, assert.strictEqual, true).to.equal(exp); - }; - - /** - * ### .notStrictEqual(actual, expected, [message]) - * - * Asserts strict inequality (`!==`) of `actual` and `expected`. - * - * assert.notStrictEqual(3, '3', 'no coercion for strict equality'); - * - * @name notStrictEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notStrictEqual = function (act, exp, msg) { - new Assertion(act, msg, assert.notStrictEqual, true).to.not.equal(exp); - }; - - /** - * ### .deepEqual(actual, expected, [message]) - * - * Asserts that `actual` is deeply equal to `expected`. - * - * assert.deepEqual({ tea: 'green' }, { tea: 'green' }); - * - * @name deepEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @alias deepStrictEqual - * @namespace Assert - * @api public - */ - - assert.deepEqual = assert.deepStrictEqual = function (act, exp, msg) { - new Assertion(act, msg, assert.deepEqual, true).to.eql(exp); - }; - - /** - * ### .notDeepEqual(actual, expected, [message]) - * - * Assert that `actual` is not deeply equal to `expected`. - * - * assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' }); - * - * @name notDeepEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notDeepEqual = function (act, exp, msg) { - new Assertion(act, msg, assert.notDeepEqual, true).to.not.eql(exp); - }; - - /** - * ### .isAbove(valueToCheck, valueToBeAbove, [message]) - * - * Asserts `valueToCheck` is strictly greater than (>) `valueToBeAbove`. - * - * assert.isAbove(5, 2, '5 is strictly greater than 2'); - * - * @name isAbove - * @param {Mixed} valueToCheck - * @param {Mixed} valueToBeAbove - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isAbove = function (val, abv, msg) { - new Assertion(val, msg, assert.isAbove, true).to.be.above(abv); - }; - - /** - * ### .isAtLeast(valueToCheck, valueToBeAtLeast, [message]) - * - * Asserts `valueToCheck` is greater than or equal to (>=) `valueToBeAtLeast`. - * - * assert.isAtLeast(5, 2, '5 is greater or equal to 2'); - * assert.isAtLeast(3, 3, '3 is greater or equal to 3'); - * - * @name isAtLeast - * @param {Mixed} valueToCheck - * @param {Mixed} valueToBeAtLeast - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isAtLeast = function (val, atlst, msg) { - new Assertion(val, msg, assert.isAtLeast, true).to.be.least(atlst); - }; - - /** - * ### .isBelow(valueToCheck, valueToBeBelow, [message]) - * - * Asserts `valueToCheck` is strictly less than (<) `valueToBeBelow`. - * - * assert.isBelow(3, 6, '3 is strictly less than 6'); - * - * @name isBelow - * @param {Mixed} valueToCheck - * @param {Mixed} valueToBeBelow - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isBelow = function (val, blw, msg) { - new Assertion(val, msg, assert.isBelow, true).to.be.below(blw); - }; - - /** - * ### .isAtMost(valueToCheck, valueToBeAtMost, [message]) - * - * Asserts `valueToCheck` is less than or equal to (<=) `valueToBeAtMost`. - * - * assert.isAtMost(3, 6, '3 is less than or equal to 6'); - * assert.isAtMost(4, 4, '4 is less than or equal to 4'); - * - * @name isAtMost - * @param {Mixed} valueToCheck - * @param {Mixed} valueToBeAtMost - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isAtMost = function (val, atmst, msg) { - new Assertion(val, msg, assert.isAtMost, true).to.be.most(atmst); - }; - - /** - * ### .isTrue(value, [message]) - * - * Asserts that `value` is true. - * - * var teaServed = true; - * assert.isTrue(teaServed, 'the tea has been served'); - * - * @name isTrue - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isTrue = function (val, msg) { - new Assertion(val, msg, assert.isTrue, true).is['true']; - }; - - /** - * ### .isNotTrue(value, [message]) - * - * Asserts that `value` is not true. - * - * var tea = 'tasty chai'; - * assert.isNotTrue(tea, 'great, time for tea!'); - * - * @name isNotTrue - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotTrue = function (val, msg) { - new Assertion(val, msg, assert.isNotTrue, true).to.not.equal(true); - }; - - /** - * ### .isFalse(value, [message]) - * - * Asserts that `value` is false. - * - * var teaServed = false; - * assert.isFalse(teaServed, 'no tea yet? hmm...'); - * - * @name isFalse - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isFalse = function (val, msg) { - new Assertion(val, msg, assert.isFalse, true).is['false']; - }; - - /** - * ### .isNotFalse(value, [message]) - * - * Asserts that `value` is not false. - * - * var tea = 'tasty chai'; - * assert.isNotFalse(tea, 'great, time for tea!'); - * - * @name isNotFalse - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotFalse = function (val, msg) { - new Assertion(val, msg, assert.isNotFalse, true).to.not.equal(false); - }; - - /** - * ### .isNull(value, [message]) - * - * Asserts that `value` is null. - * - * assert.isNull(err, 'there was no error'); - * - * @name isNull - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNull = function (val, msg) { - new Assertion(val, msg, assert.isNull, true).to.equal(null); - }; - - /** - * ### .isNotNull(value, [message]) - * - * Asserts that `value` is not null. - * - * var tea = 'tasty chai'; - * assert.isNotNull(tea, 'great, time for tea!'); - * - * @name isNotNull - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotNull = function (val, msg) { - new Assertion(val, msg, assert.isNotNull, true).to.not.equal(null); - }; - - /** - * ### .isNaN - * - * Asserts that value is NaN. - * - * assert.isNaN(NaN, 'NaN is NaN'); - * - * @name isNaN - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNaN = function (val, msg) { - new Assertion(val, msg, assert.isNaN, true).to.be.NaN; - }; - - /** - * ### .isNotNaN - * - * Asserts that value is not NaN. - * - * assert.isNotNaN(4, '4 is not NaN'); - * - * @name isNotNaN - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - assert.isNotNaN = function (val, msg) { - new Assertion(val, msg, assert.isNotNaN, true).not.to.be.NaN; - }; - - /** - * ### .exists - * - * Asserts that the target is neither `null` nor `undefined`. - * - * var foo = 'hi'; - * - * assert.exists(foo, 'foo is neither `null` nor `undefined`'); - * - * @name exists - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.exists = function (val, msg) { - new Assertion(val, msg, assert.exists, true).to.exist; - }; - - /** - * ### .notExists - * - * Asserts that the target is either `null` or `undefined`. - * - * var bar = null - * , baz; - * - * assert.notExists(bar); - * assert.notExists(baz, 'baz is either null or undefined'); - * - * @name notExists - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notExists = function (val, msg) { - new Assertion(val, msg, assert.notExists, true).to.not.exist; - }; - - /** - * ### .isUndefined(value, [message]) - * - * Asserts that `value` is `undefined`. - * - * var tea; - * assert.isUndefined(tea, 'no tea defined'); - * - * @name isUndefined - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isUndefined = function (val, msg) { - new Assertion(val, msg, assert.isUndefined, true).to.equal(undefined); - }; - - /** - * ### .isDefined(value, [message]) - * - * Asserts that `value` is not `undefined`. - * - * var tea = 'cup of chai'; - * assert.isDefined(tea, 'tea has been defined'); - * - * @name isDefined - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isDefined = function (val, msg) { - new Assertion(val, msg, assert.isDefined, true).to.not.equal(undefined); - }; - - /** - * ### .isFunction(value, [message]) - * - * Asserts that `value` is a function. - * - * function serveTea() { return 'cup of tea'; }; - * assert.isFunction(serveTea, 'great, we can have tea now'); - * - * @name isFunction - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isFunction = function (val, msg) { - new Assertion(val, msg, assert.isFunction, true).to.be.a('function'); - }; - - /** - * ### .isNotFunction(value, [message]) - * - * Asserts that `value` is _not_ a function. - * - * var serveTea = [ 'heat', 'pour', 'sip' ]; - * assert.isNotFunction(serveTea, 'great, we have listed the steps'); - * - * @name isNotFunction - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotFunction = function (val, msg) { - new Assertion(val, msg, assert.isNotFunction, true).to.not.be.a('function'); - }; - - /** - * ### .isObject(value, [message]) - * - * Asserts that `value` is an object of type 'Object' (as revealed by `Object.prototype.toString`). - * _The assertion does not match subclassed objects._ - * - * var selection = { name: 'Chai', serve: 'with spices' }; - * assert.isObject(selection, 'tea selection is an object'); - * - * @name isObject - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isObject = function (val, msg) { - new Assertion(val, msg, assert.isObject, true).to.be.a('object'); - }; - - /** - * ### .isNotObject(value, [message]) - * - * Asserts that `value` is _not_ an object of type 'Object' (as revealed by `Object.prototype.toString`). - * - * var selection = 'chai' - * assert.isNotObject(selection, 'tea selection is not an object'); - * assert.isNotObject(null, 'null is not an object'); - * - * @name isNotObject - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotObject = function (val, msg) { - new Assertion(val, msg, assert.isNotObject, true).to.not.be.a('object'); - }; - - /** - * ### .isArray(value, [message]) - * - * Asserts that `value` is an array. - * - * var menu = [ 'green', 'chai', 'oolong' ]; - * assert.isArray(menu, 'what kind of tea do we want?'); - * - * @name isArray - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isArray = function (val, msg) { - new Assertion(val, msg, assert.isArray, true).to.be.an('array'); - }; - - /** - * ### .isNotArray(value, [message]) - * - * Asserts that `value` is _not_ an array. - * - * var menu = 'green|chai|oolong'; - * assert.isNotArray(menu, 'what kind of tea do we want?'); - * - * @name isNotArray - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotArray = function (val, msg) { - new Assertion(val, msg, assert.isNotArray, true).to.not.be.an('array'); - }; - - /** - * ### .isString(value, [message]) - * - * Asserts that `value` is a string. - * - * var teaOrder = 'chai'; - * assert.isString(teaOrder, 'order placed'); - * - * @name isString - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isString = function (val, msg) { - new Assertion(val, msg, assert.isString, true).to.be.a('string'); - }; - - /** - * ### .isNotString(value, [message]) - * - * Asserts that `value` is _not_ a string. - * - * var teaOrder = 4; - * assert.isNotString(teaOrder, 'order placed'); - * - * @name isNotString - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotString = function (val, msg) { - new Assertion(val, msg, assert.isNotString, true).to.not.be.a('string'); - }; - - /** - * ### .isNumber(value, [message]) - * - * Asserts that `value` is a number. - * - * var cups = 2; - * assert.isNumber(cups, 'how many cups'); - * - * @name isNumber - * @param {Number} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNumber = function (val, msg) { - new Assertion(val, msg, assert.isNumber, true).to.be.a('number'); - }; - - /** - * ### .isNotNumber(value, [message]) - * - * Asserts that `value` is _not_ a number. - * - * var cups = '2 cups please'; - * assert.isNotNumber(cups, 'how many cups'); - * - * @name isNotNumber - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotNumber = function (val, msg) { - new Assertion(val, msg, assert.isNotNumber, true).to.not.be.a('number'); - }; - - /** - * ### .isFinite(value, [message]) - * - * Asserts that `value` is a finite number. Unlike `.isNumber`, this will fail for `NaN` and `Infinity`. - * - * var cups = 2; - * assert.isFinite(cups, 'how many cups'); - * - * assert.isFinite(NaN); // throws - * - * @name isFinite - * @param {Number} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isFinite = function (val, msg) { - new Assertion(val, msg, assert.isFinite, true).to.be.finite; - }; - - /** - * ### .isBoolean(value, [message]) - * - * Asserts that `value` is a boolean. - * - * var teaReady = true - * , teaServed = false; - * - * assert.isBoolean(teaReady, 'is the tea ready'); - * assert.isBoolean(teaServed, 'has tea been served'); - * - * @name isBoolean - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isBoolean = function (val, msg) { - new Assertion(val, msg, assert.isBoolean, true).to.be.a('boolean'); - }; - - /** - * ### .isNotBoolean(value, [message]) - * - * Asserts that `value` is _not_ a boolean. - * - * var teaReady = 'yep' - * , teaServed = 'nope'; - * - * assert.isNotBoolean(teaReady, 'is the tea ready'); - * assert.isNotBoolean(teaServed, 'has tea been served'); - * - * @name isNotBoolean - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.isNotBoolean = function (val, msg) { - new Assertion(val, msg, assert.isNotBoolean, true).to.not.be.a('boolean'); - }; - - /** - * ### .typeOf(value, name, [message]) - * - * Asserts that `value`'s type is `name`, as determined by - * `Object.prototype.toString`. - * - * assert.typeOf({ tea: 'chai' }, 'object', 'we have an object'); - * assert.typeOf(['chai', 'jasmine'], 'array', 'we have an array'); - * assert.typeOf('tea', 'string', 'we have a string'); - * assert.typeOf(/tea/, 'regexp', 'we have a regular expression'); - * assert.typeOf(null, 'null', 'we have a null'); - * assert.typeOf(undefined, 'undefined', 'we have an undefined'); - * - * @name typeOf - * @param {Mixed} value - * @param {String} name - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.typeOf = function (val, type, msg) { - new Assertion(val, msg, assert.typeOf, true).to.be.a(type); - }; - - /** - * ### .notTypeOf(value, name, [message]) - * - * Asserts that `value`'s type is _not_ `name`, as determined by - * `Object.prototype.toString`. - * - * assert.notTypeOf('tea', 'number', 'strings are not numbers'); - * - * @name notTypeOf - * @param {Mixed} value - * @param {String} typeof name - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notTypeOf = function (val, type, msg) { - new Assertion(val, msg, assert.notTypeOf, true).to.not.be.a(type); - }; - - /** - * ### .instanceOf(object, constructor, [message]) - * - * Asserts that `value` is an instance of `constructor`. - * - * var Tea = function (name) { this.name = name; } - * , chai = new Tea('chai'); - * - * assert.instanceOf(chai, Tea, 'chai is an instance of tea'); - * - * @name instanceOf - * @param {Object} object - * @param {Constructor} constructor - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.instanceOf = function (val, type, msg) { - new Assertion(val, msg, assert.instanceOf, true).to.be.instanceOf(type); - }; - - /** - * ### .notInstanceOf(object, constructor, [message]) - * - * Asserts `value` is not an instance of `constructor`. - * - * var Tea = function (name) { this.name = name; } - * , chai = new String('chai'); - * - * assert.notInstanceOf(chai, Tea, 'chai is not an instance of tea'); - * - * @name notInstanceOf - * @param {Object} object - * @param {Constructor} constructor - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notInstanceOf = function (val, type, msg) { - new Assertion(val, msg, assert.notInstanceOf, true) - .to.not.be.instanceOf(type); - }; - - /** - * ### .include(haystack, needle, [message]) - * - * Asserts that `haystack` includes `needle`. Can be used to assert the - * inclusion of a value in an array, a substring in a string, or a subset of - * properties in an object. - * - * assert.include([1,2,3], 2, 'array contains value'); - * assert.include('foobar', 'foo', 'string contains substring'); - * assert.include({ foo: 'bar', hello: 'universe' }, { foo: 'bar' }, 'object contains property'); - * - * Strict equality (===) is used. When asserting the inclusion of a value in - * an array, the array is searched for an element that's strictly equal to the - * given value. When asserting a subset of properties in an object, the object - * is searched for the given property keys, checking that each one is present - * and strictly equal to the given property value. For instance: - * - * var obj1 = {a: 1} - * , obj2 = {b: 2}; - * assert.include([obj1, obj2], obj1); - * assert.include({foo: obj1, bar: obj2}, {foo: obj1}); - * assert.include({foo: obj1, bar: obj2}, {foo: obj1, bar: obj2}); - * - * @name include - * @param {Array|String} haystack - * @param {Mixed} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.include = function (exp, inc, msg) { - new Assertion(exp, msg, assert.include, true).include(inc); - }; - - /** - * ### .notInclude(haystack, needle, [message]) - * - * Asserts that `haystack` does not include `needle`. Can be used to assert - * the absence of a value in an array, a substring in a string, or a subset of - * properties in an object. - * - * assert.notInclude([1,2,3], 4, "array doesn't contain value"); - * assert.notInclude('foobar', 'baz', "string doesn't contain substring"); - * assert.notInclude({ foo: 'bar', hello: 'universe' }, { foo: 'baz' }, 'object doesn't contain property'); - * - * Strict equality (===) is used. When asserting the absence of a value in an - * array, the array is searched to confirm the absence of an element that's - * strictly equal to the given value. When asserting a subset of properties in - * an object, the object is searched to confirm that at least one of the given - * property keys is either not present or not strictly equal to the given - * property value. For instance: - * - * var obj1 = {a: 1} - * , obj2 = {b: 2}; - * assert.notInclude([obj1, obj2], {a: 1}); - * assert.notInclude({foo: obj1, bar: obj2}, {foo: {a: 1}}); - * assert.notInclude({foo: obj1, bar: obj2}, {foo: obj1, bar: {b: 2}}); - * - * @name notInclude - * @param {Array|String} haystack - * @param {Mixed} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notInclude = function (exp, inc, msg) { - new Assertion(exp, msg, assert.notInclude, true).not.include(inc); - }; - - /** - * ### .deepInclude(haystack, needle, [message]) - * - * Asserts that `haystack` includes `needle`. Can be used to assert the - * inclusion of a value in an array or a subset of properties in an object. - * Deep equality is used. - * - * var obj1 = {a: 1} - * , obj2 = {b: 2}; - * assert.deepInclude([obj1, obj2], {a: 1}); - * assert.deepInclude({foo: obj1, bar: obj2}, {foo: {a: 1}}); - * assert.deepInclude({foo: obj1, bar: obj2}, {foo: {a: 1}, bar: {b: 2}}); - * - * @name deepInclude - * @param {Array|String} haystack - * @param {Mixed} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.deepInclude = function (exp, inc, msg) { - new Assertion(exp, msg, assert.deepInclude, true).deep.include(inc); - }; - - /** - * ### .notDeepInclude(haystack, needle, [message]) - * - * Asserts that `haystack` does not include `needle`. Can be used to assert - * the absence of a value in an array or a subset of properties in an object. - * Deep equality is used. - * - * var obj1 = {a: 1} - * , obj2 = {b: 2}; - * assert.notDeepInclude([obj1, obj2], {a: 9}); - * assert.notDeepInclude({foo: obj1, bar: obj2}, {foo: {a: 9}}); - * assert.notDeepInclude({foo: obj1, bar: obj2}, {foo: {a: 1}, bar: {b: 9}}); - * - * @name notDeepInclude - * @param {Array|String} haystack - * @param {Mixed} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notDeepInclude = function (exp, inc, msg) { - new Assertion(exp, msg, assert.notDeepInclude, true).not.deep.include(inc); - }; - - /** - * ### .nestedInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' includes 'needle'. - * Can be used to assert the inclusion of a subset of properties in an - * object. - * Enables the use of dot- and bracket-notation for referencing nested - * properties. - * '[]' and '.' in property names can be escaped using double backslashes. - * - * assert.nestedInclude({'.a': {'b': 'x'}}, {'\\.a.[b]': 'x'}); - * assert.nestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'x'}); - * - * @name nestedInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.nestedInclude = function (exp, inc, msg) { - new Assertion(exp, msg, assert.nestedInclude, true).nested.include(inc); - }; - - /** - * ### .notNestedInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' does not include 'needle'. - * Can be used to assert the absence of a subset of properties in an - * object. - * Enables the use of dot- and bracket-notation for referencing nested - * properties. - * '[]' and '.' in property names can be escaped using double backslashes. - * - * assert.notNestedInclude({'.a': {'b': 'x'}}, {'\\.a.b': 'y'}); - * assert.notNestedInclude({'a': {'[b]': 'x'}}, {'a.\\[b\\]': 'y'}); - * - * @name notNestedInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notNestedInclude = function (exp, inc, msg) { - new Assertion(exp, msg, assert.notNestedInclude, true) - .not.nested.include(inc); - }; - - /** - * ### .deepNestedInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' includes 'needle'. - * Can be used to assert the inclusion of a subset of properties in an - * object while checking for deep equality. - * Enables the use of dot- and bracket-notation for referencing nested - * properties. - * '[]' and '.' in property names can be escaped using double backslashes. - * - * assert.deepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {x: 1}}); - * assert.deepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {x: 1}}); - * - * @name deepNestedInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.deepNestedInclude = function(exp, inc, msg) { - new Assertion(exp, msg, assert.deepNestedInclude, true) - .deep.nested.include(inc); - }; - - /** - * ### .notDeepNestedInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' does not include 'needle'. - * Can be used to assert the absence of a subset of properties in an - * object while checking for deep equality. - * Enables the use of dot- and bracket-notation for referencing nested - * properties. - * '[]' and '.' in property names can be escaped using double backslashes. - * - * assert.notDeepNestedInclude({a: {b: [{x: 1}]}}, {'a.b[0]': {y: 1}}) - * assert.notDeepNestedInclude({'.a': {'[b]': {x: 1}}}, {'\\.a.\\[b\\]': {y: 2}}); - * - * @name notDeepNestedInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notDeepNestedInclude = function(exp, inc, msg) { - new Assertion(exp, msg, assert.notDeepNestedInclude, true) - .not.deep.nested.include(inc); - }; - - /** - * ### .ownInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' includes 'needle'. - * Can be used to assert the inclusion of a subset of properties in an - * object while ignoring inherited properties. - * - * assert.ownInclude({ a: 1 }, { a: 1 }); - * - * @name ownInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.ownInclude = function(exp, inc, msg) { - new Assertion(exp, msg, assert.ownInclude, true).own.include(inc); - }; - - /** - * ### .notOwnInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' includes 'needle'. - * Can be used to assert the absence of a subset of properties in an - * object while ignoring inherited properties. - * - * Object.prototype.b = 2; - * - * assert.notOwnInclude({ a: 1 }, { b: 2 }); - * - * @name notOwnInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notOwnInclude = function(exp, inc, msg) { - new Assertion(exp, msg, assert.notOwnInclude, true).not.own.include(inc); - }; - - /** - * ### .deepOwnInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' includes 'needle'. - * Can be used to assert the inclusion of a subset of properties in an - * object while ignoring inherited properties and checking for deep equality. - * - * assert.deepOwnInclude({a: {b: 2}}, {a: {b: 2}}); - * - * @name deepOwnInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.deepOwnInclude = function(exp, inc, msg) { - new Assertion(exp, msg, assert.deepOwnInclude, true) - .deep.own.include(inc); - }; - - /** - * ### .notDeepOwnInclude(haystack, needle, [message]) - * - * Asserts that 'haystack' includes 'needle'. - * Can be used to assert the absence of a subset of properties in an - * object while ignoring inherited properties and checking for deep equality. - * - * assert.notDeepOwnInclude({a: {b: 2}}, {a: {c: 3}}); - * - * @name notDeepOwnInclude - * @param {Object} haystack - * @param {Object} needle - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notDeepOwnInclude = function(exp, inc, msg) { - new Assertion(exp, msg, assert.notDeepOwnInclude, true) - .not.deep.own.include(inc); - }; - - /** - * ### .match(value, regexp, [message]) - * - * Asserts that `value` matches the regular expression `regexp`. - * - * assert.match('foobar', /^foo/, 'regexp matches'); - * - * @name match - * @param {Mixed} value - * @param {RegExp} regexp - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.match = function (exp, re, msg) { - new Assertion(exp, msg, assert.match, true).to.match(re); - }; - - /** - * ### .notMatch(value, regexp, [message]) - * - * Asserts that `value` does not match the regular expression `regexp`. - * - * assert.notMatch('foobar', /^foo/, 'regexp does not match'); - * - * @name notMatch - * @param {Mixed} value - * @param {RegExp} regexp - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notMatch = function (exp, re, msg) { - new Assertion(exp, msg, assert.notMatch, true).to.not.match(re); - }; - - /** - * ### .property(object, property, [message]) - * - * Asserts that `object` has a direct or inherited property named by - * `property`. - * - * assert.property({ tea: { green: 'matcha' }}, 'tea'); - * assert.property({ tea: { green: 'matcha' }}, 'toString'); - * - * @name property - * @param {Object} object - * @param {String} property - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.property = function (obj, prop, msg) { - new Assertion(obj, msg, assert.property, true).to.have.property(prop); - }; - - /** - * ### .notProperty(object, property, [message]) - * - * Asserts that `object` does _not_ have a direct or inherited property named - * by `property`. - * - * assert.notProperty({ tea: { green: 'matcha' }}, 'coffee'); - * - * @name notProperty - * @param {Object} object - * @param {String} property - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notProperty = function (obj, prop, msg) { - new Assertion(obj, msg, assert.notProperty, true) - .to.not.have.property(prop); - }; - - /** - * ### .propertyVal(object, property, value, [message]) - * - * Asserts that `object` has a direct or inherited property named by - * `property` with a value given by `value`. Uses a strict equality check - * (===). - * - * assert.propertyVal({ tea: 'is good' }, 'tea', 'is good'); - * - * @name propertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.propertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.propertyVal, true) - .to.have.property(prop, val); - }; - - /** - * ### .notPropertyVal(object, property, value, [message]) - * - * Asserts that `object` does _not_ have a direct or inherited property named - * by `property` with value given by `value`. Uses a strict equality check - * (===). - * - * assert.notPropertyVal({ tea: 'is good' }, 'tea', 'is bad'); - * assert.notPropertyVal({ tea: 'is good' }, 'coffee', 'is good'); - * - * @name notPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.notPropertyVal, true) - .to.not.have.property(prop, val); - }; - - /** - * ### .deepPropertyVal(object, property, value, [message]) - * - * Asserts that `object` has a direct or inherited property named by - * `property` with a value given by `value`. Uses a deep equality check. - * - * assert.deepPropertyVal({ tea: { green: 'matcha' } }, 'tea', { green: 'matcha' }); - * - * @name deepPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.deepPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.deepPropertyVal, true) - .to.have.deep.property(prop, val); - }; - - /** - * ### .notDeepPropertyVal(object, property, value, [message]) - * - * Asserts that `object` does _not_ have a direct or inherited property named - * by `property` with value given by `value`. Uses a deep equality check. - * - * assert.notDeepPropertyVal({ tea: { green: 'matcha' } }, 'tea', { black: 'matcha' }); - * assert.notDeepPropertyVal({ tea: { green: 'matcha' } }, 'tea', { green: 'oolong' }); - * assert.notDeepPropertyVal({ tea: { green: 'matcha' } }, 'coffee', { green: 'matcha' }); - * - * @name notDeepPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notDeepPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.notDeepPropertyVal, true) - .to.not.have.deep.property(prop, val); - }; - - /** - * ### .ownProperty(object, property, [message]) - * - * Asserts that `object` has a direct property named by `property`. Inherited - * properties aren't checked. - * - * assert.ownProperty({ tea: { green: 'matcha' }}, 'tea'); - * - * @name ownProperty - * @param {Object} object - * @param {String} property - * @param {String} message - * @api public - */ - - assert.ownProperty = function (obj, prop, msg) { - new Assertion(obj, msg, assert.ownProperty, true) - .to.have.own.property(prop); - }; - - /** - * ### .notOwnProperty(object, property, [message]) - * - * Asserts that `object` does _not_ have a direct property named by - * `property`. Inherited properties aren't checked. - * - * assert.notOwnProperty({ tea: { green: 'matcha' }}, 'coffee'); - * assert.notOwnProperty({}, 'toString'); - * - * @name notOwnProperty - * @param {Object} object - * @param {String} property - * @param {String} message - * @api public - */ - - assert.notOwnProperty = function (obj, prop, msg) { - new Assertion(obj, msg, assert.notOwnProperty, true) - .to.not.have.own.property(prop); - }; - - /** - * ### .ownPropertyVal(object, property, value, [message]) - * - * Asserts that `object` has a direct property named by `property` and a value - * equal to the provided `value`. Uses a strict equality check (===). - * Inherited properties aren't checked. - * - * assert.ownPropertyVal({ coffee: 'is good'}, 'coffee', 'is good'); - * - * @name ownPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.ownPropertyVal = function (obj, prop, value, msg) { - new Assertion(obj, msg, assert.ownPropertyVal, true) - .to.have.own.property(prop, value); - }; - - /** - * ### .notOwnPropertyVal(object, property, value, [message]) - * - * Asserts that `object` does _not_ have a direct property named by `property` - * with a value equal to the provided `value`. Uses a strict equality check - * (===). Inherited properties aren't checked. - * - * assert.notOwnPropertyVal({ tea: 'is better'}, 'tea', 'is worse'); - * assert.notOwnPropertyVal({}, 'toString', Object.prototype.toString); - * - * @name notOwnPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.notOwnPropertyVal = function (obj, prop, value, msg) { - new Assertion(obj, msg, assert.notOwnPropertyVal, true) - .to.not.have.own.property(prop, value); - }; - - /** - * ### .deepOwnPropertyVal(object, property, value, [message]) - * - * Asserts that `object` has a direct property named by `property` and a value - * equal to the provided `value`. Uses a deep equality check. Inherited - * properties aren't checked. - * - * assert.deepOwnPropertyVal({ tea: { green: 'matcha' } }, 'tea', { green: 'matcha' }); - * - * @name deepOwnPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.deepOwnPropertyVal = function (obj, prop, value, msg) { - new Assertion(obj, msg, assert.deepOwnPropertyVal, true) - .to.have.deep.own.property(prop, value); - }; - - /** - * ### .notDeepOwnPropertyVal(object, property, value, [message]) - * - * Asserts that `object` does _not_ have a direct property named by `property` - * with a value equal to the provided `value`. Uses a deep equality check. - * Inherited properties aren't checked. - * - * assert.notDeepOwnPropertyVal({ tea: { green: 'matcha' } }, 'tea', { black: 'matcha' }); - * assert.notDeepOwnPropertyVal({ tea: { green: 'matcha' } }, 'tea', { green: 'oolong' }); - * assert.notDeepOwnPropertyVal({ tea: { green: 'matcha' } }, 'coffee', { green: 'matcha' }); - * assert.notDeepOwnPropertyVal({}, 'toString', Object.prototype.toString); - * - * @name notDeepOwnPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @api public - */ - - assert.notDeepOwnPropertyVal = function (obj, prop, value, msg) { - new Assertion(obj, msg, assert.notDeepOwnPropertyVal, true) - .to.not.have.deep.own.property(prop, value); - }; - - /** - * ### .nestedProperty(object, property, [message]) - * - * Asserts that `object` has a direct or inherited property named by - * `property`, which can be a string using dot- and bracket-notation for - * nested reference. - * - * assert.nestedProperty({ tea: { green: 'matcha' }}, 'tea.green'); - * - * @name nestedProperty - * @param {Object} object - * @param {String} property - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.nestedProperty = function (obj, prop, msg) { - new Assertion(obj, msg, assert.nestedProperty, true) - .to.have.nested.property(prop); - }; - - /** - * ### .notNestedProperty(object, property, [message]) - * - * Asserts that `object` does _not_ have a property named by `property`, which - * can be a string using dot- and bracket-notation for nested reference. The - * property cannot exist on the object nor anywhere in its prototype chain. - * - * assert.notNestedProperty({ tea: { green: 'matcha' }}, 'tea.oolong'); - * - * @name notNestedProperty - * @param {Object} object - * @param {String} property - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notNestedProperty = function (obj, prop, msg) { - new Assertion(obj, msg, assert.notNestedProperty, true) - .to.not.have.nested.property(prop); - }; - - /** - * ### .nestedPropertyVal(object, property, value, [message]) - * - * Asserts that `object` has a property named by `property` with value given - * by `value`. `property` can use dot- and bracket-notation for nested - * reference. Uses a strict equality check (===). - * - * assert.nestedPropertyVal({ tea: { green: 'matcha' }}, 'tea.green', 'matcha'); - * - * @name nestedPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.nestedPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.nestedPropertyVal, true) - .to.have.nested.property(prop, val); - }; - - /** - * ### .notNestedPropertyVal(object, property, value, [message]) - * - * Asserts that `object` does _not_ have a property named by `property` with - * value given by `value`. `property` can use dot- and bracket-notation for - * nested reference. Uses a strict equality check (===). - * - * assert.notNestedPropertyVal({ tea: { green: 'matcha' }}, 'tea.green', 'konacha'); - * assert.notNestedPropertyVal({ tea: { green: 'matcha' }}, 'coffee.green', 'matcha'); - * - * @name notNestedPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notNestedPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.notNestedPropertyVal, true) - .to.not.have.nested.property(prop, val); - }; - - /** - * ### .deepNestedPropertyVal(object, property, value, [message]) - * - * Asserts that `object` has a property named by `property` with a value given - * by `value`. `property` can use dot- and bracket-notation for nested - * reference. Uses a deep equality check. - * - * assert.deepNestedPropertyVal({ tea: { green: { matcha: 'yum' } } }, 'tea.green', { matcha: 'yum' }); - * - * @name deepNestedPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.deepNestedPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.deepNestedPropertyVal, true) - .to.have.deep.nested.property(prop, val); - }; - - /** - * ### .notDeepNestedPropertyVal(object, property, value, [message]) - * - * Asserts that `object` does _not_ have a property named by `property` with - * value given by `value`. `property` can use dot- and bracket-notation for - * nested reference. Uses a deep equality check. - * - * assert.notDeepNestedPropertyVal({ tea: { green: { matcha: 'yum' } } }, 'tea.green', { oolong: 'yum' }); - * assert.notDeepNestedPropertyVal({ tea: { green: { matcha: 'yum' } } }, 'tea.green', { matcha: 'yuck' }); - * assert.notDeepNestedPropertyVal({ tea: { green: { matcha: 'yum' } } }, 'tea.black', { matcha: 'yum' }); - * - * @name notDeepNestedPropertyVal - * @param {Object} object - * @param {String} property - * @param {Mixed} value - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notDeepNestedPropertyVal = function (obj, prop, val, msg) { - new Assertion(obj, msg, assert.notDeepNestedPropertyVal, true) - .to.not.have.deep.nested.property(prop, val); - } - - /** - * ### .lengthOf(object, length, [message]) - * - * Asserts that `object` has a `length` or `size` with the expected value. - * - * assert.lengthOf([1,2,3], 3, 'array has length of 3'); - * assert.lengthOf('foobar', 6, 'string has length of 6'); - * assert.lengthOf(new Set([1,2,3]), 3, 'set has size of 3'); - * assert.lengthOf(new Map([['a',1],['b',2],['c',3]]), 3, 'map has size of 3'); - * - * @name lengthOf - * @param {Mixed} object - * @param {Number} length - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.lengthOf = function (exp, len, msg) { - new Assertion(exp, msg, assert.lengthOf, true).to.have.lengthOf(len); - }; - - /** - * ### .hasAnyKeys(object, [keys], [message]) - * - * Asserts that `object` has at least one of the `keys` provided. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.hasAnyKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'iDontExist', 'baz']); - * assert.hasAnyKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, iDontExist: 99, baz: 1337}); - * assert.hasAnyKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']); - * assert.hasAnyKeys(new Set([{foo: 'bar'}, 'anotherKey']), [{foo: 'bar'}, 'anotherKey']); - * - * @name hasAnyKeys - * @param {Mixed} object - * @param {Array|Object} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.hasAnyKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.hasAnyKeys, true).to.have.any.keys(keys); - } - - /** - * ### .hasAllKeys(object, [keys], [message]) - * - * Asserts that `object` has all and only all of the `keys` provided. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.hasAllKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'bar', 'baz']); - * assert.hasAllKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, bar: 99, baz: 1337]); - * assert.hasAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']); - * assert.hasAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{foo: 'bar'}, 'anotherKey']); - * - * @name hasAllKeys - * @param {Mixed} object - * @param {String[]} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.hasAllKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.hasAllKeys, true).to.have.all.keys(keys); - } - - /** - * ### .containsAllKeys(object, [keys], [message]) - * - * Asserts that `object` has all of the `keys` provided but may have more keys not listed. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'baz']); - * assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, ['foo', 'bar', 'baz']); - * assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, baz: 1337}); - * assert.containsAllKeys({foo: 1, bar: 2, baz: 3}, {foo: 30, bar: 99, baz: 1337}); - * assert.containsAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}]); - * assert.containsAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{foo: 1}, 'key']); - * assert.containsAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{foo: 'bar'}]); - * assert.containsAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{foo: 'bar'}, 'anotherKey']); - * - * @name containsAllKeys - * @param {Mixed} object - * @param {String[]} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.containsAllKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.containsAllKeys, true) - .to.contain.all.keys(keys); - } - - /** - * ### .doesNotHaveAnyKeys(object, [keys], [message]) - * - * Asserts that `object` has none of the `keys` provided. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.doesNotHaveAnyKeys({foo: 1, bar: 2, baz: 3}, ['one', 'two', 'example']); - * assert.doesNotHaveAnyKeys({foo: 1, bar: 2, baz: 3}, {one: 1, two: 2, example: 'foo'}); - * assert.doesNotHaveAnyKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{one: 'two'}, 'example']); - * assert.doesNotHaveAnyKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{one: 'two'}, 'example']); - * - * @name doesNotHaveAnyKeys - * @param {Mixed} object - * @param {String[]} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.doesNotHaveAnyKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.doesNotHaveAnyKeys, true) - .to.not.have.any.keys(keys); - } - - /** - * ### .doesNotHaveAllKeys(object, [keys], [message]) - * - * Asserts that `object` does not have at least one of the `keys` provided. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.doesNotHaveAllKeys({foo: 1, bar: 2, baz: 3}, ['one', 'two', 'example']); - * assert.doesNotHaveAllKeys({foo: 1, bar: 2, baz: 3}, {one: 1, two: 2, example: 'foo'}); - * assert.doesNotHaveAllKeys(new Map([[{foo: 1}, 'bar'], ['key', 'value']]), [{one: 'two'}, 'example']); - * assert.doesNotHaveAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{one: 'two'}, 'example']); - * - * @name doesNotHaveAllKeys - * @param {Mixed} object - * @param {String[]} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.doesNotHaveAllKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.doesNotHaveAllKeys, true) - .to.not.have.all.keys(keys); - } - - /** - * ### .hasAnyDeepKeys(object, [keys], [message]) - * - * Asserts that `object` has at least one of the `keys` provided. - * Since Sets and Maps can have objects as keys you can use this assertion to perform - * a deep comparison. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {one: 'one'}); - * assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), [{one: 'one'}, {two: 'two'}]); - * assert.hasAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]); - * assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {one: 'one'}); - * assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {three: 'three'}]); - * assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]); - * - * @name hasAnyDeepKeys - * @param {Mixed} object - * @param {Array|Object} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.hasAnyDeepKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.hasAnyDeepKeys, true) - .to.have.any.deep.keys(keys); - } - - /** - * ### .hasAllDeepKeys(object, [keys], [message]) - * - * Asserts that `object` has all and only all of the `keys` provided. - * Since Sets and Maps can have objects as keys you can use this assertion to perform - * a deep comparison. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.hasAllDeepKeys(new Map([[{one: 'one'}, 'valueOne']]), {one: 'one'}); - * assert.hasAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]); - * assert.hasAllDeepKeys(new Set([{one: 'one'}]), {one: 'one'}); - * assert.hasAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]); - * - * @name hasAllDeepKeys - * @param {Mixed} object - * @param {Array|Object} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.hasAllDeepKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.hasAllDeepKeys, true) - .to.have.all.deep.keys(keys); - } - - /** - * ### .containsAllDeepKeys(object, [keys], [message]) - * - * Asserts that `object` contains all of the `keys` provided. - * Since Sets and Maps can have objects as keys you can use this assertion to perform - * a deep comparison. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.containsAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {one: 'one'}); - * assert.containsAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{one: 'one'}, {two: 'two'}]); - * assert.containsAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {one: 'one'}); - * assert.containsAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]); - * - * @name containsAllDeepKeys - * @param {Mixed} object - * @param {Array|Object} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.containsAllDeepKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.containsAllDeepKeys, true) - .to.contain.all.deep.keys(keys); - } - - /** - * ### .doesNotHaveAnyDeepKeys(object, [keys], [message]) - * - * Asserts that `object` has none of the `keys` provided. - * Since Sets and Maps can have objects as keys you can use this assertion to perform - * a deep comparison. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.doesNotHaveAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {thisDoesNot: 'exist'}); - * assert.doesNotHaveAnyDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{twenty: 'twenty'}, {fifty: 'fifty'}]); - * assert.doesNotHaveAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {twenty: 'twenty'}); - * assert.doesNotHaveAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{twenty: 'twenty'}, {fifty: 'fifty'}]); - * - * @name doesNotHaveAnyDeepKeys - * @param {Mixed} object - * @param {Array|Object} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.doesNotHaveAnyDeepKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.doesNotHaveAnyDeepKeys, true) - .to.not.have.any.deep.keys(keys); - } - - /** - * ### .doesNotHaveAllDeepKeys(object, [keys], [message]) - * - * Asserts that `object` does not have at least one of the `keys` provided. - * Since Sets and Maps can have objects as keys you can use this assertion to perform - * a deep comparison. - * You can also provide a single object instead of a `keys` array and its keys - * will be used as the expected set of keys. - * - * assert.doesNotHaveAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [1, 2]]), {thisDoesNot: 'exist'}); - * assert.doesNotHaveAllDeepKeys(new Map([[{one: 'one'}, 'valueOne'], [{two: 'two'}, 'valueTwo']]), [{twenty: 'twenty'}, {one: 'one'}]); - * assert.doesNotHaveAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), {twenty: 'twenty'}); - * assert.doesNotHaveAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {fifty: 'fifty'}]); - * - * @name doesNotHaveAllDeepKeys - * @param {Mixed} object - * @param {Array|Object} keys - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.doesNotHaveAllDeepKeys = function (obj, keys, msg) { - new Assertion(obj, msg, assert.doesNotHaveAllDeepKeys, true) - .to.not.have.all.deep.keys(keys); - } - - /** - * ### .throws(fn, [errorLike/string/regexp], [string/regexp], [message]) - * - * If `errorLike` is an `Error` constructor, asserts that `fn` will throw an error that is an - * instance of `errorLike`. - * If `errorLike` is an `Error` instance, asserts that the error thrown is the same - * instance as `errorLike`. - * If `errMsgMatcher` is provided, it also asserts that the error thrown will have a - * message matching `errMsgMatcher`. - * - * assert.throws(fn, 'Error thrown must have this msg'); - * assert.throws(fn, /Error thrown must have a msg that matches this/); - * assert.throws(fn, ReferenceError); - * assert.throws(fn, errorInstance); - * assert.throws(fn, ReferenceError, 'Error thrown must be a ReferenceError and have this msg'); - * assert.throws(fn, errorInstance, 'Error thrown must be the same errorInstance and have this msg'); - * assert.throws(fn, ReferenceError, /Error thrown must be a ReferenceError and match this/); - * assert.throws(fn, errorInstance, /Error thrown must be the same errorInstance and match this/); - * - * @name throws - * @alias throw - * @alias Throw - * @param {Function} fn - * @param {ErrorConstructor|Error} errorLike - * @param {RegExp|String} errMsgMatcher - * @param {String} message - * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types - * @namespace Assert - * @api public - */ - - assert.throws = function (fn, errorLike, errMsgMatcher, msg) { - if ('string' === typeof errorLike || errorLike instanceof RegExp) { - errMsgMatcher = errorLike; - errorLike = null; - } - - var assertErr = new Assertion(fn, msg, assert.throws, true) - .to.throw(errorLike, errMsgMatcher); - return flag(assertErr, 'object'); - }; - - /** - * ### .doesNotThrow(fn, [errorLike/string/regexp], [string/regexp], [message]) - * - * If `errorLike` is an `Error` constructor, asserts that `fn` will _not_ throw an error that is an - * instance of `errorLike`. - * If `errorLike` is an `Error` instance, asserts that the error thrown is _not_ the same - * instance as `errorLike`. - * If `errMsgMatcher` is provided, it also asserts that the error thrown will _not_ have a - * message matching `errMsgMatcher`. - * - * assert.doesNotThrow(fn, 'Any Error thrown must not have this message'); - * assert.doesNotThrow(fn, /Any Error thrown must not match this/); - * assert.doesNotThrow(fn, Error); - * assert.doesNotThrow(fn, errorInstance); - * assert.doesNotThrow(fn, Error, 'Error must not have this message'); - * assert.doesNotThrow(fn, errorInstance, 'Error must not have this message'); - * assert.doesNotThrow(fn, Error, /Error must not match this/); - * assert.doesNotThrow(fn, errorInstance, /Error must not match this/); - * - * @name doesNotThrow - * @param {Function} fn - * @param {ErrorConstructor} errorLike - * @param {RegExp|String} errMsgMatcher - * @param {String} message - * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types - * @namespace Assert - * @api public - */ - - assert.doesNotThrow = function (fn, errorLike, errMsgMatcher, msg) { - if ('string' === typeof errorLike || errorLike instanceof RegExp) { - errMsgMatcher = errorLike; - errorLike = null; - } - - new Assertion(fn, msg, assert.doesNotThrow, true) - .to.not.throw(errorLike, errMsgMatcher); - }; - - /** - * ### .operator(val1, operator, val2, [message]) - * - * Compares two values using `operator`. - * - * assert.operator(1, '<', 2, 'everything is ok'); - * assert.operator(1, '>', 2, 'this will fail'); - * - * @name operator - * @param {Mixed} val1 - * @param {String} operator - * @param {Mixed} val2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.operator = function (val, operator, val2, msg) { - var ok; - switch(operator) { - case '==': - ok = val == val2; - break; - case '===': - ok = val === val2; - break; - case '>': - ok = val > val2; - break; - case '>=': - ok = val >= val2; - break; - case '<': - ok = val < val2; - break; - case '<=': - ok = val <= val2; - break; - case '!=': - ok = val != val2; - break; - case '!==': - ok = val !== val2; - break; - default: - msg = msg ? msg + ': ' : msg; - throw new chai.AssertionError( - msg + 'Invalid operator "' + operator + '"', - undefined, - assert.operator - ); - } - var test = new Assertion(ok, msg, assert.operator, true); - test.assert( - true === flag(test, 'object') - , 'expected ' + util.inspect(val) + ' to be ' + operator + ' ' + util.inspect(val2) - , 'expected ' + util.inspect(val) + ' to not be ' + operator + ' ' + util.inspect(val2) ); - }; - - /** - * ### .closeTo(actual, expected, delta, [message]) - * - * Asserts that the target is equal `expected`, to within a +/- `delta` range. - * - * assert.closeTo(1.5, 1, 0.5, 'numbers are close'); - * - * @name closeTo - * @param {Number} actual - * @param {Number} expected - * @param {Number} delta - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.closeTo = function (act, exp, delta, msg) { - new Assertion(act, msg, assert.closeTo, true).to.be.closeTo(exp, delta); - }; - - /** - * ### .approximately(actual, expected, delta, [message]) - * - * Asserts that the target is equal `expected`, to within a +/- `delta` range. - * - * assert.approximately(1.5, 1, 0.5, 'numbers are close'); - * - * @name approximately - * @param {Number} actual - * @param {Number} expected - * @param {Number} delta - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.approximately = function (act, exp, delta, msg) { - new Assertion(act, msg, assert.approximately, true) - .to.be.approximately(exp, delta); - }; - - /** - * ### .sameMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` have the same members in any order. Uses a - * strict equality check (===). - * - * assert.sameMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'same members'); - * - * @name sameMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.sameMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.sameMembers, true) - .to.have.same.members(set2); - } - - /** - * ### .notSameMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` don't have the same members in any order. - * Uses a strict equality check (===). - * - * assert.notSameMembers([ 1, 2, 3 ], [ 5, 1, 3 ], 'not same members'); - * - * @name notSameMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notSameMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.notSameMembers, true) - .to.not.have.same.members(set2); - } - - /** - * ### .sameDeepMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` have the same members in any order. Uses a - * deep equality check. - * - * assert.sameDeepMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [{ b: 2 }, { a: 1 }, { c: 3 }], 'same deep members'); - * - * @name sameDeepMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.sameDeepMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.sameDeepMembers, true) - .to.have.same.deep.members(set2); - } - - /** - * ### .notSameDeepMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` don't have the same members in any order. - * Uses a deep equality check. - * - * assert.notSameDeepMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [{ b: 2 }, { a: 1 }, { f: 5 }], 'not same deep members'); - * - * @name notSameDeepMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notSameDeepMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.notSameDeepMembers, true) - .to.not.have.same.deep.members(set2); - } - - /** - * ### .sameOrderedMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` have the same members in the same order. - * Uses a strict equality check (===). - * - * assert.sameOrderedMembers([ 1, 2, 3 ], [ 1, 2, 3 ], 'same ordered members'); - * - * @name sameOrderedMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.sameOrderedMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.sameOrderedMembers, true) - .to.have.same.ordered.members(set2); - } - - /** - * ### .notSameOrderedMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` don't have the same members in the same - * order. Uses a strict equality check (===). - * - * assert.notSameOrderedMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'not same ordered members'); - * - * @name notSameOrderedMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notSameOrderedMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.notSameOrderedMembers, true) - .to.not.have.same.ordered.members(set2); - } - - /** - * ### .sameDeepOrderedMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` have the same members in the same order. - * Uses a deep equality check. - * - * assert.sameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { c: 3 } ], 'same deep ordered members'); - * - * @name sameDeepOrderedMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.sameDeepOrderedMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.sameDeepOrderedMembers, true) - .to.have.same.deep.ordered.members(set2); - } - - /** - * ### .notSameDeepOrderedMembers(set1, set2, [message]) - * - * Asserts that `set1` and `set2` don't have the same members in the same - * order. Uses a deep equality check. - * - * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { z: 5 } ], 'not same deep ordered members'); - * assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { c: 3 } ], 'not same deep ordered members'); - * - * @name notSameDeepOrderedMembers - * @param {Array} set1 - * @param {Array} set2 - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notSameDeepOrderedMembers = function (set1, set2, msg) { - new Assertion(set1, msg, assert.notSameDeepOrderedMembers, true) - .to.not.have.same.deep.ordered.members(set2); - } - - /** - * ### .includeMembers(superset, subset, [message]) - * - * Asserts that `subset` is included in `superset` in any order. Uses a - * strict equality check (===). Duplicates are ignored. - * - * assert.includeMembers([ 1, 2, 3 ], [ 2, 1, 2 ], 'include members'); - * - * @name includeMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.includeMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.includeMembers, true) - .to.include.members(subset); - } - - /** - * ### .notIncludeMembers(superset, subset, [message]) - * - * Asserts that `subset` isn't included in `superset` in any order. Uses a - * strict equality check (===). Duplicates are ignored. - * - * assert.notIncludeMembers([ 1, 2, 3 ], [ 5, 1 ], 'not include members'); - * - * @name notIncludeMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notIncludeMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.notIncludeMembers, true) - .to.not.include.members(subset); - } - - /** - * ### .includeDeepMembers(superset, subset, [message]) - * - * Asserts that `subset` is included in `superset` in any order. Uses a deep - * equality check. Duplicates are ignored. - * - * assert.includeDeepMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { b: 2 } ], 'include deep members'); - * - * @name includeDeepMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.includeDeepMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.includeDeepMembers, true) - .to.include.deep.members(subset); - } - - /** - * ### .notIncludeDeepMembers(superset, subset, [message]) - * - * Asserts that `subset` isn't included in `superset` in any order. Uses a - * deep equality check. Duplicates are ignored. - * - * assert.notIncludeDeepMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { f: 5 } ], 'not include deep members'); - * - * @name notIncludeDeepMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notIncludeDeepMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.notIncludeDeepMembers, true) - .to.not.include.deep.members(subset); - } - - /** - * ### .includeOrderedMembers(superset, subset, [message]) - * - * Asserts that `subset` is included in `superset` in the same order - * beginning with the first element in `superset`. Uses a strict equality - * check (===). - * - * assert.includeOrderedMembers([ 1, 2, 3 ], [ 1, 2 ], 'include ordered members'); - * - * @name includeOrderedMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.includeOrderedMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.includeOrderedMembers, true) - .to.include.ordered.members(subset); - } - - /** - * ### .notIncludeOrderedMembers(superset, subset, [message]) - * - * Asserts that `subset` isn't included in `superset` in the same order - * beginning with the first element in `superset`. Uses a strict equality - * check (===). - * - * assert.notIncludeOrderedMembers([ 1, 2, 3 ], [ 2, 1 ], 'not include ordered members'); - * assert.notIncludeOrderedMembers([ 1, 2, 3 ], [ 2, 3 ], 'not include ordered members'); - * - * @name notIncludeOrderedMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notIncludeOrderedMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.notIncludeOrderedMembers, true) - .to.not.include.ordered.members(subset); - } - - /** - * ### .includeDeepOrderedMembers(superset, subset, [message]) - * - * Asserts that `subset` is included in `superset` in the same order - * beginning with the first element in `superset`. Uses a deep equality - * check. - * - * assert.includeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 } ], 'include deep ordered members'); - * - * @name includeDeepOrderedMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.includeDeepOrderedMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.includeDeepOrderedMembers, true) - .to.include.deep.ordered.members(subset); - } - - /** - * ### .notIncludeDeepOrderedMembers(superset, subset, [message]) - * - * Asserts that `subset` isn't included in `superset` in the same order - * beginning with the first element in `superset`. Uses a deep equality - * check. - * - * assert.notIncludeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { f: 5 } ], 'not include deep ordered members'); - * assert.notIncludeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 } ], 'not include deep ordered members'); - * assert.notIncludeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { c: 3 } ], 'not include deep ordered members'); - * - * @name notIncludeDeepOrderedMembers - * @param {Array} superset - * @param {Array} subset - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.notIncludeDeepOrderedMembers = function (superset, subset, msg) { - new Assertion(superset, msg, assert.notIncludeDeepOrderedMembers, true) - .to.not.include.deep.ordered.members(subset); - } - - /** - * ### .oneOf(inList, list, [message]) - * - * Asserts that non-object, non-array value `inList` appears in the flat array `list`. - * - * assert.oneOf(1, [ 2, 1 ], 'Not found in list'); - * - * @name oneOf - * @param {*} inList - * @param {Array<*>} list - * @param {String} message - * @namespace Assert - * @api public - */ - - assert.oneOf = function (inList, list, msg) { - new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list); - } - - /** - * ### .changes(function, object, property, [message]) - * - * Asserts that a function changes the value of a property. - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 22 }; - * assert.changes(fn, obj, 'val'); - * - * @name changes - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.changes = function (fn, obj, prop, msg) { - if (arguments.length === 3 && typeof obj === 'function') { - msg = prop; - prop = null; - } - - new Assertion(fn, msg, assert.changes, true).to.change(obj, prop); - } - - /** - * ### .changesBy(function, object, property, delta, [message]) - * - * Asserts that a function changes the value of a property by an amount (delta). - * - * var obj = { val: 10 }; - * var fn = function() { obj.val += 2 }; - * assert.changesBy(fn, obj, 'val', 2); - * - * @name changesBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.changesBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - new Assertion(fn, msg, assert.changesBy, true) - .to.change(obj, prop).by(delta); - } - - /** - * ### .doesNotChange(function, object, property, [message]) - * - * Asserts that a function does not change the value of a property. - * - * var obj = { val: 10 }; - * var fn = function() { console.log('foo'); }; - * assert.doesNotChange(fn, obj, 'val'); - * - * @name doesNotChange - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.doesNotChange = function (fn, obj, prop, msg) { - if (arguments.length === 3 && typeof obj === 'function') { - msg = prop; - prop = null; - } - - return new Assertion(fn, msg, assert.doesNotChange, true) - .to.not.change(obj, prop); - } - - /** - * ### .changesButNotBy(function, object, property, delta, [message]) - * - * Asserts that a function does not change the value of a property or of a function's return value by an amount (delta) - * - * var obj = { val: 10 }; - * var fn = function() { obj.val += 10 }; - * assert.changesButNotBy(fn, obj, 'val', 5); - * - * @name changesButNotBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.changesButNotBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - new Assertion(fn, msg, assert.changesButNotBy, true) - .to.change(obj, prop).but.not.by(delta); - } - - /** - * ### .increases(function, object, property, [message]) - * - * Asserts that a function increases a numeric object property. - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 13 }; - * assert.increases(fn, obj, 'val'); - * - * @name increases - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.increases = function (fn, obj, prop, msg) { - if (arguments.length === 3 && typeof obj === 'function') { - msg = prop; - prop = null; - } - - return new Assertion(fn, msg, assert.increases, true) - .to.increase(obj, prop); - } - - /** - * ### .increasesBy(function, object, property, delta, [message]) - * - * Asserts that a function increases a numeric object property or a function's return value by an amount (delta). - * - * var obj = { val: 10 }; - * var fn = function() { obj.val += 10 }; - * assert.increasesBy(fn, obj, 'val', 10); - * - * @name increasesBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.increasesBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - new Assertion(fn, msg, assert.increasesBy, true) - .to.increase(obj, prop).by(delta); - } - - /** - * ### .doesNotIncrease(function, object, property, [message]) - * - * Asserts that a function does not increase a numeric object property. - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 8 }; - * assert.doesNotIncrease(fn, obj, 'val'); - * - * @name doesNotIncrease - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.doesNotIncrease = function (fn, obj, prop, msg) { - if (arguments.length === 3 && typeof obj === 'function') { - msg = prop; - prop = null; - } - - return new Assertion(fn, msg, assert.doesNotIncrease, true) - .to.not.increase(obj, prop); - } - - /** - * ### .increasesButNotBy(function, object, property, delta, [message]) - * - * Asserts that a function does not increase a numeric object property or function's return value by an amount (delta). - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 15 }; - * assert.increasesButNotBy(fn, obj, 'val', 10); - * - * @name increasesButNotBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.increasesButNotBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - new Assertion(fn, msg, assert.increasesButNotBy, true) - .to.increase(obj, prop).but.not.by(delta); - } - - /** - * ### .decreases(function, object, property, [message]) - * - * Asserts that a function decreases a numeric object property. - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 5 }; - * assert.decreases(fn, obj, 'val'); - * - * @name decreases - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.decreases = function (fn, obj, prop, msg) { - if (arguments.length === 3 && typeof obj === 'function') { - msg = prop; - prop = null; - } - - return new Assertion(fn, msg, assert.decreases, true) - .to.decrease(obj, prop); - } - - /** - * ### .decreasesBy(function, object, property, delta, [message]) - * - * Asserts that a function decreases a numeric object property or a function's return value by an amount (delta) - * - * var obj = { val: 10 }; - * var fn = function() { obj.val -= 5 }; - * assert.decreasesBy(fn, obj, 'val', 5); - * - * @name decreasesBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.decreasesBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - new Assertion(fn, msg, assert.decreasesBy, true) - .to.decrease(obj, prop).by(delta); - } - - /** - * ### .doesNotDecrease(function, object, property, [message]) - * - * Asserts that a function does not decreases a numeric object property. - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 15 }; - * assert.doesNotDecrease(fn, obj, 'val'); - * - * @name doesNotDecrease - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.doesNotDecrease = function (fn, obj, prop, msg) { - if (arguments.length === 3 && typeof obj === 'function') { - msg = prop; - prop = null; - } - - return new Assertion(fn, msg, assert.doesNotDecrease, true) - .to.not.decrease(obj, prop); - } - - /** - * ### .doesNotDecreaseBy(function, object, property, delta, [message]) - * - * Asserts that a function does not decreases a numeric object property or a function's return value by an amount (delta) - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 5 }; - * assert.doesNotDecreaseBy(fn, obj, 'val', 1); - * - * @name doesNotDecreaseBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.doesNotDecreaseBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - return new Assertion(fn, msg, assert.doesNotDecreaseBy, true) - .to.not.decrease(obj, prop).by(delta); - } - - /** - * ### .decreasesButNotBy(function, object, property, delta, [message]) - * - * Asserts that a function does not decreases a numeric object property or a function's return value by an amount (delta) - * - * var obj = { val: 10 }; - * var fn = function() { obj.val = 5 }; - * assert.decreasesButNotBy(fn, obj, 'val', 1); - * - * @name decreasesButNotBy - * @param {Function} modifier function - * @param {Object} object or getter function - * @param {String} property name _optional_ - * @param {Number} change amount (delta) - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.decreasesButNotBy = function (fn, obj, prop, delta, msg) { - if (arguments.length === 4 && typeof obj === 'function') { - var tmpMsg = delta; - delta = prop; - msg = tmpMsg; - } else if (arguments.length === 3) { - delta = prop; - prop = null; - } - - new Assertion(fn, msg, assert.decreasesButNotBy, true) - .to.decrease(obj, prop).but.not.by(delta); - } - - /*! - * ### .ifError(object) - * - * Asserts if value is not a false value, and throws if it is a true value. - * This is added to allow for chai to be a drop-in replacement for Node's - * assert class. - * - * var err = new Error('I am a custom error'); - * assert.ifError(err); // Rethrows err! - * - * @name ifError - * @param {Object} object - * @namespace Assert - * @api public - */ - - assert.ifError = function (val) { - if (val) { - throw(val); - } - }; - - /** - * ### .isExtensible(object) - * - * Asserts that `object` is extensible (can have new properties added to it). - * - * assert.isExtensible({}); - * - * @name isExtensible - * @alias extensible - * @param {Object} object - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isExtensible = function (obj, msg) { - new Assertion(obj, msg, assert.isExtensible, true).to.be.extensible; - }; - - /** - * ### .isNotExtensible(object) - * - * Asserts that `object` is _not_ extensible. - * - * var nonExtensibleObject = Object.preventExtensions({}); - * var sealedObject = Object.seal({}); - * var frozenObject = Object.freeze({}); - * - * assert.isNotExtensible(nonExtensibleObject); - * assert.isNotExtensible(sealedObject); - * assert.isNotExtensible(frozenObject); - * - * @name isNotExtensible - * @alias notExtensible - * @param {Object} object - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isNotExtensible = function (obj, msg) { - new Assertion(obj, msg, assert.isNotExtensible, true).to.not.be.extensible; - }; - - /** - * ### .isSealed(object) - * - * Asserts that `object` is sealed (cannot have new properties added to it - * and its existing properties cannot be removed). - * - * var sealedObject = Object.seal({}); - * var frozenObject = Object.seal({}); - * - * assert.isSealed(sealedObject); - * assert.isSealed(frozenObject); - * - * @name isSealed - * @alias sealed - * @param {Object} object - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isSealed = function (obj, msg) { - new Assertion(obj, msg, assert.isSealed, true).to.be.sealed; - }; - - /** - * ### .isNotSealed(object) - * - * Asserts that `object` is _not_ sealed. - * - * assert.isNotSealed({}); - * - * @name isNotSealed - * @alias notSealed - * @param {Object} object - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isNotSealed = function (obj, msg) { - new Assertion(obj, msg, assert.isNotSealed, true).to.not.be.sealed; - }; - - /** - * ### .isFrozen(object) - * - * Asserts that `object` is frozen (cannot have new properties added to it - * and its existing properties cannot be modified). - * - * var frozenObject = Object.freeze({}); - * assert.frozen(frozenObject); - * - * @name isFrozen - * @alias frozen - * @param {Object} object - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isFrozen = function (obj, msg) { - new Assertion(obj, msg, assert.isFrozen, true).to.be.frozen; - }; - - /** - * ### .isNotFrozen(object) - * - * Asserts that `object` is _not_ frozen. - * - * assert.isNotFrozen({}); - * - * @name isNotFrozen - * @alias notFrozen - * @param {Object} object - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isNotFrozen = function (obj, msg) { - new Assertion(obj, msg, assert.isNotFrozen, true).to.not.be.frozen; - }; - - /** - * ### .isEmpty(target) - * - * Asserts that the target does not contain any values. - * For arrays and strings, it checks the `length` property. - * For `Map` and `Set` instances, it checks the `size` property. - * For non-function objects, it gets the count of own - * enumerable string keys. - * - * assert.isEmpty([]); - * assert.isEmpty(''); - * assert.isEmpty(new Map); - * assert.isEmpty({}); - * - * @name isEmpty - * @alias empty - * @param {Object|Array|String|Map|Set} target - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isEmpty = function(val, msg) { - new Assertion(val, msg, assert.isEmpty, true).to.be.empty; - }; - - /** - * ### .isNotEmpty(target) - * - * Asserts that the target contains values. - * For arrays and strings, it checks the `length` property. - * For `Map` and `Set` instances, it checks the `size` property. - * For non-function objects, it gets the count of own - * enumerable string keys. - * - * assert.isNotEmpty([1, 2]); - * assert.isNotEmpty('34'); - * assert.isNotEmpty(new Set([5, 6])); - * assert.isNotEmpty({ key: 7 }); - * - * @name isNotEmpty - * @alias notEmpty - * @param {Object|Array|String|Map|Set} target - * @param {String} message _optional_ - * @namespace Assert - * @api public - */ - - assert.isNotEmpty = function(val, msg) { - new Assertion(val, msg, assert.isNotEmpty, true).to.not.be.empty; - }; - - /*! - * Aliases. - */ - - (function alias(name, as){ - assert[as] = assert[name]; - return alias; - }) - ('isOk', 'ok') - ('isNotOk', 'notOk') - ('throws', 'throw') - ('throws', 'Throw') - ('isExtensible', 'extensible') - ('isNotExtensible', 'notExtensible') - ('isSealed', 'sealed') - ('isNotSealed', 'notSealed') - ('isFrozen', 'frozen') - ('isNotFrozen', 'notFrozen') - ('isEmpty', 'empty') - ('isNotEmpty', 'notEmpty'); -}; diff --git a/node_modules/chai/lib/chai/interface/expect.js b/node_modules/chai/lib/chai/interface/expect.js deleted file mode 100644 index 6867e2a..0000000 --- a/node_modules/chai/lib/chai/interface/expect.js +++ /dev/null @@ -1,47 +0,0 @@ -/*! - * chai - * Copyright(c) 2011-2014 Jake Luer - * MIT Licensed - */ - -module.exports = function (chai, util) { - chai.expect = function (val, message) { - return new chai.Assertion(val, message); - }; - - /** - * ### .fail([message]) - * ### .fail(actual, expected, [message], [operator]) - * - * Throw a failure. - * - * expect.fail(); - * expect.fail("custom error message"); - * expect.fail(1, 2); - * expect.fail(1, 2, "custom error message"); - * expect.fail(1, 2, "custom error message", ">"); - * expect.fail(1, 2, undefined, ">"); - * - * @name fail - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @param {String} operator - * @namespace BDD - * @api public - */ - - chai.expect.fail = function (actual, expected, message, operator) { - if (arguments.length < 2) { - message = actual; - actual = undefined; - } - - message = message || 'expect.fail()'; - throw new chai.AssertionError(message, { - actual: actual - , expected: expected - , operator: operator - }, chai.expect.fail); - }; -}; diff --git a/node_modules/chai/lib/chai/interface/should.js b/node_modules/chai/lib/chai/interface/should.js deleted file mode 100644 index 17902af..0000000 --- a/node_modules/chai/lib/chai/interface/should.js +++ /dev/null @@ -1,219 +0,0 @@ -/*! - * chai - * Copyright(c) 2011-2014 Jake Luer - * MIT Licensed - */ - -module.exports = function (chai, util) { - var Assertion = chai.Assertion; - - function loadShould () { - // explicitly define this method as function as to have it's name to include as `ssfi` - function shouldGetter() { - if (this instanceof String - || this instanceof Number - || this instanceof Boolean - || typeof Symbol === 'function' && this instanceof Symbol - || typeof BigInt === 'function' && this instanceof BigInt) { - return new Assertion(this.valueOf(), null, shouldGetter); - } - return new Assertion(this, null, shouldGetter); - } - function shouldSetter(value) { - // See https://github.com/chaijs/chai/issues/86: this makes - // `whatever.should = someValue` actually set `someValue`, which is - // especially useful for `global.should = require('chai').should()`. - // - // Note that we have to use [[DefineProperty]] instead of [[Put]] - // since otherwise we would trigger this very setter! - Object.defineProperty(this, 'should', { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } - // modify Object.prototype to have `should` - Object.defineProperty(Object.prototype, 'should', { - set: shouldSetter - , get: shouldGetter - , configurable: true - }); - - var should = {}; - - /** - * ### .fail([message]) - * ### .fail(actual, expected, [message], [operator]) - * - * Throw a failure. - * - * should.fail(); - * should.fail("custom error message"); - * should.fail(1, 2); - * should.fail(1, 2, "custom error message"); - * should.fail(1, 2, "custom error message", ">"); - * should.fail(1, 2, undefined, ">"); - * - * - * @name fail - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @param {String} operator - * @namespace BDD - * @api public - */ - - should.fail = function (actual, expected, message, operator) { - if (arguments.length < 2) { - message = actual; - actual = undefined; - } - - message = message || 'should.fail()'; - throw new chai.AssertionError(message, { - actual: actual - , expected: expected - , operator: operator - }, should.fail); - }; - - /** - * ### .equal(actual, expected, [message]) - * - * Asserts non-strict equality (`==`) of `actual` and `expected`. - * - * should.equal(3, '3', '== coerces values to strings'); - * - * @name equal - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Should - * @api public - */ - - should.equal = function (val1, val2, msg) { - new Assertion(val1, msg).to.equal(val2); - }; - - /** - * ### .throw(function, [constructor/string/regexp], [string/regexp], [message]) - * - * Asserts that `function` will throw an error that is an instance of - * `constructor`, or alternately that it will throw an error with message - * matching `regexp`. - * - * should.throw(fn, 'function throws a reference error'); - * should.throw(fn, /function throws a reference error/); - * should.throw(fn, ReferenceError); - * should.throw(fn, ReferenceError, 'function throws a reference error'); - * should.throw(fn, ReferenceError, /function throws a reference error/); - * - * @name throw - * @alias Throw - * @param {Function} function - * @param {ErrorConstructor} constructor - * @param {RegExp} regexp - * @param {String} message - * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types - * @namespace Should - * @api public - */ - - should.Throw = function (fn, errt, errs, msg) { - new Assertion(fn, msg).to.Throw(errt, errs); - }; - - /** - * ### .exist - * - * Asserts that the target is neither `null` nor `undefined`. - * - * var foo = 'hi'; - * - * should.exist(foo, 'foo exists'); - * - * @name exist - * @namespace Should - * @api public - */ - - should.exist = function (val, msg) { - new Assertion(val, msg).to.exist; - } - - // negation - should.not = {} - - /** - * ### .not.equal(actual, expected, [message]) - * - * Asserts non-strict inequality (`!=`) of `actual` and `expected`. - * - * should.not.equal(3, 4, 'these numbers are not equal'); - * - * @name not.equal - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @namespace Should - * @api public - */ - - should.not.equal = function (val1, val2, msg) { - new Assertion(val1, msg).to.not.equal(val2); - }; - - /** - * ### .throw(function, [constructor/regexp], [message]) - * - * Asserts that `function` will _not_ throw an error that is an instance of - * `constructor`, or alternately that it will not throw an error with message - * matching `regexp`. - * - * should.not.throw(fn, Error, 'function does not throw'); - * - * @name not.throw - * @alias not.Throw - * @param {Function} function - * @param {ErrorConstructor} constructor - * @param {RegExp} regexp - * @param {String} message - * @see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error#Error_types - * @namespace Should - * @api public - */ - - should.not.Throw = function (fn, errt, errs, msg) { - new Assertion(fn, msg).to.not.Throw(errt, errs); - }; - - /** - * ### .not.exist - * - * Asserts that the target is neither `null` nor `undefined`. - * - * var bar = null; - * - * should.not.exist(bar, 'bar does not exist'); - * - * @name not.exist - * @namespace Should - * @api public - */ - - should.not.exist = function (val, msg) { - new Assertion(val, msg).to.not.exist; - } - - should['throw'] = should['Throw']; - should.not['throw'] = should.not['Throw']; - - return should; - }; - - chai.should = loadShould; - chai.Should = loadShould; -}; diff --git a/node_modules/chai/lib/chai/utils/addChainableMethod.js b/node_modules/chai/lib/chai/utils/addChainableMethod.js deleted file mode 100644 index a713f6a..0000000 --- a/node_modules/chai/lib/chai/utils/addChainableMethod.js +++ /dev/null @@ -1,152 +0,0 @@ -/*! - * Chai - addChainingMethod utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies - */ - -var addLengthGuard = require('./addLengthGuard'); -var chai = require('../../chai'); -var flag = require('./flag'); -var proxify = require('./proxify'); -var transferFlags = require('./transferFlags'); - -/*! - * Module variables - */ - -// Check whether `Object.setPrototypeOf` is supported -var canSetPrototype = typeof Object.setPrototypeOf === 'function'; - -// Without `Object.setPrototypeOf` support, this module will need to add properties to a function. -// However, some of functions' own props are not configurable and should be skipped. -var testFn = function() {}; -var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) { - var propDesc = Object.getOwnPropertyDescriptor(testFn, name); - - // Note: PhantomJS 1.x includes `callee` as one of `testFn`'s own properties, - // but then returns `undefined` as the property descriptor for `callee`. As a - // workaround, we perform an otherwise unnecessary type-check for `propDesc`, - // and then filter it out if it's not an object as it should be. - if (typeof propDesc !== 'object') - return true; - - return !propDesc.configurable; -}); - -// Cache `Function` properties -var call = Function.prototype.call, - apply = Function.prototype.apply; - -/** - * ### .addChainableMethod(ctx, name, method, chainingBehavior) - * - * Adds a method to an object, such that the method can also be chained. - * - * utils.addChainableMethod(chai.Assertion.prototype, 'foo', function (str) { - * var obj = utils.flag(this, 'object'); - * new chai.Assertion(obj).to.be.equal(str); - * }); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.addChainableMethod('foo', fn, chainingBehavior); - * - * The result can then be used as both a method assertion, executing both `method` and - * `chainingBehavior`, or as a language chain, which only executes `chainingBehavior`. - * - * expect(fooStr).to.be.foo('bar'); - * expect(fooStr).to.be.foo.equal('foo'); - * - * @param {Object} ctx object to which the method is added - * @param {String} name of method to add - * @param {Function} method function to be used for `name`, when called - * @param {Function} chainingBehavior function to be called every time the property is accessed - * @namespace Utils - * @name addChainableMethod - * @api public - */ - -module.exports = function addChainableMethod(ctx, name, method, chainingBehavior) { - if (typeof chainingBehavior !== 'function') { - chainingBehavior = function () { }; - } - - var chainableBehavior = { - method: method - , chainingBehavior: chainingBehavior - }; - - // save the methods so we can overwrite them later, if we need to. - if (!ctx.__methods) { - ctx.__methods = {}; - } - ctx.__methods[name] = chainableBehavior; - - Object.defineProperty(ctx, name, - { get: function chainableMethodGetter() { - chainableBehavior.chainingBehavior.call(this); - - var chainableMethodWrapper = function () { - // Setting the `ssfi` flag to `chainableMethodWrapper` causes this - // function to be the starting point for removing implementation - // frames from the stack trace of a failed assertion. - // - // However, we only want to use this function as the starting point if - // the `lockSsfi` flag isn't set. - // - // If the `lockSsfi` flag is set, then this assertion is being - // invoked from inside of another assertion. In this case, the `ssfi` - // flag has already been set by the outer assertion. - // - // Note that overwriting a chainable method merely replaces the saved - // methods in `ctx.__methods` instead of completely replacing the - // overwritten assertion. Therefore, an overwriting assertion won't - // set the `ssfi` or `lockSsfi` flags. - if (!flag(this, 'lockSsfi')) { - flag(this, 'ssfi', chainableMethodWrapper); - } - - var result = chainableBehavior.method.apply(this, arguments); - if (result !== undefined) { - return result; - } - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - }; - - addLengthGuard(chainableMethodWrapper, name, true); - - // Use `Object.setPrototypeOf` if available - if (canSetPrototype) { - // Inherit all properties from the object by replacing the `Function` prototype - var prototype = Object.create(this); - // Restore the `call` and `apply` methods from `Function` - prototype.call = call; - prototype.apply = apply; - Object.setPrototypeOf(chainableMethodWrapper, prototype); - } - // Otherwise, redefine all properties (slow!) - else { - var asserterNames = Object.getOwnPropertyNames(ctx); - asserterNames.forEach(function (asserterName) { - if (excludeNames.indexOf(asserterName) !== -1) { - return; - } - - var pd = Object.getOwnPropertyDescriptor(ctx, asserterName); - Object.defineProperty(chainableMethodWrapper, asserterName, pd); - }); - } - - transferFlags(this, chainableMethodWrapper); - return proxify(chainableMethodWrapper); - } - , configurable: true - }); -}; diff --git a/node_modules/chai/lib/chai/utils/addLengthGuard.js b/node_modules/chai/lib/chai/utils/addLengthGuard.js deleted file mode 100644 index e51ce80..0000000 --- a/node_modules/chai/lib/chai/utils/addLengthGuard.js +++ /dev/null @@ -1,60 +0,0 @@ -var fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length'); - -/*! - * Chai - addLengthGuard utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .addLengthGuard(fn, assertionName, isChainable) - * - * Define `length` as a getter on the given uninvoked method assertion. The - * getter acts as a guard against chaining `length` directly off of an uninvoked - * method assertion, which is a problem because it references `function`'s - * built-in `length` property instead of Chai's `length` assertion. When the - * getter catches the user making this mistake, it throws an error with a - * helpful message. - * - * There are two ways in which this mistake can be made. The first way is by - * chaining the `length` assertion directly off of an uninvoked chainable - * method. In this case, Chai suggests that the user use `lengthOf` instead. The - * second way is by chaining the `length` assertion directly off of an uninvoked - * non-chainable method. Non-chainable methods must be invoked prior to - * chaining. In this case, Chai suggests that the user consult the docs for the - * given assertion. - * - * If the `length` property of functions is unconfigurable, then return `fn` - * without modification. - * - * Note that in ES6, the function's `length` property is configurable, so once - * support for legacy environments is dropped, Chai's `length` property can - * replace the built-in function's `length` property, and this length guard will - * no longer be necessary. In the mean time, maintaining consistency across all - * environments is the priority. - * - * @param {Function} fn - * @param {String} assertionName - * @param {Boolean} isChainable - * @namespace Utils - * @name addLengthGuard - */ - -module.exports = function addLengthGuard (fn, assertionName, isChainable) { - if (!fnLengthDesc.configurable) return fn; - - Object.defineProperty(fn, 'length', { - get: function () { - if (isChainable) { - throw Error('Invalid Chai property: ' + assertionName + '.length. Due' + - ' to a compatibility issue, "length" cannot directly follow "' + - assertionName + '". Use "' + assertionName + '.lengthOf" instead.'); - } - - throw Error('Invalid Chai property: ' + assertionName + '.length. See' + - ' docs for proper usage of "' + assertionName + '".'); - } - }); - - return fn; -}; diff --git a/node_modules/chai/lib/chai/utils/addMethod.js b/node_modules/chai/lib/chai/utils/addMethod.js deleted file mode 100644 index 021f080..0000000 --- a/node_modules/chai/lib/chai/utils/addMethod.js +++ /dev/null @@ -1,68 +0,0 @@ -/*! - * Chai - addMethod utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -var addLengthGuard = require('./addLengthGuard'); -var chai = require('../../chai'); -var flag = require('./flag'); -var proxify = require('./proxify'); -var transferFlags = require('./transferFlags'); - -/** - * ### .addMethod(ctx, name, method) - * - * Adds a method to the prototype of an object. - * - * utils.addMethod(chai.Assertion.prototype, 'foo', function (str) { - * var obj = utils.flag(this, 'object'); - * new chai.Assertion(obj).to.be.equal(str); - * }); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.addMethod('foo', fn); - * - * Then can be used as any other assertion. - * - * expect(fooStr).to.be.foo('bar'); - * - * @param {Object} ctx object to which the method is added - * @param {String} name of method to add - * @param {Function} method function to be used for name - * @namespace Utils - * @name addMethod - * @api public - */ - -module.exports = function addMethod(ctx, name, method) { - var methodWrapper = function () { - // Setting the `ssfi` flag to `methodWrapper` causes this function to be the - // starting point for removing implementation frames from the stack trace of - // a failed assertion. - // - // However, we only want to use this function as the starting point if the - // `lockSsfi` flag isn't set. - // - // If the `lockSsfi` flag is set, then either this assertion has been - // overwritten by another assertion, or this assertion is being invoked from - // inside of another assertion. In the first case, the `ssfi` flag has - // already been set by the overwriting assertion. In the second case, the - // `ssfi` flag has already been set by the outer assertion. - if (!flag(this, 'lockSsfi')) { - flag(this, 'ssfi', methodWrapper); - } - - var result = method.apply(this, arguments); - if (result !== undefined) - return result; - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - }; - - addLengthGuard(methodWrapper, name, false); - ctx[name] = proxify(methodWrapper, name); -}; diff --git a/node_modules/chai/lib/chai/utils/addProperty.js b/node_modules/chai/lib/chai/utils/addProperty.js deleted file mode 100644 index 872a8cd..0000000 --- a/node_modules/chai/lib/chai/utils/addProperty.js +++ /dev/null @@ -1,72 +0,0 @@ -/*! - * Chai - addProperty utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -var chai = require('../../chai'); -var flag = require('./flag'); -var isProxyEnabled = require('./isProxyEnabled'); -var transferFlags = require('./transferFlags'); - -/** - * ### .addProperty(ctx, name, getter) - * - * Adds a property to the prototype of an object. - * - * utils.addProperty(chai.Assertion.prototype, 'foo', function () { - * var obj = utils.flag(this, 'object'); - * new chai.Assertion(obj).to.be.instanceof(Foo); - * }); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.addProperty('foo', fn); - * - * Then can be used as any other assertion. - * - * expect(myFoo).to.be.foo; - * - * @param {Object} ctx object to which the property is added - * @param {String} name of property to add - * @param {Function} getter function to be used for name - * @namespace Utils - * @name addProperty - * @api public - */ - -module.exports = function addProperty(ctx, name, getter) { - getter = getter === undefined ? function () {} : getter; - - Object.defineProperty(ctx, name, - { get: function propertyGetter() { - // Setting the `ssfi` flag to `propertyGetter` causes this function to - // be the starting point for removing implementation frames from the - // stack trace of a failed assertion. - // - // However, we only want to use this function as the starting point if - // the `lockSsfi` flag isn't set and proxy protection is disabled. - // - // If the `lockSsfi` flag is set, then either this assertion has been - // overwritten by another assertion, or this assertion is being invoked - // from inside of another assertion. In the first case, the `ssfi` flag - // has already been set by the overwriting assertion. In the second - // case, the `ssfi` flag has already been set by the outer assertion. - // - // If proxy protection is enabled, then the `ssfi` flag has already been - // set by the proxy getter. - if (!isProxyEnabled() && !flag(this, 'lockSsfi')) { - flag(this, 'ssfi', propertyGetter); - } - - var result = getter.call(this); - if (result !== undefined) - return result; - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - } - , configurable: true - }); -}; diff --git a/node_modules/chai/lib/chai/utils/compareByInspect.js b/node_modules/chai/lib/chai/utils/compareByInspect.js deleted file mode 100644 index c8cd5e1..0000000 --- a/node_modules/chai/lib/chai/utils/compareByInspect.js +++ /dev/null @@ -1,31 +0,0 @@ -/*! - * Chai - compareByInspect utility - * Copyright(c) 2011-2016 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies - */ - -var inspect = require('./inspect'); - -/** - * ### .compareByInspect(mixed, mixed) - * - * To be used as a compareFunction with Array.prototype.sort. Compares elements - * using inspect instead of default behavior of using toString so that Symbols - * and objects with irregular/missing toString can still be sorted without a - * TypeError. - * - * @param {Mixed} first element to compare - * @param {Mixed} second element to compare - * @returns {Number} -1 if 'a' should come before 'b'; otherwise 1 - * @name compareByInspect - * @namespace Utils - * @api public - */ - -module.exports = function compareByInspect(a, b) { - return inspect(a) < inspect(b) ? -1 : 1; -}; diff --git a/node_modules/chai/lib/chai/utils/expectTypes.js b/node_modules/chai/lib/chai/utils/expectTypes.js deleted file mode 100644 index 6293db7..0000000 --- a/node_modules/chai/lib/chai/utils/expectTypes.js +++ /dev/null @@ -1,51 +0,0 @@ -/*! - * Chai - expectTypes utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .expectTypes(obj, types) - * - * Ensures that the object being tested against is of a valid type. - * - * utils.expectTypes(this, ['array', 'object', 'string']); - * - * @param {Mixed} obj constructed Assertion - * @param {Array} type A list of allowed types for this assertion - * @namespace Utils - * @name expectTypes - * @api public - */ - -var AssertionError = require('assertion-error'); -var flag = require('./flag'); -var type = require('type-detect'); - -module.exports = function expectTypes(obj, types) { - var flagMsg = flag(obj, 'message'); - var ssfi = flag(obj, 'ssfi'); - - flagMsg = flagMsg ? flagMsg + ': ' : ''; - - obj = flag(obj, 'object'); - types = types.map(function (t) { return t.toLowerCase(); }); - types.sort(); - - // Transforms ['lorem', 'ipsum'] into 'a lorem, or an ipsum' - var str = types.map(function (t, index) { - var art = ~[ 'a', 'e', 'i', 'o', 'u' ].indexOf(t.charAt(0)) ? 'an' : 'a'; - var or = types.length > 1 && index === types.length - 1 ? 'or ' : ''; - return or + art + ' ' + t; - }).join(', '); - - var objType = type(obj).toLowerCase(); - - if (!types.some(function (expected) { return objType === expected; })) { - throw new AssertionError( - flagMsg + 'object tested must be ' + str + ', but ' + objType + ' given', - undefined, - ssfi - ); - } -}; diff --git a/node_modules/chai/lib/chai/utils/flag.js b/node_modules/chai/lib/chai/utils/flag.js deleted file mode 100644 index dd53bfb..0000000 --- a/node_modules/chai/lib/chai/utils/flag.js +++ /dev/null @@ -1,33 +0,0 @@ -/*! - * Chai - flag utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .flag(object, key, [value]) - * - * Get or set a flag value on an object. If a - * value is provided it will be set, else it will - * return the currently set value or `undefined` if - * the value is not set. - * - * utils.flag(this, 'foo', 'bar'); // setter - * utils.flag(this, 'foo'); // getter, returns `bar` - * - * @param {Object} object constructed Assertion - * @param {String} key - * @param {Mixed} value (optional) - * @namespace Utils - * @name flag - * @api private - */ - -module.exports = function flag(obj, key, value) { - var flags = obj.__flags || (obj.__flags = Object.create(null)); - if (arguments.length === 3) { - flags[key] = value; - } else { - return flags[key]; - } -}; diff --git a/node_modules/chai/lib/chai/utils/getActual.js b/node_modules/chai/lib/chai/utils/getActual.js deleted file mode 100644 index 976e112..0000000 --- a/node_modules/chai/lib/chai/utils/getActual.js +++ /dev/null @@ -1,20 +0,0 @@ -/*! - * Chai - getActual utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .getActual(object, [actual]) - * - * Returns the `actual` value for an Assertion. - * - * @param {Object} object (constructed Assertion) - * @param {Arguments} chai.Assertion.prototype.assert arguments - * @namespace Utils - * @name getActual - */ - -module.exports = function getActual(obj, args) { - return args.length > 4 ? args[4] : obj._obj; -}; diff --git a/node_modules/chai/lib/chai/utils/getEnumerableProperties.js b/node_modules/chai/lib/chai/utils/getEnumerableProperties.js deleted file mode 100644 index a84252c..0000000 --- a/node_modules/chai/lib/chai/utils/getEnumerableProperties.js +++ /dev/null @@ -1,26 +0,0 @@ -/*! - * Chai - getEnumerableProperties utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .getEnumerableProperties(object) - * - * This allows the retrieval of enumerable property names of an object, - * inherited or not. - * - * @param {Object} object - * @returns {Array} - * @namespace Utils - * @name getEnumerableProperties - * @api public - */ - -module.exports = function getEnumerableProperties(object) { - var result = []; - for (var name in object) { - result.push(name); - } - return result; -}; diff --git a/node_modules/chai/lib/chai/utils/getMessage.js b/node_modules/chai/lib/chai/utils/getMessage.js deleted file mode 100644 index bb83716..0000000 --- a/node_modules/chai/lib/chai/utils/getMessage.js +++ /dev/null @@ -1,50 +0,0 @@ -/*! - * Chai - message composition utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies - */ - -var flag = require('./flag') - , getActual = require('./getActual') - , objDisplay = require('./objDisplay'); - -/** - * ### .getMessage(object, message, negateMessage) - * - * Construct the error message based on flags - * and template tags. Template tags will return - * a stringified inspection of the object referenced. - * - * Message template tags: - * - `#{this}` current asserted object - * - `#{act}` actual value - * - `#{exp}` expected value - * - * @param {Object} object (constructed Assertion) - * @param {Arguments} chai.Assertion.prototype.assert arguments - * @namespace Utils - * @name getMessage - * @api public - */ - -module.exports = function getMessage(obj, args) { - var negate = flag(obj, 'negate') - , val = flag(obj, 'object') - , expected = args[3] - , actual = getActual(obj, args) - , msg = negate ? args[2] : args[1] - , flagMsg = flag(obj, 'message'); - - if(typeof msg === "function") msg = msg(); - msg = msg || ''; - msg = msg - .replace(/#\{this\}/g, function () { return objDisplay(val); }) - .replace(/#\{act\}/g, function () { return objDisplay(actual); }) - .replace(/#\{exp\}/g, function () { return objDisplay(expected); }); - - return flagMsg ? flagMsg + ': ' + msg : msg; -}; diff --git a/node_modules/chai/lib/chai/utils/getOperator.js b/node_modules/chai/lib/chai/utils/getOperator.js deleted file mode 100644 index f7d10ef..0000000 --- a/node_modules/chai/lib/chai/utils/getOperator.js +++ /dev/null @@ -1,55 +0,0 @@ -var type = require('type-detect'); - -var flag = require('./flag'); - -function isObjectType(obj) { - var objectType = type(obj); - var objectTypes = ['Array', 'Object', 'function']; - - return objectTypes.indexOf(objectType) !== -1; -} - -/** - * ### .getOperator(message) - * - * Extract the operator from error message. - * Operator defined is based on below link - * https://nodejs.org/api/assert.html#assert_assert. - * - * Returns the `operator` or `undefined` value for an Assertion. - * - * @param {Object} object (constructed Assertion) - * @param {Arguments} chai.Assertion.prototype.assert arguments - * @namespace Utils - * @name getOperator - * @api public - */ - -module.exports = function getOperator(obj, args) { - var operator = flag(obj, 'operator'); - var negate = flag(obj, 'negate'); - var expected = args[3]; - var msg = negate ? args[2] : args[1]; - - if (operator) { - return operator; - } - - if (typeof msg === 'function') msg = msg(); - - msg = msg || ''; - if (!msg) { - return undefined; - } - - if (/\shave\s/.test(msg)) { - return undefined; - } - - var isObject = isObjectType(expected); - if (/\snot\s/.test(msg)) { - return isObject ? 'notDeepStrictEqual' : 'notStrictEqual'; - } - - return isObject ? 'deepStrictEqual' : 'strictEqual'; -}; diff --git a/node_modules/chai/lib/chai/utils/getOwnEnumerableProperties.js b/node_modules/chai/lib/chai/utils/getOwnEnumerableProperties.js deleted file mode 100644 index a4aa83a..0000000 --- a/node_modules/chai/lib/chai/utils/getOwnEnumerableProperties.js +++ /dev/null @@ -1,29 +0,0 @@ -/*! - * Chai - getOwnEnumerableProperties utility - * Copyright(c) 2011-2016 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies - */ - -var getOwnEnumerablePropertySymbols = require('./getOwnEnumerablePropertySymbols'); - -/** - * ### .getOwnEnumerableProperties(object) - * - * This allows the retrieval of directly-owned enumerable property names and - * symbols of an object. This function is necessary because Object.keys only - * returns enumerable property names, not enumerable property symbols. - * - * @param {Object} object - * @returns {Array} - * @namespace Utils - * @name getOwnEnumerableProperties - * @api public - */ - -module.exports = function getOwnEnumerableProperties(obj) { - return Object.keys(obj).concat(getOwnEnumerablePropertySymbols(obj)); -}; diff --git a/node_modules/chai/lib/chai/utils/getOwnEnumerablePropertySymbols.js b/node_modules/chai/lib/chai/utils/getOwnEnumerablePropertySymbols.js deleted file mode 100644 index 823c6b7..0000000 --- a/node_modules/chai/lib/chai/utils/getOwnEnumerablePropertySymbols.js +++ /dev/null @@ -1,27 +0,0 @@ -/*! - * Chai - getOwnEnumerablePropertySymbols utility - * Copyright(c) 2011-2016 Jake Luer - * MIT Licensed - */ - -/** - * ### .getOwnEnumerablePropertySymbols(object) - * - * This allows the retrieval of directly-owned enumerable property symbols of an - * object. This function is necessary because Object.getOwnPropertySymbols - * returns both enumerable and non-enumerable property symbols. - * - * @param {Object} object - * @returns {Array} - * @namespace Utils - * @name getOwnEnumerablePropertySymbols - * @api public - */ - -module.exports = function getOwnEnumerablePropertySymbols(obj) { - if (typeof Object.getOwnPropertySymbols !== 'function') return []; - - return Object.getOwnPropertySymbols(obj).filter(function (sym) { - return Object.getOwnPropertyDescriptor(obj, sym).enumerable; - }); -}; diff --git a/node_modules/chai/lib/chai/utils/getProperties.js b/node_modules/chai/lib/chai/utils/getProperties.js deleted file mode 100644 index ccf9631..0000000 --- a/node_modules/chai/lib/chai/utils/getProperties.js +++ /dev/null @@ -1,36 +0,0 @@ -/*! - * Chai - getProperties utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .getProperties(object) - * - * This allows the retrieval of property names of an object, enumerable or not, - * inherited or not. - * - * @param {Object} object - * @returns {Array} - * @namespace Utils - * @name getProperties - * @api public - */ - -module.exports = function getProperties(object) { - var result = Object.getOwnPropertyNames(object); - - function addProperty(property) { - if (result.indexOf(property) === -1) { - result.push(property); - } - } - - var proto = Object.getPrototypeOf(object); - while (proto !== null) { - Object.getOwnPropertyNames(proto).forEach(addProperty); - proto = Object.getPrototypeOf(proto); - } - - return result; -}; diff --git a/node_modules/chai/lib/chai/utils/index.js b/node_modules/chai/lib/chai/utils/index.js deleted file mode 100644 index c12a38e..0000000 --- a/node_modules/chai/lib/chai/utils/index.js +++ /dev/null @@ -1,178 +0,0 @@ -/*! - * chai - * Copyright(c) 2011 Jake Luer - * MIT Licensed - */ - -/*! - * Dependencies that are used for multiple exports are required here only once - */ - -var pathval = require('pathval'); - -/*! - * test utility - */ - -exports.test = require('./test'); - -/*! - * type utility - */ - -exports.type = require('type-detect'); - -/*! - * expectTypes utility - */ -exports.expectTypes = require('./expectTypes'); - -/*! - * message utility - */ - -exports.getMessage = require('./getMessage'); - -/*! - * actual utility - */ - -exports.getActual = require('./getActual'); - -/*! - * Inspect util - */ - -exports.inspect = require('./inspect'); - -/*! - * Object Display util - */ - -exports.objDisplay = require('./objDisplay'); - -/*! - * Flag utility - */ - -exports.flag = require('./flag'); - -/*! - * Flag transferring utility - */ - -exports.transferFlags = require('./transferFlags'); - -/*! - * Deep equal utility - */ - -exports.eql = require('deep-eql'); - -/*! - * Deep path info - */ - -exports.getPathInfo = pathval.getPathInfo; - -/*! - * Check if a property exists - */ - -exports.hasProperty = pathval.hasProperty; - -/*! - * Function name - */ - -exports.getName = require('get-func-name'); - -/*! - * add Property - */ - -exports.addProperty = require('./addProperty'); - -/*! - * add Method - */ - -exports.addMethod = require('./addMethod'); - -/*! - * overwrite Property - */ - -exports.overwriteProperty = require('./overwriteProperty'); - -/*! - * overwrite Method - */ - -exports.overwriteMethod = require('./overwriteMethod'); - -/*! - * Add a chainable method - */ - -exports.addChainableMethod = require('./addChainableMethod'); - -/*! - * Overwrite chainable method - */ - -exports.overwriteChainableMethod = require('./overwriteChainableMethod'); - -/*! - * Compare by inspect method - */ - -exports.compareByInspect = require('./compareByInspect'); - -/*! - * Get own enumerable property symbols method - */ - -exports.getOwnEnumerablePropertySymbols = require('./getOwnEnumerablePropertySymbols'); - -/*! - * Get own enumerable properties method - */ - -exports.getOwnEnumerableProperties = require('./getOwnEnumerableProperties'); - -/*! - * Checks error against a given set of criteria - */ - -exports.checkError = require('check-error'); - -/*! - * Proxify util - */ - -exports.proxify = require('./proxify'); - -/*! - * addLengthGuard util - */ - -exports.addLengthGuard = require('./addLengthGuard'); - -/*! - * isProxyEnabled helper - */ - -exports.isProxyEnabled = require('./isProxyEnabled'); - -/*! - * isNaN method - */ - -exports.isNaN = require('./isNaN'); - -/*! - * getOperator method - */ - -exports.getOperator = require('./getOperator'); \ No newline at end of file diff --git a/node_modules/chai/lib/chai/utils/inspect.js b/node_modules/chai/lib/chai/utils/inspect.js deleted file mode 100644 index 3c83057..0000000 --- a/node_modules/chai/lib/chai/utils/inspect.js +++ /dev/null @@ -1,33 +0,0 @@ -// This is (almost) directly from Node.js utils -// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js - -var getName = require('get-func-name'); -var loupe = require('loupe'); -var config = require('../config'); - -module.exports = inspect; - -/** - * ### .inspect(obj, [showHidden], [depth], [colors]) - * - * Echoes the value of a value. Tries to print the value out - * in the best way possible given the different types. - * - * @param {Object} obj The object to print out. - * @param {Boolean} showHidden Flag that shows hidden (not enumerable) - * properties of objects. Default is false. - * @param {Number} depth Depth in which to descend in object. Default is 2. - * @param {Boolean} colors Flag to turn on ANSI escape codes to color the - * output. Default is false (no coloring). - * @namespace Utils - * @name inspect - */ -function inspect(obj, showHidden, depth, colors) { - var options = { - colors: colors, - depth: (typeof depth === 'undefined' ? 2 : depth), - showHidden: showHidden, - truncate: config.truncateThreshold ? config.truncateThreshold : Infinity, - }; - return loupe.inspect(obj, options); -} diff --git a/node_modules/chai/lib/chai/utils/isNaN.js b/node_modules/chai/lib/chai/utils/isNaN.js deleted file mode 100644 index d64f7f4..0000000 --- a/node_modules/chai/lib/chai/utils/isNaN.js +++ /dev/null @@ -1,26 +0,0 @@ -/*! - * Chai - isNaN utility - * Copyright(c) 2012-2015 Sakthipriyan Vairamani - * MIT Licensed - */ - -/** - * ### .isNaN(value) - * - * Checks if the given value is NaN or not. - * - * utils.isNaN(NaN); // true - * - * @param {Value} The value which has to be checked if it is NaN - * @name isNaN - * @api private - */ - -function isNaN(value) { - // Refer http://www.ecma-international.org/ecma-262/6.0/#sec-isnan-number - // section's NOTE. - return value !== value; -} - -// If ECMAScript 6's Number.isNaN is present, prefer that. -module.exports = Number.isNaN || isNaN; diff --git a/node_modules/chai/lib/chai/utils/isProxyEnabled.js b/node_modules/chai/lib/chai/utils/isProxyEnabled.js deleted file mode 100644 index 11e58ed..0000000 --- a/node_modules/chai/lib/chai/utils/isProxyEnabled.js +++ /dev/null @@ -1,24 +0,0 @@ -var config = require('../config'); - -/*! - * Chai - isProxyEnabled helper - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .isProxyEnabled() - * - * Helper function to check if Chai's proxy protection feature is enabled. If - * proxies are unsupported or disabled via the user's Chai config, then return - * false. Otherwise, return true. - * - * @namespace Utils - * @name isProxyEnabled - */ - -module.exports = function isProxyEnabled() { - return config.useProxy && - typeof Proxy !== 'undefined' && - typeof Reflect !== 'undefined'; -}; diff --git a/node_modules/chai/lib/chai/utils/objDisplay.js b/node_modules/chai/lib/chai/utils/objDisplay.js deleted file mode 100644 index 3010f46..0000000 --- a/node_modules/chai/lib/chai/utils/objDisplay.js +++ /dev/null @@ -1,50 +0,0 @@ -/*! - * Chai - flag utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies - */ - -var inspect = require('./inspect'); -var config = require('../config'); - -/** - * ### .objDisplay(object) - * - * Determines if an object or an array matches - * criteria to be inspected in-line for error - * messages or should be truncated. - * - * @param {Mixed} javascript object to inspect - * @name objDisplay - * @namespace Utils - * @api public - */ - -module.exports = function objDisplay(obj) { - var str = inspect(obj) - , type = Object.prototype.toString.call(obj); - - if (config.truncateThreshold && str.length >= config.truncateThreshold) { - if (type === '[object Function]') { - return !obj.name || obj.name === '' - ? '[Function]' - : '[Function: ' + obj.name + ']'; - } else if (type === '[object Array]') { - return '[ Array(' + obj.length + ') ]'; - } else if (type === '[object Object]') { - var keys = Object.keys(obj) - , kstr = keys.length > 2 - ? keys.splice(0, 2).join(', ') + ', ...' - : keys.join(', '); - return '{ Object (' + kstr + ') }'; - } else { - return str; - } - } else { - return str; - } -}; diff --git a/node_modules/chai/lib/chai/utils/overwriteChainableMethod.js b/node_modules/chai/lib/chai/utils/overwriteChainableMethod.js deleted file mode 100644 index 4b38569..0000000 --- a/node_modules/chai/lib/chai/utils/overwriteChainableMethod.js +++ /dev/null @@ -1,69 +0,0 @@ -/*! - * Chai - overwriteChainableMethod utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -var chai = require('../../chai'); -var transferFlags = require('./transferFlags'); - -/** - * ### .overwriteChainableMethod(ctx, name, method, chainingBehavior) - * - * Overwrites an already existing chainable method - * and provides access to the previous function or - * property. Must return functions to be used for - * name. - * - * utils.overwriteChainableMethod(chai.Assertion.prototype, 'lengthOf', - * function (_super) { - * } - * , function (_super) { - * } - * ); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.overwriteChainableMethod('foo', fn, fn); - * - * Then can be used as any other assertion. - * - * expect(myFoo).to.have.lengthOf(3); - * expect(myFoo).to.have.lengthOf.above(3); - * - * @param {Object} ctx object whose method / property is to be overwritten - * @param {String} name of method / property to overwrite - * @param {Function} method function that returns a function to be used for name - * @param {Function} chainingBehavior function that returns a function to be used for property - * @namespace Utils - * @name overwriteChainableMethod - * @api public - */ - -module.exports = function overwriteChainableMethod(ctx, name, method, chainingBehavior) { - var chainableBehavior = ctx.__methods[name]; - - var _chainingBehavior = chainableBehavior.chainingBehavior; - chainableBehavior.chainingBehavior = function overwritingChainableMethodGetter() { - var result = chainingBehavior(_chainingBehavior).call(this); - if (result !== undefined) { - return result; - } - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - }; - - var _method = chainableBehavior.method; - chainableBehavior.method = function overwritingChainableMethodWrapper() { - var result = method(_method).apply(this, arguments); - if (result !== undefined) { - return result; - } - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - }; -}; diff --git a/node_modules/chai/lib/chai/utils/overwriteMethod.js b/node_modules/chai/lib/chai/utils/overwriteMethod.js deleted file mode 100644 index 7925e05..0000000 --- a/node_modules/chai/lib/chai/utils/overwriteMethod.js +++ /dev/null @@ -1,92 +0,0 @@ -/*! - * Chai - overwriteMethod utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -var addLengthGuard = require('./addLengthGuard'); -var chai = require('../../chai'); -var flag = require('./flag'); -var proxify = require('./proxify'); -var transferFlags = require('./transferFlags'); - -/** - * ### .overwriteMethod(ctx, name, fn) - * - * Overwrites an already existing method and provides - * access to previous function. Must return function - * to be used for name. - * - * utils.overwriteMethod(chai.Assertion.prototype, 'equal', function (_super) { - * return function (str) { - * var obj = utils.flag(this, 'object'); - * if (obj instanceof Foo) { - * new chai.Assertion(obj.value).to.equal(str); - * } else { - * _super.apply(this, arguments); - * } - * } - * }); - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.overwriteMethod('foo', fn); - * - * Then can be used as any other assertion. - * - * expect(myFoo).to.equal('bar'); - * - * @param {Object} ctx object whose method is to be overwritten - * @param {String} name of method to overwrite - * @param {Function} method function that returns a function to be used for name - * @namespace Utils - * @name overwriteMethod - * @api public - */ - -module.exports = function overwriteMethod(ctx, name, method) { - var _method = ctx[name] - , _super = function () { - throw new Error(name + ' is not a function'); - }; - - if (_method && 'function' === typeof _method) - _super = _method; - - var overwritingMethodWrapper = function () { - // Setting the `ssfi` flag to `overwritingMethodWrapper` causes this - // function to be the starting point for removing implementation frames from - // the stack trace of a failed assertion. - // - // However, we only want to use this function as the starting point if the - // `lockSsfi` flag isn't set. - // - // If the `lockSsfi` flag is set, then either this assertion has been - // overwritten by another assertion, or this assertion is being invoked from - // inside of another assertion. In the first case, the `ssfi` flag has - // already been set by the overwriting assertion. In the second case, the - // `ssfi` flag has already been set by the outer assertion. - if (!flag(this, 'lockSsfi')) { - flag(this, 'ssfi', overwritingMethodWrapper); - } - - // Setting the `lockSsfi` flag to `true` prevents the overwritten assertion - // from changing the `ssfi` flag. By this point, the `ssfi` flag is already - // set to the correct starting point for this assertion. - var origLockSsfi = flag(this, 'lockSsfi'); - flag(this, 'lockSsfi', true); - var result = method(_super).apply(this, arguments); - flag(this, 'lockSsfi', origLockSsfi); - - if (result !== undefined) { - return result; - } - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - } - - addLengthGuard(overwritingMethodWrapper, name, false); - ctx[name] = proxify(overwritingMethodWrapper, name); -}; diff --git a/node_modules/chai/lib/chai/utils/overwriteProperty.js b/node_modules/chai/lib/chai/utils/overwriteProperty.js deleted file mode 100644 index 5f870b0..0000000 --- a/node_modules/chai/lib/chai/utils/overwriteProperty.js +++ /dev/null @@ -1,92 +0,0 @@ -/*! - * Chai - overwriteProperty utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -var chai = require('../../chai'); -var flag = require('./flag'); -var isProxyEnabled = require('./isProxyEnabled'); -var transferFlags = require('./transferFlags'); - -/** - * ### .overwriteProperty(ctx, name, fn) - * - * Overwrites an already existing property getter and provides - * access to previous value. Must return function to use as getter. - * - * utils.overwriteProperty(chai.Assertion.prototype, 'ok', function (_super) { - * return function () { - * var obj = utils.flag(this, 'object'); - * if (obj instanceof Foo) { - * new chai.Assertion(obj.name).to.equal('bar'); - * } else { - * _super.call(this); - * } - * } - * }); - * - * - * Can also be accessed directly from `chai.Assertion`. - * - * chai.Assertion.overwriteProperty('foo', fn); - * - * Then can be used as any other assertion. - * - * expect(myFoo).to.be.ok; - * - * @param {Object} ctx object whose property is to be overwritten - * @param {String} name of property to overwrite - * @param {Function} getter function that returns a getter function to be used for name - * @namespace Utils - * @name overwriteProperty - * @api public - */ - -module.exports = function overwriteProperty(ctx, name, getter) { - var _get = Object.getOwnPropertyDescriptor(ctx, name) - , _super = function () {}; - - if (_get && 'function' === typeof _get.get) - _super = _get.get - - Object.defineProperty(ctx, name, - { get: function overwritingPropertyGetter() { - // Setting the `ssfi` flag to `overwritingPropertyGetter` causes this - // function to be the starting point for removing implementation frames - // from the stack trace of a failed assertion. - // - // However, we only want to use this function as the starting point if - // the `lockSsfi` flag isn't set and proxy protection is disabled. - // - // If the `lockSsfi` flag is set, then either this assertion has been - // overwritten by another assertion, or this assertion is being invoked - // from inside of another assertion. In the first case, the `ssfi` flag - // has already been set by the overwriting assertion. In the second - // case, the `ssfi` flag has already been set by the outer assertion. - // - // If proxy protection is enabled, then the `ssfi` flag has already been - // set by the proxy getter. - if (!isProxyEnabled() && !flag(this, 'lockSsfi')) { - flag(this, 'ssfi', overwritingPropertyGetter); - } - - // Setting the `lockSsfi` flag to `true` prevents the overwritten - // assertion from changing the `ssfi` flag. By this point, the `ssfi` - // flag is already set to the correct starting point for this assertion. - var origLockSsfi = flag(this, 'lockSsfi'); - flag(this, 'lockSsfi', true); - var result = getter(_super).call(this); - flag(this, 'lockSsfi', origLockSsfi); - - if (result !== undefined) { - return result; - } - - var newAssertion = new chai.Assertion(); - transferFlags(this, newAssertion); - return newAssertion; - } - , configurable: true - }); -}; diff --git a/node_modules/chai/lib/chai/utils/proxify.js b/node_modules/chai/lib/chai/utils/proxify.js deleted file mode 100644 index 4bbbee3..0000000 --- a/node_modules/chai/lib/chai/utils/proxify.js +++ /dev/null @@ -1,147 +0,0 @@ -var config = require('../config'); -var flag = require('./flag'); -var getProperties = require('./getProperties'); -var isProxyEnabled = require('./isProxyEnabled'); - -/*! - * Chai - proxify utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .proxify(object) - * - * Return a proxy of given object that throws an error when a non-existent - * property is read. By default, the root cause is assumed to be a misspelled - * property, and thus an attempt is made to offer a reasonable suggestion from - * the list of existing properties. However, if a nonChainableMethodName is - * provided, then the root cause is instead a failure to invoke a non-chainable - * method prior to reading the non-existent property. - * - * If proxies are unsupported or disabled via the user's Chai config, then - * return object without modification. - * - * @param {Object} obj - * @param {String} nonChainableMethodName - * @namespace Utils - * @name proxify - */ - -var builtins = ['__flags', '__methods', '_obj', 'assert']; - -module.exports = function proxify(obj, nonChainableMethodName) { - if (!isProxyEnabled()) return obj; - - return new Proxy(obj, { - get: function proxyGetter(target, property) { - // This check is here because we should not throw errors on Symbol properties - // such as `Symbol.toStringTag`. - // The values for which an error should be thrown can be configured using - // the `config.proxyExcludedKeys` setting. - if (typeof property === 'string' && - config.proxyExcludedKeys.indexOf(property) === -1 && - !Reflect.has(target, property)) { - // Special message for invalid property access of non-chainable methods. - if (nonChainableMethodName) { - throw Error('Invalid Chai property: ' + nonChainableMethodName + '.' + - property + '. See docs for proper usage of "' + - nonChainableMethodName + '".'); - } - - // If the property is reasonably close to an existing Chai property, - // suggest that property to the user. Only suggest properties with a - // distance less than 4. - var suggestion = null; - var suggestionDistance = 4; - getProperties(target).forEach(function(prop) { - if ( - !Object.prototype.hasOwnProperty(prop) && - builtins.indexOf(prop) === -1 - ) { - var dist = stringDistanceCapped( - property, - prop, - suggestionDistance - ); - if (dist < suggestionDistance) { - suggestion = prop; - suggestionDistance = dist; - } - } - }); - - if (suggestion !== null) { - throw Error('Invalid Chai property: ' + property + - '. Did you mean "' + suggestion + '"?'); - } else { - throw Error('Invalid Chai property: ' + property); - } - } - - // Use this proxy getter as the starting point for removing implementation - // frames from the stack trace of a failed assertion. For property - // assertions, this prevents the proxy getter from showing up in the stack - // trace since it's invoked before the property getter. For method and - // chainable method assertions, this flag will end up getting changed to - // the method wrapper, which is good since this frame will no longer be in - // the stack once the method is invoked. Note that Chai builtin assertion - // properties such as `__flags` are skipped since this is only meant to - // capture the starting point of an assertion. This step is also skipped - // if the `lockSsfi` flag is set, thus indicating that this assertion is - // being called from within another assertion. In that case, the `ssfi` - // flag is already set to the outer assertion's starting point. - if (builtins.indexOf(property) === -1 && !flag(target, 'lockSsfi')) { - flag(target, 'ssfi', proxyGetter); - } - - return Reflect.get(target, property); - } - }); -}; - -/** - * # stringDistanceCapped(strA, strB, cap) - * Return the Levenshtein distance between two strings, but no more than cap. - * @param {string} strA - * @param {string} strB - * @param {number} number - * @return {number} min(string distance between strA and strB, cap) - * @api private - */ - -function stringDistanceCapped(strA, strB, cap) { - if (Math.abs(strA.length - strB.length) >= cap) { - return cap; - } - - var memo = []; - // `memo` is a two-dimensional array containing distances. - // memo[i][j] is the distance between strA.slice(0, i) and - // strB.slice(0, j). - for (var i = 0; i <= strA.length; i++) { - memo[i] = Array(strB.length + 1).fill(0); - memo[i][0] = i; - } - for (var j = 0; j < strB.length; j++) { - memo[0][j] = j; - } - - for (var i = 1; i <= strA.length; i++) { - var ch = strA.charCodeAt(i - 1); - for (var j = 1; j <= strB.length; j++) { - if (Math.abs(i - j) >= cap) { - memo[i][j] = cap; - continue; - } - memo[i][j] = Math.min( - memo[i - 1][j] + 1, - memo[i][j - 1] + 1, - memo[i - 1][j - 1] + - (ch === strB.charCodeAt(j - 1) ? 0 : 1) - ); - } - } - - return memo[strA.length][strB.length]; -} diff --git a/node_modules/chai/lib/chai/utils/test.js b/node_modules/chai/lib/chai/utils/test.js deleted file mode 100644 index 09886d4..0000000 --- a/node_modules/chai/lib/chai/utils/test.js +++ /dev/null @@ -1,28 +0,0 @@ -/*! - * Chai - test utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/*! - * Module dependencies - */ - -var flag = require('./flag'); - -/** - * ### .test(object, expression) - * - * Test and object for expression. - * - * @param {Object} object (constructed Assertion) - * @param {Arguments} chai.Assertion.prototype.assert arguments - * @namespace Utils - * @name test - */ - -module.exports = function test(obj, args) { - var negate = flag(obj, 'negate') - , expr = args[0]; - return negate ? !expr : expr; -}; diff --git a/node_modules/chai/lib/chai/utils/transferFlags.js b/node_modules/chai/lib/chai/utils/transferFlags.js deleted file mode 100644 index 7b50190..0000000 --- a/node_modules/chai/lib/chai/utils/transferFlags.js +++ /dev/null @@ -1,45 +0,0 @@ -/*! - * Chai - transferFlags utility - * Copyright(c) 2012-2014 Jake Luer - * MIT Licensed - */ - -/** - * ### .transferFlags(assertion, object, includeAll = true) - * - * Transfer all the flags for `assertion` to `object`. If - * `includeAll` is set to `false`, then the base Chai - * assertion flags (namely `object`, `ssfi`, `lockSsfi`, - * and `message`) will not be transferred. - * - * - * var newAssertion = new Assertion(); - * utils.transferFlags(assertion, newAssertion); - * - * var anotherAssertion = new Assertion(myObj); - * utils.transferFlags(assertion, anotherAssertion, false); - * - * @param {Assertion} assertion the assertion to transfer the flags from - * @param {Object} object the object to transfer the flags to; usually a new assertion - * @param {Boolean} includeAll - * @namespace Utils - * @name transferFlags - * @api private - */ - -module.exports = function transferFlags(assertion, object, includeAll) { - var flags = assertion.__flags || (assertion.__flags = Object.create(null)); - - if (!object.__flags) { - object.__flags = Object.create(null); - } - - includeAll = arguments.length === 3 ? includeAll : true; - - for (var flag in flags) { - if (includeAll || - (flag !== 'object' && flag !== 'ssfi' && flag !== 'lockSsfi' && flag != 'message')) { - object.__flags[flag] = flags[flag]; - } - } -}; diff --git a/node_modules/chai/package.json b/node_modules/chai/package.json deleted file mode 100644 index 7687b87..0000000 --- a/node_modules/chai/package.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "author": "Jake Luer ", - "name": "chai", - "description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.", - "keywords": [ - "test", - "assertion", - "assert", - "testing", - "chai" - ], - "homepage": "http://chaijs.com", - "license": "MIT", - "contributors": [ - "Jake Luer ", - "Domenic Denicola (http://domenicdenicola.com)", - "Veselin Todorov ", - "John Firebaugh " - ], - "version": "4.3.6", - "repository": { - "type": "git", - "url": "https://github.com/chaijs/chai" - }, - "bugs": { - "url": "https://github.com/chaijs/chai/issues" - }, - "main": "./index", - "exports": { - ".": { - "require": "./index.js", - "import": "./index.mjs" - }, - "./*": "./*" - }, - "scripts": { - "test": "make test" - }, - "engines": { - "node": ">=4" - }, - "dependencies": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "loupe": "^2.3.1", - "pathval": "^1.1.1", - "type-detect": "^4.0.5" - }, - "devDependencies": { - "browserify": "^16.2.3", - "bump-cli": "^1.1.3", - "codecov": "^3.0.0", - "istanbul": "^0.4.3", - "karma": "^6.1.1", - "karma-chrome-launcher": "^2.2.0", - "karma-firefox-launcher": "^1.0.0", - "karma-mocha": "^2.0.1", - "karma-sauce-launcher": "^1.2.0", - "mocha": "^7.1.2" - } -} diff --git a/node_modules/chai/register-assert.js b/node_modules/chai/register-assert.js deleted file mode 100644 index f80cb4d..0000000 --- a/node_modules/chai/register-assert.js +++ /dev/null @@ -1 +0,0 @@ -global.assert = require('./').assert; diff --git a/node_modules/chai/register-expect.js b/node_modules/chai/register-expect.js deleted file mode 100644 index f905c3a..0000000 --- a/node_modules/chai/register-expect.js +++ /dev/null @@ -1 +0,0 @@ -global.expect = require('./').expect; diff --git a/node_modules/chai/register-should.js b/node_modules/chai/register-should.js deleted file mode 100644 index 5dab96f..0000000 --- a/node_modules/chai/register-should.js +++ /dev/null @@ -1 +0,0 @@ -global.should = require('./').should(); diff --git a/node_modules/chai/sauce.browsers.js b/node_modules/chai/sauce.browsers.js deleted file mode 100644 index 328f0c7..0000000 --- a/node_modules/chai/sauce.browsers.js +++ /dev/null @@ -1,106 +0,0 @@ - -/*! - * Chrome - */ - -exports['SL_Chrome'] = { - base: 'SauceLabs' - , browserName: 'chrome' -}; - -/*! - * Firefox - */ - - exports['SL_Firefox'] = { - base: 'SauceLabs' - , browserName: 'firefox' - }; - - exports['SL_Firefox_ESR'] = { - base: 'SauceLabs' - , browserName: 'firefox' - , version: 38 - }; - -/*! - * Internet Explorer - */ - -exports['SL_IE'] = { - base: 'SauceLabs' - , browserName: 'internet explorer' -}; - -/*! - * TODO: fails because of Uint8Array support - * -exports['SL_IE_Old'] = { - base: 'SauceLabs' - , browserName: 'internet explorer' - , version: 10 -}; -*/ - -exports['SL_Edge'] = { - base: 'SauceLabs' - , browserName: 'microsoftedge' -}; - -/*! - * Safari - */ - -exports['SL_Safari'] = { - base: 'SauceLabs' - , browserName: 'safari' - , platform: 'Mac 10.11' -}; - -/*! - * iPhone - */ - -/*! - * TODO: These take forever to boot or shut down. Causes timeout. - * - -exports['SL_iPhone_6'] = { - base: 'SauceLabs' - , browserName: 'iphone' - , platform: 'Mac 10.8' - , version: '6' -}; - -exports['SL_iPhone_5-1'] = { - base: 'SauceLabs' - , browserName: 'iphone' - , platform: 'Mac 10.8' - , version: '5.1' -}; - -exports['SL_iPhone_5'] = { - base: 'SauceLabs' - , browserName: 'iphone' - , platform: 'Mac 10.6' - , version: '5' -}; - -*/ - -/*! - * Android - */ - -/*! - * TODO: fails because of error serialization - * - -exports['SL_Android_4'] = { - base: 'SauceLabs' - , browserName: 'android' - , platform: 'Linux' - , version: '4' -}; - -*/ diff --git a/node_modules/check-error/LICENSE b/node_modules/check-error/LICENSE deleted file mode 100644 index 7ea799f..0000000 --- a/node_modules/check-error/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2013 Jake Luer (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. diff --git a/node_modules/check-error/README.md b/node_modules/check-error/README.md deleted file mode 100644 index 1fa64c3..0000000 --- a/node_modules/check-error/README.md +++ /dev/null @@ -1,207 +0,0 @@ -

- - ChaiJS check-error - -

- -

- Error comparison and information related utility for node and the browser. -

- -

- - license:mit - - - tag:? - - - build:? - - - coverage:? - - - npm:? - - - dependencies:? - - - devDependencies:? - -
- - Selenium Test Status - -
- - Join the Slack chat - - - Join the Gitter chat - -

- -## What is Check-Error? - -Check-Error is a module which you can use to retrieve an Error's information such as its `message` or `constructor` name and also to check whether two Errors are compatible based on their messages, constructors or even instances. - -## Installation - -### Node.js - -`check-error` is available on [npm](http://npmjs.org). To install it, type: - - $ npm install check-error - -### Browsers - -You can also use it within the browser; install via npm and use the `check-error.js` file found within the download. For example: - -```html - -``` - -## Usage - -The primary export of `check-error` is an object which has the following methods: - -* `compatibleInstance(err, errorLike)` - Checks if an error is compatible with another `errorLike` object. If `errorLike` is an error instance we do a strict comparison, otherwise we return `false` by default, because instances of objects can only be compatible if they're both error instances. -* `compatibleConstructor(err, errorLike)` - Checks if an error's constructor is compatible with another `errorLike` object. If `err` has the same constructor as `errorLike` or if `err` is an instance of `errorLike`. -* `compatibleMessage(err, errMatcher)` - Checks if an error message is compatible with an `errMatcher` RegExp or String (we check if the message contains the String). -* `getConstructorName(errorLike)` - Retrieves the name of a constructor, an error's constructor or `errorLike` itself if it's not an error instance or constructor. -* `getMessage(err)` - Retrieves the message of an error or `err` itself if it's a String. If `err` or `err.message` is undefined we return an empty String. - -```js -var checkError = require('check-error'); -``` - -#### .compatibleInstance(err, errorLike) - -```js -var checkError = require('check-error'); - -var funcThatThrows = function() { throw new TypeError('I am a TypeError') }; -var caughtErr; - -try { - funcThatThrows(); -} catch(e) { - caughtErr = e; -} - -var sameInstance = caughtErr; - -checkError.compatibleInstance(caughtErr, sameInstance); // true -checkError.compatibleInstance(caughtErr, new TypeError('Another error')); // false -``` - -#### .compatibleConstructor(err, errorLike) - -```js -var checkError = require('check-error'); - -var funcThatThrows = function() { throw new TypeError('I am a TypeError') }; -var caughtErr; - -try { - funcThatThrows(); -} catch(e) { - caughtErr = e; -} - -checkError.compatibleConstructor(caughtErr, Error); // true -checkError.compatibleConstructor(caughtErr, TypeError); // true -checkError.compatibleConstructor(caughtErr, RangeError); // false -``` - -#### .compatibleMessage(err, errMatcher) - -```js -var checkError = require('check-error'); - -var funcThatThrows = function() { throw new TypeError('I am a TypeError') }; -var caughtErr; - -try { - funcThatThrows(); -} catch(e) { - caughtErr = e; -} - -var sameInstance = caughtErr; - -checkError.compatibleMessage(caughtErr, /TypeError$/); // true -checkError.compatibleMessage(caughtErr, 'I am a'); // true -checkError.compatibleMessage(caughtErr, /unicorn/); // false -checkError.compatibleMessage(caughtErr, 'I do not exist'); // false -``` - -#### .getConstructorName(errorLike) - -```js -var checkError = require('check-error'); - -var funcThatThrows = function() { throw new TypeError('I am a TypeError') }; -var caughtErr; - -try { - funcThatThrows(); -} catch(e) { - caughtErr = e; -} - -var sameInstance = caughtErr; - -checkError.getConstructorName(caughtErr) // 'TypeError' -``` - -#### .getMessage(err) - -```js -var checkError = require('check-error'); - -var funcThatThrows = function() { throw new TypeError('I am a TypeError') }; -var caughtErr; - -try { - funcThatThrows(); -} catch(e) { - caughtErr = e; -} - -var sameInstance = caughtErr; - -checkError.getMessage(caughtErr) // 'I am a TypeError' -``` diff --git a/node_modules/check-error/check-error.js b/node_modules/check-error/check-error.js deleted file mode 100644 index 8e47a65..0000000 --- a/node_modules/check-error/check-error.js +++ /dev/null @@ -1,176 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.checkError = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o - * MIT Licensed - */ - -/** - * ### .checkError - * - * Checks that an error conforms to a given set of criteria and/or retrieves information about it. - * - * @api public - */ - -/** - * ### .compatibleInstance(thrown, errorLike) - * - * Checks if two instances are compatible (strict equal). - * Returns false if errorLike is not an instance of Error, because instances - * can only be compatible if they're both error instances. - * - * @name compatibleInstance - * @param {Error} thrown error - * @param {Error|ErrorConstructor} errorLike object to compare against - * @namespace Utils - * @api public - */ - -function compatibleInstance(thrown, errorLike) { - return errorLike instanceof Error && thrown === errorLike; -} - -/** - * ### .compatibleConstructor(thrown, errorLike) - * - * Checks if two constructors are compatible. - * This function can receive either an error constructor or - * an error instance as the `errorLike` argument. - * Constructors are compatible if they're the same or if one is - * an instance of another. - * - * @name compatibleConstructor - * @param {Error} thrown error - * @param {Error|ErrorConstructor} errorLike object to compare against - * @namespace Utils - * @api public - */ - -function compatibleConstructor(thrown, errorLike) { - if (errorLike instanceof Error) { - // If `errorLike` is an instance of any error we compare their constructors - return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor; - } else if (errorLike.prototype instanceof Error || errorLike === Error) { - // If `errorLike` is a constructor that inherits from Error, we compare `thrown` to `errorLike` directly - return thrown.constructor === errorLike || thrown instanceof errorLike; - } - - return false; -} - -/** - * ### .compatibleMessage(thrown, errMatcher) - * - * Checks if an error's message is compatible with a matcher (String or RegExp). - * If the message contains the String or passes the RegExp test, - * it is considered compatible. - * - * @name compatibleMessage - * @param {Error} thrown error - * @param {String|RegExp} errMatcher to look for into the message - * @namespace Utils - * @api public - */ - -function compatibleMessage(thrown, errMatcher) { - var comparisonString = typeof thrown === 'string' ? thrown : thrown.message; - if (errMatcher instanceof RegExp) { - return errMatcher.test(comparisonString); - } else if (typeof errMatcher === 'string') { - return comparisonString.indexOf(errMatcher) !== -1; // eslint-disable-line no-magic-numbers - } - - return false; -} - -/** - * ### .getFunctionName(constructorFn) - * - * Returns the name of a function. - * This also includes a polyfill function if `constructorFn.name` is not defined. - * - * @name getFunctionName - * @param {Function} constructorFn - * @namespace Utils - * @api private - */ - -var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\(\/]+)/; -function getFunctionName(constructorFn) { - var name = ''; - if (typeof constructorFn.name === 'undefined') { - // Here we run a polyfill if constructorFn.name is not defined - var match = String(constructorFn).match(functionNameMatch); - if (match) { - name = match[1]; - } - } else { - name = constructorFn.name; - } - - return name; -} - -/** - * ### .getConstructorName(errorLike) - * - * Gets the constructor name for an Error instance or constructor itself. - * - * @name getConstructorName - * @param {Error|ErrorConstructor} errorLike - * @namespace Utils - * @api public - */ - -function getConstructorName(errorLike) { - var constructorName = errorLike; - if (errorLike instanceof Error) { - constructorName = getFunctionName(errorLike.constructor); - } else if (typeof errorLike === 'function') { - // If `err` is not an instance of Error it is an error constructor itself or another function. - // If we've got a common function we get its name, otherwise we may need to create a new instance - // of the error just in case it's a poorly-constructed error. Please see chaijs/chai/issues/45 to know more. - constructorName = getFunctionName(errorLike).trim() || - getFunctionName(new errorLike()); // eslint-disable-line new-cap - } - - return constructorName; -} - -/** - * ### .getMessage(errorLike) - * - * Gets the error message from an error. - * If `err` is a String itself, we return it. - * If the error has no message, we return an empty string. - * - * @name getMessage - * @param {Error|String} errorLike - * @namespace Utils - * @api public - */ - -function getMessage(errorLike) { - var msg = ''; - if (errorLike && errorLike.message) { - msg = errorLike.message; - } else if (typeof errorLike === 'string') { - msg = errorLike; - } - - return msg; -} - -module.exports = { - compatibleInstance: compatibleInstance, - compatibleConstructor: compatibleConstructor, - compatibleMessage: compatibleMessage, - getMessage: getMessage, - getConstructorName: getConstructorName, -}; - -},{}]},{},[1])(1) -}); \ No newline at end of file diff --git a/node_modules/check-error/index.js b/node_modules/check-error/index.js deleted file mode 100644 index 603ef50..0000000 --- a/node_modules/check-error/index.js +++ /dev/null @@ -1,172 +0,0 @@ -'use strict'; - -/* ! - * Chai - checkError utility - * Copyright(c) 2012-2016 Jake Luer - * MIT Licensed - */ - -/** - * ### .checkError - * - * Checks that an error conforms to a given set of criteria and/or retrieves information about it. - * - * @api public - */ - -/** - * ### .compatibleInstance(thrown, errorLike) - * - * Checks if two instances are compatible (strict equal). - * Returns false if errorLike is not an instance of Error, because instances - * can only be compatible if they're both error instances. - * - * @name compatibleInstance - * @param {Error} thrown error - * @param {Error|ErrorConstructor} errorLike object to compare against - * @namespace Utils - * @api public - */ - -function compatibleInstance(thrown, errorLike) { - return errorLike instanceof Error && thrown === errorLike; -} - -/** - * ### .compatibleConstructor(thrown, errorLike) - * - * Checks if two constructors are compatible. - * This function can receive either an error constructor or - * an error instance as the `errorLike` argument. - * Constructors are compatible if they're the same or if one is - * an instance of another. - * - * @name compatibleConstructor - * @param {Error} thrown error - * @param {Error|ErrorConstructor} errorLike object to compare against - * @namespace Utils - * @api public - */ - -function compatibleConstructor(thrown, errorLike) { - if (errorLike instanceof Error) { - // If `errorLike` is an instance of any error we compare their constructors - return thrown.constructor === errorLike.constructor || thrown instanceof errorLike.constructor; - } else if (errorLike.prototype instanceof Error || errorLike === Error) { - // If `errorLike` is a constructor that inherits from Error, we compare `thrown` to `errorLike` directly - return thrown.constructor === errorLike || thrown instanceof errorLike; - } - - return false; -} - -/** - * ### .compatibleMessage(thrown, errMatcher) - * - * Checks if an error's message is compatible with a matcher (String or RegExp). - * If the message contains the String or passes the RegExp test, - * it is considered compatible. - * - * @name compatibleMessage - * @param {Error} thrown error - * @param {String|RegExp} errMatcher to look for into the message - * @namespace Utils - * @api public - */ - -function compatibleMessage(thrown, errMatcher) { - var comparisonString = typeof thrown === 'string' ? thrown : thrown.message; - if (errMatcher instanceof RegExp) { - return errMatcher.test(comparisonString); - } else if (typeof errMatcher === 'string') { - return comparisonString.indexOf(errMatcher) !== -1; // eslint-disable-line no-magic-numbers - } - - return false; -} - -/** - * ### .getFunctionName(constructorFn) - * - * Returns the name of a function. - * This also includes a polyfill function if `constructorFn.name` is not defined. - * - * @name getFunctionName - * @param {Function} constructorFn - * @namespace Utils - * @api private - */ - -var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\(\/]+)/; -function getFunctionName(constructorFn) { - var name = ''; - if (typeof constructorFn.name === 'undefined') { - // Here we run a polyfill if constructorFn.name is not defined - var match = String(constructorFn).match(functionNameMatch); - if (match) { - name = match[1]; - } - } else { - name = constructorFn.name; - } - - return name; -} - -/** - * ### .getConstructorName(errorLike) - * - * Gets the constructor name for an Error instance or constructor itself. - * - * @name getConstructorName - * @param {Error|ErrorConstructor} errorLike - * @namespace Utils - * @api public - */ - -function getConstructorName(errorLike) { - var constructorName = errorLike; - if (errorLike instanceof Error) { - constructorName = getFunctionName(errorLike.constructor); - } else if (typeof errorLike === 'function') { - // If `err` is not an instance of Error it is an error constructor itself or another function. - // If we've got a common function we get its name, otherwise we may need to create a new instance - // of the error just in case it's a poorly-constructed error. Please see chaijs/chai/issues/45 to know more. - constructorName = getFunctionName(errorLike).trim() || - getFunctionName(new errorLike()); // eslint-disable-line new-cap - } - - return constructorName; -} - -/** - * ### .getMessage(errorLike) - * - * Gets the error message from an error. - * If `err` is a String itself, we return it. - * If the error has no message, we return an empty string. - * - * @name getMessage - * @param {Error|String} errorLike - * @namespace Utils - * @api public - */ - -function getMessage(errorLike) { - var msg = ''; - if (errorLike && errorLike.message) { - msg = errorLike.message; - } else if (typeof errorLike === 'string') { - msg = errorLike; - } - - return msg; -} - -module.exports = { - compatibleInstance: compatibleInstance, - compatibleConstructor: compatibleConstructor, - compatibleMessage: compatibleMessage, - getMessage: getMessage, - getConstructorName: getConstructorName, -}; diff --git a/node_modules/check-error/package.json b/node_modules/check-error/package.json deleted file mode 100644 index fc2a5c7..0000000 --- a/node_modules/check-error/package.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "_from": "check-error@^1.0.2", - "_id": "check-error@1.0.2", - "_inBundle": false, - "_integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "_location": "/check-error", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "check-error@^1.0.2", - "name": "check-error", - "escapedName": "check-error", - "rawSpec": "^1.0.2", - "saveSpec": null, - "fetchSpec": "^1.0.2" - }, - "_requiredBy": [ - "/chai" - ], - "_resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "_shasum": "574d312edd88bb5dd8912e9286dd6c0aed4aac82", - "_spec": "check-error@^1.0.2", - "_where": "C:\\src\\github\\makensis-action\\node_modules\\chai", - "author": { - "name": "Jake Luer", - "email": "jake@alogicalparadox.com", - "url": "http://alogicalparadox.com" - }, - "bugs": { - "url": "https://github.com/chaijs/check-error/issues" - }, - "bundleDependencies": false, - "config": { - "ghooks": { - "commit-msg": "validate-commit-msg" - } - }, - "contributors": [ - { - "name": "David Losert", - "url": "https://github.com/davelosert" - }, - { - "name": "Keith Cirkel", - "url": "https://github.com/keithamus" - }, - { - "name": "Miroslav Bajtoš", - "url": "https://github.com/bajtos" - }, - { - "name": "Lucas Fernandes da Costa", - "url": "https://github.com/lucasfcosta" - } - ], - "dependencies": {}, - "deprecated": false, - "description": "Error comparison and information related utility for node and the browser", - "devDependencies": { - "browserify": "^13.0.0", - "browserify-istanbul": "^1.0.0", - "coveralls": "2.11.9", - "eslint": "^2.4.0", - "eslint-config-strict": "^8.5.0", - "eslint-plugin-filenames": "^0.2.0", - "ghooks": "^1.0.1", - "istanbul": "^0.4.2", - "karma": "^0.13.22", - "karma-browserify": "^5.0.2", - "karma-coverage": "^0.5.5", - "karma-mocha": "^0.2.2", - "karma-phantomjs-launcher": "^1.0.0", - "karma-sauce-launcher": "^0.3.1", - "lcov-result-merger": "^1.0.2", - "mocha": "^2.4.5", - "phantomjs-prebuilt": "^2.1.5", - "semantic-release": "^4.3.5", - "simple-assert": "^1.0.0", - "travis-after-all": "^1.4.4", - "validate-commit-msg": "^2.3.1" - }, - "engines": { - "node": "*" - }, - "eslintConfig": { - "extends": [ - "strict/es5" - ], - "env": { - "es6": true - }, - "globals": { - "HTMLElement": false - }, - "rules": { - "complexity": 0, - "max-statements": 0 - } - }, - "files": [ - "index.js", - "check-error.js" - ], - "homepage": "https://github.com/chaijs/check-error#readme", - "keywords": [ - "check-error", - "error", - "chai util" - ], - "license": "MIT", - "main": "./index.js", - "name": "check-error", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/chaijs/check-error.git" - }, - "scripts": { - "build": "browserify --bare $npm_package_main --standalone checkError -o check-error.js", - "lint": "eslint --ignore-path .gitignore .", - "prepublish": "npm run build", - "pretest": "npm run lint", - "semantic-release": "semantic-release pre && npm publish && semantic-release post", - "test": "npm run test:node && npm run test:browser && npm run upload-coverage", - "test:browser": "karma start --singleRun=true", - "test:node": "istanbul cover _mocha", - "upload-coverage": "lcov-result-merger 'coverage/**/lcov.info' | coveralls; exit 0" - }, - "version": "1.0.2" -} diff --git a/node_modules/deep-eql/LICENSE b/node_modules/deep-eql/LICENSE deleted file mode 100644 index 7ea799f..0000000 --- a/node_modules/deep-eql/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2013 Jake Luer (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. diff --git a/node_modules/deep-eql/README.md b/node_modules/deep-eql/README.md deleted file mode 100644 index 96ecef1..0000000 --- a/node_modules/deep-eql/README.md +++ /dev/null @@ -1,116 +0,0 @@ -

- - ChaiJS deep-eql - -

- -

- Improved deep equality testing for [node](http://nodejs.org) and the browser. -

- -

- - license:mit - - tag:? - - build:? - - coverage:? - - code quality:? - - dependencies:? - - devDependencies:? - - Supported Node Version: 4+ - -
- - Selenium Test Status - -
- - Join the Slack chat - - - Join the Gitter chat - -

- -## What is Deep-Eql? - -Deep Eql is a module which you can use to determine if two objects are "deeply" equal - that is, rather than having referential equality (`a === b`), this module checks an object's keys recursively, until it finds primitives to check for referential equality. For more on equality in JavaScript, read [the comparison operators article on mdn](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators). - -As an example, take the following: - -```js -1 === 1 // These are primitives, they hold the same reference - they are strictly equal -1 == '1' // These are two different primitives, through type coercion they hold the same value - they are loosely equal -{ a: 1 } !== { a: 1 } // These are two different objects, they hold different references and so are not strictly equal - even though they hold the same values inside -{ a: 1 } != { a: 1 } // They have the same type, meaning loose equality performs the same check as strict equality - they are still not equal. - -var deepEql = require("deep-eql"); -deepEql({ a: 1 }, { a: 1 }) === true // deepEql can determine that they share the same keys and those keys share the same values, therefore they are deeply equal! -``` - -## Installation - -### Node.js - -`deep-eql` is available on [npm](http://npmjs.org). - - $ npm install deep-eql - -## Usage - -The primary export of `deep-eql` is function that can be given two objects to compare. It will always return a boolean which can be used to determine if two objects are deeply equal. - -### Rules - -- Strict equality for non-traversable nodes according to [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is): - - `eql(NaN, NaN).should.be.true;` - - `eql(-0, +0).should.be.false;` -- All own and inherited enumerable properties are considered: - - `eql(Object.create({ foo: { a: 1 } }), Object.create({ foo: { a: 1 } })).should.be.true;` - - `eql(Object.create({ foo: { a: 1 } }), Object.create({ foo: { a: 2 } })).should.be.false;` -- Arguments are not Arrays: - - `eql([], arguments).should.be.false;` - - `eql([], Array.prototype.slice.call(arguments)).should.be.true;` -- Error objects are compared by reference (see https://github.com/chaijs/chai/issues/608): - - `eql(new Error('msg'), new Error('msg')).should.be.false;` - - `var err = new Error('msg'); eql(err, err).should.be.true;` diff --git a/node_modules/deep-eql/deep-eql.js b/node_modules/deep-eql/deep-eql.js deleted file mode 100644 index 86f0b41..0000000 --- a/node_modules/deep-eql/deep-eql.js +++ /dev/null @@ -1,833 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.deepEqual = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o - * MIT Licensed - */ - -var type = require('type-detect'); -function FakeMap() { - this._key = 'chai/deep-eql__' + Math.random() + Date.now(); -} - -FakeMap.prototype = { - get: function getMap(key) { - return key[this._key]; - }, - set: function setMap(key, value) { - if (Object.isExtensible(key)) { - Object.defineProperty(key, this._key, { - value: value, - configurable: true, - }); - } - }, -}; - -var MemoizeMap = typeof WeakMap === 'function' ? WeakMap : FakeMap; -/*! - * Check to see if the MemoizeMap has recorded a result of the two operands - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {MemoizeMap} memoizeMap - * @returns {Boolean|null} result -*/ -function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) { - // Technically, WeakMap keys can *only* be objects, not primitives. - if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) { - return null; - } - var leftHandMap = memoizeMap.get(leftHandOperand); - if (leftHandMap) { - var result = leftHandMap.get(rightHandOperand); - if (typeof result === 'boolean') { - return result; - } - } - return null; -} - -/*! - * Set the result of the equality into the MemoizeMap - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {MemoizeMap} memoizeMap - * @param {Boolean} result -*/ -function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) { - // Technically, WeakMap keys can *only* be objects, not primitives. - if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) { - return; - } - var leftHandMap = memoizeMap.get(leftHandOperand); - if (leftHandMap) { - leftHandMap.set(rightHandOperand, result); - } else { - leftHandMap = new MemoizeMap(); - leftHandMap.set(rightHandOperand, result); - memoizeMap.set(leftHandOperand, leftHandMap); - } -} - -/*! - * Primary Export - */ - -module.exports = deepEqual; -module.exports.MemoizeMap = MemoizeMap; - -/** - * Assert deeply nested sameValue equality between two objects of any type. - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {Object} [options] (optional) Additional options - * @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality. - * @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of - complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular - references to blow the stack. - * @return {Boolean} equal match - */ -function deepEqual(leftHandOperand, rightHandOperand, options) { - // If we have a comparator, we can't assume anything; so bail to its check first. - if (options && options.comparator) { - return extensiveDeepEqual(leftHandOperand, rightHandOperand, options); - } - - var simpleResult = simpleEqual(leftHandOperand, rightHandOperand); - if (simpleResult !== null) { - return simpleResult; - } - - // Deeper comparisons are pushed through to a larger function - return extensiveDeepEqual(leftHandOperand, rightHandOperand, options); -} - -/** - * Many comparisons can be canceled out early via simple equality or primitive checks. - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @return {Boolean|null} equal match - */ -function simpleEqual(leftHandOperand, rightHandOperand) { - // Equal references (except for Numbers) can be returned early - if (leftHandOperand === rightHandOperand) { - // Handle +-0 cases - return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand; - } - - // handle NaN cases - if ( - leftHandOperand !== leftHandOperand && // eslint-disable-line no-self-compare - rightHandOperand !== rightHandOperand // eslint-disable-line no-self-compare - ) { - return true; - } - - // Anything that is not an 'object', i.e. symbols, functions, booleans, numbers, - // strings, and undefined, can be compared by reference. - if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) { - // Easy out b/c it would have passed the first equality check - return false; - } - return null; -} - -/*! - * The main logic of the `deepEqual` function. - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {Object} [options] (optional) Additional options - * @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality. - * @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of - complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular - references to blow the stack. - * @return {Boolean} equal match -*/ -function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) { - options = options || {}; - options.memoize = options.memoize === false ? false : options.memoize || new MemoizeMap(); - var comparator = options && options.comparator; - - // Check if a memoized result exists. - var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize); - if (memoizeResultLeft !== null) { - return memoizeResultLeft; - } - var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize); - if (memoizeResultRight !== null) { - return memoizeResultRight; - } - - // If a comparator is present, use it. - if (comparator) { - var comparatorResult = comparator(leftHandOperand, rightHandOperand); - // Comparators may return null, in which case we want to go back to default behavior. - if (comparatorResult === false || comparatorResult === true) { - memoizeSet(leftHandOperand, rightHandOperand, options.memoize, comparatorResult); - return comparatorResult; - } - // To allow comparators to override *any* behavior, we ran them first. Since it didn't decide - // what to do, we need to make sure to return the basic tests first before we move on. - var simpleResult = simpleEqual(leftHandOperand, rightHandOperand); - if (simpleResult !== null) { - // Don't memoize this, it takes longer to set/retrieve than to just compare. - return simpleResult; - } - } - - var leftHandType = type(leftHandOperand); - if (leftHandType !== type(rightHandOperand)) { - memoizeSet(leftHandOperand, rightHandOperand, options.memoize, false); - return false; - } - - // Temporarily set the operands in the memoize object to prevent blowing the stack - memoizeSet(leftHandOperand, rightHandOperand, options.memoize, true); - - var result = extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options); - memoizeSet(leftHandOperand, rightHandOperand, options.memoize, result); - return result; -} - -function extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options) { - switch (leftHandType) { - case 'String': - case 'Number': - case 'Boolean': - case 'Date': - // If these types are their instance types (e.g. `new Number`) then re-deepEqual against their values - return deepEqual(leftHandOperand.valueOf(), rightHandOperand.valueOf()); - case 'Promise': - case 'Symbol': - case 'function': - case 'WeakMap': - case 'WeakSet': - case 'Error': - return leftHandOperand === rightHandOperand; - case 'Arguments': - case 'Int8Array': - case 'Uint8Array': - case 'Uint8ClampedArray': - case 'Int16Array': - case 'Uint16Array': - case 'Int32Array': - case 'Uint32Array': - case 'Float32Array': - case 'Float64Array': - case 'Array': - return iterableEqual(leftHandOperand, rightHandOperand, options); - case 'RegExp': - return regexpEqual(leftHandOperand, rightHandOperand); - case 'Generator': - return generatorEqual(leftHandOperand, rightHandOperand, options); - case 'DataView': - return iterableEqual(new Uint8Array(leftHandOperand.buffer), new Uint8Array(rightHandOperand.buffer), options); - case 'ArrayBuffer': - return iterableEqual(new Uint8Array(leftHandOperand), new Uint8Array(rightHandOperand), options); - case 'Set': - return entriesEqual(leftHandOperand, rightHandOperand, options); - case 'Map': - return entriesEqual(leftHandOperand, rightHandOperand, options); - default: - return objectEqual(leftHandOperand, rightHandOperand, options); - } -} - -/*! - * Compare two Regular Expressions for equality. - * - * @param {RegExp} leftHandOperand - * @param {RegExp} rightHandOperand - * @return {Boolean} result - */ - -function regexpEqual(leftHandOperand, rightHandOperand) { - return leftHandOperand.toString() === rightHandOperand.toString(); -} - -/*! - * Compare two Sets/Maps for equality. Faster than other equality functions. - * - * @param {Set} leftHandOperand - * @param {Set} rightHandOperand - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ - -function entriesEqual(leftHandOperand, rightHandOperand, options) { - // IE11 doesn't support Set#entries or Set#@@iterator, so we need manually populate using Set#forEach - if (leftHandOperand.size !== rightHandOperand.size) { - return false; - } - if (leftHandOperand.size === 0) { - return true; - } - var leftHandItems = []; - var rightHandItems = []; - leftHandOperand.forEach(function gatherEntries(key, value) { - leftHandItems.push([ key, value ]); - }); - rightHandOperand.forEach(function gatherEntries(key, value) { - rightHandItems.push([ key, value ]); - }); - return iterableEqual(leftHandItems.sort(), rightHandItems.sort(), options); -} - -/*! - * Simple equality for flat iterable objects such as Arrays, TypedArrays or Node.js buffers. - * - * @param {Iterable} leftHandOperand - * @param {Iterable} rightHandOperand - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ - -function iterableEqual(leftHandOperand, rightHandOperand, options) { - var length = leftHandOperand.length; - if (length !== rightHandOperand.length) { - return false; - } - if (length === 0) { - return true; - } - var index = -1; - while (++index < length) { - if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) { - return false; - } - } - return true; -} - -/*! - * Simple equality for generator objects such as those returned by generator functions. - * - * @param {Iterable} leftHandOperand - * @param {Iterable} rightHandOperand - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ - -function generatorEqual(leftHandOperand, rightHandOperand, options) { - return iterableEqual(getGeneratorEntries(leftHandOperand), getGeneratorEntries(rightHandOperand), options); -} - -/*! - * Determine if the given object has an @@iterator function. - * - * @param {Object} target - * @return {Boolean} `true` if the object has an @@iterator function. - */ -function hasIteratorFunction(target) { - return typeof Symbol !== 'undefined' && - typeof target === 'object' && - typeof Symbol.iterator !== 'undefined' && - typeof target[Symbol.iterator] === 'function'; -} - -/*! - * Gets all iterator entries from the given Object. If the Object has no @@iterator function, returns an empty array. - * This will consume the iterator - which could have side effects depending on the @@iterator implementation. - * - * @param {Object} target - * @returns {Array} an array of entries from the @@iterator function - */ -function getIteratorEntries(target) { - if (hasIteratorFunction(target)) { - try { - return getGeneratorEntries(target[Symbol.iterator]()); - } catch (iteratorError) { - return []; - } - } - return []; -} - -/*! - * Gets all entries from a Generator. This will consume the generator - which could have side effects. - * - * @param {Generator} target - * @returns {Array} an array of entries from the Generator. - */ -function getGeneratorEntries(generator) { - var generatorResult = generator.next(); - var accumulator = [ generatorResult.value ]; - while (generatorResult.done === false) { - generatorResult = generator.next(); - accumulator.push(generatorResult.value); - } - return accumulator; -} - -/*! - * Gets all own and inherited enumerable keys from a target. - * - * @param {Object} target - * @returns {Array} an array of own and inherited enumerable keys from the target. - */ -function getEnumerableKeys(target) { - var keys = []; - for (var key in target) { - keys.push(key); - } - return keys; -} - -/*! - * Determines if two objects have matching values, given a set of keys. Defers to deepEqual for the equality check of - * each key. If any value of the given key is not equal, the function will return false (early). - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {Array} keys An array of keys to compare the values of leftHandOperand and rightHandOperand against - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ -function keysEqual(leftHandOperand, rightHandOperand, keys, options) { - var length = keys.length; - if (length === 0) { - return true; - } - for (var i = 0; i < length; i += 1) { - if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) { - return false; - } - } - return true; -} - -/*! - * 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} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ - -function objectEqual(leftHandOperand, rightHandOperand, options) { - var leftHandKeys = getEnumerableKeys(leftHandOperand); - var rightHandKeys = getEnumerableKeys(rightHandOperand); - if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) { - leftHandKeys.sort(); - rightHandKeys.sort(); - if (iterableEqual(leftHandKeys, rightHandKeys) === false) { - return false; - } - return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options); - } - - var leftHandEntries = getIteratorEntries(leftHandOperand); - var rightHandEntries = getIteratorEntries(rightHandOperand); - if (leftHandEntries.length && leftHandEntries.length === rightHandEntries.length) { - leftHandEntries.sort(); - rightHandEntries.sort(); - return iterableEqual(leftHandEntries, rightHandEntries, options); - } - - if (leftHandKeys.length === 0 && - leftHandEntries.length === 0 && - rightHandKeys.length === 0 && - rightHandEntries.length === 0) { - return true; - } - - return false; -} - -/*! - * Returns true if the argument is a primitive. - * - * This intentionally returns true for all objects that can be compared by reference, - * including functions and symbols. - * - * @param {Mixed} value - * @return {Boolean} result - */ -function isPrimitive(value) { - return value === null || typeof value !== 'object'; -} - -},{"type-detect":2}],2:[function(require,module,exports){ -(function (global){ -'use strict'; - -/* ! - * type-detect - * Copyright(c) 2013 jake luer - * MIT Licensed - */ -var promiseExists = typeof Promise === 'function'; -var globalObject = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : self; // eslint-disable-line -var isDom = 'location' in globalObject && 'document' in globalObject; -var symbolExists = typeof Symbol !== 'undefined'; -var mapExists = typeof Map !== 'undefined'; -var setExists = typeof Set !== 'undefined'; -var weakMapExists = typeof WeakMap !== 'undefined'; -var weakSetExists = typeof WeakSet !== 'undefined'; -var dataViewExists = typeof DataView !== 'undefined'; -var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined'; -var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined'; -var setEntriesExists = setExists && typeof Set.prototype.entries === 'function'; -var mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function'; -var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries()); -var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries()); -var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function'; -var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]()); -var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === 'function'; -var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]()); -var toStringLeftSliceLength = 8; -var toStringRightSliceLength = -1; -/** - * ### typeOf (obj) - * - * Uses `Object.prototype.toString` to determine the type of an object, - * normalising behaviour across engine versions & well optimised. - * - * @param {Mixed} object - * @return {String} object type - * @api public - */ -module.exports = function typeDetect(obj) { - /* ! Speed optimisation - * Pre: - * string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled) - * boolean literal x 1,424,138 ops/sec ±4.54% (75 runs sampled) - * number literal x 1,653,153 ops/sec ±1.91% (82 runs sampled) - * undefined x 9,978,660 ops/sec ±1.92% (75 runs sampled) - * function x 2,556,769 ops/sec ±1.73% (77 runs sampled) - * Post: - * string literal x 38,564,796 ops/sec ±1.15% (79 runs sampled) - * boolean literal x 31,148,940 ops/sec ±1.10% (79 runs sampled) - * number literal x 32,679,330 ops/sec ±1.90% (78 runs sampled) - * undefined x 32,363,368 ops/sec ±1.07% (82 runs sampled) - * function x 31,296,870 ops/sec ±0.96% (83 runs sampled) - */ - var typeofObj = typeof obj; - if (typeofObj !== 'object') { - return typeofObj; - } - - /* ! Speed optimisation - * Pre: - * null x 28,645,765 ops/sec ±1.17% (82 runs sampled) - * Post: - * null x 36,428,962 ops/sec ±1.37% (84 runs sampled) - */ - if (obj === null) { - return 'null'; - } - - /* ! Spec Conformance - * Test: `Object.prototype.toString.call(window)`` - * - Node === "[object global]" - * - Chrome === "[object global]" - * - Firefox === "[object Window]" - * - PhantomJS === "[object Window]" - * - Safari === "[object Window]" - * - IE 11 === "[object Window]" - * - IE Edge === "[object Window]" - * Test: `Object.prototype.toString.call(this)`` - * - Chrome Worker === "[object global]" - * - Firefox Worker === "[object DedicatedWorkerGlobalScope]" - * - Safari Worker === "[object DedicatedWorkerGlobalScope]" - * - IE 11 Worker === "[object WorkerGlobalScope]" - * - IE Edge Worker === "[object WorkerGlobalScope]" - */ - if (obj === globalObject) { - return 'global'; - } - - /* ! Speed optimisation - * Pre: - * array literal x 2,888,352 ops/sec ±0.67% (82 runs sampled) - * Post: - * array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled) - */ - if ( - Array.isArray(obj) && - (symbolToStringTagExists === false || !(Symbol.toStringTag in obj)) - ) { - return 'Array'; - } - - if (isDom) { - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/browsers.html#location) - * WhatWG HTML$7.7.3 - The `Location` interface - * Test: `Object.prototype.toString.call(window.location)`` - * - IE <=11 === "[object Object]" - * - IE Edge <=13 === "[object Object]" - */ - if (obj === globalObject.location) { - return 'Location'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/#document) - * WhatWG HTML$3.1.1 - The `Document` object - * Note: Most browsers currently adher to the W3C DOM Level 2 spec - * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268) - * which suggests that browsers should use HTMLTableCellElement for - * both TD and TH elements. WhatWG separates these. - * WhatWG HTML states: - * > For historical reasons, Window objects must also have a - * > writable, configurable, non-enumerable property named - * > HTMLDocument whose value is the Document interface object. - * Test: `Object.prototype.toString.call(document)`` - * - Chrome === "[object HTMLDocument]" - * - Firefox === "[object HTMLDocument]" - * - Safari === "[object HTMLDocument]" - * - IE <=10 === "[object Document]" - * - IE 11 === "[object HTMLDocument]" - * - IE Edge <=13 === "[object HTMLDocument]" - */ - if (obj === globalObject.document) { - return 'Document'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray) - * WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray - * Test: `Object.prototype.toString.call(navigator.mimeTypes)`` - * - IE <=10 === "[object MSMimeTypesCollection]" - */ - if (obj === (globalObject.navigator || {}).mimeTypes) { - return 'MimeTypeArray'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray) - * WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray - * Test: `Object.prototype.toString.call(navigator.plugins)`` - * - IE <=10 === "[object MSPluginsCollection]" - */ - if (obj === (globalObject.navigator || {}).plugins) { - return 'PluginArray'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray) - * WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement` - * Test: `Object.prototype.toString.call(document.createElement('blockquote'))`` - * - IE <=10 === "[object HTMLBlockElement]" - */ - if (obj instanceof HTMLElement && obj.tagName === 'BLOCKQUOTE') { - return 'HTMLQuoteElement'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/#htmltabledatacellelement) - * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement` - * Note: Most browsers currently adher to the W3C DOM Level 2 spec - * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075) - * which suggests that browsers should use HTMLTableCellElement for - * both TD and TH elements. WhatWG separates these. - * Test: Object.prototype.toString.call(document.createElement('td')) - * - Chrome === "[object HTMLTableCellElement]" - * - Firefox === "[object HTMLTableCellElement]" - * - Safari === "[object HTMLTableCellElement]" - */ - if (obj instanceof HTMLElement && obj.tagName === 'TD') { - return 'HTMLTableDataCellElement'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/#htmltableheadercellelement) - * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement` - * Note: Most browsers currently adher to the W3C DOM Level 2 spec - * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075) - * which suggests that browsers should use HTMLTableCellElement for - * both TD and TH elements. WhatWG separates these. - * Test: Object.prototype.toString.call(document.createElement('th')) - * - Chrome === "[object HTMLTableCellElement]" - * - Firefox === "[object HTMLTableCellElement]" - * - Safari === "[object HTMLTableCellElement]" - */ - if (obj instanceof HTMLElement && obj.tagName === 'TH') { - return 'HTMLTableHeaderCellElement'; - } - } - - /* ! Speed optimisation - * Pre: - * Float64Array x 625,644 ops/sec ±1.58% (80 runs sampled) - * Float32Array x 1,279,852 ops/sec ±2.91% (77 runs sampled) - * Uint32Array x 1,178,185 ops/sec ±1.95% (83 runs sampled) - * Uint16Array x 1,008,380 ops/sec ±2.25% (80 runs sampled) - * Uint8Array x 1,128,040 ops/sec ±2.11% (81 runs sampled) - * Int32Array x 1,170,119 ops/sec ±2.88% (80 runs sampled) - * Int16Array x 1,176,348 ops/sec ±5.79% (86 runs sampled) - * Int8Array x 1,058,707 ops/sec ±4.94% (77 runs sampled) - * Uint8ClampedArray x 1,110,633 ops/sec ±4.20% (80 runs sampled) - * Post: - * Float64Array x 7,105,671 ops/sec ±13.47% (64 runs sampled) - * Float32Array x 5,887,912 ops/sec ±1.46% (82 runs sampled) - * Uint32Array x 6,491,661 ops/sec ±1.76% (79 runs sampled) - * Uint16Array x 6,559,795 ops/sec ±1.67% (82 runs sampled) - * Uint8Array x 6,463,966 ops/sec ±1.43% (85 runs sampled) - * Int32Array x 5,641,841 ops/sec ±3.49% (81 runs sampled) - * Int16Array x 6,583,511 ops/sec ±1.98% (80 runs sampled) - * Int8Array x 6,606,078 ops/sec ±1.74% (81 runs sampled) - * Uint8ClampedArray x 6,602,224 ops/sec ±1.77% (83 runs sampled) - */ - var stringTag = (symbolToStringTagExists && obj[Symbol.toStringTag]); - if (typeof stringTag === 'string') { - return stringTag; - } - - var objPrototype = Object.getPrototypeOf(obj); - /* ! Speed optimisation - * Pre: - * regex literal x 1,772,385 ops/sec ±1.85% (77 runs sampled) - * regex constructor x 2,143,634 ops/sec ±2.46% (78 runs sampled) - * Post: - * regex literal x 3,928,009 ops/sec ±0.65% (78 runs sampled) - * regex constructor x 3,931,108 ops/sec ±0.58% (84 runs sampled) - */ - if (objPrototype === RegExp.prototype) { - return 'RegExp'; - } - - /* ! Speed optimisation - * Pre: - * date x 2,130,074 ops/sec ±4.42% (68 runs sampled) - * Post: - * date x 3,953,779 ops/sec ±1.35% (77 runs sampled) - */ - if (objPrototype === Date.prototype) { - return 'Date'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag) - * ES6$25.4.5.4 - Promise.prototype[@@toStringTag] should be "Promise": - * Test: `Object.prototype.toString.call(Promise.resolve())`` - * - Chrome <=47 === "[object Object]" - * - Edge <=20 === "[object Object]" - * - Firefox 29-Latest === "[object Promise]" - * - Safari 7.1-Latest === "[object Promise]" - */ - if (promiseExists && objPrototype === Promise.prototype) { - return 'Promise'; - } - - /* ! Speed optimisation - * Pre: - * set x 2,222,186 ops/sec ±1.31% (82 runs sampled) - * Post: - * set x 4,545,879 ops/sec ±1.13% (83 runs sampled) - */ - if (setExists && objPrototype === Set.prototype) { - return 'Set'; - } - - /* ! Speed optimisation - * Pre: - * map x 2,396,842 ops/sec ±1.59% (81 runs sampled) - * Post: - * map x 4,183,945 ops/sec ±6.59% (82 runs sampled) - */ - if (mapExists && objPrototype === Map.prototype) { - return 'Map'; - } - - /* ! Speed optimisation - * Pre: - * weakset x 1,323,220 ops/sec ±2.17% (76 runs sampled) - * Post: - * weakset x 4,237,510 ops/sec ±2.01% (77 runs sampled) - */ - if (weakSetExists && objPrototype === WeakSet.prototype) { - return 'WeakSet'; - } - - /* ! Speed optimisation - * Pre: - * weakmap x 1,500,260 ops/sec ±2.02% (78 runs sampled) - * Post: - * weakmap x 3,881,384 ops/sec ±1.45% (82 runs sampled) - */ - if (weakMapExists && objPrototype === WeakMap.prototype) { - return 'WeakMap'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag) - * ES6$24.2.4.21 - DataView.prototype[@@toStringTag] should be "DataView": - * Test: `Object.prototype.toString.call(new DataView(new ArrayBuffer(1)))`` - * - Edge <=13 === "[object Object]" - */ - if (dataViewExists && objPrototype === DataView.prototype) { - return 'DataView'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag) - * ES6$23.1.5.2.2 - %MapIteratorPrototype%[@@toStringTag] should be "Map Iterator": - * Test: `Object.prototype.toString.call(new Map().entries())`` - * - Edge <=13 === "[object Object]" - */ - if (mapExists && objPrototype === mapIteratorPrototype) { - return 'Map Iterator'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag) - * ES6$23.2.5.2.2 - %SetIteratorPrototype%[@@toStringTag] should be "Set Iterator": - * Test: `Object.prototype.toString.call(new Set().entries())`` - * - Edge <=13 === "[object Object]" - */ - if (setExists && objPrototype === setIteratorPrototype) { - return 'Set Iterator'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag) - * ES6$22.1.5.2.2 - %ArrayIteratorPrototype%[@@toStringTag] should be "Array Iterator": - * Test: `Object.prototype.toString.call([][Symbol.iterator]())`` - * - Edge <=13 === "[object Object]" - */ - if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) { - return 'Array Iterator'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag) - * ES6$21.1.5.2.2 - %StringIteratorPrototype%[@@toStringTag] should be "String Iterator": - * Test: `Object.prototype.toString.call(''[Symbol.iterator]())`` - * - Edge <=13 === "[object Object]" - */ - if (stringIteratorExists && objPrototype === stringIteratorPrototype) { - return 'String Iterator'; - } - - /* ! Speed optimisation - * Pre: - * object from null x 2,424,320 ops/sec ±1.67% (76 runs sampled) - * Post: - * object from null x 5,838,000 ops/sec ±0.99% (84 runs sampled) - */ - if (objPrototype === null) { - return 'Object'; - } - - return Object - .prototype - .toString - .call(obj) - .slice(toStringLeftSliceLength, toStringRightSliceLength); -}; - -module.exports.typeDetect = module.exports; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}]},{},[1])(1) -}); \ No newline at end of file diff --git a/node_modules/deep-eql/index.js b/node_modules/deep-eql/index.js deleted file mode 100644 index b1b5295..0000000 --- a/node_modules/deep-eql/index.js +++ /dev/null @@ -1,455 +0,0 @@ -'use strict'; -/* globals Symbol: false, Uint8Array: false, WeakMap: false */ -/*! - * deep-eql - * Copyright(c) 2013 Jake Luer - * MIT Licensed - */ - -var type = require('type-detect'); -function FakeMap() { - this._key = 'chai/deep-eql__' + Math.random() + Date.now(); -} - -FakeMap.prototype = { - get: function getMap(key) { - return key[this._key]; - }, - set: function setMap(key, value) { - if (Object.isExtensible(key)) { - Object.defineProperty(key, this._key, { - value: value, - configurable: true, - }); - } - }, -}; - -var MemoizeMap = typeof WeakMap === 'function' ? WeakMap : FakeMap; -/*! - * Check to see if the MemoizeMap has recorded a result of the two operands - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {MemoizeMap} memoizeMap - * @returns {Boolean|null} result -*/ -function memoizeCompare(leftHandOperand, rightHandOperand, memoizeMap) { - // Technically, WeakMap keys can *only* be objects, not primitives. - if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) { - return null; - } - var leftHandMap = memoizeMap.get(leftHandOperand); - if (leftHandMap) { - var result = leftHandMap.get(rightHandOperand); - if (typeof result === 'boolean') { - return result; - } - } - return null; -} - -/*! - * Set the result of the equality into the MemoizeMap - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {MemoizeMap} memoizeMap - * @param {Boolean} result -*/ -function memoizeSet(leftHandOperand, rightHandOperand, memoizeMap, result) { - // Technically, WeakMap keys can *only* be objects, not primitives. - if (!memoizeMap || isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) { - return; - } - var leftHandMap = memoizeMap.get(leftHandOperand); - if (leftHandMap) { - leftHandMap.set(rightHandOperand, result); - } else { - leftHandMap = new MemoizeMap(); - leftHandMap.set(rightHandOperand, result); - memoizeMap.set(leftHandOperand, leftHandMap); - } -} - -/*! - * Primary Export - */ - -module.exports = deepEqual; -module.exports.MemoizeMap = MemoizeMap; - -/** - * Assert deeply nested sameValue equality between two objects of any type. - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {Object} [options] (optional) Additional options - * @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality. - * @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of - complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular - references to blow the stack. - * @return {Boolean} equal match - */ -function deepEqual(leftHandOperand, rightHandOperand, options) { - // If we have a comparator, we can't assume anything; so bail to its check first. - if (options && options.comparator) { - return extensiveDeepEqual(leftHandOperand, rightHandOperand, options); - } - - var simpleResult = simpleEqual(leftHandOperand, rightHandOperand); - if (simpleResult !== null) { - return simpleResult; - } - - // Deeper comparisons are pushed through to a larger function - return extensiveDeepEqual(leftHandOperand, rightHandOperand, options); -} - -/** - * Many comparisons can be canceled out early via simple equality or primitive checks. - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @return {Boolean|null} equal match - */ -function simpleEqual(leftHandOperand, rightHandOperand) { - // Equal references (except for Numbers) can be returned early - if (leftHandOperand === rightHandOperand) { - // Handle +-0 cases - return leftHandOperand !== 0 || 1 / leftHandOperand === 1 / rightHandOperand; - } - - // handle NaN cases - if ( - leftHandOperand !== leftHandOperand && // eslint-disable-line no-self-compare - rightHandOperand !== rightHandOperand // eslint-disable-line no-self-compare - ) { - return true; - } - - // Anything that is not an 'object', i.e. symbols, functions, booleans, numbers, - // strings, and undefined, can be compared by reference. - if (isPrimitive(leftHandOperand) || isPrimitive(rightHandOperand)) { - // Easy out b/c it would have passed the first equality check - return false; - } - return null; -} - -/*! - * The main logic of the `deepEqual` function. - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {Object} [options] (optional) Additional options - * @param {Array} [options.comparator] (optional) Override default algorithm, determining custom equality. - * @param {Array} [options.memoize] (optional) Provide a custom memoization object which will cache the results of - complex objects for a speed boost. By passing `false` you can disable memoization, but this will cause circular - references to blow the stack. - * @return {Boolean} equal match -*/ -function extensiveDeepEqual(leftHandOperand, rightHandOperand, options) { - options = options || {}; - options.memoize = options.memoize === false ? false : options.memoize || new MemoizeMap(); - var comparator = options && options.comparator; - - // Check if a memoized result exists. - var memoizeResultLeft = memoizeCompare(leftHandOperand, rightHandOperand, options.memoize); - if (memoizeResultLeft !== null) { - return memoizeResultLeft; - } - var memoizeResultRight = memoizeCompare(rightHandOperand, leftHandOperand, options.memoize); - if (memoizeResultRight !== null) { - return memoizeResultRight; - } - - // If a comparator is present, use it. - if (comparator) { - var comparatorResult = comparator(leftHandOperand, rightHandOperand); - // Comparators may return null, in which case we want to go back to default behavior. - if (comparatorResult === false || comparatorResult === true) { - memoizeSet(leftHandOperand, rightHandOperand, options.memoize, comparatorResult); - return comparatorResult; - } - // To allow comparators to override *any* behavior, we ran them first. Since it didn't decide - // what to do, we need to make sure to return the basic tests first before we move on. - var simpleResult = simpleEqual(leftHandOperand, rightHandOperand); - if (simpleResult !== null) { - // Don't memoize this, it takes longer to set/retrieve than to just compare. - return simpleResult; - } - } - - var leftHandType = type(leftHandOperand); - if (leftHandType !== type(rightHandOperand)) { - memoizeSet(leftHandOperand, rightHandOperand, options.memoize, false); - return false; - } - - // Temporarily set the operands in the memoize object to prevent blowing the stack - memoizeSet(leftHandOperand, rightHandOperand, options.memoize, true); - - var result = extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options); - memoizeSet(leftHandOperand, rightHandOperand, options.memoize, result); - return result; -} - -function extensiveDeepEqualByType(leftHandOperand, rightHandOperand, leftHandType, options) { - switch (leftHandType) { - case 'String': - case 'Number': - case 'Boolean': - case 'Date': - // If these types are their instance types (e.g. `new Number`) then re-deepEqual against their values - return deepEqual(leftHandOperand.valueOf(), rightHandOperand.valueOf()); - case 'Promise': - case 'Symbol': - case 'function': - case 'WeakMap': - case 'WeakSet': - case 'Error': - return leftHandOperand === rightHandOperand; - case 'Arguments': - case 'Int8Array': - case 'Uint8Array': - case 'Uint8ClampedArray': - case 'Int16Array': - case 'Uint16Array': - case 'Int32Array': - case 'Uint32Array': - case 'Float32Array': - case 'Float64Array': - case 'Array': - return iterableEqual(leftHandOperand, rightHandOperand, options); - case 'RegExp': - return regexpEqual(leftHandOperand, rightHandOperand); - case 'Generator': - return generatorEqual(leftHandOperand, rightHandOperand, options); - case 'DataView': - return iterableEqual(new Uint8Array(leftHandOperand.buffer), new Uint8Array(rightHandOperand.buffer), options); - case 'ArrayBuffer': - return iterableEqual(new Uint8Array(leftHandOperand), new Uint8Array(rightHandOperand), options); - case 'Set': - return entriesEqual(leftHandOperand, rightHandOperand, options); - case 'Map': - return entriesEqual(leftHandOperand, rightHandOperand, options); - default: - return objectEqual(leftHandOperand, rightHandOperand, options); - } -} - -/*! - * Compare two Regular Expressions for equality. - * - * @param {RegExp} leftHandOperand - * @param {RegExp} rightHandOperand - * @return {Boolean} result - */ - -function regexpEqual(leftHandOperand, rightHandOperand) { - return leftHandOperand.toString() === rightHandOperand.toString(); -} - -/*! - * Compare two Sets/Maps for equality. Faster than other equality functions. - * - * @param {Set} leftHandOperand - * @param {Set} rightHandOperand - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ - -function entriesEqual(leftHandOperand, rightHandOperand, options) { - // IE11 doesn't support Set#entries or Set#@@iterator, so we need manually populate using Set#forEach - if (leftHandOperand.size !== rightHandOperand.size) { - return false; - } - if (leftHandOperand.size === 0) { - return true; - } - var leftHandItems = []; - var rightHandItems = []; - leftHandOperand.forEach(function gatherEntries(key, value) { - leftHandItems.push([ key, value ]); - }); - rightHandOperand.forEach(function gatherEntries(key, value) { - rightHandItems.push([ key, value ]); - }); - return iterableEqual(leftHandItems.sort(), rightHandItems.sort(), options); -} - -/*! - * Simple equality for flat iterable objects such as Arrays, TypedArrays or Node.js buffers. - * - * @param {Iterable} leftHandOperand - * @param {Iterable} rightHandOperand - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ - -function iterableEqual(leftHandOperand, rightHandOperand, options) { - var length = leftHandOperand.length; - if (length !== rightHandOperand.length) { - return false; - } - if (length === 0) { - return true; - } - var index = -1; - while (++index < length) { - if (deepEqual(leftHandOperand[index], rightHandOperand[index], options) === false) { - return false; - } - } - return true; -} - -/*! - * Simple equality for generator objects such as those returned by generator functions. - * - * @param {Iterable} leftHandOperand - * @param {Iterable} rightHandOperand - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ - -function generatorEqual(leftHandOperand, rightHandOperand, options) { - return iterableEqual(getGeneratorEntries(leftHandOperand), getGeneratorEntries(rightHandOperand), options); -} - -/*! - * Determine if the given object has an @@iterator function. - * - * @param {Object} target - * @return {Boolean} `true` if the object has an @@iterator function. - */ -function hasIteratorFunction(target) { - return typeof Symbol !== 'undefined' && - typeof target === 'object' && - typeof Symbol.iterator !== 'undefined' && - typeof target[Symbol.iterator] === 'function'; -} - -/*! - * Gets all iterator entries from the given Object. If the Object has no @@iterator function, returns an empty array. - * This will consume the iterator - which could have side effects depending on the @@iterator implementation. - * - * @param {Object} target - * @returns {Array} an array of entries from the @@iterator function - */ -function getIteratorEntries(target) { - if (hasIteratorFunction(target)) { - try { - return getGeneratorEntries(target[Symbol.iterator]()); - } catch (iteratorError) { - return []; - } - } - return []; -} - -/*! - * Gets all entries from a Generator. This will consume the generator - which could have side effects. - * - * @param {Generator} target - * @returns {Array} an array of entries from the Generator. - */ -function getGeneratorEntries(generator) { - var generatorResult = generator.next(); - var accumulator = [ generatorResult.value ]; - while (generatorResult.done === false) { - generatorResult = generator.next(); - accumulator.push(generatorResult.value); - } - return accumulator; -} - -/*! - * Gets all own and inherited enumerable keys from a target. - * - * @param {Object} target - * @returns {Array} an array of own and inherited enumerable keys from the target. - */ -function getEnumerableKeys(target) { - var keys = []; - for (var key in target) { - keys.push(key); - } - return keys; -} - -/*! - * Determines if two objects have matching values, given a set of keys. Defers to deepEqual for the equality check of - * each key. If any value of the given key is not equal, the function will return false (early). - * - * @param {Mixed} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {Array} keys An array of keys to compare the values of leftHandOperand and rightHandOperand against - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ -function keysEqual(leftHandOperand, rightHandOperand, keys, options) { - var length = keys.length; - if (length === 0) { - return true; - } - for (var i = 0; i < length; i += 1) { - if (deepEqual(leftHandOperand[keys[i]], rightHandOperand[keys[i]], options) === false) { - return false; - } - } - return true; -} - -/*! - * 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} leftHandOperand - * @param {Mixed} rightHandOperand - * @param {Object} [options] (Optional) - * @return {Boolean} result - */ - -function objectEqual(leftHandOperand, rightHandOperand, options) { - var leftHandKeys = getEnumerableKeys(leftHandOperand); - var rightHandKeys = getEnumerableKeys(rightHandOperand); - if (leftHandKeys.length && leftHandKeys.length === rightHandKeys.length) { - leftHandKeys.sort(); - rightHandKeys.sort(); - if (iterableEqual(leftHandKeys, rightHandKeys) === false) { - return false; - } - return keysEqual(leftHandOperand, rightHandOperand, leftHandKeys, options); - } - - var leftHandEntries = getIteratorEntries(leftHandOperand); - var rightHandEntries = getIteratorEntries(rightHandOperand); - if (leftHandEntries.length && leftHandEntries.length === rightHandEntries.length) { - leftHandEntries.sort(); - rightHandEntries.sort(); - return iterableEqual(leftHandEntries, rightHandEntries, options); - } - - if (leftHandKeys.length === 0 && - leftHandEntries.length === 0 && - rightHandKeys.length === 0 && - rightHandEntries.length === 0) { - return true; - } - - return false; -} - -/*! - * Returns true if the argument is a primitive. - * - * This intentionally returns true for all objects that can be compared by reference, - * including functions and symbols. - * - * @param {Mixed} value - * @return {Boolean} result - */ -function isPrimitive(value) { - return value === null || typeof value !== 'object'; -} diff --git a/node_modules/deep-eql/package.json b/node_modules/deep-eql/package.json deleted file mode 100644 index e62e510..0000000 --- a/node_modules/deep-eql/package.json +++ /dev/null @@ -1,131 +0,0 @@ -{ - "_from": "deep-eql@^3.0.1", - "_id": "deep-eql@3.0.1", - "_inBundle": false, - "_integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "_location": "/deep-eql", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "deep-eql@^3.0.1", - "name": "deep-eql", - "escapedName": "deep-eql", - "rawSpec": "^3.0.1", - "saveSpec": null, - "fetchSpec": "^3.0.1" - }, - "_requiredBy": [ - "/chai" - ], - "_resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "_shasum": "dfc9404400ad1c8fe023e7da1df1c147c4b444df", - "_spec": "deep-eql@^3.0.1", - "_where": "C:\\src\\github\\makensis-action\\node_modules\\chai", - "author": { - "name": "Jake Luer", - "email": "jake@alogicalparadox.com" - }, - "bugs": { - "url": "https://github.com/chaijs/deep-eql/issues" - }, - "bundleDependencies": false, - "config": { - "ghooks": { - "commit-msg": "validate-commit-msg" - } - }, - "contributors": [ - { - "name": "Keith Cirkel", - "url": "https://github.com/keithamus" - }, - { - "name": "dougluce", - "url": "https://github.com/dougluce" - }, - { - "name": "Lorenz Leutgeb", - "url": "https://github.com/flowlo" - } - ], - "dependencies": { - "type-detect": "^4.0.0" - }, - "deprecated": false, - "description": "Improved deep equality testing for Node.js and the browser.", - "devDependencies": { - "benchmark": "^2.1.0", - "browserify": "^13.0.0", - "browserify-istanbul": "^1.0.0", - "component": "*", - "coveralls": "2.11.8", - "eslint": "^2.4.0", - "eslint-config-strict": "^8.5.0", - "eslint-plugin-filenames": "^0.2.0", - "ghooks": "^1.0.1", - "istanbul": "^0.4.2", - "karma": "^0.13.22", - "karma-browserify": "^5.0.2", - "karma-coverage": "^0.5.5", - "karma-mocha": "^0.2.2", - "karma-phantomjs-launcher": "^1.0.0", - "karma-sauce-launcher": "^0.3.1", - "kewlr": "^0.3.1", - "lcov-result-merger": "^1.0.2", - "lodash.isequal": "^4.4.0", - "mocha": "^3.1.2", - "phantomjs-prebuilt": "^2.1.5", - "semantic-release": "^4.3.5", - "simple-assert": "^1.0.0", - "travis-after-all": "^1.4.4", - "validate-commit-msg": "^2.3.1", - "watchify": "^3.7.0" - }, - "engines": { - "node": ">=0.12" - }, - "eslintConfig": { - "extends": [ - "strict/es5" - ], - "rules": { - "complexity": 0, - "spaced-comment": 0, - "no-underscore-dangle": 0, - "no-use-before-define": 0 - } - }, - "files": [ - "index.js", - "deep-eql.js" - ], - "homepage": "https://github.com/chaijs/deep-eql#readme", - "keywords": [ - "chai util", - "deep equal", - "object equal", - "testing" - ], - "license": "MIT", - "main": "./index", - "name": "deep-eql", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/chaijs/deep-eql.git" - }, - "scripts": { - "bench": "node bench", - "build": "browserify $npm_package_main --standalone deepEqual -o deep-eql.js", - "lint": "eslint --ignore-path .gitignore .", - "prepublish": "npm run build", - "pretest": "npm run lint", - "semantic-release": "semantic-release pre && npm publish && semantic-release post", - "test": "npm run test:node && npm run test:browser", - "test:browser": "karma start --singleRun=true", - "test:node": "istanbul cover _mocha", - "upload-coverage": "lcov-result-merger 'coverage/**/lcov.info' | coveralls; exit 0", - "watch": "karma start --auto-watch --singleRun=false" - }, - "version": "3.0.1" -} diff --git a/node_modules/get-func-name/LICENSE b/node_modules/get-func-name/LICENSE deleted file mode 100644 index 7ea799f..0000000 --- a/node_modules/get-func-name/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2013 Jake Luer (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. diff --git a/node_modules/get-func-name/README.md b/node_modules/get-func-name/README.md deleted file mode 100644 index e908416..0000000 --- a/node_modules/get-func-name/README.md +++ /dev/null @@ -1,123 +0,0 @@ -

- - ChaiJS -
- get-func-name -
-

- -

- Utility for getting a function's name for node and the browser. -

- -

- - license:mit - - - tag:? - - - build:? - - - coverage:? - - - npm:? - - - dependencies:? - - - devDependencies:? - -
- - Selenium Test Status - -
- - Join the Slack chat - - - Join the Gitter chat - -

- -## What is get-func-name? - -This is a module to retrieve a function's name securely and consistently both in NodeJS and the browser. - -## Installation - -### Node.js - -`get-func-name` is available on [npm](http://npmjs.org). To install it, type: - - $ npm install get-func-name - -### Browsers - -You can also use it within the browser; install via npm and use the `get-func-name.js` file found within the download. For example: - -```html - -``` - -## Usage - -The module `get-func-name` exports the following method: - -* `getFuncName(fn)` - Returns the name of a function. - -```js -var getFuncName = require('get-func-name'); -``` - -#### .getFuncName(fun) - -```js -var getFuncName = require('get-func-name'); - -var unknownFunction = function myCoolFunction(word) { - return word + 'is cool'; -}; - -var anonymousFunction = (function () { - return function () {}; -}()); - -getFuncName(unknownFunction) // 'myCoolFunction' -getFuncName(anonymousFunction) // '' -``` diff --git a/node_modules/get-func-name/get-func-name.js b/node_modules/get-func-name/get-func-name.js deleted file mode 100644 index f0c4069..0000000 --- a/node_modules/get-func-name/get-func-name.js +++ /dev/null @@ -1,48 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.getFuncName = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o - * MIT Licensed - */ - -/** - * ### .getFuncName(constructorFn) - * - * Returns the name of a function. - * When a non-function instance is passed, returns `null`. - * This also includes a polyfill function if `aFunc.name` is not defined. - * - * @name getFuncName - * @param {Function} funct - * @namespace Utils - * @api public - */ - -var toString = Function.prototype.toString; -var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/; -function getFuncName(aFunc) { - if (typeof aFunc !== 'function') { - return null; - } - - var name = ''; - if (typeof Function.prototype.name === 'undefined' && typeof aFunc.name === 'undefined') { - // Here we run a polyfill if Function does not support the `name` property and if aFunc.name is not defined - var match = toString.call(aFunc).match(functionNameMatch); - if (match) { - name = match[1]; - } - } else { - // If we've got a `name` property we just use it - name = aFunc.name; - } - - return name; -} - -module.exports = getFuncName; - -},{}]},{},[1])(1) -}); \ No newline at end of file diff --git a/node_modules/get-func-name/index.js b/node_modules/get-func-name/index.js deleted file mode 100644 index e4aa582..0000000 --- a/node_modules/get-func-name/index.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; - -/* ! - * Chai - getFuncName utility - * Copyright(c) 2012-2016 Jake Luer - * MIT Licensed - */ - -/** - * ### .getFuncName(constructorFn) - * - * Returns the name of a function. - * When a non-function instance is passed, returns `null`. - * This also includes a polyfill function if `aFunc.name` is not defined. - * - * @name getFuncName - * @param {Function} funct - * @namespace Utils - * @api public - */ - -var toString = Function.prototype.toString; -var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/; -function getFuncName(aFunc) { - if (typeof aFunc !== 'function') { - return null; - } - - var name = ''; - if (typeof Function.prototype.name === 'undefined' && typeof aFunc.name === 'undefined') { - // Here we run a polyfill if Function does not support the `name` property and if aFunc.name is not defined - var match = toString.call(aFunc).match(functionNameMatch); - if (match) { - name = match[1]; - } - } else { - // If we've got a `name` property we just use it - name = aFunc.name; - } - - return name; -} - -module.exports = getFuncName; diff --git a/node_modules/get-func-name/package.json b/node_modules/get-func-name/package.json deleted file mode 100644 index d5f382d..0000000 --- a/node_modules/get-func-name/package.json +++ /dev/null @@ -1,133 +0,0 @@ -{ - "_from": "get-func-name@^2.0.0", - "_id": "get-func-name@2.0.0", - "_inBundle": false, - "_integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "_location": "/get-func-name", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "get-func-name@^2.0.0", - "name": "get-func-name", - "escapedName": "get-func-name", - "rawSpec": "^2.0.0", - "saveSpec": null, - "fetchSpec": "^2.0.0" - }, - "_requiredBy": [ - "/chai" - ], - "_resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "_shasum": "ead774abee72e20409433a066366023dd6887a41", - "_spec": "get-func-name@^2.0.0", - "_where": "C:\\src\\github\\makensis-action\\node_modules\\chai", - "author": { - "name": "Jake Luer", - "email": "jake@alogicalparadox.com", - "url": "http://alogicalparadox.com" - }, - "bugs": { - "url": "https://github.com/chaijs/get-func-name/issues" - }, - "bundleDependencies": false, - "config": { - "ghooks": { - "commit-msg": "validate-commit-msg" - } - }, - "contributors": [ - { - "name": "Keith Cirkel", - "url": "https://github.com/keithamus" - }, - { - "name": "Lucas Fernandes da Costa", - "url": "https://github.com/lucasfcosta" - }, - { - "name": "Grant Snodgrass", - "url": "https://github.com/meeber" - }, - { - "name": "Lucas Vieira", - "url": "https://github.com/vieiralucas" - }, - { - "name": "Aleksey Shvayka", - "url": "https://github.com/shvaikalesh" - } - ], - "dependencies": {}, - "deprecated": false, - "description": "Utility for getting a function's name for node and the browser", - "devDependencies": { - "browserify": "^13.0.0", - "browserify-istanbul": "^2.0.0", - "coveralls": "2.11.14", - "eslint": "^2.4.0", - "eslint-config-strict": "^9.1.0", - "eslint-plugin-filenames": "^1.1.0", - "ghooks": "^1.0.1", - "istanbul": "^0.4.2", - "karma": "^1.3.0", - "karma-browserify": "^5.0.2", - "karma-coverage": "^1.1.1", - "karma-mocha": "^1.2.0", - "karma-phantomjs-launcher": "^1.0.0", - "karma-sauce-launcher": "^1.0.0", - "lcov-result-merger": "^1.0.2", - "mocha": "^3.1.2", - "phantomjs-prebuilt": "^2.1.5", - "semantic-release": "^4.3.5", - "simple-assert": "^1.0.0", - "travis-after-all": "^1.4.4", - "validate-commit-msg": "^2.3.1" - }, - "engines": { - "node": "*" - }, - "eslintConfig": { - "extends": [ - "strict/es5" - ], - "env": { - "es6": true - }, - "globals": { - "HTMLElement": false - }, - "rules": { - "complexity": 0, - "max-statements": 0 - } - }, - "files": [ - "index.js", - "get-func-name.js" - ], - "homepage": "https://github.com/chaijs/get-func-name#readme", - "keywords": [ - "get-func-name", - "chai util" - ], - "license": "MIT", - "main": "./index.js", - "name": "get-func-name", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/chaijs/get-func-name.git" - }, - "scripts": { - "build": "browserify --bare $npm_package_main --standalone getFuncName -o get-func-name.js", - "lint": "eslint --ignore-path .gitignore .", - "prepublish": "npm run build", - "pretest": "npm run lint", - "semantic-release": "semantic-release pre && npm publish && semantic-release post", - "test": "npm run test:node && npm run test:browser && npm run upload-coverage", - "test:browser": "karma start --singleRun=true", - "test:node": "istanbul cover _mocha", - "upload-coverage": "lcov-result-merger 'coverage/**/lcov.info' | coveralls; exit 0" - }, - "version": "2.0.0" -} diff --git a/node_modules/loupe/CHANGELOG.md b/node_modules/loupe/CHANGELOG.md deleted file mode 100644 index 11799db..0000000 --- a/node_modules/loupe/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ - -0.0.1 / 2013-12-17 -================== - - * Initial port from chai.js diff --git a/node_modules/loupe/LICENSE b/node_modules/loupe/LICENSE deleted file mode 100644 index b0c8a5a..0000000 --- a/node_modules/loupe/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -(The MIT License) - -Copyright (c) 2011-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. diff --git a/node_modules/loupe/README.md b/node_modules/loupe/README.md deleted file mode 100644 index 44f61d3..0000000 --- a/node_modules/loupe/README.md +++ /dev/null @@ -1,63 +0,0 @@ -![npm](https://img.shields.io/npm/v/loupe?logo=npm) -![Build](https://github.com/chaijs/loupe/workflows/Build/badge.svg?branch=master) -![Codecov branch](https://img.shields.io/codecov/c/github/chaijs/loupe/master?logo=codecov) - -# What is loupe? - -Loupe turns the object you give it into a string. It's similar to Node.js' `util.inspect()` function, but it works cross platform, in most modern browsers as well as Node. - -## Installation - -### Node.js - -`loupe` is available on [npm](http://npmjs.org). To install it, type: - - $ npm install loupe - -### Browsers - -You can also use it within the browser; install via npm and use the `loupe.js` file found within the download. For example: - -```html - -``` - -## Usage - -``` js -const { inspect } = require('loupe'); -``` - -```js -inspect({ foo: 'bar' }); // => "{ foo: 'bar' }" -inspect(1); // => '1' -inspect('foo'); // => "'foo'" -inspect([ 1, 2, 3 ]); // => '[ 1, 2, 3 ]' -inspect(/Test/g); // => '/Test/g' - -// ... -``` - -## Tests - -```bash -$ npm test -``` - -Coverage: - -```bash -$ npm run upload-coverage -``` - -## License - -(The MIT License) - -Copyright (c) 2011-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. diff --git a/node_modules/loupe/index.js b/node_modules/loupe/index.js deleted file mode 100644 index 0f289f8..0000000 --- a/node_modules/loupe/index.js +++ /dev/null @@ -1,195 +0,0 @@ -/* ! - * loupe - * Copyright(c) 2013 Jake Luer - * MIT Licensed - */ - -import inspectArray from './lib/array' -import inspectTypedArray from './lib/typedarray' -import inspectDate from './lib/date' -import inspectFunction from './lib/function' -import inspectMap from './lib/map' -import inspectNumber from './lib/number' -import inspectBigInt from './lib/bigint' -import inspectRegExp from './lib/regexp' -import inspectSet from './lib/set' -import inspectString from './lib/string' -import inspectSymbol from './lib/symbol' -import inspectPromise from './lib/promise' -import inspectClass from './lib/class' -import inspectObject from './lib/object' -import inspectArguments from './lib/arguments' -import inspectError from './lib/error' -import inspectHTMLElement, { inspectHTMLCollection } from './lib/html' - -import { normaliseOptions } from './lib/helpers' - -const symbolsSupported = typeof Symbol === 'function' && typeof Symbol.for === 'function' -const chaiInspect = symbolsSupported ? Symbol.for('chai/inspect') : '@@chai/inspect' -let nodeInspect = false -try { - // eslint-disable-next-line global-require - const nodeUtil = require('util') - nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false -} catch (noNodeInspect) { - nodeInspect = false -} - -const constructorMap = new WeakMap() -const stringTagMap = {} -const baseTypesMap = { - undefined: (value, options) => options.stylize('undefined', 'undefined'), - null: (value, options) => options.stylize(null, 'null'), - - boolean: (value, options) => options.stylize(value, 'boolean'), - Boolean: (value, options) => options.stylize(value, 'boolean'), - - number: inspectNumber, - Number: inspectNumber, - - bigint: inspectBigInt, - BigInt: inspectBigInt, - - string: inspectString, - String: inspectString, - - function: inspectFunction, - Function: inspectFunction, - - symbol: inspectSymbol, - // A Symbol polyfill will return `Symbol` not `symbol` from typedetect - Symbol: inspectSymbol, - - Array: inspectArray, - Date: inspectDate, - Map: inspectMap, - Set: inspectSet, - RegExp: inspectRegExp, - Promise: inspectPromise, - - // WeakSet, WeakMap are totally opaque to us - WeakSet: (value, options) => options.stylize('WeakSet{…}', 'special'), - WeakMap: (value, options) => options.stylize('WeakMap{…}', 'special'), - - Arguments: inspectArguments, - Int8Array: inspectTypedArray, - Uint8Array: inspectTypedArray, - Uint8ClampedArray: inspectTypedArray, - Int16Array: inspectTypedArray, - Uint16Array: inspectTypedArray, - Int32Array: inspectTypedArray, - Uint32Array: inspectTypedArray, - Float32Array: inspectTypedArray, - Float64Array: inspectTypedArray, - - Generator: () => '', - DataView: () => '', - ArrayBuffer: () => '', - - Error: inspectError, - - HTMLCollection: inspectHTMLCollection, - NodeList: inspectHTMLCollection, -} - -// eslint-disable-next-line complexity -const inspectCustom = (value, options, type) => { - if (chaiInspect in value && typeof value[chaiInspect] === 'function') { - return value[chaiInspect](options) - } - - if (nodeInspect && nodeInspect in value && typeof value[nodeInspect] === 'function') { - return value[nodeInspect](options.depth, options) - } - - if ('inspect' in value && typeof value.inspect === 'function') { - return value.inspect(options.depth, options) - } - - if ('constructor' in value && constructorMap.has(value.constructor)) { - return constructorMap.get(value.constructor)(value, options) - } - - if (stringTagMap[type]) { - return stringTagMap[type](value, options) - } - - return '' -} - -const toString = Object.prototype.toString - -// eslint-disable-next-line complexity -export function inspect(value, options) { - options = normaliseOptions(options) - options.inspect = inspect - const { customInspect } = options - let type = value === null ? 'null' : typeof value - if (type === 'object') { - type = toString.call(value).slice(8, -1) - } - - // If it is a base value that we already support, then use Loupe's inspector - if (baseTypesMap[type]) { - return baseTypesMap[type](value, options) - } - - // If `options.customInspect` is set to true then try to use the custom inspector - if (customInspect && value) { - const output = inspectCustom(value, options, type) - if (output) { - if (typeof output === 'string') return output - return inspect(output, options) - } - } - - const proto = value ? Object.getPrototypeOf(value) : false - // If it's a plain Object then use Loupe's inspector - if (proto === Object.prototype || proto === null) { - return inspectObject(value, options) - } - - // Specifically account for HTMLElements - // eslint-disable-next-line no-undef - if (value && typeof HTMLElement === 'function' && value instanceof HTMLElement) { - return inspectHTMLElement(value, options) - } - - if ('constructor' in value) { - // If it is a class, inspect it like an object but add the constructor name - if (value.constructor !== Object) { - return inspectClass(value, options) - } - - // If it is an object with an anonymous prototype, display it as an object. - return inspectObject(value, options) - } - - // last chance to check if it's an object - if (value === Object(value)) { - return inspectObject(value, options) - } - - // We have run out of options! Just stringify the value - return options.stylize(String(value), type) -} - -export function registerConstructor(constructor, inspector) { - if (constructorMap.has(constructor)) { - return false - } - constructorMap.add(constructor, inspector) - return true -} - -export function registerStringTag(stringTag, inspector) { - if (stringTag in stringTagMap) { - return false - } - stringTagMap[stringTag] = inspector - return true -} - -export const custom = chaiInspect - -export default inspect diff --git a/node_modules/loupe/lib/arguments.js b/node_modules/loupe/lib/arguments.js deleted file mode 100644 index e7d3a6d..0000000 --- a/node_modules/loupe/lib/arguments.js +++ /dev/null @@ -1,7 +0,0 @@ -import { inspectList } from './helpers' - -export default function inspectArguments(args, options) { - if (args.length === 0) return 'Arguments[]' - options.truncate -= 13 - return `Arguments[ ${inspectList(args, options)} ]` -} diff --git a/node_modules/loupe/lib/array.js b/node_modules/loupe/lib/array.js deleted file mode 100644 index c377029..0000000 --- a/node_modules/loupe/lib/array.js +++ /dev/null @@ -1,20 +0,0 @@ -import { inspectProperty, inspectList } from './helpers' - -export default function inspectArray(array, options) { - // Object.keys will always output the Array indices first, so we can slice by - // `array.length` to get non-index properties - const nonIndexProperties = Object.keys(array).slice(array.length) - if (!array.length && !nonIndexProperties.length) return '[]' - options.truncate -= 4 - const listContents = inspectList(array, options) - options.truncate -= listContents.length - let propertyContents = '' - if (nonIndexProperties.length) { - propertyContents = inspectList( - nonIndexProperties.map(key => [key, array[key]]), - options, - inspectProperty - ) - } - return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ''} ]` -} diff --git a/node_modules/loupe/lib/bigint.js b/node_modules/loupe/lib/bigint.js deleted file mode 100644 index d93db78..0000000 --- a/node_modules/loupe/lib/bigint.js +++ /dev/null @@ -1,7 +0,0 @@ -import { truncate, truncator } from './helpers' - -export default function inspectBigInt(number, options) { - let nums = truncate(number.toString(), options.truncate - 1) - if (nums !== truncator) nums += 'n' - return options.stylize(nums, 'bigint') -} diff --git a/node_modules/loupe/lib/class.js b/node_modules/loupe/lib/class.js deleted file mode 100644 index cd949af..0000000 --- a/node_modules/loupe/lib/class.js +++ /dev/null @@ -1,18 +0,0 @@ -import getFuncName from 'get-func-name' -import inspectObject from './object' - -const toStringTag = typeof Symbol !== 'undefined' && Symbol.toStringTag ? Symbol.toStringTag : false - -export default function inspectClass(value, options) { - let name = '' - if (toStringTag && toStringTag in value) { - name = value[toStringTag] - } - name = name || getFuncName(value.constructor) - // Babel transforms anonymous classes to the name `_class` - if (!name || name === '_class') { - name = '' - } - options.truncate -= name.length - return `${name}${inspectObject(value, options)}` -} diff --git a/node_modules/loupe/lib/date.js b/node_modules/loupe/lib/date.js deleted file mode 100644 index 0da7e3c..0000000 --- a/node_modules/loupe/lib/date.js +++ /dev/null @@ -1,8 +0,0 @@ -import { truncate } from './helpers' - -export default function inspectDate(dateObject, options) { - // If we need to - truncate the time portion, but never the date - const split = dateObject.toJSON().split('T') - const date = split[0] - return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, 'date') -} diff --git a/node_modules/loupe/lib/error.js b/node_modules/loupe/lib/error.js deleted file mode 100644 index 1fabaa9..0000000 --- a/node_modules/loupe/lib/error.js +++ /dev/null @@ -1,34 +0,0 @@ -import { truncate, inspectList, inspectProperty } from './helpers' - -const errorKeys = [ - 'stack', - 'line', - 'column', - 'name', - 'message', - 'fileName', - 'lineNumber', - 'columnNumber', - 'number', - 'description', -] - -export default function inspectObject(error, options) { - const properties = Object.getOwnPropertyNames(error).filter(key => errorKeys.indexOf(key) === -1) - const name = error.name - options.truncate -= name.length - let message = '' - if (typeof error.message === 'string') { - message = truncate(error.message, options.truncate) - } else { - properties.unshift('message') - } - message = message ? `: ${message}` : '' - options.truncate -= message.length + 5 - const propertyContents = inspectList( - properties.map(key => [key, error[key]]), - options, - inspectProperty - ) - return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ''}` -} diff --git a/node_modules/loupe/lib/function.js b/node_modules/loupe/lib/function.js deleted file mode 100644 index 75b7c55..0000000 --- a/node_modules/loupe/lib/function.js +++ /dev/null @@ -1,10 +0,0 @@ -import getFunctionName from 'get-func-name' -import { truncate } from './helpers' - -export default function inspectFunction(func, options) { - const name = getFunctionName(func) - if (!name) { - return options.stylize('[Function]', 'special') - } - return options.stylize(`[Function ${truncate(name, options.truncate - 11)}]`, 'special') -} diff --git a/node_modules/loupe/lib/helpers.js b/node_modules/loupe/lib/helpers.js deleted file mode 100644 index 8a883d6..0000000 --- a/node_modules/loupe/lib/helpers.js +++ /dev/null @@ -1,177 +0,0 @@ -const ansiColors = { - bold: ['1', '22'], - dim: ['2', '22'], - italic: ['3', '23'], - underline: ['4', '24'], - // 5 & 6 are blinking - inverse: ['7', '27'], - hidden: ['8', '28'], - strike: ['9', '29'], - // 10-20 are fonts - // 21-29 are resets for 1-9 - black: ['30', '39'], - red: ['31', '39'], - green: ['32', '39'], - yellow: ['33', '39'], - blue: ['34', '39'], - magenta: ['35', '39'], - cyan: ['36', '39'], - white: ['37', '39'], - - brightblack: ['30;1', '39'], - brightred: ['31;1', '39'], - brightgreen: ['32;1', '39'], - brightyellow: ['33;1', '39'], - brightblue: ['34;1', '39'], - brightmagenta: ['35;1', '39'], - brightcyan: ['36;1', '39'], - brightwhite: ['37;1', '39'], - - grey: ['90', '39'], -} - -const styles = { - special: 'cyan', - number: 'yellow', - bigint: 'yellow', - boolean: 'yellow', - undefined: 'grey', - null: 'bold', - string: 'green', - symbol: 'green', - date: 'magenta', - regexp: 'red', -} - -export const truncator = '…' - -function colorise(value, styleType) { - const color = ansiColors[styles[styleType]] || ansiColors[styleType] - if (!color) { - return String(value) - } - return `\u001b[${color[0]}m${String(value)}\u001b[${color[1]}m` -} - -export function normaliseOptions({ - showHidden = false, - depth = 2, - colors = false, - customInspect = true, - showProxy = false, - maxArrayLength = Infinity, - breakLength = Infinity, - seen = [], - // eslint-disable-next-line no-shadow - truncate = Infinity, - stylize = String, -} = {}) { - const options = { - showHidden: Boolean(showHidden), - depth: Number(depth), - colors: Boolean(colors), - customInspect: Boolean(customInspect), - showProxy: Boolean(showProxy), - maxArrayLength: Number(maxArrayLength), - breakLength: Number(breakLength), - truncate: Number(truncate), - seen, - stylize, - } - if (options.colors) { - options.stylize = colorise - } - return options -} - -export function truncate(string, length, tail = truncator) { - string = String(string) - const tailLength = tail.length - const stringLength = string.length - if (tailLength > length && stringLength > tailLength) { - return tail - } - if (stringLength > length && stringLength > tailLength) { - return `${string.slice(0, length - tailLength)}${tail}` - } - return string -} - -// eslint-disable-next-line complexity -export function inspectList(list, options, inspectItem, separator = ', ') { - inspectItem = inspectItem || options.inspect - const size = list.length - if (size === 0) return '' - const originalLength = options.truncate - let output = '' - let peek = '' - let truncated = '' - for (let i = 0; i < size; i += 1) { - const last = i + 1 === list.length - const secondToLast = i + 2 === list.length - truncated = `${truncator}(${list.length - i})` - const value = list[i] - - // If there is more than one remaining we need to account for a separator of `, ` - options.truncate = originalLength - output.length - (last ? 0 : separator.length) - const string = peek || inspectItem(value, options) + (last ? '' : separator) - const nextLength = output.length + string.length - const truncatedLength = nextLength + truncated.length - - // If this is the last element, and adding it would - // take us over length, but adding the truncator wouldn't - then break now - if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) { - break - } - - // If this isn't the last or second to last element to scan, - // but the string is already over length then break here - if (!last && !secondToLast && truncatedLength > originalLength) { - break - } - - // Peek at the next string to determine if we should - // break early before adding this item to the output - peek = last ? '' : inspectItem(list[i + 1], options) + (secondToLast ? '' : separator) - - // If we have one element left, but this element and - // the next takes over length, the break early - if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) { - break - } - - output += string - - // If the next element takes us to length - - // but there are more after that, then we should truncate now - if (!last && !secondToLast && nextLength + peek.length >= originalLength) { - truncated = `${truncator}(${list.length - i - 1})` - break - } - - truncated = '' - } - return `${output}${truncated}` -} - -function quoteComplexKey(key) { - if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) { - return key - } - return JSON.stringify(key) - .replace(/'/g, "\\'") - .replace(/\\"/g, '"') - .replace(/(^"|"$)/g, "'") -} - -export function inspectProperty([key, value], options) { - options.truncate -= 2 - if (typeof key === 'string') { - key = quoteComplexKey(key) - } else if (typeof key !== 'number') { - key = `[${options.inspect(key, options)}]` - } - options.truncate -= key.length - value = options.inspect(value, options) - return `${key}: ${value}` -} diff --git a/node_modules/loupe/lib/html.js b/node_modules/loupe/lib/html.js deleted file mode 100644 index e39cd34..0000000 --- a/node_modules/loupe/lib/html.js +++ /dev/null @@ -1,40 +0,0 @@ -import { truncator, inspectList } from './helpers' - -export function inspectAttribute([key, value], options) { - options.truncate -= 3 - if (!value) { - return `${options.stylize(key, 'yellow')}` - } - return `${options.stylize(key, 'yellow')}=${options.stylize(`"${value}"`, 'string')}` -} - -export function inspectHTMLCollection(collection, options) { - // eslint-disable-next-line no-use-before-define - return inspectList(collection, options, inspectHTML, '\n') -} - -export default function inspectHTML(element, options) { - const properties = element.getAttributeNames() - const name = element.tagName.toLowerCase() - const head = options.stylize(`<${name}`, 'special') - const headClose = options.stylize(`>`, 'special') - const tail = options.stylize(``, 'special') - options.truncate -= name.length * 2 + 5 - let propertyContents = '' - if (properties.length > 0) { - propertyContents += ' ' - propertyContents += inspectList( - properties.map(key => [key, element.getAttribute(key)]), - options, - inspectAttribute, - ' ' - ) - } - options.truncate -= propertyContents.length - const truncate = options.truncate - let children = inspectHTMLCollection(element.children, options) - if (children && children.length > truncate) { - children = `${truncator}(${element.children.length})` - } - return `${head}${propertyContents}${headClose}${children}${tail}` -} diff --git a/node_modules/loupe/lib/map.js b/node_modules/loupe/lib/map.js deleted file mode 100644 index 2842e30..0000000 --- a/node_modules/loupe/lib/map.js +++ /dev/null @@ -1,27 +0,0 @@ -import { inspectList } from './helpers' - -function inspectMapEntry([key, value], options) { - options.truncate -= 4 - key = options.inspect(key, options) - options.truncate -= key.length - value = options.inspect(value, options) - return `${key} => ${value}` -} - -// IE11 doesn't support `map.entries()` -function mapToEntries(map) { - const entries = [] - map.forEach((value, key) => { - entries.push([key, value]) - }) - return entries -} - -export default function inspectMap(map, options) { - const size = map.size - 1 - if (size <= 0) { - return 'Map{}' - } - options.truncate -= 7 - return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }` -} diff --git a/node_modules/loupe/lib/number.js b/node_modules/loupe/lib/number.js deleted file mode 100644 index 9def128..0000000 --- a/node_modules/loupe/lib/number.js +++ /dev/null @@ -1,18 +0,0 @@ -import { truncate } from './helpers' - -const isNaN = Number.isNaN || (i => i !== i) // eslint-disable-line no-self-compare -export default function inspectNumber(number, options) { - if (isNaN(number)) { - return options.stylize('NaN', 'number') - } - if (number === Infinity) { - return options.stylize('Infinity', 'number') - } - if (number === -Infinity) { - return options.stylize('-Infinity', 'number') - } - if (number === 0) { - return options.stylize(1 / number === Infinity ? '+0' : '-0', 'number') - } - return options.stylize(truncate(number, options.truncate), 'number') -} diff --git a/node_modules/loupe/lib/object.js b/node_modules/loupe/lib/object.js deleted file mode 100644 index 4cbb87f..0000000 --- a/node_modules/loupe/lib/object.js +++ /dev/null @@ -1,31 +0,0 @@ -import { inspectProperty, inspectList } from './helpers' - -export default function inspectObject(object, options) { - const properties = Object.getOwnPropertyNames(object) - const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [] - if (properties.length === 0 && symbols.length === 0) { - return '{}' - } - options.truncate -= 4 - options.seen = options.seen || [] - if (options.seen.indexOf(object) >= 0) { - return '[Circular]' - } - options.seen.push(object) - const propertyContents = inspectList( - properties.map(key => [key, object[key]]), - options, - inspectProperty - ) - const symbolContents = inspectList( - symbols.map(key => [key, object[key]]), - options, - inspectProperty - ) - options.seen.pop() - let sep = '' - if (propertyContents && symbolContents) { - sep = ', ' - } - return `{ ${propertyContents}${sep}${symbolContents} }` -} diff --git a/node_modules/loupe/lib/promise.js b/node_modules/loupe/lib/promise.js deleted file mode 100644 index 327e9f4..0000000 --- a/node_modules/loupe/lib/promise.js +++ /dev/null @@ -1,16 +0,0 @@ -let getPromiseValue = () => 'Promise{…}' -try { - const { getPromiseDetails, kPending, kRejected } = process.binding('util') - if (Array.isArray(getPromiseDetails(Promise.resolve()))) { - getPromiseValue = (value, options) => { - const [state, innerValue] = getPromiseDetails(value) - if (state === kPending) { - return 'Promise{}' - } - return `Promise${state === kRejected ? '!' : ''}{${options.inspect(innerValue, options)}}` - } - } -} catch (notNode) { - /* ignore */ -} -export default getPromiseValue diff --git a/node_modules/loupe/lib/regexp.js b/node_modules/loupe/lib/regexp.js deleted file mode 100644 index edad917..0000000 --- a/node_modules/loupe/lib/regexp.js +++ /dev/null @@ -1,8 +0,0 @@ -import { truncate } from './helpers' - -export default function inspectRegExp(value, options) { - const flags = value.toString().split('/')[2] - const sourceLength = options.truncate - (2 + flags.length) - const source = value.source - return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, 'regexp') -} diff --git a/node_modules/loupe/lib/set.js b/node_modules/loupe/lib/set.js deleted file mode 100644 index 99a1300..0000000 --- a/node_modules/loupe/lib/set.js +++ /dev/null @@ -1,16 +0,0 @@ -import { inspectList } from './helpers' - -// IE11 doesn't support `Array.from(set)` -function arrayFromSet(set) { - const values = [] - set.forEach(value => { - values.push(value) - }) - return values -} - -export default function inspectSet(set, options) { - if (set.size === 0) return 'Set{}' - options.truncate -= 7 - return `Set{ ${inspectList(arrayFromSet(set), options)} }` -} diff --git a/node_modules/loupe/lib/string.js b/node_modules/loupe/lib/string.js deleted file mode 100644 index 2af66cf..0000000 --- a/node_modules/loupe/lib/string.js +++ /dev/null @@ -1,29 +0,0 @@ -import { truncate } from './helpers' - -const stringEscapeChars = new RegExp( - "['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5" + - '\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]', - 'g' -) - -const escapeCharacters = { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - "'": "\\'", - '\\': '\\\\', -} -const hex = 16 -const unicodeLength = 4 -function escape(char) { - return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-unicodeLength)}` -} - -export default function inspectString(string, options) { - if (stringEscapeChars.test(string)) { - string = string.replace(stringEscapeChars, escape) - } - return options.stylize(`'${truncate(string, options.truncate - 2)}'`, 'string') -} diff --git a/node_modules/loupe/lib/symbol.js b/node_modules/loupe/lib/symbol.js deleted file mode 100644 index f98beec..0000000 --- a/node_modules/loupe/lib/symbol.js +++ /dev/null @@ -1,6 +0,0 @@ -export default function inspectSymbol(value) { - if ('description' in Symbol.prototype) { - return value.description ? `Symbol(${value.description})` : 'Symbol()' - } - return value.toString() -} diff --git a/node_modules/loupe/lib/typedarray.js b/node_modules/loupe/lib/typedarray.js deleted file mode 100644 index b98c045..0000000 --- a/node_modules/loupe/lib/typedarray.js +++ /dev/null @@ -1,45 +0,0 @@ -import getFuncName from 'get-func-name' -import { truncator, truncate, inspectProperty, inspectList } from './helpers' - -const getArrayName = array => { - // We need to special case Node.js' Buffers, which report to be Uint8Array - if (typeof Buffer === 'function' && array instanceof Buffer) { - return 'Buffer' - } - if (array[Symbol.toStringTag]) { - return array[Symbol.toStringTag] - } - return getFuncName(array.constructor) -} - -export default function inspectTypedArray(array, options) { - const name = getArrayName(array) - options.truncate -= name.length + 4 - // Object.keys will always output the Array indices first, so we can slice by - // `array.length` to get non-index properties - const nonIndexProperties = Object.keys(array).slice(array.length) - if (!array.length && !nonIndexProperties.length) return `${name}[]` - // As we know TypedArrays only contain Unsigned Integers, we can skip inspecting each one and simply - // stylise the toString() value of them - let output = '' - for (let i = 0; i < array.length; i++) { - const string = `${options.stylize(truncate(array[i], options.truncate), 'number')}${ - i === array.length - 1 ? '' : ', ' - }` - options.truncate -= string.length - if (array[i] !== array.length && options.truncate <= 3) { - output += `${truncator}(${array.length - array[i] + 1})` - break - } - output += string - } - let propertyContents = '' - if (nonIndexProperties.length) { - propertyContents = inspectList( - nonIndexProperties.map(key => [key, array[key]]), - options, - inspectProperty - ) - } - return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ''} ]` -} diff --git a/node_modules/loupe/loupe.js b/node_modules/loupe/loupe.js deleted file mode 100644 index eb82435..0000000 --- a/node_modules/loupe/loupe.js +++ /dev/null @@ -1,852 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.loupe = {})); -}(this, (function (exports) { 'use strict'; - - function _typeof(obj) { - "@babel/helpers - typeof"; - - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof = function (obj) { - return typeof obj; - }; - } else { - _typeof = function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - } - - return _typeof(obj); - } - - function _slicedToArray(arr, i) { - return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); - } - - function _arrayWithHoles(arr) { - if (Array.isArray(arr)) return arr; - } - - function _iterableToArrayLimit(arr, i) { - if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; - var _arr = []; - var _n = true; - var _d = false; - var _e = undefined; - - try { - for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { - _arr.push(_s.value); - - if (i && _arr.length === i) break; - } - } catch (err) { - _d = true; - _e = err; - } finally { - try { - if (!_n && _i["return"] != null) _i["return"](); - } finally { - if (_d) throw _e; - } - } - - return _arr; - } - - function _unsupportedIterableToArray(o, minLen) { - if (!o) return; - if (typeof o === "string") return _arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); - } - - function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) len = arr.length; - - for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; - - return arr2; - } - - function _nonIterableRest() { - throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - - var ansiColors = { - bold: ['1', '22'], - dim: ['2', '22'], - italic: ['3', '23'], - underline: ['4', '24'], - // 5 & 6 are blinking - inverse: ['7', '27'], - hidden: ['8', '28'], - strike: ['9', '29'], - // 10-20 are fonts - // 21-29 are resets for 1-9 - black: ['30', '39'], - red: ['31', '39'], - green: ['32', '39'], - yellow: ['33', '39'], - blue: ['34', '39'], - magenta: ['35', '39'], - cyan: ['36', '39'], - white: ['37', '39'], - brightblack: ['30;1', '39'], - brightred: ['31;1', '39'], - brightgreen: ['32;1', '39'], - brightyellow: ['33;1', '39'], - brightblue: ['34;1', '39'], - brightmagenta: ['35;1', '39'], - brightcyan: ['36;1', '39'], - brightwhite: ['37;1', '39'], - grey: ['90', '39'] - }; - var styles = { - special: 'cyan', - number: 'yellow', - bigint: 'yellow', - boolean: 'yellow', - undefined: 'grey', - null: 'bold', - string: 'green', - symbol: 'green', - date: 'magenta', - regexp: 'red' - }; - var truncator = '…'; - - function colorise(value, styleType) { - var color = ansiColors[styles[styleType]] || ansiColors[styleType]; - - if (!color) { - return String(value); - } - - return "\x1B[".concat(color[0], "m").concat(String(value), "\x1B[").concat(color[1], "m"); - } - - function normaliseOptions() { - var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, - _ref$showHidden = _ref.showHidden, - showHidden = _ref$showHidden === void 0 ? false : _ref$showHidden, - _ref$depth = _ref.depth, - depth = _ref$depth === void 0 ? 2 : _ref$depth, - _ref$colors = _ref.colors, - colors = _ref$colors === void 0 ? false : _ref$colors, - _ref$customInspect = _ref.customInspect, - customInspect = _ref$customInspect === void 0 ? true : _ref$customInspect, - _ref$showProxy = _ref.showProxy, - showProxy = _ref$showProxy === void 0 ? false : _ref$showProxy, - _ref$maxArrayLength = _ref.maxArrayLength, - maxArrayLength = _ref$maxArrayLength === void 0 ? Infinity : _ref$maxArrayLength, - _ref$breakLength = _ref.breakLength, - breakLength = _ref$breakLength === void 0 ? Infinity : _ref$breakLength, - _ref$seen = _ref.seen, - seen = _ref$seen === void 0 ? [] : _ref$seen, - _ref$truncate = _ref.truncate, - truncate = _ref$truncate === void 0 ? Infinity : _ref$truncate, - _ref$stylize = _ref.stylize, - stylize = _ref$stylize === void 0 ? String : _ref$stylize; - - var options = { - showHidden: Boolean(showHidden), - depth: Number(depth), - colors: Boolean(colors), - customInspect: Boolean(customInspect), - showProxy: Boolean(showProxy), - maxArrayLength: Number(maxArrayLength), - breakLength: Number(breakLength), - truncate: Number(truncate), - seen: seen, - stylize: stylize - }; - - if (options.colors) { - options.stylize = colorise; - } - - return options; - } - function truncate(string, length) { - var tail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : truncator; - string = String(string); - var tailLength = tail.length; - var stringLength = string.length; - - if (tailLength > length && stringLength > tailLength) { - return tail; - } - - if (stringLength > length && stringLength > tailLength) { - return "".concat(string.slice(0, length - tailLength)).concat(tail); - } - - return string; - } // eslint-disable-next-line complexity - - function inspectList(list, options, inspectItem) { - var separator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ', '; - inspectItem = inspectItem || options.inspect; - var size = list.length; - if (size === 0) return ''; - var originalLength = options.truncate; - var output = ''; - var peek = ''; - var truncated = ''; - - for (var i = 0; i < size; i += 1) { - var last = i + 1 === list.length; - var secondToLast = i + 2 === list.length; - truncated = "".concat(truncator, "(").concat(list.length - i, ")"); - var value = list[i]; // If there is more than one remaining we need to account for a separator of `, ` - - options.truncate = originalLength - output.length - (last ? 0 : separator.length); - var string = peek || inspectItem(value, options) + (last ? '' : separator); - var nextLength = output.length + string.length; - var truncatedLength = nextLength + truncated.length; // If this is the last element, and adding it would - // take us over length, but adding the truncator wouldn't - then break now - - if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) { - break; - } // If this isn't the last or second to last element to scan, - // but the string is already over length then break here - - - if (!last && !secondToLast && truncatedLength > originalLength) { - break; - } // Peek at the next string to determine if we should - // break early before adding this item to the output - - - peek = last ? '' : inspectItem(list[i + 1], options) + (secondToLast ? '' : separator); // If we have one element left, but this element and - // the next takes over length, the break early - - if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) { - break; - } - - output += string; // If the next element takes us to length - - // but there are more after that, then we should truncate now - - if (!last && !secondToLast && nextLength + peek.length >= originalLength) { - truncated = "".concat(truncator, "(").concat(list.length - i - 1, ")"); - break; - } - - truncated = ''; - } - - return "".concat(output).concat(truncated); - } - - function quoteComplexKey(key) { - if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) { - return key; - } - - return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'"); - } - - function inspectProperty(_ref2, options) { - var _ref3 = _slicedToArray(_ref2, 2), - key = _ref3[0], - value = _ref3[1]; - - options.truncate -= 2; - - if (typeof key === 'string') { - key = quoteComplexKey(key); - } else if (typeof key !== 'number') { - key = "[".concat(options.inspect(key, options), "]"); - } - - options.truncate -= key.length; - value = options.inspect(value, options); - return "".concat(key, ": ").concat(value); - } - - function inspectArray(array, options) { - // Object.keys will always output the Array indices first, so we can slice by - // `array.length` to get non-index properties - var nonIndexProperties = Object.keys(array).slice(array.length); - if (!array.length && !nonIndexProperties.length) return '[]'; - options.truncate -= 4; - var listContents = inspectList(array, options); - options.truncate -= listContents.length; - var propertyContents = ''; - - if (nonIndexProperties.length) { - propertyContents = inspectList(nonIndexProperties.map(function (key) { - return [key, array[key]]; - }), options, inspectProperty); - } - - return "[ ".concat(listContents).concat(propertyContents ? ", ".concat(propertyContents) : '', " ]"); - } - - /* ! - * Chai - getFuncName utility - * Copyright(c) 2012-2016 Jake Luer - * MIT Licensed - */ - - /** - * ### .getFuncName(constructorFn) - * - * Returns the name of a function. - * When a non-function instance is passed, returns `null`. - * This also includes a polyfill function if `aFunc.name` is not defined. - * - * @name getFuncName - * @param {Function} funct - * @namespace Utils - * @api public - */ - - var toString = Function.prototype.toString; - var functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/; - function getFuncName(aFunc) { - if (typeof aFunc !== 'function') { - return null; - } - - var name = ''; - if (typeof Function.prototype.name === 'undefined' && typeof aFunc.name === 'undefined') { - // Here we run a polyfill if Function does not support the `name` property and if aFunc.name is not defined - var match = toString.call(aFunc).match(functionNameMatch); - if (match) { - name = match[1]; - } - } else { - // If we've got a `name` property we just use it - name = aFunc.name; - } - - return name; - } - - var getFuncName_1 = getFuncName; - - var getArrayName = function getArrayName(array) { - // We need to special case Node.js' Buffers, which report to be Uint8Array - if (typeof Buffer === 'function' && array instanceof Buffer) { - return 'Buffer'; - } - - if (array[Symbol.toStringTag]) { - return array[Symbol.toStringTag]; - } - - return getFuncName_1(array.constructor); - }; - - function inspectTypedArray(array, options) { - var name = getArrayName(array); - options.truncate -= name.length + 4; // Object.keys will always output the Array indices first, so we can slice by - // `array.length` to get non-index properties - - var nonIndexProperties = Object.keys(array).slice(array.length); - if (!array.length && !nonIndexProperties.length) return "".concat(name, "[]"); // As we know TypedArrays only contain Unsigned Integers, we can skip inspecting each one and simply - // stylise the toString() value of them - - var output = ''; - - for (var i = 0; i < array.length; i++) { - var string = "".concat(options.stylize(truncate(array[i], options.truncate), 'number')).concat(i === array.length - 1 ? '' : ', '); - options.truncate -= string.length; - - if (array[i] !== array.length && options.truncate <= 3) { - output += "".concat(truncator, "(").concat(array.length - array[i] + 1, ")"); - break; - } - - output += string; - } - - var propertyContents = ''; - - if (nonIndexProperties.length) { - propertyContents = inspectList(nonIndexProperties.map(function (key) { - return [key, array[key]]; - }), options, inspectProperty); - } - - return "".concat(name, "[ ").concat(output).concat(propertyContents ? ", ".concat(propertyContents) : '', " ]"); - } - - function inspectDate(dateObject, options) { - // If we need to - truncate the time portion, but never the date - var split = dateObject.toJSON().split('T'); - var date = split[0]; - return options.stylize("".concat(date, "T").concat(truncate(split[1], options.truncate - date.length - 1)), 'date'); - } - - function inspectFunction(func, options) { - var name = getFuncName_1(func); - - if (!name) { - return options.stylize('[Function]', 'special'); - } - - return options.stylize("[Function ".concat(truncate(name, options.truncate - 11), "]"), 'special'); - } - - function inspectMapEntry(_ref, options) { - var _ref2 = _slicedToArray(_ref, 2), - key = _ref2[0], - value = _ref2[1]; - - options.truncate -= 4; - key = options.inspect(key, options); - options.truncate -= key.length; - value = options.inspect(value, options); - return "".concat(key, " => ").concat(value); - } // IE11 doesn't support `map.entries()` - - - function mapToEntries(map) { - var entries = []; - map.forEach(function (value, key) { - entries.push([key, value]); - }); - return entries; - } - - function inspectMap(map, options) { - var size = map.size - 1; - - if (size <= 0) { - return 'Map{}'; - } - - options.truncate -= 7; - return "Map{ ".concat(inspectList(mapToEntries(map), options, inspectMapEntry), " }"); - } - - var isNaN = Number.isNaN || function (i) { - return i !== i; - }; // eslint-disable-line no-self-compare - - - function inspectNumber(number, options) { - if (isNaN(number)) { - return options.stylize('NaN', 'number'); - } - - if (number === Infinity) { - return options.stylize('Infinity', 'number'); - } - - if (number === -Infinity) { - return options.stylize('-Infinity', 'number'); - } - - if (number === 0) { - return options.stylize(1 / number === Infinity ? '+0' : '-0', 'number'); - } - - return options.stylize(truncate(number, options.truncate), 'number'); - } - - function inspectBigInt(number, options) { - var nums = truncate(number.toString(), options.truncate - 1); - if (nums !== truncator) nums += 'n'; - return options.stylize(nums, 'bigint'); - } - - function inspectRegExp(value, options) { - var flags = value.toString().split('/')[2]; - var sourceLength = options.truncate - (2 + flags.length); - var source = value.source; - return options.stylize("/".concat(truncate(source, sourceLength), "/").concat(flags), 'regexp'); - } - - function arrayFromSet(set) { - var values = []; - set.forEach(function (value) { - values.push(value); - }); - return values; - } - - function inspectSet(set, options) { - if (set.size === 0) return 'Set{}'; - options.truncate -= 7; - return "Set{ ".concat(inspectList(arrayFromSet(set), options), " }"); - } - - var stringEscapeChars = new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5" + "\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", 'g'); - var escapeCharacters = { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - "'": "\\'", - '\\': '\\\\' - }; - var hex = 16; - var unicodeLength = 4; - - function escape(char) { - return escapeCharacters[char] || "\\u".concat("0000".concat(char.charCodeAt(0).toString(hex)).slice(-unicodeLength)); - } - - function inspectString(string, options) { - if (stringEscapeChars.test(string)) { - string = string.replace(stringEscapeChars, escape); - } - - return options.stylize("'".concat(truncate(string, options.truncate - 2), "'"), 'string'); - } - - function inspectSymbol(value) { - if ('description' in Symbol.prototype) { - return value.description ? "Symbol(".concat(value.description, ")") : 'Symbol()'; - } - - return value.toString(); - } - - var getPromiseValue = function getPromiseValue() { - return 'Promise{…}'; - }; - - try { - var _process$binding = process.binding('util'), - getPromiseDetails = _process$binding.getPromiseDetails, - kPending = _process$binding.kPending, - kRejected = _process$binding.kRejected; - - if (Array.isArray(getPromiseDetails(Promise.resolve()))) { - getPromiseValue = function getPromiseValue(value, options) { - var _getPromiseDetails = getPromiseDetails(value), - _getPromiseDetails2 = _slicedToArray(_getPromiseDetails, 2), - state = _getPromiseDetails2[0], - innerValue = _getPromiseDetails2[1]; - - if (state === kPending) { - return 'Promise{}'; - } - - return "Promise".concat(state === kRejected ? '!' : '', "{").concat(options.inspect(innerValue, options), "}"); - }; - } - } catch (notNode) { - /* ignore */ - } - - var inspectPromise = getPromiseValue; - - function inspectObject(object, options) { - var properties = Object.getOwnPropertyNames(object); - var symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : []; - - if (properties.length === 0 && symbols.length === 0) { - return '{}'; - } - - options.truncate -= 4; - options.seen = options.seen || []; - - if (options.seen.indexOf(object) >= 0) { - return '[Circular]'; - } - - options.seen.push(object); - var propertyContents = inspectList(properties.map(function (key) { - return [key, object[key]]; - }), options, inspectProperty); - var symbolContents = inspectList(symbols.map(function (key) { - return [key, object[key]]; - }), options, inspectProperty); - options.seen.pop(); - var sep = ''; - - if (propertyContents && symbolContents) { - sep = ', '; - } - - return "{ ".concat(propertyContents).concat(sep).concat(symbolContents, " }"); - } - - var toStringTag = typeof Symbol !== 'undefined' && Symbol.toStringTag ? Symbol.toStringTag : false; - function inspectClass(value, options) { - var name = ''; - - if (toStringTag && toStringTag in value) { - name = value[toStringTag]; - } - - name = name || getFuncName_1(value.constructor); // Babel transforms anonymous classes to the name `_class` - - if (!name || name === '_class') { - name = ''; - } - - options.truncate -= name.length; - return "".concat(name).concat(inspectObject(value, options)); - } - - function inspectArguments(args, options) { - if (args.length === 0) return 'Arguments[]'; - options.truncate -= 13; - return "Arguments[ ".concat(inspectList(args, options), " ]"); - } - - var errorKeys = ['stack', 'line', 'column', 'name', 'message', 'fileName', 'lineNumber', 'columnNumber', 'number', 'description']; - function inspectObject$1(error, options) { - var properties = Object.getOwnPropertyNames(error).filter(function (key) { - return errorKeys.indexOf(key) === -1; - }); - var name = error.name; - options.truncate -= name.length; - var message = ''; - - if (typeof error.message === 'string') { - message = truncate(error.message, options.truncate); - } else { - properties.unshift('message'); - } - - message = message ? ": ".concat(message) : ''; - options.truncate -= message.length + 5; - var propertyContents = inspectList(properties.map(function (key) { - return [key, error[key]]; - }), options, inspectProperty); - return "".concat(name).concat(message).concat(propertyContents ? " { ".concat(propertyContents, " }") : ''); - } - - function inspectAttribute(_ref, options) { - var _ref2 = _slicedToArray(_ref, 2), - key = _ref2[0], - value = _ref2[1]; - - options.truncate -= 3; - - if (!value) { - return "".concat(options.stylize(key, 'yellow')); - } - - return "".concat(options.stylize(key, 'yellow'), "=").concat(options.stylize("\"".concat(value, "\""), 'string')); - } - function inspectHTMLCollection(collection, options) { - // eslint-disable-next-line no-use-before-define - return inspectList(collection, options, inspectHTML, '\n'); - } - function inspectHTML(element, options) { - var properties = element.getAttributeNames(); - var name = element.tagName.toLowerCase(); - var head = options.stylize("<".concat(name), 'special'); - var headClose = options.stylize(">", 'special'); - var tail = options.stylize(""), 'special'); - options.truncate -= name.length * 2 + 5; - var propertyContents = ''; - - if (properties.length > 0) { - propertyContents += ' '; - propertyContents += inspectList(properties.map(function (key) { - return [key, element.getAttribute(key)]; - }), options, inspectAttribute, ' '); - } - - options.truncate -= propertyContents.length; - var truncate = options.truncate; - var children = inspectHTMLCollection(element.children, options); - - if (children && children.length > truncate) { - children = "".concat(truncator, "(").concat(element.children.length, ")"); - } - - return "".concat(head).concat(propertyContents).concat(headClose).concat(children).concat(tail); - } - - var symbolsSupported = typeof Symbol === 'function' && typeof Symbol.for === 'function'; - var chaiInspect = symbolsSupported ? Symbol.for('chai/inspect') : '@@chai/inspect'; - var nodeInspect = false; - - try { - // eslint-disable-next-line global-require - var nodeUtil = require('util'); - - nodeInspect = nodeUtil.inspect ? nodeUtil.inspect.custom : false; - } catch (noNodeInspect) { - nodeInspect = false; - } - - var constructorMap = new WeakMap(); - var stringTagMap = {}; - var baseTypesMap = { - undefined: function undefined$1(value, options) { - return options.stylize('undefined', 'undefined'); - }, - null: function _null(value, options) { - return options.stylize(null, 'null'); - }, - boolean: function boolean(value, options) { - return options.stylize(value, 'boolean'); - }, - Boolean: function Boolean(value, options) { - return options.stylize(value, 'boolean'); - }, - number: inspectNumber, - Number: inspectNumber, - bigint: inspectBigInt, - BigInt: inspectBigInt, - string: inspectString, - String: inspectString, - function: inspectFunction, - Function: inspectFunction, - symbol: inspectSymbol, - // A Symbol polyfill will return `Symbol` not `symbol` from typedetect - Symbol: inspectSymbol, - Array: inspectArray, - Date: inspectDate, - Map: inspectMap, - Set: inspectSet, - RegExp: inspectRegExp, - Promise: inspectPromise, - // WeakSet, WeakMap are totally opaque to us - WeakSet: function WeakSet(value, options) { - return options.stylize('WeakSet{…}', 'special'); - }, - WeakMap: function WeakMap(value, options) { - return options.stylize('WeakMap{…}', 'special'); - }, - Arguments: inspectArguments, - Int8Array: inspectTypedArray, - Uint8Array: inspectTypedArray, - Uint8ClampedArray: inspectTypedArray, - Int16Array: inspectTypedArray, - Uint16Array: inspectTypedArray, - Int32Array: inspectTypedArray, - Uint32Array: inspectTypedArray, - Float32Array: inspectTypedArray, - Float64Array: inspectTypedArray, - Generator: function Generator() { - return ''; - }, - DataView: function DataView() { - return ''; - }, - ArrayBuffer: function ArrayBuffer() { - return ''; - }, - Error: inspectObject$1, - HTMLCollection: inspectHTMLCollection, - NodeList: inspectHTMLCollection - }; // eslint-disable-next-line complexity - - var inspectCustom = function inspectCustom(value, options, type) { - if (chaiInspect in value && typeof value[chaiInspect] === 'function') { - return value[chaiInspect](options); - } - - if (nodeInspect && nodeInspect in value && typeof value[nodeInspect] === 'function') { - return value[nodeInspect](options.depth, options); - } - - if ('inspect' in value && typeof value.inspect === 'function') { - return value.inspect(options.depth, options); - } - - if ('constructor' in value && constructorMap.has(value.constructor)) { - return constructorMap.get(value.constructor)(value, options); - } - - if (stringTagMap[type]) { - return stringTagMap[type](value, options); - } - - return ''; - }; - - var toString$1 = Object.prototype.toString; // eslint-disable-next-line complexity - - function inspect(value, options) { - options = normaliseOptions(options); - options.inspect = inspect; - var _options = options, - customInspect = _options.customInspect; - var type = value === null ? 'null' : _typeof(value); - - if (type === 'object') { - type = toString$1.call(value).slice(8, -1); - } // If it is a base value that we already support, then use Loupe's inspector - - - if (baseTypesMap[type]) { - return baseTypesMap[type](value, options); - } // If `options.customInspect` is set to true then try to use the custom inspector - - - if (customInspect && value) { - var output = inspectCustom(value, options, type); - - if (output) { - if (typeof output === 'string') return output; - return inspect(output, options); - } - } - - var proto = value ? Object.getPrototypeOf(value) : false; // If it's a plain Object then use Loupe's inspector - - if (proto === Object.prototype || proto === null) { - return inspectObject(value, options); - } // Specifically account for HTMLElements - // eslint-disable-next-line no-undef - - - if (value && typeof HTMLElement === 'function' && value instanceof HTMLElement) { - return inspectHTML(value, options); - } - - if ('constructor' in value) { - // If it is a class, inspect it like an object but add the constructor name - if (value.constructor !== Object) { - return inspectClass(value, options); - } // If it is an object with an anonymous prototype, display it as an object. - - - return inspectObject(value, options); - } // last chance to check if it's an object - - - if (value === Object(value)) { - return inspectObject(value, options); - } // We have run out of options! Just stringify the value - - - return options.stylize(String(value), type); - } - function registerConstructor(constructor, inspector) { - if (constructorMap.has(constructor)) { - return false; - } - - constructorMap.add(constructor, inspector); - return true; - } - function registerStringTag(stringTag, inspector) { - if (stringTag in stringTagMap) { - return false; - } - - stringTagMap[stringTag] = inspector; - return true; - } - var custom = chaiInspect; - - exports.custom = custom; - exports.default = inspect; - exports.inspect = inspect; - exports.registerConstructor = registerConstructor; - exports.registerStringTag = registerStringTag; - - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); diff --git a/node_modules/loupe/package.json b/node_modules/loupe/package.json deleted file mode 100644 index 98689bb..0000000 --- a/node_modules/loupe/package.json +++ /dev/null @@ -1,141 +0,0 @@ -{ - "name": "loupe", - "version": "2.3.4", - "description": "Inspect utility for Node.js and browsers", - "homepage": "https://github.com/chaijs/loupe", - "license": "MIT", - "author": "Veselin Todorov ", - "contributors": [ - "Keith Cirkel (https://github.com/keithamus)" - ], - "main": "./loupe.js", - "module": "./index.js", - "browser": { - "./index.js": "./loupe.js", - "util": false - }, - "repository": { - "type": "git", - "url": "https://github.com/chaijs/loupe" - }, - "files": [ - "loupe.js", - "index.js", - "lib/*" - ], - "scripts": { - "bench": "node -r esm bench", - "commit-msg": "commitlint -x angular", - "lint": "eslint --ignore-path .gitignore .", - "prepare": "rollup -c rollup.conf.js", - "semantic-release": "semantic-release pre && npm publish && semantic-release post", - "test": "npm run test:node && npm run test:browser", - "pretest:browser": "npm run prepare", - "test:browser": "karma start --singleRun=true", - "posttest:browser": "npm run upload-coverage", - "test:node": "nyc mocha -r esm", - "posttest:node": "nyc report --report-dir \"coverage/node-$(node --version)\" --reporter=lcovonly && npm run upload-coverage", - "upload-coverage": "codecov" - }, - "eslintConfig": { - "root": true, - "parserOptions": { - "ecmaVersion": 2020 - }, - "env": { - "es6": true - }, - "plugins": [ - "filenames", - "prettier" - ], - "extends": [ - "strict/es6" - ], - "rules": { - "comma-dangle": "off", - "func-style": "off", - "no-magic-numbers": "off", - "class-methods-use-this": "off", - "array-bracket-spacing": "off", - "array-element-newline": "off", - "space-before-function-paren": "off", - "arrow-parens": "off", - "template-curly-spacing": "off", - "quotes": "off", - "generator-star-spacing": "off", - "prefer-destructuring": "off", - "no-mixed-operators": "off", - "id-blacklist": "off", - "curly": "off", - "semi": [ - "error", - "never" - ], - "prettier/prettier": [ - "error", - { - "printWidth": 120, - "tabWidth": 2, - "useTabs": false, - "semi": false, - "singleQuote": true, - "trailingComma": "es5", - "arrowParens": "avoid", - "bracketSpacing": true - } - ] - } - }, - "prettier": { - "printWidth": 120, - "tabWidth": 2, - "useTabs": false, - "semi": false, - "singleQuote": true, - "trailingComma": "es5", - "arrowParens": "avoid", - "bracketSpacing": true - }, - "dependencies": { - "get-func-name": "^2.0.0" - }, - "devDependencies": { - "@babel/core": "^7.12.10", - "@babel/preset-env": "^7.12.11", - "@commitlint/cli": "^11.0.0", - "@rollup/plugin-commonjs": "^17.0.0", - "@rollup/plugin-node-resolve": "^11.1.0", - "benchmark": "^2.1.4", - "chai": "^4.2.0", - "codecov": "^3.8.1", - "commitlint-config-angular": "^11.0.0", - "core-js": "^3.8.3", - "cross-env": "^7.0.3", - "eslint": "^7.18.0", - "eslint-config-strict": "^14.0.1", - "eslint-plugin-filenames": "^1.3.2", - "eslint-plugin-prettier": "^3.3.1", - "esm": "^3.2.25", - "husky": "^4.3.8", - "karma": "^5.2.3", - "karma-chrome-launcher": "^3.1.0", - "karma-coverage": "^2.0.3", - "karma-edge-launcher": "^0.4.2", - "karma-firefox-launcher": "^2.1.0", - "karma-ie-launcher": "^1.0.0", - "karma-mocha": "^2.0.1", - "karma-opera-launcher": "^1.0.0", - "karma-safari-launcher": "^1.0.0", - "karma-safaritechpreview-launcher": "^2.0.2", - "karma-sauce-launcher": "^4.3.4", - "mocha": "^8.2.1", - "nyc": "^15.1.0", - "prettier": "^2.2.1", - "rollup": "^2.37.1", - "rollup-plugin-babel": "^4.4.0", - "rollup-plugin-istanbul": "^3.0.0", - "semantic-release": "^17.3.6", - "simple-assert": "^1.0.0" - } -} diff --git a/node_modules/pathval/CHANGELOG.md b/node_modules/pathval/CHANGELOG.md deleted file mode 100644 index 804de5e..0000000 --- a/node_modules/pathval/CHANGELOG.md +++ /dev/null @@ -1,18 +0,0 @@ - -0.1.1 / 2013-12-30 -================== - - * expose parse - * rename lib to index - -0.1.0 / 2013-12-28 -================== - - * API BREAKING! `get` has been changed, see the README for migration path - * Add `set` method - * Start using simple-assert (closes #2) - -0.0.1 / 2013-11-24 -================== - - * Initial implementation diff --git a/node_modules/pathval/LICENSE b/node_modules/pathval/LICENSE deleted file mode 100644 index 90d22da..0000000 --- a/node_modules/pathval/LICENSE +++ /dev/null @@ -1,16 +0,0 @@ -MIT License - -Copyright (c) 2011-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. diff --git a/node_modules/pathval/README.md b/node_modules/pathval/README.md deleted file mode 100644 index 22a841e..0000000 --- a/node_modules/pathval/README.md +++ /dev/null @@ -1,147 +0,0 @@ -

- - ChaiJS - -
- pathval -

- -

- Tool for Object value retrieval given a string path for node and the browser. -

- -

- - license:mit - - - tag:? - - - build:? - - - coverage:? - - - npm:? - - - dependencies:? - - - devDependencies:? - -
- - Selenium Test Status - -
- - Join the Slack chat - - - Join the Gitter chat - -

- -## What is pathval? - -Pathval is a module which you can use to retrieve or set an Object's property for a given `String` path. - -## Installation - -### Node.js - -`pathval` is available on [npm](http://npmjs.org). To install it, type: - - $ npm install pathval - -### Browsers - -You can also use it within the browser; install via npm and use the `pathval.js` file found within the download. For example: - -```html - -``` - -## Usage - -The primary export of `pathval` is an object which has the following methods: - -* `hasProperty(object, name)` - Checks whether an `object` has `name`d property or numeric array index. -* `getPathInfo(object, path)` - Returns an object with info indicating the value of the `parent` of that path, the `name ` of the property we're retrieving and its `value`. -* `getPathValue(object, path)` - Retrieves the value of a property at a given `path` inside an `object`'. -* `setPathValue(object, path, value)` - Sets the `value` of a property at a given `path` inside an `object` and returns the object in which the property has been set. - -```js -var pathval = require('pathval'); -``` - -#### .hasProperty(object, name) - -```js -var pathval = require('pathval'); - -var obj = { prop: 'a value' }; -pathval.hasProperty(obj, 'prop'); // true -``` - -#### .getPathInfo(object, path) - -```js -var pathval = require('pathval'); - -var obj = { earth: { country: 'Brazil' } }; -pathval.getPathInfo(obj, 'earth.country'); // { parent: { country: 'Brazil' }, name: 'country', value: 'Brazil', exists: true } -``` - -#### .getPathValue(object, path) - -```js -var pathval = require('pathval'); - -var obj = { earth: { country: 'Brazil' } }; -pathval.getPathValue(obj, 'earth.country'); // 'Brazil' -``` - -#### .setPathValue(object, path, value) - -```js -var pathval = require('pathval'); - -var obj = { earth: { country: 'Brazil' } }; -pathval.setPathValue(obj, 'earth.country', 'USA'); - -obj.earth.country; // 'USA' -``` diff --git a/node_modules/pathval/index.js b/node_modules/pathval/index.js deleted file mode 100644 index d0dc43e..0000000 --- a/node_modules/pathval/index.js +++ /dev/null @@ -1,301 +0,0 @@ -'use strict'; - -/* ! - * Chai - pathval utility - * Copyright(c) 2012-2014 Jake Luer - * @see https://github.com/logicalparadox/filtr - * MIT Licensed - */ - -/** - * ### .hasProperty(object, name) - * - * This allows checking whether an object has own - * or inherited from prototype chain named property. - * - * Basically does the same thing as the `in` - * operator but works properly with null/undefined values - * and other primitives. - * - * var obj = { - * arr: ['a', 'b', 'c'] - * , str: 'Hello' - * } - * - * The following would be the results. - * - * hasProperty(obj, 'str'); // true - * hasProperty(obj, 'constructor'); // true - * hasProperty(obj, 'bar'); // false - * - * hasProperty(obj.str, 'length'); // true - * hasProperty(obj.str, 1); // true - * hasProperty(obj.str, 5); // false - * - * hasProperty(obj.arr, 'length'); // true - * hasProperty(obj.arr, 2); // true - * hasProperty(obj.arr, 3); // false - * - * @param {Object} object - * @param {String|Symbol} name - * @returns {Boolean} whether it exists - * @namespace Utils - * @name hasProperty - * @api public - */ - -function hasProperty(obj, name) { - if (typeof obj === 'undefined' || obj === null) { - return false; - } - - // The `in` operator does not work with primitives. - return name in Object(obj); -} - -/* ! - * ## parsePath(path) - * - * Helper function used to parse string object - * paths. Use in conjunction with `internalGetPathValue`. - * - * var parsed = parsePath('myobject.property.subprop'); - * - * ### Paths: - * - * * Can be infinitely deep and nested. - * * Arrays are also valid using the formal `myobject.document[3].property`. - * * Literal dots and brackets (not delimiter) must be backslash-escaped. - * - * @param {String} path - * @returns {Object} parsed - * @api private - */ - -function parsePath(path) { - var str = path.replace(/([^\\])\[/g, '$1.['); - var parts = str.match(/(\\\.|[^.]+?)+/g); - return parts.map(function mapMatches(value) { - if ( - value === 'constructor' || - value === '__proto__' || - value === 'prototype' - ) { - return {}; - } - var regexp = /^\[(\d+)\]$/; - var mArr = regexp.exec(value); - var parsed = null; - if (mArr) { - parsed = { i: parseFloat(mArr[1]) }; - } else { - parsed = { p: value.replace(/\\([.[\]])/g, '$1') }; - } - - return parsed; - }); -} - -/* ! - * ## internalGetPathValue(obj, parsed[, pathDepth]) - * - * Helper companion function for `.parsePath` that returns - * the value located at the parsed address. - * - * var value = getPathValue(obj, parsed); - * - * @param {Object} object to search against - * @param {Object} parsed definition from `parsePath`. - * @param {Number} depth (nesting level) of the property we want to retrieve - * @returns {Object|Undefined} value - * @api private - */ - -function internalGetPathValue(obj, parsed, pathDepth) { - var temporaryValue = obj; - var res = null; - pathDepth = typeof pathDepth === 'undefined' ? parsed.length : pathDepth; - - for (var i = 0; i < pathDepth; i++) { - var part = parsed[i]; - if (temporaryValue) { - if (typeof part.p === 'undefined') { - temporaryValue = temporaryValue[part.i]; - } else { - temporaryValue = temporaryValue[part.p]; - } - - if (i === pathDepth - 1) { - res = temporaryValue; - } - } - } - - return res; -} - -/* ! - * ## internalSetPathValue(obj, value, parsed) - * - * Companion function for `parsePath` that sets - * the value located at a parsed address. - * - * internalSetPathValue(obj, 'value', parsed); - * - * @param {Object} object to search and define on - * @param {*} value to use upon set - * @param {Object} parsed definition from `parsePath` - * @api private - */ - -function internalSetPathValue(obj, val, parsed) { - var tempObj = obj; - var pathDepth = parsed.length; - var part = null; - // Here we iterate through every part of the path - for (var i = 0; i < pathDepth; i++) { - var propName = null; - var propVal = null; - part = parsed[i]; - - // If it's the last part of the path, we set the 'propName' value with the property name - if (i === pathDepth - 1) { - propName = typeof part.p === 'undefined' ? part.i : part.p; - // Now we set the property with the name held by 'propName' on object with the desired val - tempObj[propName] = val; - } else if (typeof part.p !== 'undefined' && tempObj[part.p]) { - tempObj = tempObj[part.p]; - } else if (typeof part.i !== 'undefined' && tempObj[part.i]) { - tempObj = tempObj[part.i]; - } else { - // If the obj doesn't have the property we create one with that name to define it - var next = parsed[i + 1]; - // Here we set the name of the property which will be defined - propName = typeof part.p === 'undefined' ? part.i : part.p; - // Here we decide if this property will be an array or a new object - propVal = typeof next.p === 'undefined' ? [] : {}; - tempObj[propName] = propVal; - tempObj = tempObj[propName]; - } - } -} - -/** - * ### .getPathInfo(object, path) - * - * This allows the retrieval of property info in an - * object given a string path. - * - * The path info consists of an object with the - * following properties: - * - * * parent - The parent object of the property referenced by `path` - * * name - The name of the final property, a number if it was an array indexer - * * value - The value of the property, if it exists, otherwise `undefined` - * * exists - Whether the property exists or not - * - * @param {Object} object - * @param {String} path - * @returns {Object} info - * @namespace Utils - * @name getPathInfo - * @api public - */ - -function getPathInfo(obj, path) { - var parsed = parsePath(path); - var last = parsed[parsed.length - 1]; - var info = { - parent: - parsed.length > 1 ? - internalGetPathValue(obj, parsed, parsed.length - 1) : - obj, - name: last.p || last.i, - value: internalGetPathValue(obj, parsed), - }; - info.exists = hasProperty(info.parent, info.name); - - return info; -} - -/** - * ### .getPathValue(object, path) - * - * This allows the retrieval of values in an - * object given a string path. - * - * var obj = { - * prop1: { - * arr: ['a', 'b', 'c'] - * , str: 'Hello' - * } - * , prop2: { - * arr: [ { nested: 'Universe' } ] - * , str: 'Hello again!' - * } - * } - * - * The following would be the results. - * - * getPathValue(obj, 'prop1.str'); // Hello - * getPathValue(obj, 'prop1.att[2]'); // b - * getPathValue(obj, 'prop2.arr[0].nested'); // Universe - * - * @param {Object} object - * @param {String} path - * @returns {Object} value or `undefined` - * @namespace Utils - * @name getPathValue - * @api public - */ - -function getPathValue(obj, path) { - var info = getPathInfo(obj, path); - return info.value; -} - -/** - * ### .setPathValue(object, path, value) - * - * Define the value in an object at a given string path. - * - * ```js - * var obj = { - * prop1: { - * arr: ['a', 'b', 'c'] - * , str: 'Hello' - * } - * , prop2: { - * arr: [ { nested: 'Universe' } ] - * , str: 'Hello again!' - * } - * }; - * ``` - * - * The following would be acceptable. - * - * ```js - * var properties = require('tea-properties'); - * properties.set(obj, 'prop1.str', 'Hello Universe!'); - * properties.set(obj, 'prop1.arr[2]', 'B'); - * properties.set(obj, 'prop2.arr[0].nested.value', { hello: 'universe' }); - * ``` - * - * @param {Object} object - * @param {String} path - * @param {Mixed} value - * @api private - */ - -function setPathValue(obj, path, val) { - var parsed = parsePath(path); - internalSetPathValue(obj, val, parsed); - return obj; -} - -module.exports = { - hasProperty: hasProperty, - getPathInfo: getPathInfo, - getPathValue: getPathValue, - setPathValue: setPathValue, -}; diff --git a/node_modules/pathval/package.json b/node_modules/pathval/package.json deleted file mode 100644 index 6701b5f..0000000 --- a/node_modules/pathval/package.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "_from": "pathval@^1.1.1", - "_id": "pathval@1.1.1", - "_inBundle": false, - "_integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", - "_location": "/pathval", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "pathval@^1.1.1", - "name": "pathval", - "escapedName": "pathval", - "rawSpec": "^1.1.1", - "saveSpec": null, - "fetchSpec": "^1.1.1" - }, - "_requiredBy": [ - "/chai" - ], - "_resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "_shasum": "8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d", - "_spec": "pathval@^1.1.1", - "_where": "C:\\src\\github\\makensis-action\\node_modules\\chai", - "author": { - "name": "Veselin Todorov", - "email": "hi@vesln.com" - }, - "bugs": { - "url": "https://github.com/chaijs/pathval/issues" - }, - "bundleDependencies": false, - "config": { - "ghooks": { - "commit-msg": "validate-commit-msg" - } - }, - "deprecated": false, - "description": "Object value retrieval given a string path", - "devDependencies": { - "browserify": "^17.0.0", - "browserify-istanbul": "^3.0.1", - "coveralls": "^3.1.0", - "eslint": "^7.13.0", - "eslint-config-strict": "^14.0.1", - "eslint-plugin-filenames": "^1.3.2", - "ghooks": "^2.0.4", - "karma": "^5.2.3", - "karma-browserify": "^7.0.0", - "karma-coverage": "^2.0.3", - "karma-mocha": "^2.0.1", - "karma-phantomjs-launcher": "^1.0.4", - "karma-sauce-launcher": "^4.3.3", - "lcov-result-merger": "^3.1.0", - "mocha": "^8.2.1", - "nyc": "^15.1.0", - "phantomjs-prebuilt": "^2.1.16", - "semantic-release": "^17.2.2", - "simple-assert": "^1.0.0", - "travis-after-all": "^1.4.5", - "validate-commit-msg": "^2.14.0" - }, - "engines": { - "node": "*" - }, - "eslintConfig": { - "extends": [ - "strict/es5" - ], - "env": { - "es6": true - }, - "globals": { - "HTMLElement": false - }, - "rules": { - "complexity": 0, - "max-statements": 0 - } - }, - "files": [ - "index.js", - "pathval.js" - ], - "homepage": "https://github.com/chaijs/pathval", - "keywords": [ - "pathval", - "value retrieval", - "chai util" - ], - "license": "MIT", - "main": "./index.js", - "name": "pathval", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/chaijs/pathval.git" - }, - "scripts": { - "build": "browserify --standalone pathval -o pathval.js", - "lint": "eslint --ignore-path .gitignore .", - "lint:fix": "npm run lint -- --fix", - "prepublish": "npm run build", - "pretest": "npm run lint", - "semantic-release": "semantic-release pre && npm publish && semantic-release post", - "test": "npm run test:node && npm run test:browser && npm run upload-coverage", - "test:browser": "karma start --singleRun=true", - "test:node": "nyc mocha", - "upload-coverage": "lcov-result-merger 'coverage/**/lcov.info' | coveralls; exit 0" - }, - "version": "1.1.1" -} diff --git a/node_modules/pathval/pathval.js b/node_modules/pathval/pathval.js deleted file mode 100644 index 0070ed4..0000000 --- a/node_modules/pathval/pathval.js +++ /dev/null @@ -1 +0,0 @@ -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i (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. diff --git a/node_modules/type-detect/README.md b/node_modules/type-detect/README.md deleted file mode 100644 index d2c4cb7..0000000 --- a/node_modules/type-detect/README.md +++ /dev/null @@ -1,228 +0,0 @@ -

- - ChaiJS type-detect - -

-
-

- Improved typeof detection for node and the browser. -

- -

- - license:mit - - - tag:? - - - build:? - - - coverage:? - - - npm:? - - - dependencies:? - - - devDependencies:? - -
- - - - - - - - - - - - - - -
Supported Browsers
Chrome Edge Firefox Safari IE
9, 10, 11
-
- - Join the Slack chat - - - Join the Gitter chat - -

- -## What is Type-Detect? - -Type Detect is a module which you can use to detect the type of a given object. It returns a string representation of the object's type, either using [`typeof`](http://www.ecma-international.org/ecma-262/6.0/index.html#sec-typeof-operator) or [`@@toStringTag`](http://www.ecma-international.org/ecma-262/6.0/index.html#sec-symbol.tostringtag). It also normalizes some object names for consistency among browsers. - -## Why? - -The `typeof` operator will only specify primitive values; everything else is `"object"` (including `null`, arrays, regexps, etc). Many developers use `Object.prototype.toString()` - which is a fine alternative and returns many more types (null returns `[object Null]`, Arrays as `[object Array]`, regexps as `[object RegExp]` etc). - -Sadly, `Object.prototype.toString` is slow, and buggy. By slow - we mean it is slower than `typeof`. By buggy - we mean that some values (like Promises, the global object, iterators, dataviews, a bunch of HTML elements) all report different things in different browsers. - -`type-detect` fixes all of the shortcomings with `Object.prototype.toString`. We have extra code to speed up checks of JS and DOM objects, as much as 20-30x faster for some values. `type-detect` also fixes any consistencies with these objects. - -## Installation - -### Node.js - -`type-detect` is available on [npm](http://npmjs.org). To install it, type: - - $ npm install type-detect - -### Browsers - -You can also use it within the browser; install via npm and use the `type-detect.js` file found within the download. For example: - -```html - -``` - -## Usage - -The primary export of `type-detect` is function that can serve as a replacement for `typeof`. The results of this function will be more specific than that of native `typeof`. - -```js -var type = require('type-detect'); -``` - -#### array - -```js -assert(type([]) === 'Array'); -assert(type(new Array()) === 'Array'); -``` - -#### regexp - -```js -assert(type(/a-z/gi) === 'RegExp'); -assert(type(new RegExp('a-z')) === 'RegExp'); -``` - -#### function - -```js -assert(type(function () {}) === 'function'); -``` - -#### arguments - -```js -(function () { - assert(type(arguments) === 'Arguments'); -})(); -``` - -#### date - -```js -assert(type(new Date) === 'Date'); -``` - -#### number - -```js -assert(type(1) === 'number'); -assert(type(1.234) === 'number'); -assert(type(-1) === 'number'); -assert(type(-1.234) === 'number'); -assert(type(Infinity) === 'number'); -assert(type(NaN) === 'number'); -assert(type(new Number(1)) === 'Number'); // note - the object version has a capital N -``` - -#### string - -```js -assert(type('hello world') === 'string'); -assert(type(new String('hello')) === 'String'); // note - the object version has a capital S -``` - -#### null - -```js -assert(type(null) === 'null'); -assert(type(undefined) !== 'null'); -``` - -#### undefined - -```js -assert(type(undefined) === 'undefined'); -assert(type(null) !== 'undefined'); -``` - -#### object - -```js -var Noop = function () {}; -assert(type({}) === 'Object'); -assert(type(Noop) !== 'Object'); -assert(type(new Noop) === 'Object'); -assert(type(new Object) === 'Object'); -``` - -#### ECMA6 Types - -All new ECMAScript 2015 objects are also supported, such as Promises and Symbols: - -```js -assert(type(new Map() === 'Map'); -assert(type(new WeakMap()) === 'WeakMap'); -assert(type(new Set()) === 'Set'); -assert(type(new WeakSet()) === 'WeakSet'); -assert(type(Symbol()) === 'symbol'); -assert(type(new Promise(callback) === 'Promise'); -assert(type(new Int8Array()) === 'Int8Array'); -assert(type(new Uint8Array()) === 'Uint8Array'); -assert(type(new UInt8ClampedArray()) === 'Uint8ClampedArray'); -assert(type(new Int16Array()) === 'Int16Array'); -assert(type(new Uint16Array()) === 'Uint16Array'); -assert(type(new Int32Array()) === 'Int32Array'); -assert(type(new UInt32Array()) === 'Uint32Array'); -assert(type(new Float32Array()) === 'Float32Array'); -assert(type(new Float64Array()) === 'Float64Array'); -assert(type(new ArrayBuffer()) === 'ArrayBuffer'); -assert(type(new DataView(arrayBuffer)) === 'DataView'); -``` - -Also, if you use `Symbol.toStringTag` to change an Objects return value of the `toString()` Method, `type()` will return this value, e.g: - -```js -var myObject = {}; -myObject[Symbol.toStringTag] = 'myCustomType'; -assert(type(myObject) === 'myCustomType'); -``` diff --git a/node_modules/type-detect/index.js b/node_modules/type-detect/index.js deleted file mode 100644 index 98a1e03..0000000 --- a/node_modules/type-detect/index.js +++ /dev/null @@ -1,378 +0,0 @@ -/* ! - * type-detect - * Copyright(c) 2013 jake luer - * MIT Licensed - */ -const promiseExists = typeof Promise === 'function'; - -/* eslint-disable no-undef */ -const globalObject = typeof self === 'object' ? self : global; // eslint-disable-line id-blacklist - -const symbolExists = typeof Symbol !== 'undefined'; -const mapExists = typeof Map !== 'undefined'; -const setExists = typeof Set !== 'undefined'; -const weakMapExists = typeof WeakMap !== 'undefined'; -const weakSetExists = typeof WeakSet !== 'undefined'; -const dataViewExists = typeof DataView !== 'undefined'; -const symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined'; -const symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined'; -const setEntriesExists = setExists && typeof Set.prototype.entries === 'function'; -const mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function'; -const setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries()); -const mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries()); -const arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function'; -const arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]()); -const stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === 'function'; -const stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]()); -const toStringLeftSliceLength = 8; -const toStringRightSliceLength = -1; -/** - * ### typeOf (obj) - * - * Uses `Object.prototype.toString` to determine the type of an object, - * normalising behaviour across engine versions & well optimised. - * - * @param {Mixed} object - * @return {String} object type - * @api public - */ -export default function typeDetect(obj) { - /* ! Speed optimisation - * Pre: - * string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled) - * boolean literal x 1,424,138 ops/sec ±4.54% (75 runs sampled) - * number literal x 1,653,153 ops/sec ±1.91% (82 runs sampled) - * undefined x 9,978,660 ops/sec ±1.92% (75 runs sampled) - * function x 2,556,769 ops/sec ±1.73% (77 runs sampled) - * Post: - * string literal x 38,564,796 ops/sec ±1.15% (79 runs sampled) - * boolean literal x 31,148,940 ops/sec ±1.10% (79 runs sampled) - * number literal x 32,679,330 ops/sec ±1.90% (78 runs sampled) - * undefined x 32,363,368 ops/sec ±1.07% (82 runs sampled) - * function x 31,296,870 ops/sec ±0.96% (83 runs sampled) - */ - const typeofObj = typeof obj; - if (typeofObj !== 'object') { - return typeofObj; - } - - /* ! Speed optimisation - * Pre: - * null x 28,645,765 ops/sec ±1.17% (82 runs sampled) - * Post: - * null x 36,428,962 ops/sec ±1.37% (84 runs sampled) - */ - if (obj === null) { - return 'null'; - } - - /* ! Spec Conformance - * Test: `Object.prototype.toString.call(window)`` - * - Node === "[object global]" - * - Chrome === "[object global]" - * - Firefox === "[object Window]" - * - PhantomJS === "[object Window]" - * - Safari === "[object Window]" - * - IE 11 === "[object Window]" - * - IE Edge === "[object Window]" - * Test: `Object.prototype.toString.call(this)`` - * - Chrome Worker === "[object global]" - * - Firefox Worker === "[object DedicatedWorkerGlobalScope]" - * - Safari Worker === "[object DedicatedWorkerGlobalScope]" - * - IE 11 Worker === "[object WorkerGlobalScope]" - * - IE Edge Worker === "[object WorkerGlobalScope]" - */ - if (obj === globalObject) { - return 'global'; - } - - /* ! Speed optimisation - * Pre: - * array literal x 2,888,352 ops/sec ±0.67% (82 runs sampled) - * Post: - * array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled) - */ - if ( - Array.isArray(obj) && - (symbolToStringTagExists === false || !(Symbol.toStringTag in obj)) - ) { - return 'Array'; - } - - // Not caching existence of `window` and related properties due to potential - // for `window` to be unset before tests in quasi-browser environments. - if (typeof window === 'object' && window !== null) { - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/browsers.html#location) - * WhatWG HTML$7.7.3 - The `Location` interface - * Test: `Object.prototype.toString.call(window.location)`` - * - IE <=11 === "[object Object]" - * - IE Edge <=13 === "[object Object]" - */ - if (typeof window.location === 'object' && obj === window.location) { - return 'Location'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/#document) - * WhatWG HTML$3.1.1 - The `Document` object - * Note: Most browsers currently adher to the W3C DOM Level 2 spec - * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268) - * which suggests that browsers should use HTMLTableCellElement for - * both TD and TH elements. WhatWG separates these. - * WhatWG HTML states: - * > For historical reasons, Window objects must also have a - * > writable, configurable, non-enumerable property named - * > HTMLDocument whose value is the Document interface object. - * Test: `Object.prototype.toString.call(document)`` - * - Chrome === "[object HTMLDocument]" - * - Firefox === "[object HTMLDocument]" - * - Safari === "[object HTMLDocument]" - * - IE <=10 === "[object Document]" - * - IE 11 === "[object HTMLDocument]" - * - IE Edge <=13 === "[object HTMLDocument]" - */ - if (typeof window.document === 'object' && obj === window.document) { - return 'Document'; - } - - if (typeof window.navigator === 'object') { - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray) - * WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray - * Test: `Object.prototype.toString.call(navigator.mimeTypes)`` - * - IE <=10 === "[object MSMimeTypesCollection]" - */ - if (typeof window.navigator.mimeTypes === 'object' && - obj === window.navigator.mimeTypes) { - return 'MimeTypeArray'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray) - * WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray - * Test: `Object.prototype.toString.call(navigator.plugins)`` - * - IE <=10 === "[object MSPluginsCollection]" - */ - if (typeof window.navigator.plugins === 'object' && - obj === window.navigator.plugins) { - return 'PluginArray'; - } - } - - if ((typeof window.HTMLElement === 'function' || - typeof window.HTMLElement === 'object') && - obj instanceof window.HTMLElement) { - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray) - * WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement` - * Test: `Object.prototype.toString.call(document.createElement('blockquote'))`` - * - IE <=10 === "[object HTMLBlockElement]" - */ - if (obj.tagName === 'BLOCKQUOTE') { - return 'HTMLQuoteElement'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/#htmltabledatacellelement) - * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement` - * Note: Most browsers currently adher to the W3C DOM Level 2 spec - * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075) - * which suggests that browsers should use HTMLTableCellElement for - * both TD and TH elements. WhatWG separates these. - * Test: Object.prototype.toString.call(document.createElement('td')) - * - Chrome === "[object HTMLTableCellElement]" - * - Firefox === "[object HTMLTableCellElement]" - * - Safari === "[object HTMLTableCellElement]" - */ - if (obj.tagName === 'TD') { - return 'HTMLTableDataCellElement'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/#htmltableheadercellelement) - * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement` - * Note: Most browsers currently adher to the W3C DOM Level 2 spec - * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075) - * which suggests that browsers should use HTMLTableCellElement for - * both TD and TH elements. WhatWG separates these. - * Test: Object.prototype.toString.call(document.createElement('th')) - * - Chrome === "[object HTMLTableCellElement]" - * - Firefox === "[object HTMLTableCellElement]" - * - Safari === "[object HTMLTableCellElement]" - */ - if (obj.tagName === 'TH') { - return 'HTMLTableHeaderCellElement'; - } - } - } - - /* ! Speed optimisation - * Pre: - * Float64Array x 625,644 ops/sec ±1.58% (80 runs sampled) - * Float32Array x 1,279,852 ops/sec ±2.91% (77 runs sampled) - * Uint32Array x 1,178,185 ops/sec ±1.95% (83 runs sampled) - * Uint16Array x 1,008,380 ops/sec ±2.25% (80 runs sampled) - * Uint8Array x 1,128,040 ops/sec ±2.11% (81 runs sampled) - * Int32Array x 1,170,119 ops/sec ±2.88% (80 runs sampled) - * Int16Array x 1,176,348 ops/sec ±5.79% (86 runs sampled) - * Int8Array x 1,058,707 ops/sec ±4.94% (77 runs sampled) - * Uint8ClampedArray x 1,110,633 ops/sec ±4.20% (80 runs sampled) - * Post: - * Float64Array x 7,105,671 ops/sec ±13.47% (64 runs sampled) - * Float32Array x 5,887,912 ops/sec ±1.46% (82 runs sampled) - * Uint32Array x 6,491,661 ops/sec ±1.76% (79 runs sampled) - * Uint16Array x 6,559,795 ops/sec ±1.67% (82 runs sampled) - * Uint8Array x 6,463,966 ops/sec ±1.43% (85 runs sampled) - * Int32Array x 5,641,841 ops/sec ±3.49% (81 runs sampled) - * Int16Array x 6,583,511 ops/sec ±1.98% (80 runs sampled) - * Int8Array x 6,606,078 ops/sec ±1.74% (81 runs sampled) - * Uint8ClampedArray x 6,602,224 ops/sec ±1.77% (83 runs sampled) - */ - const stringTag = (symbolToStringTagExists && obj[Symbol.toStringTag]); - if (typeof stringTag === 'string') { - return stringTag; - } - - const objPrototype = Object.getPrototypeOf(obj); - /* ! Speed optimisation - * Pre: - * regex literal x 1,772,385 ops/sec ±1.85% (77 runs sampled) - * regex constructor x 2,143,634 ops/sec ±2.46% (78 runs sampled) - * Post: - * regex literal x 3,928,009 ops/sec ±0.65% (78 runs sampled) - * regex constructor x 3,931,108 ops/sec ±0.58% (84 runs sampled) - */ - if (objPrototype === RegExp.prototype) { - return 'RegExp'; - } - - /* ! Speed optimisation - * Pre: - * date x 2,130,074 ops/sec ±4.42% (68 runs sampled) - * Post: - * date x 3,953,779 ops/sec ±1.35% (77 runs sampled) - */ - if (objPrototype === Date.prototype) { - return 'Date'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag) - * ES6$25.4.5.4 - Promise.prototype[@@toStringTag] should be "Promise": - * Test: `Object.prototype.toString.call(Promise.resolve())`` - * - Chrome <=47 === "[object Object]" - * - Edge <=20 === "[object Object]" - * - Firefox 29-Latest === "[object Promise]" - * - Safari 7.1-Latest === "[object Promise]" - */ - if (promiseExists && objPrototype === Promise.prototype) { - return 'Promise'; - } - - /* ! Speed optimisation - * Pre: - * set x 2,222,186 ops/sec ±1.31% (82 runs sampled) - * Post: - * set x 4,545,879 ops/sec ±1.13% (83 runs sampled) - */ - if (setExists && objPrototype === Set.prototype) { - return 'Set'; - } - - /* ! Speed optimisation - * Pre: - * map x 2,396,842 ops/sec ±1.59% (81 runs sampled) - * Post: - * map x 4,183,945 ops/sec ±6.59% (82 runs sampled) - */ - if (mapExists && objPrototype === Map.prototype) { - return 'Map'; - } - - /* ! Speed optimisation - * Pre: - * weakset x 1,323,220 ops/sec ±2.17% (76 runs sampled) - * Post: - * weakset x 4,237,510 ops/sec ±2.01% (77 runs sampled) - */ - if (weakSetExists && objPrototype === WeakSet.prototype) { - return 'WeakSet'; - } - - /* ! Speed optimisation - * Pre: - * weakmap x 1,500,260 ops/sec ±2.02% (78 runs sampled) - * Post: - * weakmap x 3,881,384 ops/sec ±1.45% (82 runs sampled) - */ - if (weakMapExists && objPrototype === WeakMap.prototype) { - return 'WeakMap'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag) - * ES6$24.2.4.21 - DataView.prototype[@@toStringTag] should be "DataView": - * Test: `Object.prototype.toString.call(new DataView(new ArrayBuffer(1)))`` - * - Edge <=13 === "[object Object]" - */ - if (dataViewExists && objPrototype === DataView.prototype) { - return 'DataView'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag) - * ES6$23.1.5.2.2 - %MapIteratorPrototype%[@@toStringTag] should be "Map Iterator": - * Test: `Object.prototype.toString.call(new Map().entries())`` - * - Edge <=13 === "[object Object]" - */ - if (mapExists && objPrototype === mapIteratorPrototype) { - return 'Map Iterator'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag) - * ES6$23.2.5.2.2 - %SetIteratorPrototype%[@@toStringTag] should be "Set Iterator": - * Test: `Object.prototype.toString.call(new Set().entries())`` - * - Edge <=13 === "[object Object]" - */ - if (setExists && objPrototype === setIteratorPrototype) { - return 'Set Iterator'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag) - * ES6$22.1.5.2.2 - %ArrayIteratorPrototype%[@@toStringTag] should be "Array Iterator": - * Test: `Object.prototype.toString.call([][Symbol.iterator]())`` - * - Edge <=13 === "[object Object]" - */ - if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) { - return 'Array Iterator'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag) - * ES6$21.1.5.2.2 - %StringIteratorPrototype%[@@toStringTag] should be "String Iterator": - * Test: `Object.prototype.toString.call(''[Symbol.iterator]())`` - * - Edge <=13 === "[object Object]" - */ - if (stringIteratorExists && objPrototype === stringIteratorPrototype) { - return 'String Iterator'; - } - - /* ! Speed optimisation - * Pre: - * object from null x 2,424,320 ops/sec ±1.67% (76 runs sampled) - * Post: - * object from null x 5,838,000 ops/sec ±0.99% (84 runs sampled) - */ - if (objPrototype === null) { - return 'Object'; - } - - return Object - .prototype - .toString - .call(obj) - .slice(toStringLeftSliceLength, toStringRightSliceLength); -} diff --git a/node_modules/type-detect/package.json b/node_modules/type-detect/package.json deleted file mode 100644 index 277269a..0000000 --- a/node_modules/type-detect/package.json +++ /dev/null @@ -1,169 +0,0 @@ -{ - "_from": "type-detect@^4.0.5", - "_id": "type-detect@4.0.8", - "_inBundle": false, - "_integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "_location": "/type-detect", - "_phantomChildren": {}, - "_requested": { - "type": "range", - "registry": true, - "raw": "type-detect@^4.0.5", - "name": "type-detect", - "escapedName": "type-detect", - "rawSpec": "^4.0.5", - "saveSpec": null, - "fetchSpec": "^4.0.5" - }, - "_requiredBy": [ - "/chai", - "/deep-eql" - ], - "_resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "_shasum": "7646fb5f18871cfbb7749e69bd39a6388eb7450c", - "_spec": "type-detect@^4.0.5", - "_where": "C:\\src\\github\\makensis-action\\node_modules\\chai", - "author": { - "name": "Jake Luer", - "email": "jake@alogicalparadox.com", - "url": "http://alogicalparadox.com" - }, - "bugs": { - "url": "https://github.com/chaijs/type-detect/issues" - }, - "bundleDependencies": false, - "contributors": [ - { - "name": "Keith Cirkel", - "url": "https://github.com/keithamus" - }, - { - "name": "David Losert", - "url": "https://github.com/davelosert" - }, - { - "name": "Aleksey Shvayka", - "url": "https://github.com/shvaikalesh" - }, - { - "name": "Lucas Fernandes da Costa", - "url": "https://github.com/lucasfcosta" - }, - { - "name": "Grant Snodgrass", - "url": "https://github.com/meeber" - }, - { - "name": "Jeremy Tice", - "url": "https://github.com/jetpacmonkey" - }, - { - "name": "Edward Betts", - "url": "https://github.com/EdwardBetts" - }, - { - "name": "dvlsg", - "url": "https://github.com/dvlsg" - }, - { - "name": "Amila Welihinda", - "url": "https://github.com/amilajack" - }, - { - "name": "Jake Champion", - "url": "https://github.com/JakeChampion" - }, - { - "name": "Miroslav Bajtoš", - "url": "https://github.com/bajtos" - } - ], - "deprecated": false, - "description": "Improved typeof detection for node.js and the browser.", - "devDependencies": { - "@commitlint/cli": "^4.2.2", - "benchmark": "^2.1.0", - "buble": "^0.16.0", - "codecov": "^3.0.0", - "commitlint-config-angular": "^4.2.1", - "cross-env": "^5.1.1", - "eslint": "^4.10.0", - "eslint-config-strict": "^14.0.0", - "eslint-plugin-filenames": "^1.2.0", - "husky": "^0.14.3", - "karma": "^1.7.1", - "karma-chrome-launcher": "^2.2.0", - "karma-coverage": "^1.1.1", - "karma-detect-browsers": "^2.2.5", - "karma-edge-launcher": "^0.4.2", - "karma-firefox-launcher": "^1.0.1", - "karma-ie-launcher": "^1.0.0", - "karma-mocha": "^1.3.0", - "karma-opera-launcher": "^1.0.0", - "karma-safari-launcher": "^1.0.0", - "karma-safaritechpreview-launcher": "0.0.6", - "karma-sauce-launcher": "^1.2.0", - "mocha": "^4.0.1", - "nyc": "^11.3.0", - "rollup": "^0.50.0", - "rollup-plugin-buble": "^0.16.0", - "rollup-plugin-commonjs": "^8.2.6", - "rollup-plugin-istanbul": "^1.1.0", - "rollup-plugin-node-resolve": "^3.0.0", - "semantic-release": "^8.2.0", - "simple-assert": "^1.0.0" - }, - "engines": { - "node": ">=4" - }, - "eslintConfig": { - "env": { - "es6": true - }, - "extends": [ - "strict/es6" - ], - "globals": { - "HTMLElement": false - }, - "rules": { - "complexity": 0, - "max-statements": 0, - "prefer-rest-params": 0 - } - }, - "files": [ - "index.js", - "type-detect.js" - ], - "homepage": "https://github.com/chaijs/type-detect#readme", - "keywords": [ - "type", - "typeof", - "types" - ], - "license": "MIT", - "main": "./type-detect.js", - "name": "type-detect", - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/chaijs/type-detect.git" - }, - "scripts": { - "bench": "node bench", - "build": "rollup -c rollup.conf.js", - "commit-msg": "commitlint -x angular", - "lint": "eslint --ignore-path .gitignore .", - "posttest:browser": "npm run upload-coverage", - "posttest:node": "nyc report --report-dir \"coverage/node-$(node --version)\" --reporter=lcovonly && npm run upload-coverage", - "prepare": "cross-env NODE_ENV=production npm run build", - "pretest:browser": "cross-env NODE_ENV=test npm run build", - "pretest:node": "cross-env NODE_ENV=test npm run build", - "semantic-release": "semantic-release pre && npm publish && semantic-release post", - "test": "npm run test:node && npm run test:browser", - "test:browser": "karma start --singleRun=true", - "test:node": "nyc mocha type-detect.test.js", - "upload-coverage": "codecov" - }, - "version": "4.0.8" -} diff --git a/node_modules/type-detect/type-detect.js b/node_modules/type-detect/type-detect.js deleted file mode 100644 index 2f55525..0000000 --- a/node_modules/type-detect/type-detect.js +++ /dev/null @@ -1,388 +0,0 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global.typeDetect = factory()); -}(this, (function () { 'use strict'; - -/* ! - * type-detect - * Copyright(c) 2013 jake luer - * MIT Licensed - */ -var promiseExists = typeof Promise === 'function'; - -/* eslint-disable no-undef */ -var globalObject = typeof self === 'object' ? self : global; // eslint-disable-line id-blacklist - -var symbolExists = typeof Symbol !== 'undefined'; -var mapExists = typeof Map !== 'undefined'; -var setExists = typeof Set !== 'undefined'; -var weakMapExists = typeof WeakMap !== 'undefined'; -var weakSetExists = typeof WeakSet !== 'undefined'; -var dataViewExists = typeof DataView !== 'undefined'; -var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined'; -var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined'; -var setEntriesExists = setExists && typeof Set.prototype.entries === 'function'; -var mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function'; -var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries()); -var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries()); -var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function'; -var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]()); -var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === 'function'; -var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]()); -var toStringLeftSliceLength = 8; -var toStringRightSliceLength = -1; -/** - * ### typeOf (obj) - * - * Uses `Object.prototype.toString` to determine the type of an object, - * normalising behaviour across engine versions & well optimised. - * - * @param {Mixed} object - * @return {String} object type - * @api public - */ -function typeDetect(obj) { - /* ! Speed optimisation - * Pre: - * string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled) - * boolean literal x 1,424,138 ops/sec ±4.54% (75 runs sampled) - * number literal x 1,653,153 ops/sec ±1.91% (82 runs sampled) - * undefined x 9,978,660 ops/sec ±1.92% (75 runs sampled) - * function x 2,556,769 ops/sec ±1.73% (77 runs sampled) - * Post: - * string literal x 38,564,796 ops/sec ±1.15% (79 runs sampled) - * boolean literal x 31,148,940 ops/sec ±1.10% (79 runs sampled) - * number literal x 32,679,330 ops/sec ±1.90% (78 runs sampled) - * undefined x 32,363,368 ops/sec ±1.07% (82 runs sampled) - * function x 31,296,870 ops/sec ±0.96% (83 runs sampled) - */ - var typeofObj = typeof obj; - if (typeofObj !== 'object') { - return typeofObj; - } - - /* ! Speed optimisation - * Pre: - * null x 28,645,765 ops/sec ±1.17% (82 runs sampled) - * Post: - * null x 36,428,962 ops/sec ±1.37% (84 runs sampled) - */ - if (obj === null) { - return 'null'; - } - - /* ! Spec Conformance - * Test: `Object.prototype.toString.call(window)`` - * - Node === "[object global]" - * - Chrome === "[object global]" - * - Firefox === "[object Window]" - * - PhantomJS === "[object Window]" - * - Safari === "[object Window]" - * - IE 11 === "[object Window]" - * - IE Edge === "[object Window]" - * Test: `Object.prototype.toString.call(this)`` - * - Chrome Worker === "[object global]" - * - Firefox Worker === "[object DedicatedWorkerGlobalScope]" - * - Safari Worker === "[object DedicatedWorkerGlobalScope]" - * - IE 11 Worker === "[object WorkerGlobalScope]" - * - IE Edge Worker === "[object WorkerGlobalScope]" - */ - if (obj === globalObject) { - return 'global'; - } - - /* ! Speed optimisation - * Pre: - * array literal x 2,888,352 ops/sec ±0.67% (82 runs sampled) - * Post: - * array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled) - */ - if ( - Array.isArray(obj) && - (symbolToStringTagExists === false || !(Symbol.toStringTag in obj)) - ) { - return 'Array'; - } - - // Not caching existence of `window` and related properties due to potential - // for `window` to be unset before tests in quasi-browser environments. - if (typeof window === 'object' && window !== null) { - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/browsers.html#location) - * WhatWG HTML$7.7.3 - The `Location` interface - * Test: `Object.prototype.toString.call(window.location)`` - * - IE <=11 === "[object Object]" - * - IE Edge <=13 === "[object Object]" - */ - if (typeof window.location === 'object' && obj === window.location) { - return 'Location'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/#document) - * WhatWG HTML$3.1.1 - The `Document` object - * Note: Most browsers currently adher to the W3C DOM Level 2 spec - * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268) - * which suggests that browsers should use HTMLTableCellElement for - * both TD and TH elements. WhatWG separates these. - * WhatWG HTML states: - * > For historical reasons, Window objects must also have a - * > writable, configurable, non-enumerable property named - * > HTMLDocument whose value is the Document interface object. - * Test: `Object.prototype.toString.call(document)`` - * - Chrome === "[object HTMLDocument]" - * - Firefox === "[object HTMLDocument]" - * - Safari === "[object HTMLDocument]" - * - IE <=10 === "[object Document]" - * - IE 11 === "[object HTMLDocument]" - * - IE Edge <=13 === "[object HTMLDocument]" - */ - if (typeof window.document === 'object' && obj === window.document) { - return 'Document'; - } - - if (typeof window.navigator === 'object') { - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray) - * WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray - * Test: `Object.prototype.toString.call(navigator.mimeTypes)`` - * - IE <=10 === "[object MSMimeTypesCollection]" - */ - if (typeof window.navigator.mimeTypes === 'object' && - obj === window.navigator.mimeTypes) { - return 'MimeTypeArray'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray) - * WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray - * Test: `Object.prototype.toString.call(navigator.plugins)`` - * - IE <=10 === "[object MSPluginsCollection]" - */ - if (typeof window.navigator.plugins === 'object' && - obj === window.navigator.plugins) { - return 'PluginArray'; - } - } - - if ((typeof window.HTMLElement === 'function' || - typeof window.HTMLElement === 'object') && - obj instanceof window.HTMLElement) { - /* ! Spec Conformance - * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray) - * WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement` - * Test: `Object.prototype.toString.call(document.createElement('blockquote'))`` - * - IE <=10 === "[object HTMLBlockElement]" - */ - if (obj.tagName === 'BLOCKQUOTE') { - return 'HTMLQuoteElement'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/#htmltabledatacellelement) - * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement` - * Note: Most browsers currently adher to the W3C DOM Level 2 spec - * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075) - * which suggests that browsers should use HTMLTableCellElement for - * both TD and TH elements. WhatWG separates these. - * Test: Object.prototype.toString.call(document.createElement('td')) - * - Chrome === "[object HTMLTableCellElement]" - * - Firefox === "[object HTMLTableCellElement]" - * - Safari === "[object HTMLTableCellElement]" - */ - if (obj.tagName === 'TD') { - return 'HTMLTableDataCellElement'; - } - - /* ! Spec Conformance - * (https://html.spec.whatwg.org/#htmltableheadercellelement) - * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement` - * Note: Most browsers currently adher to the W3C DOM Level 2 spec - * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075) - * which suggests that browsers should use HTMLTableCellElement for - * both TD and TH elements. WhatWG separates these. - * Test: Object.prototype.toString.call(document.createElement('th')) - * - Chrome === "[object HTMLTableCellElement]" - * - Firefox === "[object HTMLTableCellElement]" - * - Safari === "[object HTMLTableCellElement]" - */ - if (obj.tagName === 'TH') { - return 'HTMLTableHeaderCellElement'; - } - } - } - - /* ! Speed optimisation - * Pre: - * Float64Array x 625,644 ops/sec ±1.58% (80 runs sampled) - * Float32Array x 1,279,852 ops/sec ±2.91% (77 runs sampled) - * Uint32Array x 1,178,185 ops/sec ±1.95% (83 runs sampled) - * Uint16Array x 1,008,380 ops/sec ±2.25% (80 runs sampled) - * Uint8Array x 1,128,040 ops/sec ±2.11% (81 runs sampled) - * Int32Array x 1,170,119 ops/sec ±2.88% (80 runs sampled) - * Int16Array x 1,176,348 ops/sec ±5.79% (86 runs sampled) - * Int8Array x 1,058,707 ops/sec ±4.94% (77 runs sampled) - * Uint8ClampedArray x 1,110,633 ops/sec ±4.20% (80 runs sampled) - * Post: - * Float64Array x 7,105,671 ops/sec ±13.47% (64 runs sampled) - * Float32Array x 5,887,912 ops/sec ±1.46% (82 runs sampled) - * Uint32Array x 6,491,661 ops/sec ±1.76% (79 runs sampled) - * Uint16Array x 6,559,795 ops/sec ±1.67% (82 runs sampled) - * Uint8Array x 6,463,966 ops/sec ±1.43% (85 runs sampled) - * Int32Array x 5,641,841 ops/sec ±3.49% (81 runs sampled) - * Int16Array x 6,583,511 ops/sec ±1.98% (80 runs sampled) - * Int8Array x 6,606,078 ops/sec ±1.74% (81 runs sampled) - * Uint8ClampedArray x 6,602,224 ops/sec ±1.77% (83 runs sampled) - */ - var stringTag = (symbolToStringTagExists && obj[Symbol.toStringTag]); - if (typeof stringTag === 'string') { - return stringTag; - } - - var objPrototype = Object.getPrototypeOf(obj); - /* ! Speed optimisation - * Pre: - * regex literal x 1,772,385 ops/sec ±1.85% (77 runs sampled) - * regex constructor x 2,143,634 ops/sec ±2.46% (78 runs sampled) - * Post: - * regex literal x 3,928,009 ops/sec ±0.65% (78 runs sampled) - * regex constructor x 3,931,108 ops/sec ±0.58% (84 runs sampled) - */ - if (objPrototype === RegExp.prototype) { - return 'RegExp'; - } - - /* ! Speed optimisation - * Pre: - * date x 2,130,074 ops/sec ±4.42% (68 runs sampled) - * Post: - * date x 3,953,779 ops/sec ±1.35% (77 runs sampled) - */ - if (objPrototype === Date.prototype) { - return 'Date'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag) - * ES6$25.4.5.4 - Promise.prototype[@@toStringTag] should be "Promise": - * Test: `Object.prototype.toString.call(Promise.resolve())`` - * - Chrome <=47 === "[object Object]" - * - Edge <=20 === "[object Object]" - * - Firefox 29-Latest === "[object Promise]" - * - Safari 7.1-Latest === "[object Promise]" - */ - if (promiseExists && objPrototype === Promise.prototype) { - return 'Promise'; - } - - /* ! Speed optimisation - * Pre: - * set x 2,222,186 ops/sec ±1.31% (82 runs sampled) - * Post: - * set x 4,545,879 ops/sec ±1.13% (83 runs sampled) - */ - if (setExists && objPrototype === Set.prototype) { - return 'Set'; - } - - /* ! Speed optimisation - * Pre: - * map x 2,396,842 ops/sec ±1.59% (81 runs sampled) - * Post: - * map x 4,183,945 ops/sec ±6.59% (82 runs sampled) - */ - if (mapExists && objPrototype === Map.prototype) { - return 'Map'; - } - - /* ! Speed optimisation - * Pre: - * weakset x 1,323,220 ops/sec ±2.17% (76 runs sampled) - * Post: - * weakset x 4,237,510 ops/sec ±2.01% (77 runs sampled) - */ - if (weakSetExists && objPrototype === WeakSet.prototype) { - return 'WeakSet'; - } - - /* ! Speed optimisation - * Pre: - * weakmap x 1,500,260 ops/sec ±2.02% (78 runs sampled) - * Post: - * weakmap x 3,881,384 ops/sec ±1.45% (82 runs sampled) - */ - if (weakMapExists && objPrototype === WeakMap.prototype) { - return 'WeakMap'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag) - * ES6$24.2.4.21 - DataView.prototype[@@toStringTag] should be "DataView": - * Test: `Object.prototype.toString.call(new DataView(new ArrayBuffer(1)))`` - * - Edge <=13 === "[object Object]" - */ - if (dataViewExists && objPrototype === DataView.prototype) { - return 'DataView'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag) - * ES6$23.1.5.2.2 - %MapIteratorPrototype%[@@toStringTag] should be "Map Iterator": - * Test: `Object.prototype.toString.call(new Map().entries())`` - * - Edge <=13 === "[object Object]" - */ - if (mapExists && objPrototype === mapIteratorPrototype) { - return 'Map Iterator'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag) - * ES6$23.2.5.2.2 - %SetIteratorPrototype%[@@toStringTag] should be "Set Iterator": - * Test: `Object.prototype.toString.call(new Set().entries())`` - * - Edge <=13 === "[object Object]" - */ - if (setExists && objPrototype === setIteratorPrototype) { - return 'Set Iterator'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag) - * ES6$22.1.5.2.2 - %ArrayIteratorPrototype%[@@toStringTag] should be "Array Iterator": - * Test: `Object.prototype.toString.call([][Symbol.iterator]())`` - * - Edge <=13 === "[object Object]" - */ - if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) { - return 'Array Iterator'; - } - - /* ! Spec Conformance - * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag) - * ES6$21.1.5.2.2 - %StringIteratorPrototype%[@@toStringTag] should be "String Iterator": - * Test: `Object.prototype.toString.call(''[Symbol.iterator]())`` - * - Edge <=13 === "[object Object]" - */ - if (stringIteratorExists && objPrototype === stringIteratorPrototype) { - return 'String Iterator'; - } - - /* ! Speed optimisation - * Pre: - * object from null x 2,424,320 ops/sec ±1.67% (76 runs sampled) - * Post: - * object from null x 5,838,000 ops/sec ±0.99% (84 runs sampled) - */ - if (objPrototype === null) { - return 'Object'; - } - - return Object - .prototype - .toString - .call(obj) - .slice(toStringLeftSliceLength, toStringRightSliceLength); -} - -return typeDetect; - -}))); diff --git a/package-lock.json b/package-lock.json index e8a4d1f..9ff5ec2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "@actions/github": "^5.0.3" }, "devDependencies": { - "chai": "^4.3.6", "mocha": "^10.0.0", "yaml": "^2.1.1" }, @@ -207,15 +206,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "node_modules/assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -275,24 +265,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/chai": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", - "integrity": "sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==", - "dev": true, - "dependencies": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "loupe": "^2.3.1", - "pathval": "^1.1.1", - "type-detect": "^4.0.5" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -321,15 +293,6 @@ "node": ">=8" } }, - "node_modules/check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -427,18 +390,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "dev": true, - "dependencies": { - "type-detect": "^4.0.0" - }, - "engines": { - "node": ">=0.12" - } - }, "node_modules/deprecation": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", @@ -546,15 +497,6 @@ "node": "6.* || 8.* || >= 10.*" } }, - "node_modules/get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -766,15 +708,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/loupe": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz", - "integrity": "sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==", - "dev": true, - "dependencies": { - "get-func-name": "^2.0.0" - } - }, "node_modules/minimatch": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", @@ -930,15 +863,6 @@ "node": ">=0.10.0" } }, - "node_modules/pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -1088,15 +1012,6 @@ "node": ">=0.6.11 <=0.7.0 || >=0.7.3" } }, - "node_modules/type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/universal-user-agent": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", @@ -1383,12 +1298,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true - }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -1436,21 +1345,6 @@ "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", "dev": true }, - "chai": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.6.tgz", - "integrity": "sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==", - "dev": true, - "requires": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "loupe": "^2.3.1", - "pathval": "^1.1.1", - "type-detect": "^4.0.5" - } - }, "chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -1472,12 +1366,6 @@ } } }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true - }, "chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -1549,15 +1437,6 @@ "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", "dev": true }, - "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", - "dev": true, - "requires": { - "type-detect": "^4.0.0" - } - }, "deprecation": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", @@ -1631,12 +1510,6 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true - }, "glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -1790,15 +1663,6 @@ "is-unicode-supported": "^0.1.0" } }, - "loupe": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.4.tgz", - "integrity": "sha512-OvKfgCC2Ndby6aSTREl5aCCPTNIzlDfQZvZxNUrBrihDhL3xcrYegTblhmEiCrg2kKQz4XsFIaemE5BF4ybSaQ==", - "dev": true, - "requires": { - "get-func-name": "^2.0.0" - } - }, "minimatch": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", @@ -1902,12 +1766,6 @@ "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true }, - "pathval": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", - "dev": true - }, "picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -2007,12 +1865,6 @@ "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==" }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true - }, "universal-user-agent": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",