jexidb 1.0.8 → 2.0.0
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/LICENSE +2 -2
- package/README.md +556 -127
- package/dist/FileHandler.js +688 -0
- package/dist/IndexManager.js +353 -0
- package/dist/IntegrityChecker.js +364 -0
- package/dist/JSONLDatabase.js +1132 -0
- package/dist/index.js +598 -0
- package/package.json +65 -59
- package/src/FileHandler.js +674 -0
- package/src/IndexManager.js +363 -0
- package/src/IntegrityChecker.js +379 -0
- package/src/JSONLDatabase.js +1189 -0
- package/src/index.js +594 -0
- package/.gitattributes +0 -2
- package/babel.config.json +0 -5
- package/dist/Database.cjs +0 -1085
- package/src/Database.mjs +0 -376
- package/src/FileHandler.mjs +0 -202
- package/src/IndexManager.mjs +0 -230
- package/src/Serializer.mjs +0 -120
- package/test/README.md +0 -13
- package/test/test-json-compressed.jdb +0 -0
- package/test/test-json.jdb +0 -0
- package/test/test-v8-compressed.jdb +0 -0
- package/test/test-v8.jdb +0 -0
- package/test/test.mjs +0 -168
package/dist/Database.cjs
DELETED
|
@@ -1,1085 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Database = void 0;
|
|
7
|
-
var _events = require("events");
|
|
8
|
-
var _FileHandler = _interopRequireDefault(require("./FileHandler.mjs"));
|
|
9
|
-
var _IndexManager = _interopRequireDefault(require("./IndexManager.mjs"));
|
|
10
|
-
var _Serializer = _interopRequireDefault(require("./Serializer.mjs"));
|
|
11
|
-
var _asyncMutex = require("async-mutex");
|
|
12
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
13
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
14
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
15
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
16
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
17
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
18
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
19
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
20
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
21
|
-
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
22
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
23
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
24
|
-
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
25
|
-
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
26
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
27
|
-
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
28
|
-
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
29
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
30
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
31
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
32
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
33
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
34
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
35
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
36
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
37
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
38
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
39
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
40
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
41
|
-
function _awaitAsyncGenerator(e) { return new _OverloadYield(e, 0); }
|
|
42
|
-
function _wrapAsyncGenerator(e) { return function () { return new AsyncGenerator(e.apply(this, arguments)); }; }
|
|
43
|
-
function AsyncGenerator(e) { var r, t; function resume(r, t) { try { var n = e[r](t), o = n.value, u = o instanceof _OverloadYield; Promise.resolve(u ? o.v : o).then(function (t) { if (u) { var i = "return" === r ? "return" : "next"; if (!o.k || t.done) return resume(i, t); t = e[i](t).value; } settle(n.done ? "return" : "normal", t); }, function (e) { resume("throw", e); }); } catch (e) { settle("throw", e); } } function settle(e, n) { switch (e) { case "return": r.resolve({ value: n, done: !0 }); break; case "throw": r.reject(n); break; default: r.resolve({ value: n, done: !1 }); } (r = r.next) ? resume(r.key, r.arg) : t = null; } this._invoke = function (e, n) { return new Promise(function (o, u) { var i = { key: e, arg: n, resolve: o, reject: u, next: null }; t ? t = t.next = i : (r = t = i, resume(e, n)); }); }, "function" != typeof e["return"] && (this["return"] = void 0); }
|
|
44
|
-
AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function () { return this; }, AsyncGenerator.prototype.next = function (e) { return this._invoke("next", e); }, AsyncGenerator.prototype["throw"] = function (e) { return this._invoke("throw", e); }, AsyncGenerator.prototype["return"] = function (e) { return this._invoke("return", e); };
|
|
45
|
-
function _OverloadYield(e, d) { this.v = e, this.k = d; }
|
|
46
|
-
function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
|
|
47
|
-
function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(r) { var n = this.s["return"]; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, "throw": function _throw(r) { var n = this.s["return"]; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); }
|
|
48
|
-
var Database = exports.Database = /*#__PURE__*/function (_EventEmitter) {
|
|
49
|
-
function Database(file) {
|
|
50
|
-
var _this2;
|
|
51
|
-
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
52
|
-
_classCallCheck(this, Database);
|
|
53
|
-
_this2 = _callSuper(this, Database);
|
|
54
|
-
_this2.opts = Object.assign({
|
|
55
|
-
v8: false,
|
|
56
|
-
index: {
|
|
57
|
-
data: {}
|
|
58
|
-
},
|
|
59
|
-
indexes: {},
|
|
60
|
-
compress: false,
|
|
61
|
-
compressIndex: false,
|
|
62
|
-
maxMemoryUsage: 64 * 1024 // 64KB
|
|
63
|
-
}, opts);
|
|
64
|
-
_this2.offsets = [];
|
|
65
|
-
_this2.shouldSave = false;
|
|
66
|
-
_this2.serializer = new _Serializer["default"](_this2.opts);
|
|
67
|
-
_this2.fileHandler = new _FileHandler["default"](file);
|
|
68
|
-
_this2.indexManager = new _IndexManager["default"](_this2.opts);
|
|
69
|
-
_this2.indexOffset = 0;
|
|
70
|
-
_this2.writeBuffer = [];
|
|
71
|
-
_this2.mutex = new _asyncMutex.Mutex();
|
|
72
|
-
return _this2;
|
|
73
|
-
}
|
|
74
|
-
_inherits(Database, _EventEmitter);
|
|
75
|
-
return _createClass(Database, [{
|
|
76
|
-
key: "use",
|
|
77
|
-
value: function use(plugin) {
|
|
78
|
-
if (this.destroyed) throw new Error('Database is destroyed');
|
|
79
|
-
plugin(this);
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "init",
|
|
83
|
-
value: function () {
|
|
84
|
-
var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
85
|
-
var _this3 = this;
|
|
86
|
-
var _this$fileHandler, lastLine, offsets, ptr, indexLine, index;
|
|
87
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
88
|
-
while (1) switch (_context.prev = _context.next) {
|
|
89
|
-
case 0:
|
|
90
|
-
if (!this.destroyed) {
|
|
91
|
-
_context.next = 2;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
throw new Error('Database is destroyed');
|
|
95
|
-
case 2:
|
|
96
|
-
if (!this.initialized) {
|
|
97
|
-
_context.next = 4;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
return _context.abrupt("return");
|
|
101
|
-
case 4:
|
|
102
|
-
if (!this.initlializing) {
|
|
103
|
-
_context.next = 8;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
_context.next = 7;
|
|
107
|
-
return new Promise(function (resolve) {
|
|
108
|
-
return _this3.once('init', resolve);
|
|
109
|
-
});
|
|
110
|
-
case 7:
|
|
111
|
-
return _context.abrupt("return", _context.sent);
|
|
112
|
-
case 8:
|
|
113
|
-
this.initializing = true;
|
|
114
|
-
_context.prev = 9;
|
|
115
|
-
if (!this.opts.clear) {
|
|
116
|
-
_context.next = 14;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
_context.next = 13;
|
|
120
|
-
return this.fileHandler.truncate(0)["catch"](console.error);
|
|
121
|
-
case 13:
|
|
122
|
-
throw new Error('Cleared, empty file');
|
|
123
|
-
case 14:
|
|
124
|
-
_context.next = 16;
|
|
125
|
-
return this.fileHandler.readLastLine();
|
|
126
|
-
case 16:
|
|
127
|
-
lastLine = _context.sent;
|
|
128
|
-
if (!(!lastLine || !lastLine.length)) {
|
|
129
|
-
_context.next = 19;
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
throw new Error('File does not exists or is a empty file');
|
|
133
|
-
case 19:
|
|
134
|
-
_context.next = 21;
|
|
135
|
-
return this.serializer.deserialize(lastLine, {
|
|
136
|
-
compress: this.opts.compressIndex
|
|
137
|
-
});
|
|
138
|
-
case 21:
|
|
139
|
-
offsets = _context.sent;
|
|
140
|
-
if (Array.isArray(offsets)) {
|
|
141
|
-
_context.next = 24;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
throw new Error('File to parse offsets, expected an array');
|
|
145
|
-
case 24:
|
|
146
|
-
this.indexOffset = offsets[offsets.length - 2];
|
|
147
|
-
this.offsets = offsets;
|
|
148
|
-
ptr = this.locate(offsets.length - 2);
|
|
149
|
-
this.offsets = this.offsets.slice(0, -2);
|
|
150
|
-
this.shouldTruncate = true;
|
|
151
|
-
_context.next = 31;
|
|
152
|
-
return (_this$fileHandler = this.fileHandler).readRange.apply(_this$fileHandler, _toConsumableArray(ptr));
|
|
153
|
-
case 31:
|
|
154
|
-
indexLine = _context.sent;
|
|
155
|
-
_context.next = 34;
|
|
156
|
-
return this.serializer.deserialize(indexLine, {
|
|
157
|
-
compress: this.opts.compressIndex
|
|
158
|
-
});
|
|
159
|
-
case 34:
|
|
160
|
-
index = _context.sent;
|
|
161
|
-
index && this.indexManager.load(index);
|
|
162
|
-
_context.next = 43;
|
|
163
|
-
break;
|
|
164
|
-
case 38:
|
|
165
|
-
_context.prev = 38;
|
|
166
|
-
_context.t0 = _context["catch"](9);
|
|
167
|
-
if (Array.isArray(this.offsets)) {
|
|
168
|
-
this.offsets = [];
|
|
169
|
-
}
|
|
170
|
-
this.indexOffset = 0;
|
|
171
|
-
if (!String(_context.t0).includes('empty file')) {
|
|
172
|
-
console.error('Error loading database:', _context.t0);
|
|
173
|
-
}
|
|
174
|
-
case 43:
|
|
175
|
-
_context.prev = 43;
|
|
176
|
-
this.initializing = false;
|
|
177
|
-
this.initialized = true;
|
|
178
|
-
this.emit('init');
|
|
179
|
-
return _context.finish(43);
|
|
180
|
-
case 48:
|
|
181
|
-
case "end":
|
|
182
|
-
return _context.stop();
|
|
183
|
-
}
|
|
184
|
-
}, _callee, this, [[9, 38, 43, 48]]);
|
|
185
|
-
}));
|
|
186
|
-
function init() {
|
|
187
|
-
return _init.apply(this, arguments);
|
|
188
|
-
}
|
|
189
|
-
return init;
|
|
190
|
-
}()
|
|
191
|
-
}, {
|
|
192
|
-
key: "save",
|
|
193
|
-
value: function () {
|
|
194
|
-
var _save = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
195
|
-
var _this4 = this;
|
|
196
|
-
var index, field, term, offsets, indexString, _field, _term, offsetsString;
|
|
197
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
198
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
199
|
-
case 0:
|
|
200
|
-
if (!this.destroyed) {
|
|
201
|
-
_context2.next = 2;
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
throw new Error('Database is destroyed');
|
|
205
|
-
case 2:
|
|
206
|
-
if (this.initialized) {
|
|
207
|
-
_context2.next = 4;
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
throw new Error('Database not initialized');
|
|
211
|
-
case 4:
|
|
212
|
-
if (!this.saving) {
|
|
213
|
-
_context2.next = 6;
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
return _context2.abrupt("return", new Promise(function (resolve) {
|
|
217
|
-
return _this4.once('save', resolve);
|
|
218
|
-
}));
|
|
219
|
-
case 6:
|
|
220
|
-
this.saving = true;
|
|
221
|
-
_context2.next = 9;
|
|
222
|
-
return this.flush();
|
|
223
|
-
case 9:
|
|
224
|
-
if (this.shouldSave) {
|
|
225
|
-
_context2.next = 11;
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
228
|
-
return _context2.abrupt("return");
|
|
229
|
-
case 11:
|
|
230
|
-
this.emit('before-save');
|
|
231
|
-
index = Object.assign({
|
|
232
|
-
data: {}
|
|
233
|
-
}, this.indexManager.index);
|
|
234
|
-
for (field in this.indexManager.index.data) {
|
|
235
|
-
for (term in this.indexManager.index.data[field]) {
|
|
236
|
-
index.data[field][term] = _toConsumableArray(this.indexManager.index.data[field][term]); // set to array
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
offsets = this.offsets.slice(0);
|
|
240
|
-
_context2.next = 17;
|
|
241
|
-
return this.serializer.serialize(index, {
|
|
242
|
-
compress: this.opts.compressIndex,
|
|
243
|
-
linebreak: true
|
|
244
|
-
});
|
|
245
|
-
case 17:
|
|
246
|
-
indexString = _context2.sent;
|
|
247
|
-
// force linebreak here to allow 'init' to read last line as offsets correctly
|
|
248
|
-
for (_field in this.indexManager.index.data) {
|
|
249
|
-
for (_term in this.indexManager.index.data[_field]) {
|
|
250
|
-
this.indexManager.index.data[_field][_term] = new Set(index.data[_field][_term]); // set back to set because of serialization
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
offsets.push(this.indexOffset);
|
|
254
|
-
offsets.push(this.indexOffset + indexString.length);
|
|
255
|
-
// save offsets as JSON always to prevent linebreaks on last line, which breaks 'init()'
|
|
256
|
-
_context2.next = 23;
|
|
257
|
-
return this.serializer.serialize(offsets, {
|
|
258
|
-
json: true,
|
|
259
|
-
compress: false,
|
|
260
|
-
linebreak: false
|
|
261
|
-
});
|
|
262
|
-
case 23:
|
|
263
|
-
offsetsString = _context2.sent;
|
|
264
|
-
this.writeBuffer.push(indexString);
|
|
265
|
-
this.writeBuffer.push(offsetsString);
|
|
266
|
-
_context2.next = 28;
|
|
267
|
-
return this.flush();
|
|
268
|
-
case 28:
|
|
269
|
-
// write the index and offsets
|
|
270
|
-
this.shouldTruncate = true;
|
|
271
|
-
this.shouldSave = false;
|
|
272
|
-
this.saving = false;
|
|
273
|
-
this.emit('save');
|
|
274
|
-
case 32:
|
|
275
|
-
case "end":
|
|
276
|
-
return _context2.stop();
|
|
277
|
-
}
|
|
278
|
-
}, _callee2, this);
|
|
279
|
-
}));
|
|
280
|
-
function save() {
|
|
281
|
-
return _save.apply(this, arguments);
|
|
282
|
-
}
|
|
283
|
-
return save;
|
|
284
|
-
}()
|
|
285
|
-
}, {
|
|
286
|
-
key: "ready",
|
|
287
|
-
value: function () {
|
|
288
|
-
var _ready = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
289
|
-
var _this5 = this;
|
|
290
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
291
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
292
|
-
case 0:
|
|
293
|
-
if (this.initialized) {
|
|
294
|
-
_context3.next = 3;
|
|
295
|
-
break;
|
|
296
|
-
}
|
|
297
|
-
_context3.next = 3;
|
|
298
|
-
return new Promise(function (resolve) {
|
|
299
|
-
return _this5.once('init', resolve);
|
|
300
|
-
});
|
|
301
|
-
case 3:
|
|
302
|
-
case "end":
|
|
303
|
-
return _context3.stop();
|
|
304
|
-
}
|
|
305
|
-
}, _callee3, this);
|
|
306
|
-
}));
|
|
307
|
-
function ready() {
|
|
308
|
-
return _ready.apply(this, arguments);
|
|
309
|
-
}
|
|
310
|
-
return ready;
|
|
311
|
-
}()
|
|
312
|
-
}, {
|
|
313
|
-
key: "locate",
|
|
314
|
-
value: function locate(n) {
|
|
315
|
-
if (this.offsets[n] === undefined) {
|
|
316
|
-
if (this.offsets[n - 1]) {
|
|
317
|
-
return [this.indexOffset, Number.MAX_SAFE_INTEGER];
|
|
318
|
-
}
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
var end = this.offsets[n + 1] || this.indexOffset || Number.MAX_SAFE_INTEGER;
|
|
322
|
-
return [this.offsets[n], end];
|
|
323
|
-
}
|
|
324
|
-
}, {
|
|
325
|
-
key: "getRanges",
|
|
326
|
-
value: function getRanges(map) {
|
|
327
|
-
var _this6 = this;
|
|
328
|
-
return (map || Array.from(this.offsets.keys())).map(function (n) {
|
|
329
|
-
var ret = _this6.locate(n);
|
|
330
|
-
if (ret !== undefined) return {
|
|
331
|
-
start: ret[0],
|
|
332
|
-
end: ret[1],
|
|
333
|
-
index: n
|
|
334
|
-
};
|
|
335
|
-
}).filter(function (n) {
|
|
336
|
-
return n !== undefined;
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
}, {
|
|
340
|
-
key: "readLines",
|
|
341
|
-
value: function () {
|
|
342
|
-
var _readLines = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(map, ranges) {
|
|
343
|
-
var results, i, start;
|
|
344
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
345
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
346
|
-
case 0:
|
|
347
|
-
if (!ranges) ranges = this.getRanges(map);
|
|
348
|
-
_context4.next = 3;
|
|
349
|
-
return this.fileHandler.readRanges(ranges, this.serializer.deserialize.bind(this.serializer));
|
|
350
|
-
case 3:
|
|
351
|
-
results = _context4.sent;
|
|
352
|
-
i = 0;
|
|
353
|
-
_context4.t0 = _regeneratorRuntime().keys(results);
|
|
354
|
-
case 6:
|
|
355
|
-
if ((_context4.t1 = _context4.t0()).done) {
|
|
356
|
-
_context4.next = 14;
|
|
357
|
-
break;
|
|
358
|
-
}
|
|
359
|
-
start = _context4.t1.value;
|
|
360
|
-
if (!(!results[start] || results[start]._ !== undefined)) {
|
|
361
|
-
_context4.next = 10;
|
|
362
|
-
break;
|
|
363
|
-
}
|
|
364
|
-
return _context4.abrupt("continue", 6);
|
|
365
|
-
case 10:
|
|
366
|
-
while (this.offsets[i] != start && i < map.length) i++; // weak comparison as 'start' is a string
|
|
367
|
-
results[start]._ = map[i++];
|
|
368
|
-
_context4.next = 6;
|
|
369
|
-
break;
|
|
370
|
-
case 14:
|
|
371
|
-
return _context4.abrupt("return", Object.values(results).filter(function (r) {
|
|
372
|
-
return r !== undefined;
|
|
373
|
-
}));
|
|
374
|
-
case 15:
|
|
375
|
-
case "end":
|
|
376
|
-
return _context4.stop();
|
|
377
|
-
}
|
|
378
|
-
}, _callee4, this);
|
|
379
|
-
}));
|
|
380
|
-
function readLines(_x, _x2) {
|
|
381
|
-
return _readLines.apply(this, arguments);
|
|
382
|
-
}
|
|
383
|
-
return readLines;
|
|
384
|
-
}()
|
|
385
|
-
}, {
|
|
386
|
-
key: "insert",
|
|
387
|
-
value: function () {
|
|
388
|
-
var _insert = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(data) {
|
|
389
|
-
var line, position;
|
|
390
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
391
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
392
|
-
case 0:
|
|
393
|
-
if (!this.destroyed) {
|
|
394
|
-
_context5.next = 2;
|
|
395
|
-
break;
|
|
396
|
-
}
|
|
397
|
-
throw new Error('Database is destroyed');
|
|
398
|
-
case 2:
|
|
399
|
-
if (this.initialized) {
|
|
400
|
-
_context5.next = 5;
|
|
401
|
-
break;
|
|
402
|
-
}
|
|
403
|
-
_context5.next = 5;
|
|
404
|
-
return this.init();
|
|
405
|
-
case 5:
|
|
406
|
-
if (this.shouldTruncate) {
|
|
407
|
-
this.writeBuffer.push(this.indexOffset);
|
|
408
|
-
this.shouldTruncate = false;
|
|
409
|
-
}
|
|
410
|
-
_context5.next = 8;
|
|
411
|
-
return this.serializer.serialize(data, {
|
|
412
|
-
compress: this.opts.compress,
|
|
413
|
-
v8: this.opts.v8
|
|
414
|
-
});
|
|
415
|
-
case 8:
|
|
416
|
-
line = _context5.sent;
|
|
417
|
-
// using Buffer for offsets accuracy
|
|
418
|
-
position = this.offsets.length;
|
|
419
|
-
this.offsets.push(this.indexOffset);
|
|
420
|
-
this.indexOffset += line.length;
|
|
421
|
-
this.emit('insert', data, position);
|
|
422
|
-
this.writeBuffer.push(line);
|
|
423
|
-
if (!(!this.flushing && this.currentWriteBufferSize() > this.opts.maxMemoryUsage)) {
|
|
424
|
-
_context5.next = 17;
|
|
425
|
-
break;
|
|
426
|
-
}
|
|
427
|
-
_context5.next = 17;
|
|
428
|
-
return this.flush();
|
|
429
|
-
case 17:
|
|
430
|
-
this.indexManager.add(data, position);
|
|
431
|
-
this.shouldSave = true;
|
|
432
|
-
case 19:
|
|
433
|
-
case "end":
|
|
434
|
-
return _context5.stop();
|
|
435
|
-
}
|
|
436
|
-
}, _callee5, this);
|
|
437
|
-
}));
|
|
438
|
-
function insert(_x3) {
|
|
439
|
-
return _insert.apply(this, arguments);
|
|
440
|
-
}
|
|
441
|
-
return insert;
|
|
442
|
-
}()
|
|
443
|
-
}, {
|
|
444
|
-
key: "currentWriteBufferSize",
|
|
445
|
-
value: function currentWriteBufferSize() {
|
|
446
|
-
var lengths = this.writeBuffer.filter(function (b) {
|
|
447
|
-
return Buffer.isBuffer(b);
|
|
448
|
-
}).map(function (b) {
|
|
449
|
-
return b.length;
|
|
450
|
-
});
|
|
451
|
-
return lengths.reduce(function (a, b) {
|
|
452
|
-
return a + b;
|
|
453
|
-
}, 0);
|
|
454
|
-
}
|
|
455
|
-
}, {
|
|
456
|
-
key: "flush",
|
|
457
|
-
value: function flush() {
|
|
458
|
-
var _this7 = this;
|
|
459
|
-
if (this.flushing) {
|
|
460
|
-
return this.flushing;
|
|
461
|
-
}
|
|
462
|
-
return this.flushing = new Promise(function (resolve, reject) {
|
|
463
|
-
if (_this7.destroyed) return reject(new Error('Database is destroyed'));
|
|
464
|
-
if (!_this7.writeBuffer.length) return resolve();
|
|
465
|
-
var err;
|
|
466
|
-
_this7._flush()["catch"](function (e) {
|
|
467
|
-
return err = e;
|
|
468
|
-
})["finally"](function () {
|
|
469
|
-
err ? reject(err) : resolve();
|
|
470
|
-
_this7.flushing = false;
|
|
471
|
-
});
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
}, {
|
|
475
|
-
key: "_flush",
|
|
476
|
-
value: function () {
|
|
477
|
-
var _flush2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
478
|
-
var release, fd, data, pos, err;
|
|
479
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
480
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
481
|
-
case 0:
|
|
482
|
-
_context6.next = 2;
|
|
483
|
-
return this.mutex.acquire();
|
|
484
|
-
case 2:
|
|
485
|
-
release = _context6.sent;
|
|
486
|
-
_context6.next = 5;
|
|
487
|
-
return _fs["default"].promises.open(this.fileHandler.file, 'a');
|
|
488
|
-
case 5:
|
|
489
|
-
fd = _context6.sent;
|
|
490
|
-
_context6.prev = 6;
|
|
491
|
-
case 7:
|
|
492
|
-
if (!this.writeBuffer.length) {
|
|
493
|
-
_context6.next = 26;
|
|
494
|
-
break;
|
|
495
|
-
}
|
|
496
|
-
data = void 0;
|
|
497
|
-
pos = this.writeBuffer.findIndex(function (b) {
|
|
498
|
-
return typeof b === 'number';
|
|
499
|
-
});
|
|
500
|
-
if (!(pos === 0)) {
|
|
501
|
-
_context6.next = 21;
|
|
502
|
-
break;
|
|
503
|
-
}
|
|
504
|
-
_context6.next = 13;
|
|
505
|
-
return fd.close();
|
|
506
|
-
case 13:
|
|
507
|
-
_context6.next = 15;
|
|
508
|
-
return this.fileHandler.truncate(this.writeBuffer.shift());
|
|
509
|
-
case 15:
|
|
510
|
-
_context6.next = 17;
|
|
511
|
-
return _fs["default"].promises.open(this.fileHandler.file, 'a');
|
|
512
|
-
case 17:
|
|
513
|
-
fd = _context6.sent;
|
|
514
|
-
return _context6.abrupt("continue", 7);
|
|
515
|
-
case 21:
|
|
516
|
-
if (pos === -1) {
|
|
517
|
-
data = Buffer.concat(this.writeBuffer);
|
|
518
|
-
this.writeBuffer.length = 0;
|
|
519
|
-
} else {
|
|
520
|
-
data = Buffer.concat(this.writeBuffer.slice(0, pos));
|
|
521
|
-
this.writeBuffer.splice(0, pos);
|
|
522
|
-
}
|
|
523
|
-
case 22:
|
|
524
|
-
_context6.next = 24;
|
|
525
|
-
return fd.write(data);
|
|
526
|
-
case 24:
|
|
527
|
-
_context6.next = 7;
|
|
528
|
-
break;
|
|
529
|
-
case 26:
|
|
530
|
-
this.shouldSave = true;
|
|
531
|
-
_context6.next = 32;
|
|
532
|
-
break;
|
|
533
|
-
case 29:
|
|
534
|
-
_context6.prev = 29;
|
|
535
|
-
_context6.t0 = _context6["catch"](6);
|
|
536
|
-
console.error('Error flushing:', _context6.t0);
|
|
537
|
-
case 32:
|
|
538
|
-
_context6.prev = 32;
|
|
539
|
-
_context6.next = 35;
|
|
540
|
-
return fd.close()["catch"](function (e) {
|
|
541
|
-
return err = e;
|
|
542
|
-
});
|
|
543
|
-
case 35:
|
|
544
|
-
release();
|
|
545
|
-
err && console.error('Error closing file:', err);
|
|
546
|
-
return _context6.finish(32);
|
|
547
|
-
case 38:
|
|
548
|
-
case "end":
|
|
549
|
-
return _context6.stop();
|
|
550
|
-
}
|
|
551
|
-
}, _callee6, this, [[6, 29, 32, 38]]);
|
|
552
|
-
}));
|
|
553
|
-
function _flush() {
|
|
554
|
-
return _flush2.apply(this, arguments);
|
|
555
|
-
}
|
|
556
|
-
return _flush;
|
|
557
|
-
}()
|
|
558
|
-
}, {
|
|
559
|
-
key: "walk",
|
|
560
|
-
value: function walk(map) {
|
|
561
|
-
var _this = this;
|
|
562
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
563
|
-
return _wrapAsyncGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
564
|
-
var ranges, groupedRanges, fd, _iterator2, _step2, groupedRange, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, row, entry;
|
|
565
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
566
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
567
|
-
case 0:
|
|
568
|
-
if (!_this.destroyed) {
|
|
569
|
-
_context7.next = 2;
|
|
570
|
-
break;
|
|
571
|
-
}
|
|
572
|
-
throw new Error('Database is destroyed');
|
|
573
|
-
case 2:
|
|
574
|
-
if (_this.initialized) {
|
|
575
|
-
_context7.next = 5;
|
|
576
|
-
break;
|
|
577
|
-
}
|
|
578
|
-
_context7.next = 5;
|
|
579
|
-
return _awaitAsyncGenerator(_this.init());
|
|
580
|
-
case 5:
|
|
581
|
-
_context7.t0 = _this.shouldSave;
|
|
582
|
-
if (!_context7.t0) {
|
|
583
|
-
_context7.next = 9;
|
|
584
|
-
break;
|
|
585
|
-
}
|
|
586
|
-
_context7.next = 9;
|
|
587
|
-
return _awaitAsyncGenerator(_this.save()["catch"](console.error));
|
|
588
|
-
case 9:
|
|
589
|
-
if (!(_this.indexOffset === 0)) {
|
|
590
|
-
_context7.next = 11;
|
|
591
|
-
break;
|
|
592
|
-
}
|
|
593
|
-
return _context7.abrupt("return");
|
|
594
|
-
case 11:
|
|
595
|
-
if (!Array.isArray(map)) {
|
|
596
|
-
if (map instanceof Set) {
|
|
597
|
-
map = _toConsumableArray(map);
|
|
598
|
-
} else if (map && _typeof(map) === 'object') {
|
|
599
|
-
map = _toConsumableArray(_this.indexManager.query(map, options));
|
|
600
|
-
} else {
|
|
601
|
-
map = _toConsumableArray(Array(_this.offsets.length).keys());
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
ranges = _this.getRanges(map);
|
|
605
|
-
_context7.next = 15;
|
|
606
|
-
return _awaitAsyncGenerator(_this.fileHandler.groupedRanges(ranges));
|
|
607
|
-
case 15:
|
|
608
|
-
groupedRanges = _context7.sent;
|
|
609
|
-
_context7.next = 18;
|
|
610
|
-
return _awaitAsyncGenerator(_fs["default"].promises.open(_this.fileHandler.file, 'r'));
|
|
611
|
-
case 18:
|
|
612
|
-
fd = _context7.sent;
|
|
613
|
-
_context7.prev = 19;
|
|
614
|
-
_iterator2 = _createForOfIteratorHelper(groupedRanges);
|
|
615
|
-
_context7.prev = 21;
|
|
616
|
-
_iterator2.s();
|
|
617
|
-
case 23:
|
|
618
|
-
if ((_step2 = _iterator2.n()).done) {
|
|
619
|
-
_context7.next = 66;
|
|
620
|
-
break;
|
|
621
|
-
}
|
|
622
|
-
groupedRange = _step2.value;
|
|
623
|
-
_iteratorAbruptCompletion = false;
|
|
624
|
-
_didIteratorError = false;
|
|
625
|
-
_context7.prev = 27;
|
|
626
|
-
_iterator = _asyncIterator(_this.fileHandler.readGroupedRange(groupedRange, fd));
|
|
627
|
-
case 29:
|
|
628
|
-
_context7.next = 31;
|
|
629
|
-
return _awaitAsyncGenerator(_iterator.next());
|
|
630
|
-
case 31:
|
|
631
|
-
if (!(_iteratorAbruptCompletion = !(_step = _context7.sent).done)) {
|
|
632
|
-
_context7.next = 48;
|
|
633
|
-
break;
|
|
634
|
-
}
|
|
635
|
-
row = _step.value;
|
|
636
|
-
_context7.next = 35;
|
|
637
|
-
return _awaitAsyncGenerator(_this.serializer.deserialize(row.line, {
|
|
638
|
-
compress: _this.opts.compress,
|
|
639
|
-
v8: _this.opts.v8
|
|
640
|
-
}));
|
|
641
|
-
case 35:
|
|
642
|
-
entry = _context7.sent;
|
|
643
|
-
if (!(entry === null)) {
|
|
644
|
-
_context7.next = 38;
|
|
645
|
-
break;
|
|
646
|
-
}
|
|
647
|
-
return _context7.abrupt("continue", 45);
|
|
648
|
-
case 38:
|
|
649
|
-
if (!options.includeOffsets) {
|
|
650
|
-
_context7.next = 43;
|
|
651
|
-
break;
|
|
652
|
-
}
|
|
653
|
-
_context7.next = 41;
|
|
654
|
-
return {
|
|
655
|
-
entry: entry,
|
|
656
|
-
start: row.start
|
|
657
|
-
};
|
|
658
|
-
case 41:
|
|
659
|
-
_context7.next = 45;
|
|
660
|
-
break;
|
|
661
|
-
case 43:
|
|
662
|
-
_context7.next = 45;
|
|
663
|
-
return entry;
|
|
664
|
-
case 45:
|
|
665
|
-
_iteratorAbruptCompletion = false;
|
|
666
|
-
_context7.next = 29;
|
|
667
|
-
break;
|
|
668
|
-
case 48:
|
|
669
|
-
_context7.next = 54;
|
|
670
|
-
break;
|
|
671
|
-
case 50:
|
|
672
|
-
_context7.prev = 50;
|
|
673
|
-
_context7.t1 = _context7["catch"](27);
|
|
674
|
-
_didIteratorError = true;
|
|
675
|
-
_iteratorError = _context7.t1;
|
|
676
|
-
case 54:
|
|
677
|
-
_context7.prev = 54;
|
|
678
|
-
_context7.prev = 55;
|
|
679
|
-
if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
|
|
680
|
-
_context7.next = 59;
|
|
681
|
-
break;
|
|
682
|
-
}
|
|
683
|
-
_context7.next = 59;
|
|
684
|
-
return _awaitAsyncGenerator(_iterator["return"]());
|
|
685
|
-
case 59:
|
|
686
|
-
_context7.prev = 59;
|
|
687
|
-
if (!_didIteratorError) {
|
|
688
|
-
_context7.next = 62;
|
|
689
|
-
break;
|
|
690
|
-
}
|
|
691
|
-
throw _iteratorError;
|
|
692
|
-
case 62:
|
|
693
|
-
return _context7.finish(59);
|
|
694
|
-
case 63:
|
|
695
|
-
return _context7.finish(54);
|
|
696
|
-
case 64:
|
|
697
|
-
_context7.next = 23;
|
|
698
|
-
break;
|
|
699
|
-
case 66:
|
|
700
|
-
_context7.next = 71;
|
|
701
|
-
break;
|
|
702
|
-
case 68:
|
|
703
|
-
_context7.prev = 68;
|
|
704
|
-
_context7.t2 = _context7["catch"](21);
|
|
705
|
-
_iterator2.e(_context7.t2);
|
|
706
|
-
case 71:
|
|
707
|
-
_context7.prev = 71;
|
|
708
|
-
_iterator2.f();
|
|
709
|
-
return _context7.finish(71);
|
|
710
|
-
case 74:
|
|
711
|
-
_context7.prev = 74;
|
|
712
|
-
_context7.next = 77;
|
|
713
|
-
return _awaitAsyncGenerator(fd.close());
|
|
714
|
-
case 77:
|
|
715
|
-
return _context7.finish(74);
|
|
716
|
-
case 78:
|
|
717
|
-
case "end":
|
|
718
|
-
return _context7.stop();
|
|
719
|
-
}
|
|
720
|
-
}, _callee7, null, [[19,, 74, 78], [21, 68, 71, 74], [27, 50, 54, 64], [55,, 59, 63]]);
|
|
721
|
-
}))();
|
|
722
|
-
}
|
|
723
|
-
}, {
|
|
724
|
-
key: "query",
|
|
725
|
-
value: function () {
|
|
726
|
-
var _query = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(criteria) {
|
|
727
|
-
var options,
|
|
728
|
-
results,
|
|
729
|
-
_options$orderBy$spli,
|
|
730
|
-
_options$orderBy$spli2,
|
|
731
|
-
field,
|
|
732
|
-
_options$orderBy$spli3,
|
|
733
|
-
direction,
|
|
734
|
-
matchingLines,
|
|
735
|
-
_args8 = arguments;
|
|
736
|
-
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
737
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
738
|
-
case 0:
|
|
739
|
-
options = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
|
|
740
|
-
if (!this.destroyed) {
|
|
741
|
-
_context8.next = 3;
|
|
742
|
-
break;
|
|
743
|
-
}
|
|
744
|
-
throw new Error('Database is destroyed');
|
|
745
|
-
case 3:
|
|
746
|
-
if (this.initialized) {
|
|
747
|
-
_context8.next = 6;
|
|
748
|
-
break;
|
|
749
|
-
}
|
|
750
|
-
_context8.next = 6;
|
|
751
|
-
return this.init();
|
|
752
|
-
case 6:
|
|
753
|
-
_context8.t0 = this.shouldSave;
|
|
754
|
-
if (!_context8.t0) {
|
|
755
|
-
_context8.next = 10;
|
|
756
|
-
break;
|
|
757
|
-
}
|
|
758
|
-
_context8.next = 10;
|
|
759
|
-
return this.save()["catch"](console.error);
|
|
760
|
-
case 10:
|
|
761
|
-
if (!Array.isArray(criteria)) {
|
|
762
|
-
_context8.next = 19;
|
|
763
|
-
break;
|
|
764
|
-
}
|
|
765
|
-
_context8.next = 13;
|
|
766
|
-
return this.readLines(criteria);
|
|
767
|
-
case 13:
|
|
768
|
-
results = _context8.sent;
|
|
769
|
-
if (options.orderBy) {
|
|
770
|
-
_options$orderBy$spli = options.orderBy.split(' '), _options$orderBy$spli2 = _slicedToArray(_options$orderBy$spli, 2), field = _options$orderBy$spli2[0], _options$orderBy$spli3 = _options$orderBy$spli2[1], direction = _options$orderBy$spli3 === void 0 ? 'asc' : _options$orderBy$spli3;
|
|
771
|
-
results.sort(function (a, b) {
|
|
772
|
-
if (a[field] > b[field]) return direction === 'asc' ? 1 : -1;
|
|
773
|
-
if (a[field] < b[field]) return direction === 'asc' ? -1 : 1;
|
|
774
|
-
return 0;
|
|
775
|
-
});
|
|
776
|
-
}
|
|
777
|
-
if (options.limit) {
|
|
778
|
-
results = results.slice(0, options.limit);
|
|
779
|
-
}
|
|
780
|
-
return _context8.abrupt("return", results);
|
|
781
|
-
case 19:
|
|
782
|
-
_context8.next = 21;
|
|
783
|
-
return this.indexManager.query(criteria, options);
|
|
784
|
-
case 21:
|
|
785
|
-
matchingLines = _context8.sent;
|
|
786
|
-
if (!(!matchingLines || !matchingLines.size)) {
|
|
787
|
-
_context8.next = 24;
|
|
788
|
-
break;
|
|
789
|
-
}
|
|
790
|
-
return _context8.abrupt("return", []);
|
|
791
|
-
case 24:
|
|
792
|
-
_context8.next = 26;
|
|
793
|
-
return this.query(_toConsumableArray(matchingLines), options);
|
|
794
|
-
case 26:
|
|
795
|
-
return _context8.abrupt("return", _context8.sent);
|
|
796
|
-
case 27:
|
|
797
|
-
case "end":
|
|
798
|
-
return _context8.stop();
|
|
799
|
-
}
|
|
800
|
-
}, _callee8, this);
|
|
801
|
-
}));
|
|
802
|
-
function query(_x4) {
|
|
803
|
-
return _query.apply(this, arguments);
|
|
804
|
-
}
|
|
805
|
-
return query;
|
|
806
|
-
}()
|
|
807
|
-
}, {
|
|
808
|
-
key: "update",
|
|
809
|
-
value: function () {
|
|
810
|
-
var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(criteria, data) {
|
|
811
|
-
var _this8 = this;
|
|
812
|
-
var options,
|
|
813
|
-
matchingLines,
|
|
814
|
-
ranges,
|
|
815
|
-
validMatchingLines,
|
|
816
|
-
entries,
|
|
817
|
-
lines,
|
|
818
|
-
_iterator3,
|
|
819
|
-
_step3,
|
|
820
|
-
_loop,
|
|
821
|
-
offsets,
|
|
822
|
-
byteOffset,
|
|
823
|
-
k,
|
|
824
|
-
_args10 = arguments;
|
|
825
|
-
return _regeneratorRuntime().wrap(function _callee9$(_context10) {
|
|
826
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
827
|
-
case 0:
|
|
828
|
-
options = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : {};
|
|
829
|
-
if (this.shouldTruncate) {
|
|
830
|
-
this.writeBuffer.push(this.indexOffset);
|
|
831
|
-
this.shouldTruncate = false;
|
|
832
|
-
}
|
|
833
|
-
if (!this.destroyed) {
|
|
834
|
-
_context10.next = 4;
|
|
835
|
-
break;
|
|
836
|
-
}
|
|
837
|
-
throw new Error('Database is destroyed');
|
|
838
|
-
case 4:
|
|
839
|
-
if (this.initialized) {
|
|
840
|
-
_context10.next = 7;
|
|
841
|
-
break;
|
|
842
|
-
}
|
|
843
|
-
_context10.next = 7;
|
|
844
|
-
return this.init();
|
|
845
|
-
case 7:
|
|
846
|
-
_context10.t0 = this.shouldSave;
|
|
847
|
-
if (!_context10.t0) {
|
|
848
|
-
_context10.next = 11;
|
|
849
|
-
break;
|
|
850
|
-
}
|
|
851
|
-
_context10.next = 11;
|
|
852
|
-
return this.save()["catch"](console.error);
|
|
853
|
-
case 11:
|
|
854
|
-
_context10.next = 13;
|
|
855
|
-
return this.indexManager.query(criteria, options);
|
|
856
|
-
case 13:
|
|
857
|
-
matchingLines = _context10.sent;
|
|
858
|
-
if (!(!matchingLines || !matchingLines.size)) {
|
|
859
|
-
_context10.next = 16;
|
|
860
|
-
break;
|
|
861
|
-
}
|
|
862
|
-
return _context10.abrupt("return", []);
|
|
863
|
-
case 16:
|
|
864
|
-
ranges = this.getRanges(_toConsumableArray(matchingLines));
|
|
865
|
-
validMatchingLines = new Set(ranges.map(function (r) {
|
|
866
|
-
return r.index;
|
|
867
|
-
}));
|
|
868
|
-
if (validMatchingLines.size) {
|
|
869
|
-
_context10.next = 20;
|
|
870
|
-
break;
|
|
871
|
-
}
|
|
872
|
-
return _context10.abrupt("return", []);
|
|
873
|
-
case 20:
|
|
874
|
-
_context10.next = 22;
|
|
875
|
-
return this.readLines(_toConsumableArray(validMatchingLines), ranges);
|
|
876
|
-
case 22:
|
|
877
|
-
entries = _context10.sent;
|
|
878
|
-
lines = [];
|
|
879
|
-
_iterator3 = _createForOfIteratorHelper(entries);
|
|
880
|
-
_context10.prev = 25;
|
|
881
|
-
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
882
|
-
var entry, err, updated, ret;
|
|
883
|
-
return _regeneratorRuntime().wrap(function _loop$(_context9) {
|
|
884
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
885
|
-
case 0:
|
|
886
|
-
entry = _step3.value;
|
|
887
|
-
updated = Object.assign(entry, data);
|
|
888
|
-
_context9.next = 4;
|
|
889
|
-
return _this8.serializer.serialize(updated)["catch"](function (e) {
|
|
890
|
-
return err = e;
|
|
891
|
-
});
|
|
892
|
-
case 4:
|
|
893
|
-
ret = _context9.sent;
|
|
894
|
-
err || lines.push(ret);
|
|
895
|
-
case 6:
|
|
896
|
-
case "end":
|
|
897
|
-
return _context9.stop();
|
|
898
|
-
}
|
|
899
|
-
}, _loop);
|
|
900
|
-
});
|
|
901
|
-
_iterator3.s();
|
|
902
|
-
case 28:
|
|
903
|
-
if ((_step3 = _iterator3.n()).done) {
|
|
904
|
-
_context10.next = 32;
|
|
905
|
-
break;
|
|
906
|
-
}
|
|
907
|
-
return _context10.delegateYield(_loop(), "t1", 30);
|
|
908
|
-
case 30:
|
|
909
|
-
_context10.next = 28;
|
|
910
|
-
break;
|
|
911
|
-
case 32:
|
|
912
|
-
_context10.next = 37;
|
|
913
|
-
break;
|
|
914
|
-
case 34:
|
|
915
|
-
_context10.prev = 34;
|
|
916
|
-
_context10.t2 = _context10["catch"](25);
|
|
917
|
-
_iterator3.e(_context10.t2);
|
|
918
|
-
case 37:
|
|
919
|
-
_context10.prev = 37;
|
|
920
|
-
_iterator3.f();
|
|
921
|
-
return _context10.finish(37);
|
|
922
|
-
case 40:
|
|
923
|
-
offsets = [];
|
|
924
|
-
byteOffset = 0, k = 0;
|
|
925
|
-
this.offsets.forEach(function (n, i) {
|
|
926
|
-
var prevByteOffset = byteOffset;
|
|
927
|
-
if (validMatchingLines.has(i) && ranges[k]) {
|
|
928
|
-
var r = ranges[k];
|
|
929
|
-
byteOffset += lines[k].length - (r.end - r.start);
|
|
930
|
-
k++;
|
|
931
|
-
}
|
|
932
|
-
offsets.push(n + prevByteOffset);
|
|
933
|
-
});
|
|
934
|
-
this.offsets = offsets;
|
|
935
|
-
this.indexOffset += byteOffset;
|
|
936
|
-
_context10.next = 47;
|
|
937
|
-
return this.fileHandler.replaceLines(ranges, lines);
|
|
938
|
-
case 47:
|
|
939
|
-
_toConsumableArray(validMatchingLines).forEach(function (lineNumber, i) {
|
|
940
|
-
_this8.indexManager.dryRemove(lineNumber);
|
|
941
|
-
_this8.indexManager.add(entries[i], lineNumber);
|
|
942
|
-
});
|
|
943
|
-
this.shouldSave = true;
|
|
944
|
-
return _context10.abrupt("return", entries);
|
|
945
|
-
case 50:
|
|
946
|
-
case "end":
|
|
947
|
-
return _context10.stop();
|
|
948
|
-
}
|
|
949
|
-
}, _callee9, this, [[25, 34, 37, 40]]);
|
|
950
|
-
}));
|
|
951
|
-
function update(_x5, _x6) {
|
|
952
|
-
return _update.apply(this, arguments);
|
|
953
|
-
}
|
|
954
|
-
return update;
|
|
955
|
-
}()
|
|
956
|
-
}, {
|
|
957
|
-
key: "delete",
|
|
958
|
-
value: function () {
|
|
959
|
-
var _delete2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(criteria) {
|
|
960
|
-
var options,
|
|
961
|
-
matchingLines,
|
|
962
|
-
ranges,
|
|
963
|
-
validMatchingLines,
|
|
964
|
-
offsets,
|
|
965
|
-
byteOffset,
|
|
966
|
-
k,
|
|
967
|
-
_args11 = arguments;
|
|
968
|
-
return _regeneratorRuntime().wrap(function _callee10$(_context11) {
|
|
969
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
970
|
-
case 0:
|
|
971
|
-
options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
|
|
972
|
-
if (this.shouldTruncate) {
|
|
973
|
-
this.writeBuffer.push(this.indexOffset);
|
|
974
|
-
this.shouldTruncate = false;
|
|
975
|
-
}
|
|
976
|
-
if (!this.destroyed) {
|
|
977
|
-
_context11.next = 4;
|
|
978
|
-
break;
|
|
979
|
-
}
|
|
980
|
-
throw new Error('Database is destroyed');
|
|
981
|
-
case 4:
|
|
982
|
-
if (this.initialized) {
|
|
983
|
-
_context11.next = 7;
|
|
984
|
-
break;
|
|
985
|
-
}
|
|
986
|
-
_context11.next = 7;
|
|
987
|
-
return this.init();
|
|
988
|
-
case 7:
|
|
989
|
-
_context11.t0 = this.shouldSave;
|
|
990
|
-
if (!_context11.t0) {
|
|
991
|
-
_context11.next = 11;
|
|
992
|
-
break;
|
|
993
|
-
}
|
|
994
|
-
_context11.next = 11;
|
|
995
|
-
return this.save()["catch"](console.error);
|
|
996
|
-
case 11:
|
|
997
|
-
_context11.next = 13;
|
|
998
|
-
return this.indexManager.query(criteria, options);
|
|
999
|
-
case 13:
|
|
1000
|
-
matchingLines = _context11.sent;
|
|
1001
|
-
if (!(!matchingLines || !matchingLines.size)) {
|
|
1002
|
-
_context11.next = 16;
|
|
1003
|
-
break;
|
|
1004
|
-
}
|
|
1005
|
-
return _context11.abrupt("return", 0);
|
|
1006
|
-
case 16:
|
|
1007
|
-
ranges = this.getRanges(_toConsumableArray(matchingLines));
|
|
1008
|
-
validMatchingLines = new Set(ranges.map(function (r) {
|
|
1009
|
-
return r.index;
|
|
1010
|
-
}));
|
|
1011
|
-
_context11.next = 20;
|
|
1012
|
-
return this.fileHandler.replaceLines(ranges, []);
|
|
1013
|
-
case 20:
|
|
1014
|
-
offsets = [];
|
|
1015
|
-
byteOffset = 0, k = 0;
|
|
1016
|
-
this.offsets.forEach(function (n, i) {
|
|
1017
|
-
if (validMatchingLines.has(i)) {
|
|
1018
|
-
var r = ranges[k];
|
|
1019
|
-
byteOffset -= r.end - r.start;
|
|
1020
|
-
k++;
|
|
1021
|
-
} else {
|
|
1022
|
-
offsets.push(n + byteOffset);
|
|
1023
|
-
}
|
|
1024
|
-
});
|
|
1025
|
-
this.offsets = offsets;
|
|
1026
|
-
this.indexOffset += byteOffset;
|
|
1027
|
-
this.indexManager.remove(_toConsumableArray(validMatchingLines));
|
|
1028
|
-
this.shouldSave = true;
|
|
1029
|
-
return _context11.abrupt("return", ranges.length);
|
|
1030
|
-
case 28:
|
|
1031
|
-
case "end":
|
|
1032
|
-
return _context11.stop();
|
|
1033
|
-
}
|
|
1034
|
-
}, _callee10, this);
|
|
1035
|
-
}));
|
|
1036
|
-
function _delete(_x7) {
|
|
1037
|
-
return _delete2.apply(this, arguments);
|
|
1038
|
-
}
|
|
1039
|
-
return _delete;
|
|
1040
|
-
}()
|
|
1041
|
-
}, {
|
|
1042
|
-
key: "destroy",
|
|
1043
|
-
value: function () {
|
|
1044
|
-
var _destroy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
1045
|
-
return _regeneratorRuntime().wrap(function _callee11$(_context12) {
|
|
1046
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
1047
|
-
case 0:
|
|
1048
|
-
_context12.t0 = this.shouldSave;
|
|
1049
|
-
if (!_context12.t0) {
|
|
1050
|
-
_context12.next = 4;
|
|
1051
|
-
break;
|
|
1052
|
-
}
|
|
1053
|
-
_context12.next = 4;
|
|
1054
|
-
return this.save()["catch"](console.error);
|
|
1055
|
-
case 4:
|
|
1056
|
-
this.destroyed = true;
|
|
1057
|
-
this.indexOffset = 0;
|
|
1058
|
-
this.indexManager.index = {};
|
|
1059
|
-
this.writeBuffer.length = 0;
|
|
1060
|
-
this.initialized = false;
|
|
1061
|
-
this.fileHandler.destroy();
|
|
1062
|
-
case 10:
|
|
1063
|
-
case "end":
|
|
1064
|
-
return _context12.stop();
|
|
1065
|
-
}
|
|
1066
|
-
}, _callee11, this);
|
|
1067
|
-
}));
|
|
1068
|
-
function destroy() {
|
|
1069
|
-
return _destroy.apply(this, arguments);
|
|
1070
|
-
}
|
|
1071
|
-
return destroy;
|
|
1072
|
-
}()
|
|
1073
|
-
}, {
|
|
1074
|
-
key: "length",
|
|
1075
|
-
get: function get() {
|
|
1076
|
-
var _this$offsets;
|
|
1077
|
-
return (this === null || this === void 0 || (_this$offsets = this.offsets) === null || _this$offsets === void 0 ? void 0 : _this$offsets.length) || 0;
|
|
1078
|
-
}
|
|
1079
|
-
}, {
|
|
1080
|
-
key: "index",
|
|
1081
|
-
get: function get() {
|
|
1082
|
-
return this.indexManager.index;
|
|
1083
|
-
}
|
|
1084
|
-
}]);
|
|
1085
|
-
}(_events.EventEmitter);
|