UNPKG

dynamodb-dashboard

Version:
529 lines (526 loc) 28.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _lodash = require("lodash"); var _aws = _interopRequireDefault(require("../config/aws")); var _dynamodb = require("../utils/dynamodb"); var _dynamodb2 = require("../constants/dynamodb"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; } 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); } function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { "throw": 1, "return": 2, "break": 3, "continue": 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, "catch": function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); } function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); } function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; } function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); } function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); } function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); } function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (c = i[4] || 3, u = i[5] === e ? i[3] : i[5], i[4] = 3, i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); } function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); } function _OverloadYield(e, d) { this.v = e, this.k = d; } function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); } 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."); } 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; } } function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); } 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; } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } 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); } 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); }); }; } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } 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); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } 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); } var ItemServiceProvider = exports["default"] = /*#__PURE__*/function () { /** * @param {AWS} _AWS_ */ function ItemServiceProvider() { var _AWS_ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _aws["default"]; _classCallCheck(this, ItemServiceProvider); this.AWS = _AWS_; } // https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html // https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html /** * * @param {"scan"|"query"} operation * @param {string} tableName * @param {object} conditions * * @returns {Promise<object>} */ return _createClass(ItemServiceProvider, [{ key: "fetch", value: function () { var _fetch = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(operation, tableName, conditions) { var options, params, items, scannedCount, intermediateExclusiveStartKey, response, slice, item, indices, _args = arguments; return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: options = _args.length > 3 && _args[3] !== undefined ? _args[3] : {}; params = _objectSpread({ TableName: tableName }, conditions); items = []; scannedCount = 0; // Slice intermediateExclusiveStartKey = params.ExclusiveStartKey; case 5: _context.next = 7; return this.AWS.document[operation](params, options); case 7: response = _context.sent; // AWS.document.scan(...), AWS.document.query(...) scannedCount += response.ScannedCount; items.push.apply(items, _toConsumableArray(response.Items)); params.ExclusiveStartKey = response.LastEvaluatedKey; // Slice intermediateExclusiveStartKey || (intermediateExclusiveStartKey = response.LastEvaluatedKey); if (!(items.length >= params.Limit)) { _context.next = 14; break; } return _context.abrupt("break", 15); case 14: if (params.ExclusiveStartKey) { _context.next = 5; break; } case 15: /* Slice * eg: * Limit = 10 * intermediateExclusiveStartKey = g * items = [...[a,b,c,d,e,f,g], ...[h,i,j,k,l]] * slice = [a,b,c,d,e,f,g,h,i,j] * ExclusiveStartKey = pick(j, Object.keys(g)) */ slice = items.slice(0, params.Limit); if (items.length > slice.length) { item = slice.at(-1); indices = Object.keys(intermediateExclusiveStartKey); params.ExclusiveStartKey = (0, _lodash.pick)(item, indices); } return _context.abrupt("return", { Items: slice.map(function (item) { return (0, _dynamodb.serialize)(item); }), Count: slice.length, ScannedCount: scannedCount, LastEvaluatedKey: params.ExclusiveStartKey }); case 18: case "end": return _context.stop(); } }, _callee, this); })); function fetch(_x, _x2, _x3) { return _fetch.apply(this, arguments); } return fetch; }() /** * @param {string} tableName * @param {object} keys * * @returns {Promise<object>} */ }, { key: "get", value: (function () { var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(tableName, keys) { var params, response; return _regeneratorRuntime().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: params = { TableName: tableName, Key: keys }; _context2.next = 3; return this.AWS.document.get(params); case 3: response = _context2.sent; response.Item = (0, _dynamodb.serialize)(response.Item); return _context2.abrupt("return", response); case 6: case "end": return _context2.stop(); } }, _callee2, this); })); function get(_x4, _x5) { return _get.apply(this, arguments); } return get; }() /** * A single call to BatchWriteItem can transmit up to 16MB of data over the network, consisting of up to 25 item put or delete operations. * * @param {string} tableName * @param {Array<object>} items * * @returns {Promise<Array<object>>} */ ) }, { key: "destroy", value: (function () { var _destroy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(tableName, items) { var chunks, requests, response; return _regeneratorRuntime().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: chunks = (0, _lodash.chunk)(items, 25); requests = chunks.map(function (chunkedItem) { return { RequestItems: _defineProperty({}, tableName, chunkedItem) }; }); _context3.next = 4; return Promise.all(requests.map(this.AWS.document.batchWrite.bind(this.AWS.document))); case 4: response = _context3.sent; return _context3.abrupt("return", response); case 6: case "end": return _context3.stop(); } }, _callee3, this); })); function destroy(_x6, _x7) { return _destroy.apply(this, arguments); } return destroy; }() /** * @param {string} tableName * @param {object} conditions * @param {function} callback * * @returns {Promise<{ Count: number, ScannedCount: number }>} */ ) }, { key: "all", value: (function () { var _all = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tableName, conditions) { var callback, count, scannedCount, params, operation, response, _args5 = arguments; return _regeneratorRuntime().wrap(function _callee5$(_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: callback = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() { return _regeneratorRuntime().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: case "end": return _context4.stop(); } }, _callee4); })); count = 0; scannedCount = 0; params = _objectSpread(_objectSpread({}, conditions), {}, { Limit: 10000, TableName: tableName }); operation = Boolean(params.KeyConditionExpression) ? _dynamodb2.OPERATIONS.QUERY : _dynamodb2.OPERATIONS.SCAN; case 5: _context5.next = 7; return this.AWS.document[operation](params); case 7: response = _context5.sent; _context5.next = 10; return callback(tableName, response.Items); case 10: count += response.Items.length; scannedCount += response.ScannedCount; params.ExclusiveStartKey = response.LastEvaluatedKey; case 13: if (params.ExclusiveStartKey) { _context5.next = 5; break; } case 14: return _context5.abrupt("return", { Count: count, ScannedCount: scannedCount }); case 15: case "end": return _context5.stop(); } }, _callee5, this); })); function all(_x8, _x9) { return _all.apply(this, arguments); } return all; }() /** * @param {string} tableName * @param {object} schema * @param {object} body * * @returns {Promise<object>} */ ) }, { key: "create", value: (function () { var _create = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(tableName, schema, body) { var options, params, response, _args6 = arguments; return _regeneratorRuntime().wrap(function _callee6$(_context6) { while (1) switch (_context6.prev = _context6.next) { case 0: options = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : {}; params = { Item: body, TableName: tableName, ConditionExpression: schema.map(function (key) { return "attribute_not_exists(#".concat(key, ")"); }).join(" AND "), ExpressionAttributeNames: (0, _lodash.fromPairs)(schema.map(function (key) { return ["#".concat(key), key]; })) }; _context6.next = 4; return this.AWS.document.put(params, options); case 4: response = _context6.sent; return _context6.abrupt("return", response); case 6: case "end": return _context6.stop(); } }, _callee6, this); })); function create(_x0, _x1, _x10) { return _create.apply(this, arguments); } return create; }() /** * @param {string} tableName * @param {object} schema * @param {{ ref: object, body: object }} param * * @returns {Promise<object>} */ ) }, { key: "update", value: (function () { var _update = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(tableName, schema, _ref2) { var ref, body, _yield$this$AWS$docum, Item, params, response; return _regeneratorRuntime().wrap(function _callee7$(_context7) { while (1) switch (_context7.prev = _context7.next) { case 0: ref = _ref2.ref, body = _ref2.body; _context7.next = 3; return this.AWS.document.get({ Key: ref, TableName: tableName }); case 3: _yield$this$AWS$docum = _context7.sent; Item = _yield$this$AWS$docum.Item; params = { Key: ref, TableName: tableName, Item: (0, _dynamodb.deserialize)(Item, body), ConditionExpression: schema.map(function (key) { return "attribute_exists(#".concat(key, ")"); }).join(" AND "), ExpressionAttributeNames: (0, _lodash.fromPairs)(schema.map(function (key) { return ["#".concat(key), key]; })) }; _context7.next = 8; return this.AWS.document.put(params); case 8: response = _context7.sent; return _context7.abrupt("return", response); case 10: case "end": return _context7.stop(); } }, _callee7, this); })); function update(_x11, _x12, _x13) { return _update.apply(this, arguments); } return update; }() /** * @param {string} tableName * @param {object} schema * @param {{ ref: object, body: object }} param * * @returns {Promise<object>} */ ) }, { key: "transactUpdate", value: (function () { var _transactUpdate = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(tableName, schema, _ref3) { var ref, body, _yield$this$AWS$docum2, Item, response; return _regeneratorRuntime().wrap(function _callee8$(_context8) { while (1) switch (_context8.prev = _context8.next) { case 0: ref = _ref3.ref, body = _ref3.body; _context8.next = 3; return this.AWS.document.get({ TableName: tableName, Key: ref }); case 3: _yield$this$AWS$docum2 = _context8.sent; Item = _yield$this$AWS$docum2.Item; response = this.AWS.document.transactWrite({ TransactItems: [{ Delete: { Key: ref, TableName: tableName } }, { Put: { Item: (0, _dynamodb.deserialize)(Item, body), TableName: tableName, Key: (0, _lodash.pick)(body, schema), ConditionExpression: schema.map(function (key) { return "attribute_not_exists(#".concat(key, ")"); }).join(" AND "), ExpressionAttributeNames: (0, _lodash.fromPairs)(schema.map(function (key) { return ["#".concat(key), key]; })) } }] }); return _context8.abrupt("return", response); case 7: case "end": return _context8.stop(); } }, _callee8, this); })); function transactUpdate(_x14, _x15, _x16) { return _transactUpdate.apply(this, arguments); } return transactUpdate; }() /** * @param {string} tableName * @param {object} conditions * * @returns {Promise<{ Count: number, ScannedCount: number }>} */ ) }, { key: "count", value: (function () { var _count = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(tableName, conditions) { var response; return _regeneratorRuntime().wrap(function _callee9$(_context9) { while (1) switch (_context9.prev = _context9.next) { case 0: _context9.next = 2; return this.all(tableName, conditions); case 2: response = _context9.sent; return _context9.abrupt("return", response); case 4: case "end": return _context9.stop(); } }, _callee9, this); })); function count(_x17, _x18) { return _count.apply(this, arguments); } return count; }() /** * @param {string} tableName * @param {object} conditions * * @returns {Promise<{ Count: number, ScannedCount: number }>} */ ) }, { key: "truncate", value: (function () { var _truncate = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee1(tableName, schema, conditions) { var _this = this; var destroyer, response; return _regeneratorRuntime().wrap(function _callee1$(_context1) { while (1) switch (_context1.prev = _context1.next) { case 0: destroyer = /*#__PURE__*/function () { var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(tableName, items) { var requests, response; return _regeneratorRuntime().wrap(function _callee0$(_context0) { while (1) switch (_context0.prev = _context0.next) { case 0: requests = items.map(function (item) { return { DeleteRequest: { Key: (0, _lodash.pick)(item, schema) } }; }); _context0.next = 3; return _this.destroy(tableName, requests); case 3: response = _context0.sent; return _context0.abrupt("return", response); case 5: case "end": return _context0.stop(); } }, _callee0); })); return function destroyer(_x22, _x23) { return _ref4.apply(this, arguments); }; }(); _context1.next = 3; return this.all(tableName, conditions, destroyer); case 3: response = _context1.sent; return _context1.abrupt("return", response); case 5: case "end": return _context1.stop(); } }, _callee1, this); })); function truncate(_x19, _x20, _x21) { return _truncate.apply(this, arguments); } return truncate; }()) }]); }();