UNPKG

data-engine

Version:

Data engine is small data management lib for some sort and filter.

1,299 lines (1,100 loc) 34.1 kB
/** @license Engine v3.1.1 * data-engine.development.js * * Copyright Jan Silhan * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.DataEngine = factory()); }(this, (function () { 'use strict'; /* eslint-disable */ function warnFunction() { var _console2; (_console2 = console).warn.apply(_console2, arguments); } function errorFunction() { var _console3; var _ref = new Error(), stack = _ref.stack; (_console3 = console).error.apply(_console3, [stack, '\n'].concat(Array.prototype.slice.call(arguments))); } function noop() {} var warn = noop; var error = noop; { error = errorFunction; warn = warnFunction; } var basicCompare = function (item) { return function (toCompare) { return item === toCompare; }; }; var dateCompare = function (item) { return function (toCompare) { var compareDate = toCompare; if (!toCompare.getTime) { compareDate = new Date(toCompare); } return item.getTime() === compareDate.getTime(); }; }; var arrayCompare = function (item) { return function (toCompare) { return item.some(function (itm) { return itm.compare(toCompare); }); }; }; var regexpCompare = function (item) { return function (toCompare) { return item.test("" + toCompare); }; }; var funcCompare = function (item) { return function (toCompare) { return item(toCompare); }; }; function isBetween(fromRange, toRange, toCompare) { if (fromRange && toRange) return fromRange <= toCompare && toRange >= toCompare; if (fromRange) return fromRange <= toCompare; return toRange >= toCompare; } function isTimeBetween(fromRange, toRange, toCompare) { var compareDate = toCompare; if (!toCompare.getTime) { compareDate = new Date(toCompare); } if (fromRange && toRange) { return fromRange.getTime() <= compareDate.getTime() && toRange.getTime() >= compareDate.getTime(); } if (fromRange) return fromRange.getTime() <= compareDate.getTime(); return toRange.getTime() >= compareDate.getTime(); } /** * Compares range * * @param {any} toCompare item which will be compared * @memberOf FilterValue */ var rangeCompare = function (item) { var type = item.from ? typeof item.from : typeof item.to; if (type !== 'object') return function (toCompare) { return isBetween(item.from, item.to, toCompare); }; return function (toCompare) { return isTimeBetween(item.from, item.to, toCompare); }; }; var booleanRetype = function (item) { return !!item; }; var stringRetype = function (item) { return "" + item; }; // eslint-disable-next-line /** * Try to retype to number * * @param {any} item which should be retyped * @return {number} retyped number * @memberOf FilterValue */ var numberRetype = function (item) { return parseFloat(item); }; var specials = ['-', '[', ']', '/', '{', '}', '(', ')', '*', '+', '?', '.', '\\', '^', '$', '|']; var regex = RegExp('[' + specials.join('\\') + ']', 'g'); /** * Replacing unwanted characters with \ * * @param {string} string string which you want to escape * @returns {string} escaped values */ function regexEscape(string) { return string.replace(regex, '\\$&'); } var regexpRetype = function (item) { return new RegExp(regexEscape('' + item), 'i'); }; var dateRetype = function (item) { try { var date = new Date(item); if (!isNaN(date.getTime())) return date; throw new TypeError(item + ' does not have format to parse with native function!'); } catch (e) { error(item + ' does not have format to parse with native function!'); throw e; } }; var number = 'number'; var string = 'string'; var boolean = 'boolean'; var fce = 'function'; var regexp = 'regexp'; var date = 'date'; var staticTypes = [number, string, boolean, regexp, date]; var primitiveTypes = { number: number, string: string, boolean: boolean, 'function': fce }; /** * Basic types of testable items. * Enum for data types */ var types = { boolean: basicCompare, string: basicCompare, number: basicCompare, 'null': basicCompare, date: dateCompare, array: arrayCompare, regexp: regexpCompare, 'function': funcCompare, range: rangeCompare }; var retype = { number: numberRetype, string: stringRetype, boolean: booleanRetype, regexp: regexpRetype, date: dateRetype }; /** * Checking for primitive types detectable with typeof * * * @returns {string|null} name of primitive type or null * @memberOf FilterValue */ var checkPrimitiveType = function (item) { return primitiveTypes[typeof item] || null; }; /** * checkBasicTypes checking basic types * * @param {any} item * @return {string/null} name of type if exist * @memberOf FilterValue */ var checkRangeAbleTypes = function (item) { switch (typeof item) { case 'string': return 'string'; case 'number': return 'number'; case 'object': if (item instanceof Date) { return 'date'; } return null; default: return null; } }; /** * Validation if possible to static type item * @param {any} item * @return {boolean} true when it's possible to retype * @memberOf FilterValue */ var validStaticType = function (item) { return staticTypes.some(function (key) { return key === item; }); }; 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; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } // eslint-disable-next-line // import { types, retype } from './constants/types'; var FilterValue = function () { /** * Creates an instance of FilterValue. * string, number, regexp, function, array of items mentioned before * * @param {string} name - name of filter * @param {any} item - value * @param {string} type - type of item * @memberOf FilterValue */ function FilterValue() { var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var item = arguments[1]; var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; _classCallCheck(this, FilterValue); _initialiseProps.call(this); this.originalItem = null; this.Name = name; if (type !== null) { this.Type = type; } if (item !== undefined) { this.Value = item; } } /** * Preparing item for right validation. * @private * @param {any} item - filter value! * * @return {Array/any} right element. * @memberOf FilterValue */ FilterValue.prototype.prepareItem = function prepareItem(item) { switch (this.type) { case 'array': if (Array.isArray(item[item.length - 1])) { error('Multi dimensional array is not supported!'); throw new TypeError('Multi dimensional array is not supported!'); } return item.map(function (value) { return new FilterValue(item.Name, value); }); default: return item; } }; /** * Setter for name * * @param {string} name new name * @memberOf FilterValue */ _createClass(FilterValue, [{ key: 'Name', set: function (name) { if (typeof name === 'string') { this.name = name; } } /** * Getter for name * * @readonly * @return {string} name * @memberOf FilterValue */ , get: function () { return this.name; } /** * Setter for type * * @param {string} type new static type * * @memberOf FilterValue */ }, { key: 'Type', set: function (type) { if (validStaticType(type)) { this.staticType = type; return; } this.staticType = null; throw new TypeError(type + ' is not supported. Cannot set static type'); } /** * Getter for type * * @returns {string} Static type * @memberOf FilterValue */ , get: function () { return this.staticType; } /** * getter for internal type * @private * @returns {string} type */ }, { key: 'InternalType', get: function () { return this.type; } /** * Remove static Type * * @memberOf FilterValue */ }, { key: 'Value', /** Setter for new value * Update filter value * * @param {any} item new item * @memberOf FilterValue */ set: function (item) { this.originalItem = item; var newItem = item; if (this.staticType) { try { newItem = retype[this.staticType](item); } catch (e) { error(e); throw new TypeError(item + ' cannot by typed to ' + this.staticType); } } this.type = this.checkValidity(newItem); if (this.type) { this.item = this.prepareItem(newItem); this.compareFunc = types[this.type](this.item); } else { warn('Possible types are Date, string, RegExp, number, function, Array<string, RegExp, number, null, function>. Array can have mixed values.'); throw new TypeError(item + ' is not supported. Use custom function!'); } } /** * Getter for original value * @returns {any} original item */ , get: function () { return this.item; } /** * Getter for original value passed to setter * @returns {any} value set by user */ }, { key: 'original', get: function () { return this.originalItem; } /** * Applying filter to item which will return true/false. True when it should be ignored. * @private * @param {any} toCompare - item which will be compared. * @memberOf FilterValue */ /** * Checking validity of supported types * valid types are * null, string, number, regexp, function, array of items mentioned before! * @private * @param {any} item * @return {string|null} return type or null * @memberOf FilterValue */ }]); return FilterValue; }(); FilterValue.regexpEscape = regexEscape; var _initialiseProps = function () { var _this = this; this.staticType = null; this.removeType = function () { _this.staticType = null; }; this.compare = function (toCompare) { return _this.compareFunc(toCompare); }; this.checkValidity = function (item) { var type = checkPrimitiveType(item); if (type) { return type; } if (item === null) { return 'null'; } else if (Array.isArray(item)) { return 'array'; } else if (item instanceof RegExp) { return 'regexp'; } else if (item instanceof Date) { return 'date'; } else if ((item.from || item.to) && (checkRangeAbleTypes(item.from) || checkRangeAbleTypes(item.to))) { return 'range'; } return null; }; }; var filterValue = Object.freeze({ default: FilterValue }); var FilterValue$2 = ( filterValue && FilterValue ) || filterValue; var filterValue$1 = FilterValue$2['default'] ? FilterValue$2['default'] : FilterValue$2; var _createClass$1 = 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; }; }(); function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Sort engine, just basic sort provider * * @export * @class Sort */ var Sort = function () { /** * Creates an instance of Sort. * @param {any} data - original data * @param {string} [primaryKey=null] - primary key which will be fallback when keys are equals * @param {function} [sortFunction=null] - custom sort function * @param {boolean} [direction=true] - custom sort function * * @memberOf Sort */ function Sort() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, data = _ref.data, primaryKey = _ref.primaryKey, sortFunction = _ref.sortFunction, direction = _ref.direction; _classCallCheck$1(this, Sort); _initialiseProps$1.call(this); this.Direction = direction; this.sortFunc = this.defaultSort; this.SortFunction = sortFunction; this.PrimaryKey = primaryKey; this.Data = data; } /** * Update data, refresh old data with new. * * @param {any} data new data * @param {boolean} shouldSort should be resorted * @memberOf Sort */ _createClass$1(Sort, [{ key: 'Data', set: function (data) { this.setData(data); } /** * Setter for custom function * * @param {function} func your custom sort function * @memberOf Sort */ , get: function () { return this.data; } }, { key: 'SortFunction', set: function (func) { this.setSortFunction(func); } /** * Setter for direction * @param {boolean} direction of sort */ }, { key: 'Direction', set: function (direction) { if (typeof direction === 'boolean') this.direction = direction;else this.direction = true; } /** * Getter for direction * @returns {boolean} */ , get: function () { return this.direction; } /** * Setter for primary key (fallback key) * * @param {string} key primary key * @memberOf Sort */ }, { key: 'PrimaryKey', set: function (key) { this.setPrimaryKey(key); } /** * Getter for primary key * @returns {string|null} */ , get: function () { return this.primaryKey; } /** * Remover primary key set to default * * * @memberOf Sort */ /** * Setup default sort function * * * @memberOf Sort */ /** * Compare primary key * Fallback function when current values are equal. * @param {any} a - first item * @param {any} b - second item * @return {number} position of elements * @memberOf Sort */ /** * Compare by current name * * @param {any} a - first item * @param {any} b - second item * @return {number} position of elements * @memberOf Sort */ /** * sort by name, sets new name and check if we need to only reverse * * @param {string} name key for sort * @memberOf Sort */ /** * Setting right function for sort, * @private */ /** * default sort with key * Default sorting function when user won't add own function. * @private * @param {any} a - first item * @param {any} b - second item * @return {number} position of elements * @memberOf Sort */ /** * default sort * Default sorting function when user won't add own function. * * @param {any} a - first item * @param {any} b - second item * @return {number} position of elements * @memberOf Sort */ /** * Well just sort function. when we need resort. * * @return {Array} sorted data * @memberOf Sort */ /** * well just reverse sorted array * * @return {Array} reversed data * @memberOf Sort */ /** * Getter for data * * * @memberOf Sort */ }]); return Sort; }(); var _initialiseProps$1 = function () { var _this = this; this.primaryKey = null; this.direction = true; this.data = []; this.currentName = null; this.setData = function (data) { var shouldSort = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; if (!Array.isArray(data)) { _this.data = []; return []; } _this.data = data; if (shouldSort) { _this.sortData(); } return _this.data; }; this.setSortFunction = function (func) { if (typeof func === 'function') { _this.sortFunc = func; _this.isCustomFunction = true; } }; this.setPrimaryKey = function (key) { if (_this.isCustomFunction) { return; } if (typeof key === 'string' && key.length > 0) { _this.primaryKey = key; if (_this.currentName === null) { _this.currentName = key; } _this.setOwnSortFunction(); } }; this.removePrimaryKey = function () { _this.primaryKey = null; _this.setOwnSortFunction(); }; this.setDefaultSort = function () { _this.isCustomFunction = false; _this.setOwnSortFunction(); }; this.comparePrimaryKey = function (a, b) { var first = a[_this.primaryKey]; var second = b[_this.primaryKey]; if (first === second) return 0; return first > second === _this.direction ? 1 : -1; }; this.compare = function (a, b) { var first = a[_this.currentName]; var second = b[_this.currentName]; if (first === second) return 0; return first > second === _this.direction ? 1 : -1; }; this.sortBy = function (name) { if (_this.currentName === name) { return _this.reverseData(); } _this.currentName = name; _this.setOwnSortFunction(); return _this.sortData(); }; this.setOwnSortFunction = function () { var isCustomFunction = _this.isCustomFunction, primaryKey = _this.primaryKey, currentName = _this.currentName; if (isCustomFunction) { return; } if (primaryKey !== null && primaryKey !== currentName) { _this.sortFunc = _this.defaultSortWithKey; } else { _this.sortFunc = _this.defaultSort; } }; this.defaultSortWithKey = function (a, b) { var first = a[_this.currentName]; var second = b[_this.currentName]; if (first === second) { return _this.comparePrimaryKey(a, b); } return first > second === _this.direction ? 1 : -1; }; this.defaultSort = function (a, b) { return _this.compare(a, b); }; this.sortData = function () { if (_this.currentName) { _this.data = _this.data.sort(_this.sortFunc); } return _this.data; }; this.reverseData = function () { _this.data = _this.data.reverse(); return _this.data; }; this.getData = function () { return _this.Data; }; }; var dataSort = Object.freeze({ default: Sort }); var Sort$2 = ( dataSort && Sort ) || dataSort; var dataSort$1 = Sort$2['default'] ? Sort$2['default'] : Sort$2; var _createClass$2 = 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; }; }(); function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Filter engine * * @class Filter */ var Filter = function () { /** * Creates an instance of Filter. * @param {any} data - initial data * * @memberOf Filter */ function Filter() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, data = _ref.data, sortEngine = _ref.sortEngine; _classCallCheck$2(this, Filter); _initialiseProps$2.call(this); this.filters = {}; this.SortEngine = sortEngine; this.Data = data; this.filtered = this.getData(); } /** * Setter for data * * @param {Array} data - original data * @memberOf Filter */ _createClass$2(Filter, [{ key: 'Data', set: function (data) { if (data && Array.isArray(data)) { this.data = data; this.updateFilter(); return; } this.data = []; this.filtered = []; } /** * Setter for data * @return {Array<any>} original data * @memberOf Filter */ , get: function () { return this.getData(); } /** * Helper function for creating new filterValue * @private * @param {string} name - name of collumn * @param {any} value - value of filter * @param {string} type - static type for value * @returns {FilterValue} new filter value */ /** * Simple add filter function * @param {string} name - name of collumn * @param {any} value - value of filter * @param {string} type - static type for value * @return {Array<any>} filtered array */ /** * Add or modify filter value * * * @param {Array<FilterValue>} items - array of filter items * @throws {TypeError} when item isn't instance of FilterValue * @return {Array} new filtered array * @memberOf Filter */ /** * Remove one or as many filters as you add value * only updating when at least one filter was removed * * @param {Array<string | FilterValue>} item - filter item * * @return {Array<any>} new filtered array * @memberOf Filter */ /** * Clears all filters, * it's possible that sort is still active so we need to filter anyway * * @return {Array<any>} new filtered array * @memberOf Filter */ /** * Update filtered array. * * @return {Array} new filtered array * @memberOf Filter */ /** * Filter line by all criteria. * Helper function for filtering. * @private * @param {object} line - line from original data. * @return {bool} * @memberOf Filter */ /** * Simple getter * * @returns {array} filtered data * * @memberOf Filter */ }, { key: 'FilteredData', get: function () { return this.getFilteredData(); } /** * Helper function when sort is not in filter * filtering without sort * @private * @return {Array<any>} filtered data */ /** * Helper function with sort * Filtering with sort * @private * @return {Array<any>} filtered and sorted array */ /** * Getter for filter * @param {string} name - name of filter * @returns {FilterValue | null} return filter value */ }, { key: 'SortEngine', /** * Setter for sort engine * @param {Sort} sortEngine - instance of Sort */ set: function (sortEngine) { if (sortEngine instanceof dataSort$1) { this.sortEngine = sortEngine; this.updateFce = this.filterWSort; } else { this.sortEngine = null; this.updateFce = this.filterWOSort; } } /** * Getter for sort engine * @returns {Sort} - instance of Sort */ , get: function () { return this.sortEngine; } }]); return Filter; }(); Filter.FilterValue = filterValue$1; Filter.Sort = dataSort$1; var _initialiseProps$2 = function () { var _this = this; this.updateFce = this.filterWOSort; this.data = []; this.filtered = []; this.sortEngine = null; this.setData = function (data) { _this.Data = data; }; this.getData = function () { return _this.data; }; this.createFilter = function (name, value, type) { return new filterValue$1(name, value, type); }; this.addFilter = function (name, value, type) { return _this.update(_this.createFilter(name, value, type)); }; this.update = function () { for (var _len = arguments.length, items = Array(_len), _key = 0; _key < _len; _key++) { items[_key] = arguments[_key]; } var returnFunc = _this.getFilteredData; items.forEach(function (item) { // Exception when item isn't filterValue! if (!(item instanceof filterValue$1)) { throw new TypeError(item + ' has to have filterValue instance'); } _this.filters[item.Name] = item; returnFunc = _this.updateFilter; }); return returnFunc(); }; this.removeFilters = function () { for (var _len2 = arguments.length, names = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { names[_key2] = arguments[_key2]; } var returnFunc = _this.getFilteredData; names.forEach(function (item) { var removalName = typeof item === 'string' ? item : item.Name; if (_this.filters[removalName]) { delete _this.filters[removalName]; returnFunc = _this.updateFilter; } }); return returnFunc(); }; this.clearFilters = function () { _this.filters = {}; _this.updateFilter(); return _this.FilteredData; }; this.updateFilter = function () { _this.filtered = _this.updateFce(_this.data.filter(_this.filterAll)); return _this.FilteredData; }; this.filterAll = function (line) { return Object.keys(_this.filters).every(function (key) { return _this.filters[key].compare(line[key]); }); }; this.getFilteredData = function () { return _this.filtered; }; this.filterWOSort = function (data) { return data; }; this.filterWSort = function (data) { return _this.SortEngine.setData(data); }; this.getFilter = function (name) { if (_this.filters[name]) { return _this.filters[name]; } return null; }; }; var dataFilter = Object.freeze({ default: Filter }); var Filter$2 = ( dataFilter && Filter ) || dataFilter; var dataFilter$1 = Filter$2['default'] ? Filter$2['default'] : Filter$2; var _createClass$3 = 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; }; }(); function _classCallCheck$3(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Data engine providing sort and filter functionality * * @export * @class DataEngine */ var DataEngine = function () { /** * Creates an instance of DataEngine. * @param {Array} [data=null] * @param {string} [primaryKey=null] * @param {function} [sortFunction=null] * * @memberOf DataEngine */ function DataEngine() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, data = _ref.data, primaryKey = _ref.primaryKey, sortFunction = _ref.sortFunction, direction = _ref.direction; _classCallCheck$3(this, DataEngine); _initialiseProps$3.call(this); this.filterEngine = new dataFilter$1({ data: data, sortEngine: new dataSort$1({ data: data, primaryKey: primaryKey, sortFunction: sortFunction, direction: direction }) }); } /** * Getter for filter Engine * @returns {Filter} instance of filter */ _createClass$3(DataEngine, [{ key: 'FilterEngine', get: function () { return this.filterEngine; } /** * Getter for sort engine * @returns {Sort} instance of sort */ }, { key: 'SortEngine', get: function () { return this.filterEngine.SortEngine; } /** * Setter for updating data * @param {Array<any>} data - original data */ }, { key: 'Data', set: function (data) { this.setData(data); } /** * @see data-filter */ /** * @see data-filter */ /** * @see data-filter */ /** * @see data-filter */ /** * Setter for custom function * * @param {function} func your custom sort function * @memberOf Sort */ /** * @see data-sort */ /** * @see data-sort */ /** * @see data-sort */ /** * @see data-sort */ /** * Getter for filtered data * * @return {array} sorted and filtered array * @memberOf DataEngine */ , get: function () { return this.FilterEngine.FilteredData; } }]); return DataEngine; }(); DataEngine.Filter = dataFilter$1; DataEngine.Sort = dataSort$1; DataEngine.FilterValue = filterValue$1; var _initialiseProps$3 = function () { var _this = this; this.setData = function (data) { _this.filterEngine.Data = data; }; this.updateFilters = function () { var _FilterEngine; return (_FilterEngine = _this.FilterEngine).update.apply(_FilterEngine, arguments); }; this.removeFilters = function () { var _FilterEngine2; return (_FilterEngine2 = _this.FilterEngine).removeFilters.apply(_FilterEngine2, arguments); }; this.addFilter = function (name, value, type) { return _this.FilterEngine.addFilter(name, value, type); }; this.clearFilters = function () { return _this.FilterEngine.clearFilters(); }; this.setSortFunction = function (func) { return _this.SortEngine.setSortFunction(func); }; this.setPrimaryKey = function (key) { return _this.SortEngine.setPrimaryKey(key); }; this.removePrimaryKey = function () { return _this.SortEngine.removePrimaryKey(); }; this.setDefaultSort = function () { return _this.SortEngine.setDefaultSort(); }; this.sortBy = function (name) { return _this.SortEngine.sortBy(name); }; this.getData = function () { return _this.Data; }; }; var dataEngine = Object.freeze({ default: DataEngine }); var DataEngine$2 = ( dataEngine && DataEngine ) || dataEngine; var dataEngine$1 = DataEngine$2['default'] ? DataEngine$2['default'] : DataEngine$2; return dataEngine$1; })));