@theledger/couchdb-query-engine
Advanced tools
Comparing version 2.3.2 to 2.4.0
@@ -1,248 +0,262 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _getIterator2 = _interopRequireDefault(require("@babel/runtime/core-js/get-iterator")); | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { 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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); | ||
var _is = require('./is'); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); | ||
var is = _interopRequireWildcard(_is); | ||
var is = _interopRequireWildcard(require("./is")); | ||
var _same = require('./same'); | ||
var _same = _interopRequireDefault(require("./same")); | ||
var _same2 = _interopRequireDefault(_same); | ||
var _utils = require("./utils"); | ||
var _utils = require('./utils'); | ||
var Engine = | ||
/*#__PURE__*/ | ||
function () { | ||
function Engine() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
_ref$virtuals = _ref.virtuals, | ||
virtuals = _ref$virtuals === void 0 ? [] : _ref$virtuals, | ||
_ref$conditions = _ref.conditions, | ||
conditions = _ref$conditions === void 0 ? [] : _ref$conditions, | ||
_ref$expansions = _ref.expansions, | ||
expansions = _ref$expansions === void 0 ? [] : _ref$expansions; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
(0, _classCallCheck2.default)(this, Engine); | ||
this.registry = { | ||
virtuals: virtuals, | ||
conditions: conditions, | ||
expansions: expansions | ||
}; | ||
} | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
(0, _createClass2.default)(Engine, [{ | ||
key: "clone", | ||
value: function clone() { | ||
return new Engine({ | ||
virtuals: this.registry.virtuals.slice(), | ||
conditions: this.registry.conditions.slice(), | ||
expansions: this.registry.expansions.slice() | ||
}); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var Engine = function () { | ||
function Engine() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
_ref$virtuals = _ref.virtuals, | ||
virtuals = _ref$virtuals === undefined ? [] : _ref$virtuals, | ||
_ref$conditions = _ref.conditions, | ||
conditions = _ref$conditions === undefined ? [] : _ref$conditions, | ||
_ref$expansions = _ref.expansions, | ||
expansions = _ref$expansions === undefined ? [] : _ref$expansions; | ||
_classCallCheck(this, Engine); | ||
this.registry = { virtuals: virtuals, conditions: conditions, expansions: expansions }; | ||
} | ||
}, { | ||
key: "append2", | ||
value: function append2(d) { | ||
for (var t in d) { | ||
if (t === 'expansions' || t === 'virtuals' || t === 'conditions') { | ||
for (var k in d[t]) { | ||
var f = d[t][k]; | ||
this.append(t, k, f); | ||
} | ||
_createClass(Engine, [{ | ||
key: 'clone', | ||
value: function clone() { | ||
return new Engine({ | ||
virtuals: this.registry.virtuals.slice(), | ||
conditions: this.registry.conditions.slice(), | ||
expansions: this.registry.expansions.slice() | ||
}); | ||
} | ||
} | ||
} | ||
}, { | ||
key: "append", | ||
value: function append(t, k, f) { | ||
this.registry[t].push([k, f]); | ||
} | ||
}, { | ||
key: "prepend", | ||
value: function prepend(t, k, f) { | ||
this.registry[t].shift([k, f]); | ||
} | ||
}, { | ||
key: "replace", | ||
value: function replace(t, k, f) { | ||
var _rule = this.rule(k), | ||
_rule2 = (0, _slicedToArray2.default)(_rule, 1), | ||
tk = _rule2[0]; | ||
}, { | ||
key: 'append2', | ||
value: function append2(d) { | ||
for (var t in d) { | ||
if (t === 'expansions' || t === 'virtuals' || t === 'conditions') { | ||
for (var k in d[t]) { | ||
var f = d[t][k]; | ||
this.append(t, k, f); | ||
} | ||
} | ||
} | ||
} | ||
}, { | ||
key: 'append', | ||
value: function append(t, k, f) { | ||
if (tk) { | ||
this.registry[tk][k] = f; | ||
} else { | ||
this.append(t, k, f); | ||
} | ||
} // Find rule with k name. | ||
this.registry[t].push([k, f]); | ||
} | ||
}, { | ||
key: 'prepend', | ||
value: function prepend(t, k, f) { | ||
}, { | ||
key: "rule", | ||
value: function rule(k) { | ||
var r = [undefined, undefined]; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
this.registry[t].shift([k, f]); | ||
} | ||
}, { | ||
key: 'replace', | ||
value: function replace(t, k, f) { | ||
var _rule = this.rule(k), | ||
_rule2 = _slicedToArray(_rule, 1), | ||
tk = _rule2[0]; | ||
try { | ||
for (var _iterator = (0, _getIterator2.default)((0, _utils.kvs)(this.registry)), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var _ref4 = _step.value; | ||
if (tk) { | ||
var _ref3 = (0, _slicedToArray2.default)(_ref4, 2); | ||
this.registry[tk][k] = f; | ||
} else { | ||
var _tk = _ref3[0]; | ||
var _tv = _ref3[1]; | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
this.append(t, k, f); | ||
} | ||
} | ||
try { | ||
for (var _iterator2 = (0, _getIterator2.default)(_tv), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var _ref7 = _step2.value; | ||
// Find rule with k name. | ||
var _ref6 = (0, _slicedToArray2.default)(_ref7, 2); | ||
}, { | ||
key: 'rule', | ||
value: function rule(k) { | ||
var _rk = _ref6[0]; | ||
var _rf = _ref6[1]; | ||
var r = [undefined, undefined]; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
if (k === _rk) { | ||
r = [_tk, _rf]; | ||
break; | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) { | ||
_iterator2.return(); | ||
} | ||
for (var _iterator = (0, _utils.kvs)(this.registry)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var _ref2 = _step.value; | ||
var _ref3 = _slicedToArray(_ref2, 2); | ||
var tk = _ref3[0]; | ||
var tv = _ref3[1]; | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = tv[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var _ref4 = _step2.value; | ||
var _ref5 = _slicedToArray(_ref4, 2); | ||
var rk = _ref5[0]; | ||
var rf = _ref5[1]; | ||
if (k === rk) { | ||
r = [tk, rf]; | ||
break; | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return) { | ||
_iterator2.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
} | ||
return r; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
}, { | ||
key: 'test', | ||
value: function test(d) { | ||
var q = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return r; | ||
} | ||
}, { | ||
key: "test", | ||
value: function test(d) { | ||
var q = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var r = true; | ||
if (is.leaf(q)) { | ||
// Implicit equality. | ||
r = r && (0, _same.default)(d, q); | ||
} else { | ||
var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
var r = true; | ||
try { | ||
for (var _iterator3 = (0, _getIterator2.default)((0, _utils.kvs)(q)), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
var _ref10 = _step3.value; | ||
if (is.leaf(q)) { | ||
var _ref9 = (0, _slicedToArray2.default)(_ref10, 2); | ||
// Implicit equality. | ||
r = r && (0, _same2.default)(d, q); | ||
} else { | ||
var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
var _qk = _ref9[0]; | ||
var _qv = _ref9[1]; | ||
try { | ||
if (_qk[0] === '$') { | ||
var _rule3 = this.rule(_qk), | ||
_rule4 = (0, _slicedToArray2.default)(_rule3, 2), | ||
t = _rule4[0], | ||
f = _rule4[1]; | ||
for (var _iterator3 = (0, _utils.kvs)(q)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
var _ref6 = _step3.value; | ||
switch (t) { | ||
case 'expansions': | ||
r = r && this.test(d, f); | ||
break; | ||
var _ref7 = _slicedToArray(_ref6, 2); | ||
case 'virtuals': | ||
r = r && this.test(f.bind(this)(d, _qv), _qv); | ||
break; | ||
var qk = _ref7[0]; | ||
var qv = _ref7[1]; | ||
case 'conditions': | ||
r = r && f.bind(this)(d, _qv, q); | ||
break; | ||
default: | ||
throw new Error("Unknown rule ".concat(_qk)); | ||
} | ||
if (qk[0] === '$') { | ||
var _rule3 = this.rule(qk), | ||
_rule4 = _slicedToArray(_rule3, 2), | ||
t = _rule4[0], | ||
f = _rule4[1]; | ||
if (r === false) { | ||
break; | ||
} | ||
} else { | ||
// Allow " $foo" to reference "$foo" attributes. | ||
var tqk = (0, _utils.decoded)(_qk); | ||
switch (t) { | ||
case 'expansions': | ||
r = r && this.test(d, f); | ||
break; | ||
case 'virtuals': | ||
r = r && this.test(f.bind(this)(d, qv), qv); | ||
break; | ||
case 'conditions': | ||
r = r && f.bind(this)(d, qv, q); | ||
break; | ||
default: | ||
throw new Error('Unknown rule ' + qk); | ||
} | ||
var _ref11 = (0, _utils.resolve)(d, tqk) || [], | ||
_ref12 = (0, _slicedToArray2.default)(_ref11, 2), | ||
dvp = _ref12[0], | ||
dk = _ref12[1]; | ||
if (r === false) { | ||
if (dvp !== null && dk.length === 1) { | ||
// ...it's resolved. | ||
r = r && this.test(dvp[dk[0]], _qv); | ||
} else { | ||
// We can still match `{ $exists: false }`, possibly in nested | ||
// `{ $or: [] }`. | ||
r = r && this.test(undefined, _qv); | ||
} | ||
break; | ||
} | ||
} else { | ||
// Allow " $foo" to reference "$foo" attributes. | ||
var tqk = (0, _utils.decoded)(qk); | ||
var _ref8 = (0, _utils.resolve)(d, tqk) || [], | ||
_ref9 = _slicedToArray(_ref8, 2), | ||
dvp = _ref9[0], | ||
dk = _ref9[1]; | ||
if (dvp !== null && dk.length === 1) { | ||
// ...it's resolved. | ||
r = r && this.test(dvp[dk[0]], qv); | ||
} else { | ||
// We can still match `{ $exists: false }`, possibly in nested | ||
// `{ $or: [] }`. | ||
r = r && this.test(undefined, qv); | ||
} | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return) { | ||
_iterator3.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return != null) { | ||
_iterator3.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
} | ||
} | ||
return r; | ||
} | ||
} | ||
}]); | ||
return r; | ||
} | ||
}]); | ||
return Engine; | ||
return Engine; | ||
}(); | ||
exports.default = Engine; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,7 +0,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -11,10 +9,18 @@ exports.test = test; | ||
var _engine = _interopRequireDefault(require("../engine")); | ||
var _engine = require('../engine'); | ||
var mongo = new _engine.default(); // Comparision | ||
var _engine2 = _interopRequireDefault(_engine); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var mongo = new _engine2.default(); | ||
// Comparision | ||
var rules = ['eq', 'ne', 'gt', 'gte', 'lt', 'lte', 'in', 'nin', 'or', 'and', 'nor', 'not', 'exists', 'type', 'mod', 'regex', 'all', 'elem-match', 'size']; | ||
rules.forEach(function (rule) { | ||
mongo.append2(require("../rules/".concat(rule))); | ||
mongo.append2(require('../rules/' + rule)); | ||
}); | ||
/** | ||
@@ -27,6 +33,6 @@ * Test whether or not data matches query | ||
*/ | ||
function test(data, query) { | ||
return mongo.test(data, query); | ||
return mongo.test(data, query); | ||
} | ||
/** | ||
@@ -39,26 +45,26 @@ * Filter out data using a qquery | ||
*/ | ||
function parseQuery(data, query) { | ||
if (!query.selector) { | ||
throw new Error('Query needs a selector field'); | ||
} | ||
var result = []; | ||
function parseQuery(data, query) { | ||
if (!query.selector) { | ||
throw new Error('Query needs a selector field'); | ||
} | ||
for (var key in data) { | ||
var value = data[key]; | ||
var result = []; | ||
var positive = mongo.test(value, query.selector); | ||
for (var key in data) { | ||
var value = data[key]; | ||
var positive = mongo.test(value, query.selector); | ||
if (positive) { | ||
result.push({ | ||
key: key, | ||
value: value | ||
}); | ||
if (positive) { | ||
result.push({ | ||
key: key, | ||
value: value | ||
}); | ||
} | ||
} | ||
} | ||
var skip = query.skip || 0; | ||
var limit = query.limit || result.length; | ||
return result.slice(skip, limit); | ||
var skip = query.skip || 0; | ||
var limit = query.limit || result.length; | ||
return result.slice(skip, limit); | ||
} |
@@ -1,16 +0,17 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
exports.array = array; | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
var _is = require('./is'); | ||
var is = _interopRequireWildcard(require("./is")); | ||
var is = _interopRequireWildcard(_is); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function array(a) { | ||
@@ -22,8 +23,8 @@ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
if (options.length !== a.length) { | ||
throw new TypeError("Expected array with length ".concat(options.length, ", got length ").concat(a.length, ".")); | ||
throw new TypeError('Expected array with length ' + options.length + ', got length ' + a.length + '.'); | ||
} | ||
} | ||
} else { | ||
throw new TypeError("Expected array, got ".concat((0, _typeof2.default)(a), ".")); | ||
throw new TypeError('Expected array, got ' + (typeof a === 'undefined' ? 'undefined' : _typeof(a)) + '.'); | ||
} | ||
} |
@@ -1,26 +0,15 @@ | ||
"use strict"; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "parseQuery", { | ||
enumerable: true, | ||
get: function get() { | ||
return _mongo.parseQuery; | ||
} | ||
}); | ||
Object.defineProperty(exports, "test", { | ||
enumerable: true, | ||
get: function get() { | ||
return _mongo.test; | ||
} | ||
}); | ||
exports.default = void 0; | ||
exports.test = exports.parseQuery = undefined; | ||
var _mongo = require("./engine/mongo"); | ||
var _mongo = require('./engine/mongo'); | ||
var _default = { | ||
parseQuery: _mongo.parseQuery, | ||
test: _mongo.test | ||
}; | ||
exports.default = _default; | ||
exports.parseQuery = _mongo.parseQuery; | ||
exports.test = _mongo.test; | ||
exports.default = { | ||
parseQuery: _mongo.parseQuery, | ||
test: _mongo.test | ||
}; |
@@ -1,8 +0,9 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
exports.rep = rep; | ||
@@ -21,7 +22,2 @@ exports.array = array; | ||
exports.leaf = leaf; | ||
var _keys = _interopRequireDefault(require("@babel/runtime/core-js/object/keys")); | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
function rep(a, b) { | ||
@@ -40,3 +36,3 @@ return Object.prototype.toString.call(a) === b; | ||
function object(a) { | ||
return (0, _typeof2.default)(a) === 'object' && a !== null; | ||
return (typeof a === 'undefined' ? 'undefined' : _typeof(a)) === 'object' && a !== null; | ||
} | ||
@@ -50,5 +46,5 @@ | ||
return typeof a === 'number'; | ||
} // Return true if value is an array with string elements only. | ||
} | ||
// Return true if value is an array with string elements only. | ||
function strings(a) { | ||
@@ -78,16 +74,14 @@ return array(a) && a.every(function (e) { | ||
return Buffer != null ? Buffer.isBuffer(a) : false; | ||
} // Leaf is a value that we can't decend into. | ||
} | ||
// Leaf is a value that we can't decend into. | ||
function leaf(a) { | ||
var r = true; | ||
switch (true) { | ||
case array(a) && a.length > 0: | ||
case object(a) && (0, _keys.default)(a).length > 0: | ||
case object(a) && Object.keys(a).length > 0: | ||
r = false; | ||
break; | ||
} | ||
return r; | ||
} |
@@ -1,14 +0,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var is = _interopRequireWildcard(require("../is")); | ||
var _is = require('../is'); | ||
var _default = { | ||
var is = _interopRequireWildcard(_is); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.default = { | ||
conditions: { | ||
$all: function $all(d, q) { | ||
@@ -19,5 +21,5 @@ return is.array(d) && is.array(q) && q.every(function (e) { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,14 +0,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var ensure = _interopRequireWildcard(require("../ensure")); | ||
var _ensure = require('../ensure'); | ||
var _default = { | ||
var ensure = _interopRequireWildcard(_ensure); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.default = { | ||
conditions: { | ||
$and: function $and(d, q) { | ||
@@ -22,5 +24,5 @@ var _this = this; | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,21 +0,23 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _is = _interopRequireDefault(require("../is")); | ||
var _is = require('../is'); | ||
var _default = { | ||
var _is2 = _interopRequireDefault(_is); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = { | ||
conditions: { | ||
// Evaluates to true if all conditions are not met, false otherwise. | ||
$array: function $array(d, q) { | ||
return _is.default.array(d) ^ q; | ||
return _is2.default.array(d) ^ q; | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,14 +0,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var is = _interopRequireWildcard(require("../is")); | ||
var _is = require('../is'); | ||
var _default = { | ||
var is = _interopRequireWildcard(_is); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.default = { | ||
conditions: { | ||
$elemMatch: function $elemMatch(d, q) { | ||
@@ -21,5 +23,5 @@ var _this = this; | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
expansions: { | ||
// Matches e-mail string. | ||
@@ -15,5 +15,5 @@ $email: { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,20 +0,20 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _same = _interopRequireDefault(require("../same")); | ||
var _same = require('../same'); | ||
var _default = { | ||
conditions: { | ||
$eq: function $eq(d, q) { | ||
return (0, _same.default)(d, q); | ||
var _same2 = _interopRequireDefault(_same); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = { | ||
conditions: { | ||
$eq: function $eq(d, q) { | ||
return (0, _same2.default)(d, q); | ||
} | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,14 +0,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _is = _interopRequireDefault(require("../is")); | ||
var _is = require('../is'); | ||
var _default = { | ||
var _is2 = _interopRequireDefault(_is); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = { | ||
conditions: { | ||
// Evaluates to true if all conditions are met, false otherwise. | ||
@@ -18,9 +20,9 @@ $none: function $none(d, q) { | ||
return _is.default.array(d) && d.every(function (e) { | ||
return _is2.default.array(d) && d.every(function (e) { | ||
return _this.test(e, q); | ||
}); | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,20 +0,22 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var is = _interopRequireWildcard(require("../is")); | ||
var _is = require('../is'); | ||
var _default = { | ||
var is = _interopRequireWildcard(_is); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.default = { | ||
conditions: { | ||
$exists: function $exists(d, q) { | ||
return !(!!q ^ !is.none(d)); | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
expansions: { | ||
// Matches Extended JSON ObjectId. | ||
@@ -18,5 +18,5 @@ '$ext:oid': { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -6,4 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
conditions: { | ||
@@ -15,3 +14,2 @@ $gt: function $gt(d, q) { | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; |
@@ -6,4 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
conditions: { | ||
@@ -15,3 +14,2 @@ $gte: function $gte(d, q) { | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
expansions: { | ||
// Matches hex string. | ||
@@ -15,5 +15,5 @@ '$hex': { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _utils = require("../utils"); | ||
var _utils = require('../utils'); | ||
var _default = { | ||
exports.default = { | ||
conditions: { | ||
// Evaluates to true if provided value is in array document. | ||
@@ -20,5 +20,5 @@ $in: function $in(d, q) { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,33 +0,33 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _is = require('../is'); | ||
var is = _interopRequireWildcard(require("../is")); | ||
var is = _interopRequireWildcard(_is); | ||
var _default = { | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
exports.default = { | ||
conditions: { | ||
// Evaluates to true if provided rule name prefixed with $ evaluates to true. | ||
$is: function $is(d, q) { | ||
var r = false; | ||
switch (true) { | ||
switch (true) { | ||
// Single rule, ie: { foo: { $is: 'number' } } | ||
case is.string(q): | ||
r = this.test(d, (0, _defineProperty2.default)({}, "$".concat(q), true)); | ||
r = this.test(d, _defineProperty({}, '$' + q, true)); | ||
break; | ||
// Any of provided rules, ie: { foo: { $is: [ 'number', 'string' ] } } | ||
case is.strings(q): | ||
r = this.test(d, { | ||
$or: q.map(function (e) { | ||
return (0, _defineProperty2.default)({}, "$".concat(e), true); | ||
return _defineProperty({}, '$' + e, true); | ||
}) | ||
@@ -40,8 +40,7 @@ }); | ||
} | ||
return r; | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,30 +0,28 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _keys = _interopRequireDefault(require("@babel/runtime/core-js/object/keys")); | ||
var _is = require('../is'); | ||
var _is = _interopRequireDefault(require("../is")); | ||
var _is2 = _interopRequireDefault(_is); | ||
var _default = { | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = { | ||
virtuals: { | ||
// Returns keys of values. | ||
$keys: function $keys(d) { | ||
var r = undefined; | ||
try { | ||
r = (0, _keys.default)(d); | ||
r = Object.keys(d); | ||
r.sort(); | ||
} catch (ex) {} | ||
return r; | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,18 +6,16 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
virtuals: { | ||
// Returns length of arrays, strings and all objects with .length property. | ||
$length: function $length(d) { | ||
var r = undefined; | ||
if (d != null && d.hasOwnProperty('length')) { | ||
r = d.length; | ||
} | ||
return r; | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -6,4 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
conditions: { | ||
@@ -15,3 +14,2 @@ $lt: function $lt(d, q) { | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; |
@@ -6,4 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
conditions: { | ||
@@ -15,3 +14,2 @@ $lte: function $lte(d, q) { | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; |
@@ -1,23 +0,23 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var ensure = _interopRequireWildcard(require("../ensure")); | ||
var _ensure = require('../ensure'); | ||
var _default = { | ||
var ensure = _interopRequireWildcard(_ensure); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.default = { | ||
conditions: { | ||
$mod: function $mod(d, q) { | ||
ensure.array(q, { | ||
length: 2 | ||
}); | ||
ensure.array(q, { length: 2 }); | ||
return d % q[0] === q[1]; | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,20 +0,20 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _same = _interopRequireDefault(require("../same")); | ||
var _same = require('../same'); | ||
var _default = { | ||
var _same2 = _interopRequireDefault(_same); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = { | ||
conditions: { | ||
$ne: function $ne(d, q) { | ||
return !(0, _same.default)(d, q); | ||
return !(0, _same2.default)(d, q); | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _utils = require("../utils"); | ||
var _utils = require('../utils'); | ||
var _default = { | ||
exports.default = { | ||
conditions: { | ||
// Evaluates to true if provided value is not in array document. | ||
@@ -20,5 +20,5 @@ $nin: function $nin(d, q) { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,14 +0,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _is = _interopRequireDefault(require("../is")); | ||
var _is = require('../is'); | ||
var _default = { | ||
var _is2 = _interopRequireDefault(_is); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = { | ||
conditions: { | ||
// Evaluates to true if all conditions are not met, false otherwise. | ||
@@ -18,9 +20,9 @@ $none: function $none(d, q) { | ||
return _is.default.array(d) && !d.every(function (e) { | ||
return _is2.default.array(d) && !d.every(function (e) { | ||
return _this.test(e, q); | ||
}); | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,14 +0,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var ensure = _interopRequireWildcard(require("../ensure")); | ||
var _ensure = require('../ensure'); | ||
var _default = { | ||
var ensure = _interopRequireWildcard(_ensure); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.default = { | ||
conditions: { | ||
$nor: function $nor(d, q) { | ||
@@ -22,5 +24,5 @@ var _this = this; | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,20 +0,22 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var ensure = _interopRequireWildcard(require("../ensure")); | ||
var _ensure = require('../ensure'); | ||
var _default = { | ||
var ensure = _interopRequireWildcard(_ensure); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.default = { | ||
conditions: { | ||
$not: function $not(d, q) { | ||
return !this.test(d, q); | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
expansions: { | ||
// Matches integer numbers (..., -2, -1, 0, 1, 2, ...) | ||
@@ -15,5 +15,5 @@ '$number:integer': { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
expansions: { | ||
// Matches natural numbers (0, 1, 2...). | ||
@@ -15,5 +15,5 @@ '$number:natural': { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
expansions: { | ||
// Matches numbers. | ||
@@ -14,5 +14,5 @@ '$number': { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,29 +0,29 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var is = _interopRequireWildcard(require("../is")); | ||
var _is = require('../is'); | ||
var _default = { | ||
var is = _interopRequireWildcard(_is); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.default = { | ||
conditions: { | ||
// HACK: To support $regex's $options. | ||
$options: function $options(d, q, p) { | ||
var r = false; | ||
if (!is.none(p.$regex)) { | ||
r = true; | ||
} else { | ||
throw new TypeError("$options reserved for $regex."); | ||
throw new TypeError('$options reserved for $regex.'); | ||
} | ||
return r; | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,14 +0,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var ensure = _interopRequireWildcard(require("../ensure")); | ||
var _ensure = require('../ensure'); | ||
var _default = { | ||
var ensure = _interopRequireWildcard(_ensure); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.default = { | ||
conditions: { | ||
$or: function $or(d, q) { | ||
@@ -22,5 +24,5 @@ var _this = this; | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,20 +0,22 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var ensure = _interopRequireWildcard(require("../ensure")); | ||
var _ensure = require('../ensure'); | ||
var _default = { | ||
var ensure = _interopRequireWildcard(_ensure); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.default = { | ||
conditions: { | ||
$regex: function $regex(d, q, p) { | ||
return !!d.match(new RegExp(q, p.$options)); | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,20 +0,22 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var is = _interopRequireWildcard(require("../is")); | ||
var _is = require('../is'); | ||
var _default = { | ||
var is = _interopRequireWildcard(_is); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.default = { | ||
conditions: { | ||
$size: function $size(d, q) { | ||
return q === (is.array(d) ? d.length : 0); | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,14 +0,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _is = _interopRequireDefault(require("../is")); | ||
var _is = require('../is'); | ||
var _default = { | ||
var _is2 = _interopRequireDefault(_is); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = { | ||
conditions: { | ||
// Evaluates to true if at least one condition is met, false otherwise. | ||
@@ -18,9 +20,9 @@ $none: function $none(d, q) { | ||
return _is.default.array(d) && d.some(function (e) { | ||
return _is2.default.array(d) && d.some(function (e) { | ||
return _this.test(e, q); | ||
}); | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,14 +0,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _is = _interopRequireDefault(require("../is")); | ||
var _is = require('../is'); | ||
var _default = { | ||
var _is2 = _interopRequireDefault(_is); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = { | ||
conditions: { | ||
// Evaluates to true if value is sorted array. | ||
@@ -18,6 +20,6 @@ // | ||
$sorted: function $sorted(d, q) { | ||
var r = false; // Comparision direction. | ||
var r = false; | ||
// Comparision direction. | ||
var cmp = undefined; | ||
switch (q) { | ||
@@ -28,5 +30,3 @@ case -1: | ||
}; | ||
break; | ||
default: | ||
@@ -36,9 +36,7 @@ cmp = function cmp(a, b) { | ||
}; | ||
break; | ||
} // Result mangle. | ||
} | ||
// Result mangle. | ||
var rm = undefined; | ||
switch (q) { | ||
@@ -49,5 +47,3 @@ case false: | ||
}; | ||
break; | ||
default: | ||
@@ -57,10 +53,8 @@ rm = function rm(r) { | ||
}; | ||
break; | ||
} | ||
if (_is.default.array(d)) { | ||
if (_is2.default.array(d)) { | ||
r = true; | ||
var n = d.length; | ||
for (var i = 1; i < n; i++) { | ||
@@ -76,5 +70,5 @@ if (!cmp(d[i - 1], d[i])) { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
expansions: { | ||
// Matches ISO date strings. | ||
@@ -14,5 +14,5 @@ '$strftime:iso': { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,14 +0,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var strftime = _interopRequireWildcard(require("../strftime")); | ||
var _strftime = require('../strftime'); | ||
var _default = { | ||
var strftime = _interopRequireWildcard(_strftime); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.default = { | ||
conditions: { | ||
// Matches strings with specified date-time format. | ||
@@ -18,5 +20,5 @@ $strftime: function $strftime(d, q) { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
expansions: { | ||
// Matches ObjectId string. | ||
@@ -15,5 +15,5 @@ '$string:oid': { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
expansions: { | ||
// Matches string. | ||
@@ -14,5 +14,5 @@ '$string': { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _default = { | ||
exports.default = { | ||
conditions: { | ||
$type: function $type(d, q) { | ||
return (0, _typeof2.default)(d) === q; | ||
return (typeof d === "undefined" ? "undefined" : _typeof(d)) === q; | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; |
@@ -1,14 +0,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _is = _interopRequireDefault(require("../is")); | ||
var _is = require('../is'); | ||
var _default = { | ||
var _is2 = _interopRequireDefault(_is); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = { | ||
conditions: { | ||
// Evaluates to true if value is an array with unique values. | ||
@@ -19,5 +21,5 @@ $unique: function $unique(d, q) { | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; | ||
module.exports = exports['default']; |
@@ -6,11 +6,11 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
exports.default = { | ||
conditions: { | ||
$where: function $where(d, q) { | ||
return q(d); | ||
} | ||
} | ||
}; | ||
exports.default = _default; | ||
module.exports = exports["default"]; |
@@ -1,7 +0,3 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -13,13 +9,15 @@ value: true | ||
var _keys = _interopRequireDefault(require("@babel/runtime/core-js/object/keys")); | ||
var _is = require('./is'); | ||
var is = _interopRequireWildcard(require("./is")); | ||
var is = _interopRequireWildcard(_is); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
// Return true if arrays are the same. | ||
function arrays(a, b) { | ||
var sort = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
var r = true; | ||
var an = a.length; | ||
var bn = b.length; | ||
if (an === bn) { | ||
@@ -30,3 +28,2 @@ if (sort) { | ||
} | ||
for (var i = 0; i < an; i++) { | ||
@@ -41,11 +38,10 @@ if (a[i] !== b[i]) { | ||
} | ||
return r; | ||
} // Return true if two values are the same. | ||
} | ||
// Return true if two values are the same. | ||
function same(a, b) { | ||
var r = false; | ||
switch (true) { | ||
switch (true) { | ||
// Same scalars. | ||
@@ -55,6 +51,7 @@ case a === b: | ||
break; | ||
// Objects. | ||
case is.object(a) && is.object(b): | ||
switch (true) { | ||
// Dates. | ||
@@ -64,9 +61,9 @@ case is.date(a) && is.date(b): | ||
break; | ||
// RegExps. | ||
case is.regexp(a) && is.regexp(b): | ||
r = a.source === b.source && a.global === b.global && a.multiline === b.multiline && a.lastIndex === b.lastIndex && a.ignoreCase === b.ignoreCase; | ||
break; | ||
// Array like. | ||
case is.array(a) && is.array(b): | ||
@@ -77,8 +74,7 @@ case is.args(a) && is.args(b): | ||
break; | ||
// Other objects. | ||
default: | ||
var aks = (0, _keys.default)(a); | ||
var bks = (0, _keys.default)(b); | ||
var aks = Object.keys(a); | ||
var bks = Object.keys(b); | ||
if (arrays(aks, bks, true)) { | ||
@@ -89,10 +85,7 @@ r = aks.every(function (k) { | ||
} | ||
break; | ||
} | ||
break; | ||
} | ||
return r; | ||
} |
@@ -1,12 +0,11 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { 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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
exports.test = test; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
function strsplice(a, i, n, b) { | ||
@@ -17,21 +16,17 @@ return a.slice(0, i) + (b || '') + str.slice(i + n); | ||
var fmt = { | ||
// Day | ||
'%a': /(Sun|Mon|Tue|Wed|Thu|Fri|Sat)/, | ||
'%A': /(Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)/, | ||
'%d': /(0[1-9]|[12][0-9]|3[01])/, | ||
// 01..31 | ||
'%e': /( [1-9]|[12][0-9]|3[01])/, | ||
// _1..31 | ||
'%d': /(0[1-9]|[12][0-9]|3[01])/, // 01..31 | ||
'%e': /( [1-9]|[12][0-9]|3[01])/, // _1..31 | ||
'%j': /([0-2][0-9]{2}|3[0-5][0-9]|36[0-6])/, | ||
'%u': /([1-7])/, | ||
// 1..7 | ||
'%w': /(0-6)/, | ||
// 0..6 | ||
'%u': /([1-7])/, // 1..7 | ||
'%w': /(0-6)/, // 0..6 | ||
// Week | ||
'%U': /(0[0-9]|[1-4][0-9]|5[0-3])/, | ||
// 00..53 | ||
'%V': /(0[1-9]|[1-4][0-9]|5[0-3])/, | ||
// 01..53 | ||
'%W': /(0[0-9]|[1-4][0-9]|5[0-3])/, | ||
// 00..53 | ||
'%U': /(0[0-9]|[1-4][0-9]|5[0-3])/, // 00..53 | ||
'%V': /(0[1-9]|[1-4][0-9]|5[0-3])/, // 01..53 | ||
'%W': /(0[0-9]|[1-4][0-9]|5[0-3])/, // 00..53 | ||
// Month | ||
@@ -41,26 +36,17 @@ '%b': /(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)/, | ||
'%h': /(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)/, | ||
'%m': /(0[1-9]|1[0-2])/, | ||
// 01..12 | ||
'%m': /(0[1-9]|1[0-2])/, // 01..12 | ||
// Year | ||
'%C': /([0-9]{2})/, | ||
// 00..99 | ||
'%g': /([0-9]{2})/, | ||
// 00..99 | ||
'%G': /([0-9]{4})/, | ||
// 0000..9999 | ||
'%y': /([0-9]{2})/, | ||
// 00..99 | ||
'%Y': /([0-9]{4})/, | ||
// 0000..9999 | ||
'%C': /([0-9]{2})/, // 00..99 | ||
'%g': /([0-9]{2})/, // 00..99 | ||
'%G': /([0-9]{4})/, // 0000..9999 | ||
'%y': /([0-9]{2})/, // 00..99 | ||
'%Y': /([0-9]{4})/, // 0000..9999 | ||
// Time | ||
'%H': /(0[0-9]|1[0-9]|2[0-3])/, | ||
// 00..23 | ||
'%k': /( [0-9]|1[0-9]|2[0-3])/, | ||
// _0..23 | ||
'%I': /(0[1-9]|1[0-2])/, | ||
// 01..12 | ||
'%l': /( [1-9]|1[0-2])/, | ||
// _1..12 | ||
'%M': /([0-5][0-9])/, | ||
// 00..59 | ||
'%H': /(0[0-9]|1[0-9]|2[0-3])/, // 00..23 | ||
'%k': /( [0-9]|1[0-9]|2[0-3])/, // _0..23 | ||
'%I': /(0[1-9]|1[0-2])/, // 01..12 | ||
'%l': /( [1-9]|1[0-2])/, // _1..12 | ||
'%M': /([0-5][0-9])/, // 00..59 | ||
'%p': /(AM|PM)/, | ||
@@ -75,2 +61,3 @@ '%P': /(am|pm)/, | ||
'%Z': /([A-Z]+)/, | ||
// Time and Date Stamps | ||
@@ -82,12 +69,14 @@ // %c not supported. | ||
// %x not supported. | ||
// Misc | ||
'%n': /\n/, | ||
'%t': /\t/, | ||
'%%': /\%/ // Maximum format string length. | ||
'%%': /\%/ | ||
}; | ||
var max = 1023; | ||
// Maximum format string length. | ||
};var max = 1023; | ||
function test_(f, d) { | ||
var r = false; | ||
var i = 0; | ||
@@ -99,11 +88,10 @@ var j = 0; | ||
r = true; | ||
while (r && i < f.length && j < d.length) { | ||
if (f[i] === '%') { | ||
var t = f.substr(i, 2); // console.log('t', t, f, i) | ||
var t = f.substr(i, 2); | ||
// console.log('t', t, f, i) | ||
var u = fmt[t]; | ||
if (u) { | ||
if (typeof u === 'string') { | ||
// fmt rule is a string, expand, ie. '%F' -> '%Y-%m-%d'. | ||
@@ -113,9 +101,7 @@ f = strsplice(f, 0, 2, u); | ||
var m = d.substr(j).match(fmt[t]); | ||
if (m) { | ||
// console.log('matched', t) | ||
i += 2; | ||
j += m[0].length; | ||
i += 2;j += m[0].length; | ||
} else { | ||
err = new Error("invalid input for ".concat(t)); | ||
err = new Error('invalid input for ' + t); | ||
r = false; | ||
@@ -125,3 +111,3 @@ } | ||
} else { | ||
err = new Error("unknown token ".concat(t)); | ||
err = new Error('unknown token ' + t); | ||
r = false; | ||
@@ -132,6 +118,5 @@ } | ||
// console.log('++', f[i]) | ||
i++; | ||
j++; | ||
i++;j++; | ||
} else { | ||
err = new Error("direct match failed ".concat(f[i], " != ").concat(d[j])); | ||
err = new Error('direct match failed ' + f[i] + ' != ' + d[j]); | ||
r = false; | ||
@@ -141,11 +126,9 @@ } | ||
} | ||
if (r) { | ||
if (i !== f.length) { | ||
err = new Error("invalid extras"); | ||
err = new Error('invalid extras'); | ||
r = false; | ||
} | ||
if (j !== d.length) { | ||
err = new Error("not fully matched"); | ||
err = new Error('not fully matched'); | ||
r = false; | ||
@@ -161,3 +144,3 @@ } | ||
var _test_ = test_(a, b), | ||
_test_2 = (0, _slicedToArray2.default)(_test_, 4), | ||
_test_2 = _slicedToArray(_test_, 4), | ||
err = _test_2[0], | ||
@@ -164,0 +147,0 @@ r = _test_2[1], |
1066
lib/utils.js
@@ -1,10 +0,13 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _regenerator = require('babel-runtime/regenerator'); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _regenerator2 = _interopRequireDefault(_regenerator); | ||
var _slicedToArray = function () { function sliceIterator(arr, i) { 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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
exports.patrics = patrics; | ||
@@ -25,364 +28,368 @@ exports.patrics2 = patrics2; | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _is = require('./is'); | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var is = _interopRequireWildcard(_is); | ||
var _keys = _interopRequireDefault(require("@babel/runtime/core-js/object/keys")); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
var _getIterator2 = _interopRequireDefault(require("@babel/runtime/core-js/get-iterator")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var is = _interopRequireWildcard(require("./is")); | ||
var _marked = /*#__PURE__*/_regenerator2.default.mark(kvs); | ||
var _marked = | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(kvs); | ||
// S.R. Petrick, "A Direct Determination of the Irredundant Forms of a Boolean Function from the Set of Prime Implicants" | ||
// Technical Report AFCRC-TR-56-110, Air Force Cambridge Research Center, Cambridge, Mass., Apr. 1956. | ||
function patrics(minterms) { | ||
// Get prime implicants. | ||
var F = {}; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = (0, _getIterator2.default)(minterms), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var _minterm = _step.value; | ||
// Get prime implicants. | ||
var F = {}; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
if (_minterm[2] !== 'v') { | ||
if (!F[_minterm[0]]) { | ||
F[_minterm[0]] = _minterm[3]; | ||
try { | ||
for (var _iterator = minterms[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var minterm = _step.value; | ||
if (minterm[2] !== 'v') { | ||
if (!F[minterm[0]]) { | ||
F[minterm[0]] = minterm[3]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
} | ||
var P = []; | ||
var PO = {}; | ||
var alpha = 'abcdefghijklmnopqrstuvwxy'; | ||
var ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXY'; | ||
var P = []; | ||
var PO = {}; | ||
var alpha = 'abcdefghijklmnopqrstuvwxy'; | ||
var ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXY'; | ||
for (var k in F) { | ||
var v = F[k]; | ||
var pk = k.split('').map(function (e, i) { | ||
return { '0': ALPHA[i], '1': alpha[i], '-': null }[e]; | ||
}).filter(function (e) { | ||
return e; | ||
}).join(''); | ||
P.push([pk, v]); | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
for (var k in F) { | ||
var v = F[k]; | ||
var pk = k.split('').map(function (e, i) { | ||
return { | ||
'0': ALPHA[i], | ||
'1': alpha[i], | ||
'-': null | ||
}[e]; | ||
}).filter(function (e) { | ||
return e; | ||
}).join(''); | ||
P.push([pk, v]); | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = v[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var pi = _step2.value; | ||
try { | ||
for (var _iterator2 = (0, _getIterator2.default)(v), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var _pi = _step2.value; | ||
PO[_pi] = true; | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return != null) { | ||
_iterator2.return(); | ||
PO[pi] = true; | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return) { | ||
_iterator2.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
} | ||
var PI = Object.keys(PO).map(function (e) { | ||
return parseInt(e); | ||
}).sort(); | ||
var PI = (0, _keys.default)(PO).map(function (e) { | ||
return parseInt(e); | ||
}).sort(); // console.log('P:') | ||
// P.forEach(function (p, i) { | ||
// console.log(`P${i}`, p[0], p[1].join(', ')) | ||
// }) | ||
// | ||
// console.log('PI:') | ||
// console.log(PI) | ||
// | ||
var PR = PI.map(function (pi) { | ||
var r = []; | ||
P.forEach(function (e, i) { | ||
if (e[1].indexOf(pi) !== -1) { | ||
r.push(i); | ||
} | ||
// console.log('P:') | ||
// P.forEach(function (p, i) { | ||
// console.log(`P${i}`, p[0], p[1].join(', ')) | ||
// }) | ||
// | ||
// console.log('PI:') | ||
// console.log(PI) | ||
// | ||
var PR = PI.map(function (pi) { | ||
var r = []; | ||
P.forEach(function (e, i) { | ||
if (e[1].indexOf(pi) !== -1) { | ||
r.push(i); | ||
} | ||
}); | ||
return r.map(function (e) { | ||
return 'P' + e; | ||
}); | ||
}); | ||
return r.map(function (e) { | ||
return "P".concat(e); | ||
}); | ||
}); // console.log('PR:', PR.map((e) => `(${e.join(' + ')})`).join(' ')) | ||
var PM = PR.map(function (e) { | ||
return e.map(function (f) { | ||
return [f]; | ||
}); | ||
}); | ||
// console.log('PR:', PR.map((e) => `(${e.join(' + ')})`).join(' ')) | ||
while (PM.length > 1) { | ||
var p = PM.pop(); | ||
p.forEach(function (e) { | ||
e.forEach(function (e2) { | ||
PM.forEach(function (f) { | ||
f.forEach(function (g) { | ||
if (g.indexOf(e2) === -1) { | ||
g.push(e2); | ||
} | ||
}); | ||
var PM = PR.map(function (e) { | ||
return e.map(function (f) { | ||
return [f]; | ||
}); | ||
}); | ||
}); | ||
} // return PM[0].map((e) => e.join('')).join('+') | ||
// console.log('PM0:', PM[0].map((e) => e.join('*')).join(' + ')) | ||
while (PM.length > 1) { | ||
var p = PM.pop(); | ||
p.forEach(function (e) { | ||
e.forEach(function (e2) { | ||
PM.forEach(function (f) { | ||
f.forEach(function (g) { | ||
if (g.indexOf(e2) === -1) { | ||
g.push(e2); | ||
} | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
return PM[0].map(function (e) { | ||
return e.map(function (f) { | ||
return P[parseInt(f.substr(1))][0]; | ||
}).join(''); | ||
}).join('+'); | ||
// return PM[0].map((e) => e.join('')).join('+') | ||
// console.log('PM0:', PM[0].map((e) => e.join('*')).join(' + ')) | ||
return PM[0].map(function (e) { | ||
return e.map(function (f) { | ||
return P[parseInt(f.substr(1))][0]; | ||
}).join(''); | ||
}).join('+'); | ||
} | ||
function patrics2(minterms) { | ||
var P = patrics(minterms); | ||
var alpha = 'abcdefghijklmnopqrstuvwxy'; | ||
var ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXY'; | ||
var or = P.split('+').map(function (p) { | ||
var and = p.split('').map(function (e) { | ||
return alpha.indexOf(e); | ||
}).filter(function (e) { | ||
return e !== -1; | ||
}); | ||
var nor = p.split('').map(function (e) { | ||
return ALPHA.indexOf(e); | ||
}).filter(function (e) { | ||
return e !== -1; | ||
}); | ||
var r = {}; | ||
var P = patrics(minterms); | ||
var alpha = 'abcdefghijklmnopqrstuvwxy'; | ||
var ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXY'; | ||
if (and.length > 0) { | ||
r.$and = and; | ||
} | ||
var or = P.split('+').map(function (p) { | ||
if (nor.length > 0) { | ||
r.$nor = nor; | ||
} | ||
var and = p.split('').map(function (e) { | ||
return alpha.indexOf(e); | ||
}).filter(function (e) { | ||
return e !== -1; | ||
}); | ||
var nor = p.split('').map(function (e) { | ||
return ALPHA.indexOf(e); | ||
}).filter(function (e) { | ||
return e !== -1; | ||
}); | ||
if ((0, _keys.default)(r).length > 0) { | ||
return r; | ||
} else { | ||
return null; | ||
} | ||
}); | ||
var r = {}; | ||
if (and.length > 0) { | ||
r.$and = and; | ||
} | ||
if (nor.length > 0) { | ||
r.$nor = nor; | ||
} | ||
if (Object.keys(r).length > 0) { | ||
return r; | ||
} else { | ||
return null; | ||
} | ||
}); | ||
if (or.length > 0) { | ||
if (or.length === 1) { | ||
return or[0]; | ||
if (or.length > 0) { | ||
if (or.length === 1) { | ||
return or[0]; | ||
} else { | ||
return { $or: or }; | ||
} | ||
} else { | ||
return { | ||
$or: or | ||
}; | ||
return null; | ||
} | ||
} else { | ||
return null; | ||
} | ||
} // Minterm expansion. | ||
} | ||
// Minterm expansion. | ||
function mintermexp(minterms) { | ||
function diff(a, b) { | ||
var r = []; | ||
var n = 0; | ||
var f = false; | ||
for (var i = 0; i < a.length; i++) { | ||
if (a[i] === '0' && b[i] === '1' || a[i] === '1' && b[i] === '0') { | ||
r.push('-'); | ||
if (++n > 1) { | ||
f = true; | ||
break; | ||
function diff(a, b) { | ||
var r = []; | ||
var n = 0; | ||
var f = false; | ||
for (var i = 0; i < a.length; i++) { | ||
if (a[i] === '0' && b[i] === '1' || a[i] === '1' && b[i] === '0') { | ||
r.push('-'); | ||
if (++n > 1) { | ||
f = true; | ||
break; | ||
} | ||
} else { | ||
if (a[i] === b[i]) { | ||
r.push(a[i]); | ||
} else { | ||
f = true; | ||
break; | ||
} | ||
} | ||
} | ||
} else { | ||
if (a[i] === b[i]) { | ||
r.push(a[i]); | ||
if (f) { | ||
return false; | ||
} else { | ||
f = true; | ||
break; | ||
return r.join(''); | ||
} | ||
} | ||
} | ||
if (f) { | ||
return false; | ||
} else { | ||
return r.join(''); | ||
} | ||
} | ||
function combine1(i) { | ||
var r = []; | ||
for (; i < minterms.length; i++) { | ||
var o = minterms[i][1]; | ||
for (var j = i + 1; j < minterms.length; j++) { | ||
var od = minterms[j][1] - o; | ||
if (od === 0) { | ||
continue; | ||
} | ||
if (od === 1) { | ||
var d = diff(minterms[i][0], minterms[j][0]); | ||
if (d) { | ||
var _1s = d.split('').filter(function (e) { | ||
return e === '1'; | ||
}).length; | ||
minterms[i][2] = 'v'; | ||
minterms[j][2] = 'v'; | ||
var k = []; | ||
var _arr = [minterms[i][3], minterms[j][3]]; | ||
for (var _i = 0; _i < _arr.length; _i++) { | ||
var z = _arr[_i];var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
function combine1(i) { | ||
var r = []; | ||
try { | ||
for (var _iterator3 = z[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
var l = _step3.value; | ||
for (; i < minterms.length; i++) { | ||
var o = minterms[i][1]; | ||
for (var j = i + 1; j < minterms.length; j++) { | ||
var od = minterms[j][1] - o; | ||
if (od === 0) { | ||
continue; | ||
if (k.indexOf(l) === -1) { | ||
k.push(l); | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return) { | ||
_iterator3.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
} | ||
} | ||
} | ||
} | ||
r.push([d, _1s, ' ', k]); | ||
} | ||
} else { | ||
break; | ||
} | ||
} | ||
} | ||
if (od === 1) { | ||
var d = diff(minterms[i][0], minterms[j][0]); | ||
// r.sort((a, b) => a[1] - b[1]) | ||
if (d) { | ||
var _1s = d.split('').filter(function (e) { | ||
return e === '1'; | ||
}).length; | ||
minterms[i][2] = 'v'; | ||
minterms[j][2] = 'v'; | ||
var k = []; | ||
var _arr = [minterms[i][3], minterms[j][3]]; | ||
var _iteratorNormalCompletion4 = true; | ||
var _didIteratorError4 = false; | ||
var _iteratorError4 = undefined; | ||
for (var _i = 0; _i < _arr.length; _i++) { | ||
var z = _arr[_i]; | ||
var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
try { | ||
for (var _iterator4 = r[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { | ||
var e = _step4.value; | ||
try { | ||
for (var _iterator3 = (0, _getIterator2.default)(z), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
var _l = _step3.value; | ||
if (k.indexOf(_l) === -1) { | ||
k.push(_l); | ||
} | ||
minterms.push(e); | ||
} | ||
} catch (err) { | ||
_didIteratorError4 = true; | ||
_iteratorError4 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion4 && _iterator4.return) { | ||
_iterator4.return(); | ||
} | ||
} catch (err) { | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return != null) { | ||
_iterator3.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
} | ||
} finally { | ||
if (_didIteratorError4) { | ||
throw _iteratorError4; | ||
} | ||
} | ||
} | ||
r.push([d, _1s, ' ', k]); | ||
} | ||
} else { | ||
break; | ||
} | ||
} | ||
} // r.sort((a, b) => a[1] - b[1]) | ||
return i; | ||
} | ||
for (var _i2 = 0; _i2 < r.length; _i2++) { | ||
var e = r[_i2]; | ||
minterms.push(e); | ||
{ | ||
var i = 0; | ||
while (true) { | ||
var j = combine1(i); | ||
if (i == j) { | ||
break; | ||
} else { | ||
i = j; | ||
} | ||
} | ||
} | ||
} | ||
return i; | ||
} | ||
// Generate initial minterms. | ||
function minterms(q, n) { | ||
var r = []; | ||
{ | ||
var i = 0; | ||
var _loop = function _loop(i) { | ||
while (true) { | ||
var j = combine1(i); | ||
// String binary representation. | ||
var s = new Array(n).fill('0').map(function (e, j) { | ||
return 1 << j & i ? '1' : '0'; | ||
}).join(''); | ||
if (i == j) { | ||
break; | ||
} else { | ||
i = j; | ||
} | ||
} | ||
} | ||
} // Generate initial minterms. | ||
// Number of 1s. | ||
var _1s = s.split('').filter(function (e) { | ||
return e === '1'; | ||
}).length; | ||
if (itest(q, i)) { | ||
r.push([s, _1s, ' ', [i]]); | ||
} | ||
}; | ||
function minterms(q, n) { | ||
var r = []; | ||
var _loop = function _loop(i) { | ||
// String binary representation. | ||
var s = new Array(n).fill('0').map(function (e, j) { | ||
return 1 << j & i ? '1' : '0'; | ||
}).join(''); // Number of 1s. | ||
var _1s = s.split('').filter(function (e) { | ||
return e === '1'; | ||
}).length; | ||
if (itest(q, i)) { | ||
r.push([s, _1s, ' ', [i]]); | ||
for (var i = 0; i < Math.pow(2, n); i++) { | ||
_loop(i); | ||
} | ||
}; | ||
for (var i = 0; i < Math.pow(2, n); i++) { | ||
_loop(i); | ||
} // Sort by count of 1s. | ||
// Sort by count of 1s. | ||
r.sort(function (a, b) { | ||
return a[1] - b[1]; | ||
}); | ||
r.sort(function (a, b) { | ||
return a[1] - b[1]; | ||
}); | ||
return r; | ||
return r; | ||
} | ||
function itest2(qa, qb, n) { | ||
var r = true; | ||
var r = true; | ||
var _loop2 = function _loop2(i) { | ||
var ra = itest(qa, i); | ||
var rb = itest(qb, i); | ||
var _loop2 = function _loop2(i) { | ||
var ra = itest(qa, i); | ||
var rb = itest(qb, i); | ||
if (ra !== rb) { | ||
var _s = new Array(n).fill('0').map(function (e, j) { | ||
return 1 << j & i ? '1' : '0'; | ||
}).join(''); | ||
console.error(ra + ' !== ' + rb + ' for ' + _s); | ||
r = false; | ||
return 'break'; | ||
} | ||
}; | ||
if (ra !== rb) { | ||
var s = new Array(n).fill('0').map(function (e, j) { | ||
return 1 << j & i ? '1' : '0'; | ||
}).join(''); | ||
console.error("".concat(ra, " !== ").concat(rb, " for ").concat(s)); | ||
r = false; | ||
return "break"; | ||
for (var i = 0; i < Math.pow(2, n); i++) { | ||
var _ret2 = _loop2(i); | ||
if (_ret2 === 'break') break; | ||
} | ||
}; | ||
return r; | ||
} | ||
for (var i = 0; i < Math.pow(2, n); i++) { | ||
var _ret = _loop2(i); | ||
if (_ret === "break") break; | ||
} | ||
return r; | ||
} // Perform query test using binary as input. | ||
// Perform query test using binary as input. | ||
// | ||
@@ -392,282 +399,301 @@ // @param [Object] q Index map query, ie. `{ $and: [ 0, { $or: [ 1, 2 ] } ] }` | ||
// @return [Boolean] True if criteria is satisfied, false otherwise. | ||
function itest(q, i) { | ||
var r = false; | ||
var r = false; | ||
if (is.number(q)) { | ||
r = 1 << q & i ? true : false; | ||
} else { | ||
r = ['$and', '$or', '$nor', '$not'].every(function (k) { | ||
var r = true; | ||
if (is.none(q[k])) { | ||
r = true; | ||
} else { | ||
switch (k) { | ||
case '$and': | ||
r = q[k].every(function (e) { | ||
return itest(e, i); | ||
}); | ||
break; | ||
case '$or': | ||
r = q[k].some(function (e) { | ||
return itest(e, i); | ||
}); | ||
break; | ||
case '$nor': | ||
r = q[k].every(function (e) { | ||
return !itest(e, i); | ||
}); | ||
break; | ||
case '$not': | ||
r = !itest(q[k], i); | ||
break; | ||
} | ||
} | ||
return r; | ||
}); | ||
} | ||
return r; | ||
} | ||
if (is.number(q)) { | ||
r = 1 << q & i ? true : false; | ||
} else { | ||
r = ['$and', '$or', '$nor', '$not'].every(function (k) { | ||
var r = true; | ||
if (is.none(q[k])) { | ||
r = true; | ||
} else { | ||
switch (k) { | ||
case '$and': | ||
r = q[k].every(function (e) { | ||
return itest(e, i); | ||
}); | ||
break; | ||
case '$or': | ||
r = q[k].some(function (e) { | ||
return itest(e, i); | ||
}); | ||
break; | ||
case '$nor': | ||
r = q[k].every(function (e) { | ||
return !itest(e, i); | ||
}); | ||
break; | ||
case '$not': | ||
r = !itest(q[k], i); | ||
break; | ||
} | ||
} | ||
return r; | ||
}); | ||
} | ||
return r; | ||
} // Map query to fragments. | ||
// Map query to fragments. | ||
function map(q, f) { | ||
var r = null; | ||
var r = null; | ||
if (is.plain(q)) { | ||
r = {}; | ||
var d = {}; | ||
if (is.plain(q)) { | ||
r = {}; | ||
var d = {}; // Split fragment and query parts. | ||
// Split fragment and query parts. | ||
var _iteratorNormalCompletion5 = true; | ||
var _didIteratorError5 = false; | ||
var _iteratorError5 = undefined; | ||
var _iteratorNormalCompletion4 = true; | ||
var _didIteratorError4 = false; | ||
var _iteratorError4 = undefined; | ||
try { | ||
for (var _iterator5 = kvs(q)[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { | ||
var _ref = _step5.value; | ||
try { | ||
for (var _iterator4 = (0, _getIterator2.default)(kvs(q)), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { | ||
var _ref3 = _step4.value; | ||
var _ref2 = _slicedToArray(_ref, 2); | ||
var _ref2 = (0, _slicedToArray2.default)(_ref3, 2); | ||
var k = _ref2[0]; | ||
var v = _ref2[1]; | ||
var _k = _ref2[0]; | ||
var _v = _ref2[1]; | ||
if (['$and', '$or', '$nor'].indexOf(k) !== -1) { | ||
r[k] = map(v, f); | ||
} else { | ||
d[k] = v; | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError5 = true; | ||
_iteratorError5 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion5 && _iterator5.return) { | ||
_iterator5.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError5) { | ||
throw _iteratorError5; | ||
} | ||
} | ||
} | ||
if (['$and', '$or', '$nor'].indexOf(_k) !== -1) { | ||
r[_k] = map(_v, f); | ||
if (!is.leaf(d)) { | ||
var fd = f(d); | ||
if (is.leaf(r)) { | ||
r = fd; | ||
} else { | ||
r = { $and: [fd, r] }; | ||
} | ||
} | ||
} else { | ||
if (is.array(q)) { | ||
r = q.map(function (e) { | ||
return map(e, f); | ||
}); | ||
} else { | ||
d[_k] = _v; | ||
r = f(q); | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError4 = true; | ||
_iteratorError4 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion4 && _iterator4.return != null) { | ||
_iterator4.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError4) { | ||
throw _iteratorError4; | ||
} | ||
} | ||
} | ||
if (!is.leaf(d)) { | ||
var fd = f(d); | ||
if (is.leaf(r)) { | ||
r = fd; | ||
} else { | ||
r = { | ||
$and: [fd, r] | ||
}; | ||
} | ||
} | ||
} else { | ||
if (is.array(q)) { | ||
r = q.map(function (e) { | ||
return map(e, f); | ||
}); | ||
} else { | ||
r = f(q); | ||
} | ||
} | ||
return r; | ||
return r; | ||
} | ||
function unmap(q, fs) { | ||
var r = null; | ||
var r = null; | ||
if (is.plain(q)) { | ||
r = {}; | ||
var _iteratorNormalCompletion6 = true; | ||
var _didIteratorError6 = false; | ||
var _iteratorError6 = undefined; | ||
if (is.plain(q)) { | ||
r = {}; | ||
var _iteratorNormalCompletion5 = true; | ||
var _didIteratorError5 = false; | ||
var _iteratorError5 = undefined; | ||
try { | ||
for (var _iterator6 = kvs(q)[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) { | ||
var _ref3 = _step6.value; | ||
try { | ||
for (var _iterator5 = (0, _getIterator2.default)(kvs(q)), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { | ||
var _ref6 = _step5.value; | ||
var _ref4 = _slicedToArray(_ref3, 2); | ||
var _ref5 = (0, _slicedToArray2.default)(_ref6, 2); | ||
var k = _ref4[0]; | ||
var v = _ref4[1]; | ||
var _k2 = _ref5[0]; | ||
var _v2 = _ref5[1]; | ||
r[_k2] = unmap(_v2, fs); | ||
} | ||
} catch (err) { | ||
_didIteratorError5 = true; | ||
_iteratorError5 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion5 && _iterator5.return != null) { | ||
_iterator5.return(); | ||
r[k] = unmap(v, fs); | ||
} | ||
} catch (err) { | ||
_didIteratorError6 = true; | ||
_iteratorError6 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion6 && _iterator6.return) { | ||
_iterator6.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError6) { | ||
throw _iteratorError6; | ||
} | ||
} | ||
} | ||
} finally { | ||
if (_didIteratorError5) { | ||
throw _iteratorError5; | ||
} else { | ||
if (is.array(q)) { | ||
r = q.map(function (e) { | ||
return unmap(e, fs); | ||
}); | ||
} else { | ||
r = fs[q][1]; | ||
} | ||
} | ||
} | ||
} else { | ||
if (is.array(q)) { | ||
r = q.map(function (e) { | ||
return unmap(e, fs); | ||
}); | ||
} else { | ||
r = fs[q][1]; | ||
} | ||
} | ||
return r; | ||
} | ||
return r; | ||
function biconditional(a, b) { | ||
return !!a ^ !!b ? false : true; | ||
} | ||
function biconditional(a, b) { | ||
return !!a ^ !!b ? false : true; | ||
} // Decode query key from ' $foo' -> '$foo'. Encoding allows to refer to document | ||
// Decode query key from ' $foo' -> '$foo'. Encoding allows to refer to document | ||
// attributes which would conflict with ops. | ||
function decoded(qk) { | ||
var r = qk; | ||
var trim = false; | ||
loop: for (var i = 0; i < qk.length; i++) { | ||
switch (qk[i]) { | ||
case ' ': | ||
trim = true; | ||
continue loop; | ||
function decoded(qk) { | ||
var r = qk; | ||
var trim = false; | ||
case '$': | ||
if (trim) { | ||
r = qk.substr(1); | ||
} | ||
break loop; | ||
loop: for (var i = 0; i < qk.length; i++) { | ||
switch (qk[i]) { | ||
case ' ': | ||
trim = true; | ||
continue loop; | ||
case '$': | ||
if (trim) { | ||
r = qk.substr(1); | ||
default: | ||
break loop; | ||
} | ||
} | ||
break loop; | ||
return r; | ||
} | ||
default: | ||
break loop; | ||
// Arrize path by splitting 'foo.bar' -> [ 'foo', 'bar' ], unless string starts | ||
// with ' ' then ' foo.bar' -> [ 'foo.bar' ]. | ||
function split(a) { | ||
var r = undefined; | ||
if (a[0] === ' ') { | ||
r = [a.substring(1)]; | ||
} else { | ||
r = a.split('.'); | ||
} | ||
} | ||
return r; | ||
} | ||
return r; | ||
} // Arrize path by splitting 'foo.bar' -> [ 'foo', 'bar' ], unless string starts | ||
// with ' ' then ' foo.bar' -> [ 'foo.bar' ]. | ||
// Resolve key path on an object. | ||
function resolve(a, path) { | ||
var stack = split(path); | ||
var last = []; | ||
if (stack.length > 0) { | ||
last.unshift(stack.pop()); | ||
} | ||
function split(a) { | ||
var r = undefined; | ||
var k = undefined; | ||
var e = a; | ||
if (!is.none(e)) { | ||
while (!is.none(k = stack.shift())) { | ||
if (!is.none(e[k])) { | ||
e = e[k]; | ||
} else { | ||
stack.unshift(k); | ||
break; | ||
} | ||
} | ||
} | ||
if (a[0] === ' ') { | ||
r = [a.substring(1)]; | ||
} else { | ||
r = a.split('.'); | ||
} | ||
// Pull all unresolved components into last. | ||
while (!is.none(k = stack.pop())) { | ||
last.unshift(k); | ||
} | ||
return r; | ||
} // Resolve key path on an object. | ||
return [e, last]; | ||
} | ||
function arrize(a) { | ||
return Array.isArray(a) ? a : [a]; | ||
} | ||
function resolve(a, path) { | ||
var stack = split(path); | ||
var last = []; | ||
function kvs(a) { | ||
var _iteratorNormalCompletion7, _didIteratorError7, _iteratorError7, _iterator7, _step7, k; | ||
if (stack.length > 0) { | ||
last.unshift(stack.pop()); | ||
} | ||
return _regenerator2.default.wrap(function kvs$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (!is.object(a)) { | ||
_context.next = 28; | ||
break; | ||
} | ||
var k = undefined; | ||
var e = a; | ||
_iteratorNormalCompletion7 = true; | ||
_didIteratorError7 = false; | ||
_iteratorError7 = undefined; | ||
_context.prev = 4; | ||
_iterator7 = Object.keys(a)[Symbol.iterator](); | ||
if (!is.none(e)) { | ||
while (!is.none(k = stack.shift())) { | ||
if (!is.none(e[k])) { | ||
e = e[k]; | ||
} else { | ||
stack.unshift(k); | ||
break; | ||
} | ||
} | ||
} // Pull all unresolved components into last. | ||
case 6: | ||
if (_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done) { | ||
_context.next = 14; | ||
break; | ||
} | ||
k = _step7.value; | ||
while (!is.none(k = stack.pop())) { | ||
last.unshift(k); | ||
} | ||
if (!a.hasOwnProperty(k)) { | ||
_context.next = 11; | ||
break; | ||
} | ||
return [e, last]; | ||
} | ||
_context.next = 11; | ||
return [k, a[k]]; | ||
function arrize(a) { | ||
return Array.isArray(a) ? a : [a]; | ||
} | ||
case 11: | ||
_iteratorNormalCompletion7 = true; | ||
_context.next = 6; | ||
break; | ||
function kvs(a) { | ||
var _arr2, _i3, k; | ||
case 14: | ||
_context.next = 20; | ||
break; | ||
return _regenerator.default.wrap(function kvs$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (!is.object(a)) { | ||
_context.next = 11; | ||
break; | ||
} | ||
case 16: | ||
_context.prev = 16; | ||
_context.t0 = _context['catch'](4); | ||
_didIteratorError7 = true; | ||
_iteratorError7 = _context.t0; | ||
_arr2 = (0, _keys.default)(a); | ||
_i3 = 0; | ||
case 20: | ||
_context.prev = 20; | ||
_context.prev = 21; | ||
case 3: | ||
if (!(_i3 < _arr2.length)) { | ||
_context.next = 11; | ||
break; | ||
} | ||
if (!_iteratorNormalCompletion7 && _iterator7.return) { | ||
_iterator7.return(); | ||
} | ||
k = _arr2[_i3]; | ||
case 23: | ||
_context.prev = 23; | ||
if (!a.hasOwnProperty(k)) { | ||
_context.next = 8; | ||
break; | ||
} | ||
if (!_didIteratorError7) { | ||
_context.next = 26; | ||
break; | ||
} | ||
_context.next = 8; | ||
return [k, a[k]]; | ||
throw _iteratorError7; | ||
case 8: | ||
_i3++; | ||
_context.next = 3; | ||
break; | ||
case 26: | ||
return _context.finish(23); | ||
case 11: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _marked, this); | ||
case 27: | ||
return _context.finish(20); | ||
case 28: | ||
case 'end': | ||
return _context.stop(); | ||
} | ||
} | ||
}, _marked, this, [[4, 16, 20, 28], [21,, 23, 27]]); | ||
} |
{ | ||
"name": "@theledger/couchdb-query-engine", | ||
"version": "2.3.2", | ||
"version": "2.4.0", | ||
"description": "Evaluate and filters criteria queries on JSON objects MongoDB style", | ||
@@ -10,5 +10,5 @@ "main": "./lib/index.js", | ||
"test:prod": "cross-env BABEL_ENV=production npm run test", | ||
"test:only": "mocha --require @babel/register --require @babel/polyfill --recursive", | ||
"test:only": "mocha --require babel-core/register --require babel-polyfill --recursive", | ||
"test:watch": "npm test -- --watch", | ||
"cover": "istanbul cover _mocha -- --require @babel/register --require @babel/polyfill --recursive", | ||
"cover": "istanbul cover _mocha -- --require babel-core/register --require babel-polyfill --recursive", | ||
"lint": "eslint src test", | ||
@@ -41,13 +41,13 @@ "lint:fix": "eslint src test --fix", | ||
"homepage": "https://github.com/wearetheledger/node-couchdb-query-engine#readme", | ||
"dependencies": {}, | ||
"dependencies": { | ||
"babel-runtime": "^6.26.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.0.0-beta.40", | ||
"@babel/core": "^7.0.0-beta.40", | ||
"@babel/plugin-transform-regenerator": "^7.0.0-beta.40", | ||
"@babel/plugin-transform-runtime": "^7.0.0-beta.40", | ||
"@babel/polyfill": "^7.0.0-beta.40", | ||
"@babel/preset-env": "^7.0.0-beta.40", | ||
"@babel/register": "^7.0.0-beta.40", | ||
"babel-cli": "^6.26.0", | ||
"babel-eslint": "^8.2.1", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-polyfill": "^6.26.0", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-minify": "^0.3.0", | ||
"chai": "^4.1.2", | ||
@@ -54,0 +54,0 @@ "cross-env": "^5.1.3", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
97873
17
1
2958
+ Addedbabel-runtime@^6.26.0
+ Addedbabel-runtime@6.26.0(transitive)
+ Addedcore-js@2.6.12(transitive)
+ Addedregenerator-runtime@0.11.1(transitive)