/
index.min.js
1 lines (1 loc) · 2.08 KB
/
index.min.js
1
var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n,o=arguments[t];for(n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},_createClass=function(){function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),e}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}!function(e){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))?module.exports=e():"function"==typeof define&&define.amd?define(e):DataProcessing=e()}(function(){"use strict";function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];_classCallCheck(this,t),this.source=e}return _createClass(t,[{key:"add",value:function(e){return this.source.push(e),this.source}},{key:"update",value:function(e,t){var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],o="";if("object"===(void 0===e?"undefined":_typeof(e))&&e.constructor===Array){o=[];for(var r=0,i=e.length;r<i;r++)o.push(t[e[r]])}else o=t[e];var u=this.get(e,o),s=u.index,c=u.item;return-1<s&&(u={},n?u=t:_extends(u,c,t),this.source.splice(s,1,u)),this.source}},{key:"updateBeatch",value:function(e,t){for(var n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],o=0,r=this.source.length;o<r;o++)this.update(e,t[o],n);return this.source}},{key:"delete",value:function(e,t){t=this.get(e,t).index;return-1<t&&this.source.splice(t,1),this.source}},{key:"get",value:function(e,t){for(var n=-1,o={},r=0,i=this.source.length;r<i;r++){var u=this.source[r];if("object"===(void 0===e?"undefined":_typeof(e))&&e.constructor===Array){for(var s=[],c=0;c<e.length;c++)s.push(u[e[c]]);if(t.join("@")===s.join("@")){n=r,o=u;break}}if(u[e]===t){n=r,o=u;break}}return{index:n,item:o}}}]),t});