Comparing version 2.0.0-rc.6 to 2.0.0-rc.7
@@ -1,2 +0,2 @@ | ||
/** @license Data-Engine v2.0.0-rc.6 | ||
/** @license Data-Engine v2.0.0-rc.7 | ||
* data-sort.development.js | ||
@@ -55,3 +55,4 @@ * | ||
*/ | ||
function Sort(data) { | ||
function Sort() { | ||
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
var primaryKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
@@ -63,7 +64,7 @@ var sortFunction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
this.data = data; | ||
this.sortDefault = function () {}; | ||
this.currentName = null; | ||
this.sortFunc = this.defaultSort; | ||
this.setPrimaryKey(primaryKey); | ||
this.sortFunc = this.defaultSort; | ||
this.setSortFunction(sortFunction); | ||
this.setData(data); | ||
} | ||
@@ -197,4 +198,2 @@ /** | ||
} | ||
_this.currentName = null; | ||
return data; | ||
@@ -211,6 +210,10 @@ }; | ||
this.setPrimaryKey = function (key) { | ||
if (typeof key === 'string') { | ||
if (!_this.isCustomFunction) { | ||
_this.sortFunc = _this.defaultSortWithKey; | ||
return; | ||
} | ||
if (typeof key === 'string' && key.length > 0) { | ||
_this.primaryKey = key; | ||
if (!_this.isCustomFunction) { | ||
_this.sortFunc = _this.defaultSortWithKey; | ||
if (_this.currentName === null) { | ||
_this.currentName = key; | ||
} | ||
@@ -242,6 +245,6 @@ } | ||
if (_this.currentName === name) { | ||
return _this.justReverse(); | ||
return _this.reverseData(); | ||
} | ||
_this.currentName = name; | ||
return _this.justSort(); | ||
return _this.sortData(); | ||
}; | ||
@@ -251,3 +254,3 @@ | ||
if (a[_this.currentName] === b[_this.currentName]) { | ||
return _this.sortDefault(a, b); | ||
return _this.comparePrimaryKey(a, b); | ||
} | ||
@@ -254,0 +257,0 @@ return _this.compare(a, b); |
@@ -1,2 +0,2 @@ | ||
/** @license Data-Engine v2.0.0-rc.6 | ||
/** @license Data-Engine v2.0.0-rc.7 | ||
* data-sort.production.min.js | ||
@@ -9,6 +9,6 @@ * | ||
*/ | ||
'use strict';var f=function(){function a(a,c){for(var b=0;b<c.length;b++){var d=c[b];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(b,c,e){c&&a(b.prototype,c);e&&a(b,e);return b}}(),h=function(){function a(b){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");g.call(this); | ||
this.data=b;this.sortDefault=function(){};this.setPrimaryKey(c);this.sortFunc=this.defaultSort;this.setSortFunction(e)}f(a,[{key:"SortFunction",set:function(a){this.setSortFunction(a)}},{key:"PrimaryKey",set:function(a){this.setPrimaryKey(a)}}]);return a}(); | ||
function g(){var a=this;this.setData=function(b){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:!0;a.data=b;if(c)return a.sortData();a.currentName=null;return b};this.setSortFunction=function(b){"function"===typeof b&&(a.sortFunc=b,a.isCustomFunction=!0)};this.setPrimaryKey=function(b){"string"===typeof b&&(a.primaryKey=b,a.isCustomFunction||(a.sortFunc=a.defaultSortWithKey))};this.removePrimaryKey=function(){a.primaryKey="";a.isCustomFunction||(a.sortFunc=a.defaultSort)};this.setDefaultSort= | ||
function(){a.isCustomFunction=!1;a.sortFunc=a.primaryKey?a.defaultSortWithKey:a.defaultSort};this.comparePrimaryKey=function(b,c){return b[a.primaryKey]>c[a.primaryKey]};this.compare=function(b,c){return b[a.currentName]>c[a.currentName]};this.sortBy=function(b){if(a.currentName===b)return a.justReverse();a.currentName=b;return a.justSort()};this.defaultSortWithKey=function(b,c){return b[a.currentName]===c[a.currentName]?a.sortDefault(b,c):a.compare(b,c)};this.defaultSort=function(b,c){return a.compare(b, | ||
c)};this.sortData=function(){return a.currentName?a.data.sort(a.sortFunc):a.data};this.reverseData=function(){return a.data.reverse()};this.getData=function(){return a.data}}var k=Object.freeze({default:h}),l=k&&h||k;module.exports=l.default?l.default:l; | ||
'use strict';var f=function(){function a(a,c){for(var b=0;b<c.length;b++){var d=c[b];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(b,c,e){c&&a(b.prototype,c);e&&a(b,e);return b}}(),h=function(){function a(){var b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!(this instanceof a))throw new TypeError("Cannot call a class as a function"); | ||
g.call(this);this.currentName=null;this.sortFunc=this.defaultSort;this.setPrimaryKey(c);this.setSortFunction(e);this.setData(b)}f(a,[{key:"SortFunction",set:function(a){this.setSortFunction(a)}},{key:"PrimaryKey",set:function(a){this.setPrimaryKey(a)}}]);return a}(); | ||
function g(){var a=this;this.setData=function(b){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:!0;a.data=b;return c?a.sortData():b};this.setSortFunction=function(b){"function"===typeof b&&(a.sortFunc=b,a.isCustomFunction=!0)};this.setPrimaryKey=function(b){a.isCustomFunction?"string"===typeof b&&0<b.length&&(a.primaryKey=b,null===a.currentName&&(a.currentName=b)):a.sortFunc=a.defaultSortWithKey};this.removePrimaryKey=function(){a.primaryKey="";a.isCustomFunction||(a.sortFunc=a.defaultSort)}; | ||
this.setDefaultSort=function(){a.isCustomFunction=!1;a.sortFunc=a.primaryKey?a.defaultSortWithKey:a.defaultSort};this.comparePrimaryKey=function(b,c){return b[a.primaryKey]>c[a.primaryKey]};this.compare=function(b,c){return b[a.currentName]>c[a.currentName]};this.sortBy=function(b){if(a.currentName===b)return a.reverseData();a.currentName=b;return a.sortData()};this.defaultSortWithKey=function(b,c){return b[a.currentName]===c[a.currentName]?a.comparePrimaryKey(b,c):a.compare(b,c)};this.defaultSort= | ||
function(b,c){return a.compare(b,c)};this.sortData=function(){return a.currentName?a.data.sort(a.sortFunc):a.data};this.reverseData=function(){return a.data.reverse()};this.getData=function(){return a.data}}var k=Object.freeze({default:h}),l=k&&h||k;module.exports=l.default?l.default:l; |
{ | ||
"name": "data-sort", | ||
"description": "Data engine is small data management lib for some sort and filter.", | ||
"version": "2.0.0-rc.6", | ||
"version": "2.0.0-rc.7", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "Data", |
@@ -1,2 +0,2 @@ | ||
/** @license Engine v2.0.0-rc.6 | ||
/** @license Engine v2.0.0-rc.7 | ||
* data-sort.development.js | ||
@@ -57,3 +57,4 @@ * | ||
*/ | ||
function Sort(data) { | ||
function Sort() { | ||
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
var primaryKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; | ||
@@ -65,7 +66,7 @@ var sortFunction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
this.data = data; | ||
this.sortDefault = function () {}; | ||
this.currentName = null; | ||
this.sortFunc = this.defaultSort; | ||
this.setPrimaryKey(primaryKey); | ||
this.sortFunc = this.defaultSort; | ||
this.setSortFunction(sortFunction); | ||
this.setData(data); | ||
} | ||
@@ -199,4 +200,2 @@ /** | ||
} | ||
_this.currentName = null; | ||
return data; | ||
@@ -213,6 +212,10 @@ }; | ||
this.setPrimaryKey = function (key) { | ||
if (typeof key === 'string') { | ||
if (!_this.isCustomFunction) { | ||
_this.sortFunc = _this.defaultSortWithKey; | ||
return; | ||
} | ||
if (typeof key === 'string' && key.length > 0) { | ||
_this.primaryKey = key; | ||
if (!_this.isCustomFunction) { | ||
_this.sortFunc = _this.defaultSortWithKey; | ||
if (_this.currentName === null) { | ||
_this.currentName = key; | ||
} | ||
@@ -244,6 +247,6 @@ } | ||
if (_this.currentName === name) { | ||
return _this.justReverse(); | ||
return _this.reverseData(); | ||
} | ||
_this.currentName = name; | ||
return _this.justSort(); | ||
return _this.sortData(); | ||
}; | ||
@@ -253,3 +256,3 @@ | ||
if (a[_this.currentName] === b[_this.currentName]) { | ||
return _this.sortDefault(a, b); | ||
return _this.comparePrimaryKey(a, b); | ||
} | ||
@@ -256,0 +259,0 @@ return _this.compare(a, b); |
@@ -1,2 +0,2 @@ | ||
/** @license Data-Engine v2.0.0-rc.6 | ||
/** @license Data-Engine v2.0.0-rc.7 | ||
* data-sort.production.min.js | ||
@@ -9,6 +9,6 @@ * | ||
*/ | ||
'use strict';(function(e,b){"object"===typeof exports&&"undefined"!==typeof module?module.exports=b():"function"===typeof define&&define.amd?define(b):e.Sort=b()})(this,function(){var e=function(){function a(a,d){for(var c=0;c<d.length;c++){var b=d[c];b.enumerable=b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(c,d,b){d&&a(c.prototype,d);b&&a(c,b);return c}}(),b=function(){function a(c){var b=1<arguments.length&&void 0!==arguments[1]? | ||
arguments[1]:null,e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");g.call(this);this.data=c;this.sortDefault=function(){};this.setPrimaryKey(b);this.sortFunc=this.defaultSort;this.setSortFunction(e)}e(a,[{key:"SortFunction",set:function(a){this.setSortFunction(a)}},{key:"PrimaryKey",set:function(a){this.setPrimaryKey(a)}}]);return a}(),g=function(){var a=this;this.setData=function(c){var b=1<arguments.length&& | ||
void 0!==arguments[1]?arguments[1]:!0;a.data=c;if(b)return a.sortData();a.currentName=null;return c};this.setSortFunction=function(c){"function"===typeof c&&(a.sortFunc=c,a.isCustomFunction=!0)};this.setPrimaryKey=function(c){"string"===typeof c&&(a.primaryKey=c,a.isCustomFunction||(a.sortFunc=a.defaultSortWithKey))};this.removePrimaryKey=function(){a.primaryKey="";a.isCustomFunction||(a.sortFunc=a.defaultSort)};this.setDefaultSort=function(){a.isCustomFunction=!1;a.sortFunc=a.primaryKey?a.defaultSortWithKey: | ||
a.defaultSort};this.comparePrimaryKey=function(c,b){return c[a.primaryKey]>b[a.primaryKey]};this.compare=function(c,b){return c[a.currentName]>b[a.currentName]};this.sortBy=function(c){if(a.currentName===c)return a.justReverse();a.currentName=c;return a.justSort()};this.defaultSortWithKey=function(c,b){return c[a.currentName]===b[a.currentName]?a.sortDefault(c,b):a.compare(c,b)};this.defaultSort=function(b,d){return a.compare(b,d)};this.sortData=function(){return a.currentName?a.data.sort(a.sortFunc): | ||
a.data};this.reverseData=function(){return a.data.reverse()};this.getData=function(){return a.data}},f=Object.freeze({default:b});b=f&&b||f;return b.default?b.default:b}); | ||
'use strict';(function(e,b){"object"===typeof exports&&"undefined"!==typeof module?module.exports=b():"function"===typeof define&&define.amd?define(b):e.Sort=b()})(this,function(){var e=function(){function a(a,d){for(var c=0;c<d.length;c++){var b=d[c];b.enumerable=b.enumerable||!1;b.configurable=!0;"value"in b&&(b.writable=!0);Object.defineProperty(a,b.key,b)}}return function(c,d,b){d&&a(c.prototype,d);b&&a(c,b);return c}}(),b=function(){function a(){var c=0<arguments.length&&void 0!==arguments[0]? | ||
arguments[0]:[],b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");g.call(this);this.currentName=null;this.sortFunc=this.defaultSort;this.setPrimaryKey(b);this.setSortFunction(e);this.setData(c)}e(a,[{key:"SortFunction",set:function(a){this.setSortFunction(a)}},{key:"PrimaryKey",set:function(a){this.setPrimaryKey(a)}}]);return a}(),g=function(){var a= | ||
this;this.setData=function(c){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:!0;a.data=c;return b?a.sortData():c};this.setSortFunction=function(c){"function"===typeof c&&(a.sortFunc=c,a.isCustomFunction=!0)};this.setPrimaryKey=function(c){a.isCustomFunction?"string"===typeof c&&0<c.length&&(a.primaryKey=c,null===a.currentName&&(a.currentName=c)):a.sortFunc=a.defaultSortWithKey};this.removePrimaryKey=function(){a.primaryKey="";a.isCustomFunction||(a.sortFunc=a.defaultSort)};this.setDefaultSort= | ||
function(){a.isCustomFunction=!1;a.sortFunc=a.primaryKey?a.defaultSortWithKey:a.defaultSort};this.comparePrimaryKey=function(c,b){return c[a.primaryKey]>b[a.primaryKey]};this.compare=function(c,b){return c[a.currentName]>b[a.currentName]};this.sortBy=function(c){if(a.currentName===c)return a.reverseData();a.currentName=c;return a.sortData()};this.defaultSortWithKey=function(c,b){return c[a.currentName]===b[a.currentName]?a.comparePrimaryKey(c,b):a.compare(c,b)};this.defaultSort=function(b,d){return a.compare(b, | ||
d)};this.sortData=function(){return a.currentName?a.data.sort(a.sortFunc):a.data};this.reverseData=function(){return a.data.reverse()};this.getData=function(){return a.data}},f=Object.freeze({default:b});b=f&&b||f;return b.default?b.default:b}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22620
528