@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,98 +0,0 @@
|
|
|
1
|
-
$_mod.def("/@feathersjs/adapter-commons$4.5.1/lib/filter-query", function(require, exports, module, __filename, __dirname) { "use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const commons_1 = require('/@feathersjs/commons$4.5.1/lib/index'/*"@feathersjs/commons"*/);
|
|
4
|
-
const errors_1 = require('/@feathersjs/errors$4.5.1/lib/index'/*"@feathersjs/errors"*/);
|
|
5
|
-
function parse(number) {
|
|
6
|
-
if (typeof number !== 'undefined') {
|
|
7
|
-
return Math.abs(parseInt(number, 10));
|
|
8
|
-
}
|
|
9
|
-
return undefined;
|
|
10
|
-
}
|
|
11
|
-
// Returns the pagination limit and will take into account the
|
|
12
|
-
// default and max pagination settings
|
|
13
|
-
function getLimit(limit, paginate) {
|
|
14
|
-
if (paginate && paginate.default) {
|
|
15
|
-
const lower = typeof limit === 'number' && !isNaN(limit) ? limit : paginate.default;
|
|
16
|
-
const upper = typeof paginate.max === 'number' ? paginate.max : Number.MAX_VALUE;
|
|
17
|
-
return Math.min(lower, upper);
|
|
18
|
-
}
|
|
19
|
-
return limit;
|
|
20
|
-
}
|
|
21
|
-
// Makes sure that $sort order is always converted to an actual number
|
|
22
|
-
function convertSort(sort) {
|
|
23
|
-
if (typeof sort !== 'object' || Array.isArray(sort)) {
|
|
24
|
-
return sort;
|
|
25
|
-
}
|
|
26
|
-
return Object.keys(sort).reduce((result, key) => {
|
|
27
|
-
result[key] = typeof sort[key] === 'object'
|
|
28
|
-
? sort[key] : parseInt(sort[key], 10);
|
|
29
|
-
return result;
|
|
30
|
-
}, {});
|
|
31
|
-
}
|
|
32
|
-
function cleanQuery(query, operators, filters) {
|
|
33
|
-
if (Array.isArray(query)) {
|
|
34
|
-
return query.map(value => cleanQuery(value, operators, filters));
|
|
35
|
-
}
|
|
36
|
-
else if (commons_1._.isObject(query) && query.constructor === {}.constructor) {
|
|
37
|
-
const result = {};
|
|
38
|
-
commons_1._.each(query, (value, key) => {
|
|
39
|
-
if (key[0] === '$') {
|
|
40
|
-
if (filters[key] !== undefined) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (!operators.includes(key)) {
|
|
44
|
-
throw new errors_1.BadRequest(`Invalid query parameter ${key}`, query);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
result[key] = cleanQuery(value, operators, filters);
|
|
48
|
-
});
|
|
49
|
-
Object.getOwnPropertySymbols(query).forEach(symbol => {
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
result[symbol] = query[symbol];
|
|
52
|
-
});
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
return query;
|
|
56
|
-
}
|
|
57
|
-
function assignFilters(object, query, filters, options) {
|
|
58
|
-
if (Array.isArray(filters)) {
|
|
59
|
-
commons_1._.each(filters, (key) => {
|
|
60
|
-
if (query[key] !== undefined) {
|
|
61
|
-
object[key] = query[key];
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
commons_1._.each(filters, (converter, key) => {
|
|
67
|
-
const converted = converter(query[key], options);
|
|
68
|
-
if (converted !== undefined) {
|
|
69
|
-
object[key] = converted;
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
return object;
|
|
74
|
-
}
|
|
75
|
-
exports.FILTERS = {
|
|
76
|
-
$sort: (value) => convertSort(value),
|
|
77
|
-
$limit: (value, options) => getLimit(parse(value), options.paginate),
|
|
78
|
-
$skip: (value) => parse(value),
|
|
79
|
-
$select: (value) => value
|
|
80
|
-
};
|
|
81
|
-
exports.OPERATORS = ['$in', '$nin', '$lt', '$lte', '$gt', '$gte', '$ne', '$or'];
|
|
82
|
-
// Converts Feathers special query parameters and pagination settings
|
|
83
|
-
// and returns them separately a `filters` and the rest of the query
|
|
84
|
-
// as `query`
|
|
85
|
-
function filterQuery(query, options = {}) {
|
|
86
|
-
const { filters: additionalFilters = {}, operators: additionalOperators = [] } = options;
|
|
87
|
-
const result = {};
|
|
88
|
-
result.filters = assignFilters({}, query, exports.FILTERS, options);
|
|
89
|
-
result.filters = assignFilters(result.filters, query, additionalFilters, options);
|
|
90
|
-
result.query = cleanQuery(query, exports.OPERATORS.concat(additionalOperators), result.filters);
|
|
91
|
-
return result;
|
|
92
|
-
}
|
|
93
|
-
exports.default = filterQuery;
|
|
94
|
-
if (typeof module !== 'undefined') {
|
|
95
|
-
module.exports = Object.assign(filterQuery, module.exports);
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=filter-query.js.map
|
|
98
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
$_mod.def("/@feathersjs/adapter-commons$4.5.1/lib/index", function(require, exports, module, __filename, __dirname) { "use strict";
|
|
2
|
-
function __export(m) {
|
|
3
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
-
}
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const commons_1 = require('/@feathersjs/commons$4.5.1/lib/index'/*"@feathersjs/commons"*/);
|
|
7
|
-
var service_1 = require('/@feathersjs/adapter-commons$4.5.1/lib/service'/*"./service"*/);
|
|
8
|
-
exports.AdapterService = service_1.AdapterService;
|
|
9
|
-
var filter_query_1 = require('/@feathersjs/adapter-commons$4.5.1/lib/filter-query'/*"./filter-query"*/);
|
|
10
|
-
exports.filterQuery = filter_query_1.default;
|
|
11
|
-
exports.FILTERS = filter_query_1.FILTERS;
|
|
12
|
-
exports.OPERATORS = filter_query_1.OPERATORS;
|
|
13
|
-
__export(require('/@feathersjs/adapter-commons$4.5.1/lib/sort'/*"./sort"*/));
|
|
14
|
-
// Return a function that filters a result object or array
|
|
15
|
-
// and picks only the fields passed as `params.query.$select`
|
|
16
|
-
// and additional `otherFields`
|
|
17
|
-
function select(params, ...otherFields) {
|
|
18
|
-
const fields = params && params.query && params.query.$select;
|
|
19
|
-
if (Array.isArray(fields) && otherFields.length) {
|
|
20
|
-
fields.push(...otherFields);
|
|
21
|
-
}
|
|
22
|
-
const convert = (result) => {
|
|
23
|
-
if (!Array.isArray(fields)) {
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
26
|
-
return commons_1._.pick(result, ...fields);
|
|
27
|
-
};
|
|
28
|
-
return (result) => {
|
|
29
|
-
if (Array.isArray(result)) {
|
|
30
|
-
return result.map(convert);
|
|
31
|
-
}
|
|
32
|
-
return convert(result);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
exports.select = select;
|
|
36
|
-
//# sourceMappingURL=index.js.map
|
|
37
|
-
});
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
$_mod.def("/@feathersjs/adapter-commons$4.5.1/lib/service", 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 errors_1 = require('/@feathersjs/errors$4.5.1/lib/index'/*"@feathersjs/errors"*/);
|
|
7
|
-
const filter_query_1 = __importDefault(require('/@feathersjs/adapter-commons$4.5.1/lib/filter-query'/*"./filter-query"*/));
|
|
8
|
-
const callMethod = (self, name, ...args) => {
|
|
9
|
-
if (typeof self[name] !== 'function') {
|
|
10
|
-
return Promise.reject(new errors_1.NotImplemented(`Method ${name} not available`));
|
|
11
|
-
}
|
|
12
|
-
return self[name](...args);
|
|
13
|
-
};
|
|
14
|
-
const alwaysMulti = {
|
|
15
|
-
find: true,
|
|
16
|
-
get: false,
|
|
17
|
-
update: false
|
|
18
|
-
};
|
|
19
|
-
class AdapterService {
|
|
20
|
-
constructor(options) {
|
|
21
|
-
this.options = Object.assign({
|
|
22
|
-
id: 'id',
|
|
23
|
-
events: [],
|
|
24
|
-
paginate: {},
|
|
25
|
-
multi: false,
|
|
26
|
-
filters: [],
|
|
27
|
-
whitelist: []
|
|
28
|
-
}, options);
|
|
29
|
-
}
|
|
30
|
-
get id() {
|
|
31
|
-
return this.options.id;
|
|
32
|
-
}
|
|
33
|
-
get events() {
|
|
34
|
-
return this.options.events;
|
|
35
|
-
}
|
|
36
|
-
filterQuery(params = {}, opts = {}) {
|
|
37
|
-
const paginate = typeof params.paginate !== 'undefined'
|
|
38
|
-
? params.paginate : this.options.paginate;
|
|
39
|
-
const { query = {} } = params;
|
|
40
|
-
const options = Object.assign({
|
|
41
|
-
operators: this.options.whitelist || [],
|
|
42
|
-
filters: this.options.filters,
|
|
43
|
-
paginate
|
|
44
|
-
}, opts);
|
|
45
|
-
const result = filter_query_1.default(query, options);
|
|
46
|
-
return Object.assign(result, { paginate });
|
|
47
|
-
}
|
|
48
|
-
allowsMulti(method) {
|
|
49
|
-
const always = alwaysMulti[method];
|
|
50
|
-
if (typeof always !== 'undefined') {
|
|
51
|
-
return always;
|
|
52
|
-
}
|
|
53
|
-
const option = this.options.multi;
|
|
54
|
-
if (option === true || option === false) {
|
|
55
|
-
return option;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return option.includes(method);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
find(params) {
|
|
62
|
-
return callMethod(this, '_find', params);
|
|
63
|
-
}
|
|
64
|
-
get(id, params) {
|
|
65
|
-
return callMethod(this, '_get', id, params);
|
|
66
|
-
}
|
|
67
|
-
create(data, params) {
|
|
68
|
-
if (Array.isArray(data) && !this.allowsMulti('create')) {
|
|
69
|
-
return Promise.reject(new errors_1.MethodNotAllowed(`Can not create multiple entries`));
|
|
70
|
-
}
|
|
71
|
-
return callMethod(this, '_create', data, params);
|
|
72
|
-
}
|
|
73
|
-
update(id, data, params) {
|
|
74
|
-
if (id === null || Array.isArray(data)) {
|
|
75
|
-
return Promise.reject(new errors_1.BadRequest(`You can not replace multiple instances. Did you mean 'patch'?`));
|
|
76
|
-
}
|
|
77
|
-
return callMethod(this, '_update', id, data, params);
|
|
78
|
-
}
|
|
79
|
-
patch(id, data, params) {
|
|
80
|
-
if (id === null && !this.allowsMulti('patch')) {
|
|
81
|
-
return Promise.reject(new errors_1.MethodNotAllowed(`Can not patch multiple entries`));
|
|
82
|
-
}
|
|
83
|
-
return callMethod(this, '_patch', id, data, params);
|
|
84
|
-
}
|
|
85
|
-
remove(id, params) {
|
|
86
|
-
if (id === null && !this.allowsMulti('remove')) {
|
|
87
|
-
return Promise.reject(new errors_1.MethodNotAllowed(`Can not remove multiple entries`));
|
|
88
|
-
}
|
|
89
|
-
return callMethod(this, '_remove', id, params);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.AdapterService = AdapterService;
|
|
93
|
-
//# sourceMappingURL=service.js.map
|
|
94
|
-
});
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
$_mod.def("/@feathersjs/adapter-commons$4.5.1/lib/sort", function(require, exports, module, __filename, __dirname) { "use strict";
|
|
2
|
-
// Sorting algorithm taken from NeDB (https://github.com/louischatriot/nedb)
|
|
3
|
-
// See https://github.com/louischatriot/nedb/blob/e3f0078499aa1005a59d0c2372e425ab789145c1/lib/model.js#L189
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
function compareNSB(a, b) {
|
|
6
|
-
if (a < b) {
|
|
7
|
-
return -1;
|
|
8
|
-
}
|
|
9
|
-
if (a > b) {
|
|
10
|
-
return 1;
|
|
11
|
-
}
|
|
12
|
-
return 0;
|
|
13
|
-
}
|
|
14
|
-
exports.compareNSB = compareNSB;
|
|
15
|
-
function compareArrays(a, b) {
|
|
16
|
-
let i;
|
|
17
|
-
let comp;
|
|
18
|
-
for (i = 0; i < Math.min(a.length, b.length); i += 1) {
|
|
19
|
-
comp = exports.compare(a[i], b[i]);
|
|
20
|
-
if (comp !== 0) {
|
|
21
|
-
return comp;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
// Common section was identical, longest one wins
|
|
25
|
-
return exports.compareNSB(a.length, b.length);
|
|
26
|
-
}
|
|
27
|
-
exports.compareArrays = compareArrays;
|
|
28
|
-
function compare(a, b, compareStrings = exports.compareNSB) {
|
|
29
|
-
const { compareNSB, compare, compareArrays } = exports;
|
|
30
|
-
// undefined
|
|
31
|
-
if (a === undefined) {
|
|
32
|
-
return b === undefined ? 0 : -1;
|
|
33
|
-
}
|
|
34
|
-
if (b === undefined) {
|
|
35
|
-
return a === undefined ? 0 : 1;
|
|
36
|
-
}
|
|
37
|
-
// null
|
|
38
|
-
if (a === null) {
|
|
39
|
-
return b === null ? 0 : -1;
|
|
40
|
-
}
|
|
41
|
-
if (b === null) {
|
|
42
|
-
return a === null ? 0 : 1;
|
|
43
|
-
}
|
|
44
|
-
// Numbers
|
|
45
|
-
if (typeof a === 'number') {
|
|
46
|
-
return typeof b === 'number' ? compareNSB(a, b) : -1;
|
|
47
|
-
}
|
|
48
|
-
if (typeof b === 'number') {
|
|
49
|
-
return typeof a === 'number' ? compareNSB(a, b) : 1;
|
|
50
|
-
}
|
|
51
|
-
// Strings
|
|
52
|
-
if (typeof a === 'string') {
|
|
53
|
-
return typeof b === 'string' ? compareStrings(a, b) : -1;
|
|
54
|
-
}
|
|
55
|
-
if (typeof b === 'string') {
|
|
56
|
-
return typeof a === 'string' ? compareStrings(a, b) : 1;
|
|
57
|
-
}
|
|
58
|
-
// Booleans
|
|
59
|
-
if (typeof a === 'boolean') {
|
|
60
|
-
return typeof b === 'boolean' ? compareNSB(a, b) : -1;
|
|
61
|
-
}
|
|
62
|
-
if (typeof b === 'boolean') {
|
|
63
|
-
return typeof a === 'boolean' ? compareNSB(a, b) : 1;
|
|
64
|
-
}
|
|
65
|
-
// Dates
|
|
66
|
-
if (a instanceof Date) {
|
|
67
|
-
return b instanceof Date ? compareNSB(a.getTime(), b.getTime()) : -1;
|
|
68
|
-
}
|
|
69
|
-
if (b instanceof Date) {
|
|
70
|
-
return a instanceof Date ? compareNSB(a.getTime(), b.getTime()) : 1;
|
|
71
|
-
}
|
|
72
|
-
// Arrays (first element is most significant and so on)
|
|
73
|
-
if (Array.isArray(a)) {
|
|
74
|
-
return Array.isArray(b) ? compareArrays(a, b) : -1;
|
|
75
|
-
}
|
|
76
|
-
if (Array.isArray(b)) {
|
|
77
|
-
return Array.isArray(a) ? compareArrays(a, b) : 1;
|
|
78
|
-
}
|
|
79
|
-
// Objects
|
|
80
|
-
const aKeys = Object.keys(a).sort();
|
|
81
|
-
const bKeys = Object.keys(b).sort();
|
|
82
|
-
let comp = 0;
|
|
83
|
-
for (let i = 0; i < Math.min(aKeys.length, bKeys.length); i += 1) {
|
|
84
|
-
comp = compare(a[aKeys[i]], b[bKeys[i]]);
|
|
85
|
-
if (comp !== 0) {
|
|
86
|
-
return comp;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return compareNSB(aKeys.length, bKeys.length);
|
|
90
|
-
}
|
|
91
|
-
exports.compare = compare;
|
|
92
|
-
// An in-memory sorting function according to the
|
|
93
|
-
// $sort special query parameter
|
|
94
|
-
function sorter($sort) {
|
|
95
|
-
const criteria = Object.keys($sort).map(key => {
|
|
96
|
-
const direction = $sort[key];
|
|
97
|
-
return { key, direction };
|
|
98
|
-
});
|
|
99
|
-
return function (a, b) {
|
|
100
|
-
let compare;
|
|
101
|
-
for (const criterion of criteria) {
|
|
102
|
-
compare = criterion.direction * exports.compare(a[criterion.key], b[criterion.key]);
|
|
103
|
-
if (compare !== 0) {
|
|
104
|
-
return compare;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return 0;
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
exports.sorter = sorter;
|
|
111
|
-
//# sourceMappingURL=sort.js.map
|
|
112
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
$_mod.run("/@feathersjs/client$4.5.0/browser/test");
|