@feathersjs/client 5.0.0-pre.0 → 5.0.0-pre.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +229 -0
- package/README.md +2 -2
- package/dist/core.d.ts +1 -0
- package/dist/core.js +1861 -3627
- package/dist/core.js.map +1 -1
- package/dist/core.min.js +1 -1
- package/dist/feathers.d.ts +8 -0
- package/dist/feathers.js +5106 -5755
- package/dist/feathers.js.map +1 -1
- package/dist/feathers.min.js +1 -1
- package/package.json +44 -38
- package/src/core.ts +1 -0
- package/src/feathers.ts +13 -0
- package/.babelrc +0 -8
- package/.cache/lasso/default/6a3076a5/dependencyFingerprints/cache +0 -0
- package/.cache/lasso/default/6a3076a5/key +0 -1
- package/.cache/lasso/default/6a3076a5/lasso-require/inspect-/5d47a286cdceb98f64bf9128488dd355fde40e81/cache +0 -0
- package/.cache/lasso/default/7be4a25c/dependencyFingerprints/cache +0 -0
- package/.cache/lasso/default/7be4a25c/key +0 -1
- package/.cache/lasso/default/7be4a25c/lasso-require/inspect/cache +0 -0
- package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.0/lib/filter-query.js +0 -1998
- package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.0/lib/index.js +0 -694
- package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.0/lib/service.js +0 -1636
- package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.0/lib/sort.js +0 -2259
- package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.1/lib/filter-query.js +0 -98
- package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.1/lib/index.js +0 -37
- package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.1/lib/service.js +0 -94
- package/.mocha-puppeteer/test-page/@feathersjs/adapter-commons$4.5.1/lib/sort.js +0 -112
- package/.mocha-puppeteer/test-page/@feathersjs/client$4.5.0/browser/test-run.js +0 -1
- package/.mocha-puppeteer/test-page/@feathersjs/client$4.5.0/browser/test.js +0 -1037
- package/.mocha-puppeteer/test-page/@feathersjs/client$4.5.0/dist/feathers.js +0 -78377
- package/.mocha-puppeteer/test-page/@feathersjs/client$4.5.1/browser/test-run.js +0 -1
- package/.mocha-puppeteer/test-page/@feathersjs/client$4.5.1/browser/test.js +0 -102
- package/.mocha-puppeteer/test-page/@feathersjs/client$4.5.1/dist/feathers.js +0 -5231
- package/.mocha-puppeteer/test-page/@feathersjs/commons$4.5.0/lib/hooks.js +0 -2626
- package/.mocha-puppeteer/test-page/@feathersjs/commons$4.5.0/lib/index.js +0 -540
- package/.mocha-puppeteer/test-page/@feathersjs/commons$4.5.0/lib/utils.js +0 -1991
- package/.mocha-puppeteer/test-page/@feathersjs/commons$4.5.1/lib/hooks.js +0 -170
- package/.mocha-puppeteer/test-page/@feathersjs/commons$4.5.1/lib/index.js +0 -17
- package/.mocha-puppeteer/test-page/@feathersjs/commons$4.5.1/lib/utils.js +0 -102
- package/.mocha-puppeteer/test-page/@feathersjs/errors$4.5.0/lib/index.js +0 -2262
- package/.mocha-puppeteer/test-page/@feathersjs/errors$4.5.1/lib/index.js +0 -251
- package/.mocha-puppeteer/test-page/@feathersjs/tests$4.5.0/lib/client.js +0 -1506
- package/.mocha-puppeteer/test-page/@feathersjs/tests$4.5.1/lib/client.js +0 -83
- package/.mocha-puppeteer/test-page/assert$1.5.0/assert.js +0 -508
- package/.mocha-puppeteer/test-page/debug$4.1.1/src/browser.js +0 -266
- package/.mocha-puppeteer/test-page/debug$4.1.1/src/common.js +0 -268
- package/.mocha-puppeteer/test-page/feathers-memory$4.1.0/lib/index.js +0 -143
- package/.mocha-puppeteer/test-page/inherits$2.0.1/inherits_browser.js +0 -25
- package/.mocha-puppeteer/test-page/lasso-modules-client$2.0.5/src/index.js +0 -592
- package/.mocha-puppeteer/test-page/lasso-modules-meta.js +0 -28
- package/.mocha-puppeteer/test-page/marko$4.18.35/src/runtime/components/boot-run.js +0 -1
- package/.mocha-puppeteer/test-page/marko$4.18.35/src/runtime/components/boot.js +0 -95
- package/.mocha-puppeteer/test-page/marko$4.18.42/src/runtime/components/boot-run.js +0 -1
- package/.mocha-puppeteer/test-page/marko$4.18.42/src/runtime/components/boot.js +0 -95
- package/.mocha-puppeteer/test-page/marko$4.19.0/src/runtime/components/boot-run.js +0 -1
- package/.mocha-puppeteer/test-page/marko$4.19.0/src/runtime/components/boot.js +0 -3
- package/.mocha-puppeteer/test-page/mocha$3.5.3/mocha.css +0 -326
- package/.mocha-puppeteer/test-page/mocha$3.5.3/mocha.js +0 -16590
- package/.mocha-puppeteer/test-page/mocha-puppeteer$0.14.0/lib/pages/test-page/run-tests-run.js +0 -1
- package/.mocha-puppeteer/test-page/mocha-puppeteer$0.14.0/lib/pages/test-page/run-tests.js +0 -53
- package/.mocha-puppeteer/test-page/mocha-puppeteer$0.14.0/lib/pages/test-page/setup-run.js +0 -1
- package/.mocha-puppeteer/test-page/mocha-puppeteer$0.14.0/lib/pages/test-page/setup.js +0 -10
- package/.mocha-puppeteer/test-page/ms$2.1.2/index.js +0 -164
- package/.mocha-puppeteer/test-page/object-assign$4.1.1/index.js +0 -92
- package/.mocha-puppeteer/test-page/process$0.11.10/browser.js +0 -186
- package/.mocha-puppeteer/test-page/sift$8.5.1/lib/index.js +0 -738
- package/.mocha-puppeteer/test-page/superagent$3.8.3/superagent.js +0 -2035
- package/.mocha-puppeteer/test-page/util$0.10.3/support/isBufferBrowser.js +0 -7
- package/.mocha-puppeteer/test-page/util$0.10.3/util.js +0 -588
- package/.nyc_output/coverage.json +0 -1
- package/authentication.js +0 -1
- package/dist/authentication.js +0 -2242
- package/dist/authentication.js.map +0 -1
- package/dist/authentication.min.js +0 -1
- package/dist/rest.js +0 -3287
- package/dist/rest.js.map +0 -1
- package/dist/rest.min.js +0 -1
- package/dist/socketio.js +0 -2384
- package/dist/socketio.js.map +0 -1
- package/dist/socketio.min.js +0 -1
- package/index.d.ts +0 -23
- package/index.js +0 -1
- package/rest.js +0 -1
- package/socketio.js +0 -1
- package/webpack.config.js +0 -69
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
$_mod.def("/@feathersjs/tests$4.5.1/lib/client", function(require, exports, module, __filename, __dirname) { "use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const assert_1 = __importDefault(require('/assert$1.5.0/assert'/*"assert"*/));
|
|
7
|
-
function setupTests(app, name) {
|
|
8
|
-
const getService = () => (name && typeof app.service === 'function')
|
|
9
|
-
? app.service(name) : app;
|
|
10
|
-
describe('Service base tests', () => {
|
|
11
|
-
it('.find', () => {
|
|
12
|
-
return getService().find().then((todos) => {
|
|
13
|
-
assert_1.default.deepEqual(todos, [{
|
|
14
|
-
text: 'some todo',
|
|
15
|
-
complete: false,
|
|
16
|
-
id: 0
|
|
17
|
-
}]);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
it('.get and params passing', () => {
|
|
21
|
-
const query = {
|
|
22
|
-
some: 'thing',
|
|
23
|
-
other: ['one', 'two'],
|
|
24
|
-
nested: { a: { b: 'object' } }
|
|
25
|
-
};
|
|
26
|
-
return getService().get(0, { query })
|
|
27
|
-
.then((todo) => assert_1.default.deepEqual(todo, {
|
|
28
|
-
id: 0,
|
|
29
|
-
text: 'some todo',
|
|
30
|
-
complete: false,
|
|
31
|
-
query
|
|
32
|
-
}));
|
|
33
|
-
});
|
|
34
|
-
it('.create and created event', done => {
|
|
35
|
-
getService().once('created', (data) => {
|
|
36
|
-
assert_1.default.strictEqual(data.text, 'created todo');
|
|
37
|
-
assert_1.default.ok(data.complete);
|
|
38
|
-
done();
|
|
39
|
-
});
|
|
40
|
-
getService().create({ text: 'created todo', complete: true });
|
|
41
|
-
});
|
|
42
|
-
it('.update and updated event', done => {
|
|
43
|
-
getService().once('updated', (data) => {
|
|
44
|
-
assert_1.default.strictEqual(data.text, 'updated todo');
|
|
45
|
-
assert_1.default.ok(data.complete);
|
|
46
|
-
done();
|
|
47
|
-
});
|
|
48
|
-
getService().create({ text: 'todo to update', complete: false })
|
|
49
|
-
.then((todo) => getService().update(todo.id, {
|
|
50
|
-
text: 'updated todo',
|
|
51
|
-
complete: true
|
|
52
|
-
}));
|
|
53
|
-
});
|
|
54
|
-
it('.patch and patched event', done => {
|
|
55
|
-
getService().once('patched', (data) => {
|
|
56
|
-
assert_1.default.strictEqual(data.text, 'todo to patch');
|
|
57
|
-
assert_1.default.ok(data.complete);
|
|
58
|
-
done();
|
|
59
|
-
});
|
|
60
|
-
getService().create({ text: 'todo to patch', complete: false })
|
|
61
|
-
.then((todo) => getService().patch(todo.id, { complete: true }));
|
|
62
|
-
});
|
|
63
|
-
it('.remove and removed event', done => {
|
|
64
|
-
getService().once('removed', (data) => {
|
|
65
|
-
assert_1.default.strictEqual(data.text, 'todo to remove');
|
|
66
|
-
assert_1.default.strictEqual(data.complete, false);
|
|
67
|
-
done();
|
|
68
|
-
});
|
|
69
|
-
getService().create({ text: 'todo to remove', complete: false })
|
|
70
|
-
.then((todo) => getService().remove(todo.id)).catch(done);
|
|
71
|
-
});
|
|
72
|
-
it('.get with error', () => {
|
|
73
|
-
const query = { error: true };
|
|
74
|
-
return getService().get(0, { query }).catch((error) => assert_1.default.ok(error && error.message));
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
exports.setupTests = setupTests;
|
|
79
|
-
if (typeof module !== 'undefined') {
|
|
80
|
-
module.exports = Object.assign(setupTests, module.exports);
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=client.js.map
|
|
83
|
-
});
|
|
@@ -1,508 +0,0 @@
|
|
|
1
|
-
$_mod.def("/assert$1.5.0/assert", function(require, exports, module, __filename, __dirname) { 'use strict';
|
|
2
|
-
|
|
3
|
-
var objectAssign = require('/object-assign$4.1.1/index'/*'object-assign'*/);
|
|
4
|
-
|
|
5
|
-
// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
|
|
6
|
-
// original notice:
|
|
7
|
-
|
|
8
|
-
/*!
|
|
9
|
-
* The buffer module from node.js, for the browser.
|
|
10
|
-
*
|
|
11
|
-
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
12
|
-
* @license MIT
|
|
13
|
-
*/
|
|
14
|
-
function compare(a, b) {
|
|
15
|
-
if (a === b) {
|
|
16
|
-
return 0;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var x = a.length;
|
|
20
|
-
var y = b.length;
|
|
21
|
-
|
|
22
|
-
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
23
|
-
if (a[i] !== b[i]) {
|
|
24
|
-
x = a[i];
|
|
25
|
-
y = b[i];
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (x < y) {
|
|
31
|
-
return -1;
|
|
32
|
-
}
|
|
33
|
-
if (y < x) {
|
|
34
|
-
return 1;
|
|
35
|
-
}
|
|
36
|
-
return 0;
|
|
37
|
-
}
|
|
38
|
-
function isBuffer(b) {
|
|
39
|
-
if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
|
|
40
|
-
return global.Buffer.isBuffer(b);
|
|
41
|
-
}
|
|
42
|
-
return !!(b != null && b._isBuffer);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// based on node assert, original notice:
|
|
46
|
-
// NB: The URL to the CommonJS spec is kept just for tradition.
|
|
47
|
-
// node-assert has evolved a lot since then, both in API and behavior.
|
|
48
|
-
|
|
49
|
-
// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
|
|
50
|
-
//
|
|
51
|
-
// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
|
|
52
|
-
//
|
|
53
|
-
// Originally from narwhal.js (http://narwhaljs.org)
|
|
54
|
-
// Copyright (c) 2009 Thomas Robinson <280north.com>
|
|
55
|
-
//
|
|
56
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
57
|
-
// of this software and associated documentation files (the 'Software'), to
|
|
58
|
-
// deal in the Software without restriction, including without limitation the
|
|
59
|
-
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
60
|
-
// sell copies of the Software, and to permit persons to whom the Software is
|
|
61
|
-
// furnished to do so, subject to the following conditions:
|
|
62
|
-
//
|
|
63
|
-
// The above copyright notice and this permission notice shall be included in
|
|
64
|
-
// all copies or substantial portions of the Software.
|
|
65
|
-
//
|
|
66
|
-
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
67
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
68
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
69
|
-
// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
70
|
-
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
71
|
-
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
72
|
-
|
|
73
|
-
var util = require('/util$0.10.3/util'/*'util/'*/);
|
|
74
|
-
var hasOwn = Object.prototype.hasOwnProperty;
|
|
75
|
-
var pSlice = Array.prototype.slice;
|
|
76
|
-
var functionsHaveNames = (function () {
|
|
77
|
-
return function foo() {}.name === 'foo';
|
|
78
|
-
}());
|
|
79
|
-
function pToString (obj) {
|
|
80
|
-
return Object.prototype.toString.call(obj);
|
|
81
|
-
}
|
|
82
|
-
function isView(arrbuf) {
|
|
83
|
-
if (isBuffer(arrbuf)) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
if (typeof global.ArrayBuffer !== 'function') {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
if (typeof ArrayBuffer.isView === 'function') {
|
|
90
|
-
return ArrayBuffer.isView(arrbuf);
|
|
91
|
-
}
|
|
92
|
-
if (!arrbuf) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
if (arrbuf instanceof DataView) {
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
// 1. The assert module provides functions that throw
|
|
104
|
-
// AssertionError's when particular conditions are not met. The
|
|
105
|
-
// assert module must conform to the following interface.
|
|
106
|
-
|
|
107
|
-
var assert = module.exports = ok;
|
|
108
|
-
|
|
109
|
-
// 2. The AssertionError is defined in assert.
|
|
110
|
-
// new assert.AssertionError({ message: message,
|
|
111
|
-
// actual: actual,
|
|
112
|
-
// expected: expected })
|
|
113
|
-
|
|
114
|
-
var regex = /\s*function\s+([^\(\s]*)\s*/;
|
|
115
|
-
// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
|
|
116
|
-
function getName(func) {
|
|
117
|
-
if (!util.isFunction(func)) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (functionsHaveNames) {
|
|
121
|
-
return func.name;
|
|
122
|
-
}
|
|
123
|
-
var str = func.toString();
|
|
124
|
-
var match = str.match(regex);
|
|
125
|
-
return match && match[1];
|
|
126
|
-
}
|
|
127
|
-
assert.AssertionError = function AssertionError(options) {
|
|
128
|
-
this.name = 'AssertionError';
|
|
129
|
-
this.actual = options.actual;
|
|
130
|
-
this.expected = options.expected;
|
|
131
|
-
this.operator = options.operator;
|
|
132
|
-
if (options.message) {
|
|
133
|
-
this.message = options.message;
|
|
134
|
-
this.generatedMessage = false;
|
|
135
|
-
} else {
|
|
136
|
-
this.message = getMessage(this);
|
|
137
|
-
this.generatedMessage = true;
|
|
138
|
-
}
|
|
139
|
-
var stackStartFunction = options.stackStartFunction || fail;
|
|
140
|
-
if (Error.captureStackTrace) {
|
|
141
|
-
Error.captureStackTrace(this, stackStartFunction);
|
|
142
|
-
} else {
|
|
143
|
-
// non v8 browsers so we can have a stacktrace
|
|
144
|
-
var err = new Error();
|
|
145
|
-
if (err.stack) {
|
|
146
|
-
var out = err.stack;
|
|
147
|
-
|
|
148
|
-
// try to strip useless frames
|
|
149
|
-
var fn_name = getName(stackStartFunction);
|
|
150
|
-
var idx = out.indexOf('\n' + fn_name);
|
|
151
|
-
if (idx >= 0) {
|
|
152
|
-
// once we have located the function frame
|
|
153
|
-
// we need to strip out everything before it (and its line)
|
|
154
|
-
var next_line = out.indexOf('\n', idx + 1);
|
|
155
|
-
out = out.substring(next_line + 1);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
this.stack = out;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
// assert.AssertionError instanceof Error
|
|
164
|
-
util.inherits(assert.AssertionError, Error);
|
|
165
|
-
|
|
166
|
-
function truncate(s, n) {
|
|
167
|
-
if (typeof s === 'string') {
|
|
168
|
-
return s.length < n ? s : s.slice(0, n);
|
|
169
|
-
} else {
|
|
170
|
-
return s;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
function inspect(something) {
|
|
174
|
-
if (functionsHaveNames || !util.isFunction(something)) {
|
|
175
|
-
return util.inspect(something);
|
|
176
|
-
}
|
|
177
|
-
var rawname = getName(something);
|
|
178
|
-
var name = rawname ? ': ' + rawname : '';
|
|
179
|
-
return '[Function' + name + ']';
|
|
180
|
-
}
|
|
181
|
-
function getMessage(self) {
|
|
182
|
-
return truncate(inspect(self.actual), 128) + ' ' +
|
|
183
|
-
self.operator + ' ' +
|
|
184
|
-
truncate(inspect(self.expected), 128);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// At present only the three keys mentioned above are used and
|
|
188
|
-
// understood by the spec. Implementations or sub modules can pass
|
|
189
|
-
// other keys to the AssertionError's constructor - they will be
|
|
190
|
-
// ignored.
|
|
191
|
-
|
|
192
|
-
// 3. All of the following functions must throw an AssertionError
|
|
193
|
-
// when a corresponding condition is not met, with a message that
|
|
194
|
-
// may be undefined if not provided. All assertion methods provide
|
|
195
|
-
// both the actual and expected values to the assertion error for
|
|
196
|
-
// display purposes.
|
|
197
|
-
|
|
198
|
-
function fail(actual, expected, message, operator, stackStartFunction) {
|
|
199
|
-
throw new assert.AssertionError({
|
|
200
|
-
message: message,
|
|
201
|
-
actual: actual,
|
|
202
|
-
expected: expected,
|
|
203
|
-
operator: operator,
|
|
204
|
-
stackStartFunction: stackStartFunction
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// EXTENSION! allows for well behaved errors defined elsewhere.
|
|
209
|
-
assert.fail = fail;
|
|
210
|
-
|
|
211
|
-
// 4. Pure assertion tests whether a value is truthy, as determined
|
|
212
|
-
// by !!guard.
|
|
213
|
-
// assert.ok(guard, message_opt);
|
|
214
|
-
// This statement is equivalent to assert.equal(true, !!guard,
|
|
215
|
-
// message_opt);. To test strictly for the value true, use
|
|
216
|
-
// assert.strictEqual(true, guard, message_opt);.
|
|
217
|
-
|
|
218
|
-
function ok(value, message) {
|
|
219
|
-
if (!value) fail(value, true, message, '==', assert.ok);
|
|
220
|
-
}
|
|
221
|
-
assert.ok = ok;
|
|
222
|
-
|
|
223
|
-
// 5. The equality assertion tests shallow, coercive equality with
|
|
224
|
-
// ==.
|
|
225
|
-
// assert.equal(actual, expected, message_opt);
|
|
226
|
-
|
|
227
|
-
assert.equal = function equal(actual, expected, message) {
|
|
228
|
-
if (actual != expected) fail(actual, expected, message, '==', assert.equal);
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
// 6. The non-equality assertion tests for whether two objects are not equal
|
|
232
|
-
// with != assert.notEqual(actual, expected, message_opt);
|
|
233
|
-
|
|
234
|
-
assert.notEqual = function notEqual(actual, expected, message) {
|
|
235
|
-
if (actual == expected) {
|
|
236
|
-
fail(actual, expected, message, '!=', assert.notEqual);
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
// 7. The equivalence assertion tests a deep equality relation.
|
|
241
|
-
// assert.deepEqual(actual, expected, message_opt);
|
|
242
|
-
|
|
243
|
-
assert.deepEqual = function deepEqual(actual, expected, message) {
|
|
244
|
-
if (!_deepEqual(actual, expected, false)) {
|
|
245
|
-
fail(actual, expected, message, 'deepEqual', assert.deepEqual);
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
|
|
250
|
-
if (!_deepEqual(actual, expected, true)) {
|
|
251
|
-
fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
function _deepEqual(actual, expected, strict, memos) {
|
|
256
|
-
// 7.1. All identical values are equivalent, as determined by ===.
|
|
257
|
-
if (actual === expected) {
|
|
258
|
-
return true;
|
|
259
|
-
} else if (isBuffer(actual) && isBuffer(expected)) {
|
|
260
|
-
return compare(actual, expected) === 0;
|
|
261
|
-
|
|
262
|
-
// 7.2. If the expected value is a Date object, the actual value is
|
|
263
|
-
// equivalent if it is also a Date object that refers to the same time.
|
|
264
|
-
} else if (util.isDate(actual) && util.isDate(expected)) {
|
|
265
|
-
return actual.getTime() === expected.getTime();
|
|
266
|
-
|
|
267
|
-
// 7.3 If the expected value is a RegExp object, the actual value is
|
|
268
|
-
// equivalent if it is also a RegExp object with the same source and
|
|
269
|
-
// properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
|
|
270
|
-
} else if (util.isRegExp(actual) && util.isRegExp(expected)) {
|
|
271
|
-
return actual.source === expected.source &&
|
|
272
|
-
actual.global === expected.global &&
|
|
273
|
-
actual.multiline === expected.multiline &&
|
|
274
|
-
actual.lastIndex === expected.lastIndex &&
|
|
275
|
-
actual.ignoreCase === expected.ignoreCase;
|
|
276
|
-
|
|
277
|
-
// 7.4. Other pairs that do not both pass typeof value == 'object',
|
|
278
|
-
// equivalence is determined by ==.
|
|
279
|
-
} else if ((actual === null || typeof actual !== 'object') &&
|
|
280
|
-
(expected === null || typeof expected !== 'object')) {
|
|
281
|
-
return strict ? actual === expected : actual == expected;
|
|
282
|
-
|
|
283
|
-
// If both values are instances of typed arrays, wrap their underlying
|
|
284
|
-
// ArrayBuffers in a Buffer each to increase performance
|
|
285
|
-
// This optimization requires the arrays to have the same type as checked by
|
|
286
|
-
// Object.prototype.toString (aka pToString). Never perform binary
|
|
287
|
-
// comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
|
|
288
|
-
// bit patterns are not identical.
|
|
289
|
-
} else if (isView(actual) && isView(expected) &&
|
|
290
|
-
pToString(actual) === pToString(expected) &&
|
|
291
|
-
!(actual instanceof Float32Array ||
|
|
292
|
-
actual instanceof Float64Array)) {
|
|
293
|
-
return compare(new Uint8Array(actual.buffer),
|
|
294
|
-
new Uint8Array(expected.buffer)) === 0;
|
|
295
|
-
|
|
296
|
-
// 7.5 For all other Object pairs, including Array objects, equivalence is
|
|
297
|
-
// determined by having the same number of owned properties (as verified
|
|
298
|
-
// with Object.prototype.hasOwnProperty.call), the same set of keys
|
|
299
|
-
// (although not necessarily the same order), equivalent values for every
|
|
300
|
-
// corresponding key, and an identical 'prototype' property. Note: this
|
|
301
|
-
// accounts for both named and indexed properties on Arrays.
|
|
302
|
-
} else if (isBuffer(actual) !== isBuffer(expected)) {
|
|
303
|
-
return false;
|
|
304
|
-
} else {
|
|
305
|
-
memos = memos || {actual: [], expected: []};
|
|
306
|
-
|
|
307
|
-
var actualIndex = memos.actual.indexOf(actual);
|
|
308
|
-
if (actualIndex !== -1) {
|
|
309
|
-
if (actualIndex === memos.expected.indexOf(expected)) {
|
|
310
|
-
return true;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
memos.actual.push(actual);
|
|
315
|
-
memos.expected.push(expected);
|
|
316
|
-
|
|
317
|
-
return objEquiv(actual, expected, strict, memos);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
function isArguments(object) {
|
|
322
|
-
return Object.prototype.toString.call(object) == '[object Arguments]';
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
function objEquiv(a, b, strict, actualVisitedObjects) {
|
|
326
|
-
if (a === null || a === undefined || b === null || b === undefined)
|
|
327
|
-
return false;
|
|
328
|
-
// if one is a primitive, the other must be same
|
|
329
|
-
if (util.isPrimitive(a) || util.isPrimitive(b))
|
|
330
|
-
return a === b;
|
|
331
|
-
if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
|
|
332
|
-
return false;
|
|
333
|
-
var aIsArgs = isArguments(a);
|
|
334
|
-
var bIsArgs = isArguments(b);
|
|
335
|
-
if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
|
|
336
|
-
return false;
|
|
337
|
-
if (aIsArgs) {
|
|
338
|
-
a = pSlice.call(a);
|
|
339
|
-
b = pSlice.call(b);
|
|
340
|
-
return _deepEqual(a, b, strict);
|
|
341
|
-
}
|
|
342
|
-
var ka = objectKeys(a);
|
|
343
|
-
var kb = objectKeys(b);
|
|
344
|
-
var key, i;
|
|
345
|
-
// having the same number of owned properties (keys incorporates
|
|
346
|
-
// hasOwnProperty)
|
|
347
|
-
if (ka.length !== kb.length)
|
|
348
|
-
return false;
|
|
349
|
-
//the same set of keys (although not necessarily the same order),
|
|
350
|
-
ka.sort();
|
|
351
|
-
kb.sort();
|
|
352
|
-
//~~~cheap key test
|
|
353
|
-
for (i = ka.length - 1; i >= 0; i--) {
|
|
354
|
-
if (ka[i] !== kb[i])
|
|
355
|
-
return false;
|
|
356
|
-
}
|
|
357
|
-
//equivalent values for every corresponding key, and
|
|
358
|
-
//~~~possibly expensive deep test
|
|
359
|
-
for (i = ka.length - 1; i >= 0; i--) {
|
|
360
|
-
key = ka[i];
|
|
361
|
-
if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
|
|
362
|
-
return false;
|
|
363
|
-
}
|
|
364
|
-
return true;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// 8. The non-equivalence assertion tests for any deep inequality.
|
|
368
|
-
// assert.notDeepEqual(actual, expected, message_opt);
|
|
369
|
-
|
|
370
|
-
assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
|
|
371
|
-
if (_deepEqual(actual, expected, false)) {
|
|
372
|
-
fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
assert.notDeepStrictEqual = notDeepStrictEqual;
|
|
377
|
-
function notDeepStrictEqual(actual, expected, message) {
|
|
378
|
-
if (_deepEqual(actual, expected, true)) {
|
|
379
|
-
fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
// 9. The strict equality assertion tests strict equality, as determined by ===.
|
|
385
|
-
// assert.strictEqual(actual, expected, message_opt);
|
|
386
|
-
|
|
387
|
-
assert.strictEqual = function strictEqual(actual, expected, message) {
|
|
388
|
-
if (actual !== expected) {
|
|
389
|
-
fail(actual, expected, message, '===', assert.strictEqual);
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
// 10. The strict non-equality assertion tests for strict inequality, as
|
|
394
|
-
// determined by !==. assert.notStrictEqual(actual, expected, message_opt);
|
|
395
|
-
|
|
396
|
-
assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
|
|
397
|
-
if (actual === expected) {
|
|
398
|
-
fail(actual, expected, message, '!==', assert.notStrictEqual);
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
function expectedException(actual, expected) {
|
|
403
|
-
if (!actual || !expected) {
|
|
404
|
-
return false;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
if (Object.prototype.toString.call(expected) == '[object RegExp]') {
|
|
408
|
-
return expected.test(actual);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
try {
|
|
412
|
-
if (actual instanceof expected) {
|
|
413
|
-
return true;
|
|
414
|
-
}
|
|
415
|
-
} catch (e) {
|
|
416
|
-
// Ignore. The instanceof check doesn't work for arrow functions.
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
if (Error.isPrototypeOf(expected)) {
|
|
420
|
-
return false;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
return expected.call({}, actual) === true;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
function _tryBlock(block) {
|
|
427
|
-
var error;
|
|
428
|
-
try {
|
|
429
|
-
block();
|
|
430
|
-
} catch (e) {
|
|
431
|
-
error = e;
|
|
432
|
-
}
|
|
433
|
-
return error;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
function _throws(shouldThrow, block, expected, message) {
|
|
437
|
-
var actual;
|
|
438
|
-
|
|
439
|
-
if (typeof block !== 'function') {
|
|
440
|
-
throw new TypeError('"block" argument must be a function');
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
if (typeof expected === 'string') {
|
|
444
|
-
message = expected;
|
|
445
|
-
expected = null;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
actual = _tryBlock(block);
|
|
449
|
-
|
|
450
|
-
message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
|
|
451
|
-
(message ? ' ' + message : '.');
|
|
452
|
-
|
|
453
|
-
if (shouldThrow && !actual) {
|
|
454
|
-
fail(actual, expected, 'Missing expected exception' + message);
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
var userProvidedMessage = typeof message === 'string';
|
|
458
|
-
var isUnwantedException = !shouldThrow && util.isError(actual);
|
|
459
|
-
var isUnexpectedException = !shouldThrow && actual && !expected;
|
|
460
|
-
|
|
461
|
-
if ((isUnwantedException &&
|
|
462
|
-
userProvidedMessage &&
|
|
463
|
-
expectedException(actual, expected)) ||
|
|
464
|
-
isUnexpectedException) {
|
|
465
|
-
fail(actual, expected, 'Got unwanted exception' + message);
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
if ((shouldThrow && actual && expected &&
|
|
469
|
-
!expectedException(actual, expected)) || (!shouldThrow && actual)) {
|
|
470
|
-
throw actual;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
// 11. Expected to throw an error:
|
|
475
|
-
// assert.throws(block, Error_opt, message_opt);
|
|
476
|
-
|
|
477
|
-
assert.throws = function(block, /*optional*/error, /*optional*/message) {
|
|
478
|
-
_throws(true, block, error, message);
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
// EXTENSION! This is annoying to write outside this module.
|
|
482
|
-
assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
|
|
483
|
-
_throws(false, block, error, message);
|
|
484
|
-
};
|
|
485
|
-
|
|
486
|
-
assert.ifError = function(err) { if (err) throw err; };
|
|
487
|
-
|
|
488
|
-
// Expose a strict only variant of assert
|
|
489
|
-
function strict(value, message) {
|
|
490
|
-
if (!value) fail(value, true, message, '==', strict);
|
|
491
|
-
}
|
|
492
|
-
assert.strict = objectAssign(strict, assert, {
|
|
493
|
-
equal: assert.strictEqual,
|
|
494
|
-
deepEqual: assert.deepStrictEqual,
|
|
495
|
-
notEqual: assert.notStrictEqual,
|
|
496
|
-
notDeepEqual: assert.notDeepStrictEqual
|
|
497
|
-
});
|
|
498
|
-
assert.strict.strict = assert.strict;
|
|
499
|
-
|
|
500
|
-
var objectKeys = Object.keys || function (obj) {
|
|
501
|
-
var keys = [];
|
|
502
|
-
for (var key in obj) {
|
|
503
|
-
if (hasOwn.call(obj, key)) keys.push(key);
|
|
504
|
-
}
|
|
505
|
-
return keys;
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
});
|