Socket
Socket
Sign inDemoInstall

mini-linq-js

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mini-linq-js - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

2

dist/mini-linq.full.min.js

@@ -25,2 +25,2 @@ /* ! https://github.com/akopachov/mini-linq-js */

*/
!function(){var stringTrim=function(a){return"string"!=typeof a||null===a?a:String.prototype.trim?a.trim():a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},expressionCache={};LINQ={utils:{parseExpression:function(a){if("function"==typeof a)return a;if(null==a||"string"!=typeof a||a.indexOf("=>")<0)throw new SyntaxError('Expression "'+a+'" is invalid');if("function"==typeof expressionCache[a])return expressionCache[a];var b,c=a.split("=>"),d=stringTrim(c[0]).replace(/[\(\)\s]/gi,""),e=stringTrim(c[1]);try{e.indexOf("return")<0&&(e="return ("+e+")"),b=new Function(d,e)}catch(f){b=new Function(d,e)}if("function"!=typeof b)throw new SyntaxError('Expression "'+a+'" is invalid');return expressionCache[a]=b,b},getType:function(a){var b=typeof a;if("object"!==b)return b;if(null===a)return"null";var c=a.constructor,d="function"==typeof c&&c.name;return"string"==typeof d&&d.length>0?d:"object"},getDefaultValue:function(type){if("string"!=typeof type)throw new TypeError("Type must be a string.");switch(type){case"boolean":return!1;case"function":return function(){};case"null":return null;case"number":return 0;case"object":return{};case"string":return"";case"symbol":return Symbol();case"undefined":return}try{var ctor="function"==typeof this[type]?this[type]:eval(type);return new ctor}catch(e){return{}}},isArray:function(a){return Array.isArray?Array.isArray(a):"[object Array]"===Object.prototype.toString.call(a)}},methods:{any:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)return this.length>0;if("function"==typeof Array.prototype.some)return this.some(a);for(var b=0,c=this.length;c>b;b++)if(a(this[b],b,this))return!0;return!1},all:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Predicate is required");if("function"==typeof Array.prototype.every)return this.every(a);var b=function(){return!a.apply(this,arguments)};return!LINQ.methods.any.apply(this,[b])},where:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Predicate is required");if("function"==typeof Array.prototype.filter)return this.filter(a);for(var b=[],c=0,d=this.length;d>c;c++)a(this[c],c,this)&&b.push(this[c]);return b},select:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Selector is required");if("function"==typeof Array.prototype.map)return this.map(a);for(var b=[],c=0,d=this.length;d>c;c++)b.push(a(this[c],c,this));return b},selectMany:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Selector is required");for(var b=[],c=0,d=this.length;d>c;c++){var e=a(this[c],c,this);if(LINQ.utils.isArray(e))for(var f=0,g=e.length;g>f;f++)b.push(e[f])}return b},count:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)return this.length;if("function"==typeof Array.prototype.filter)return this.filter(a).length;for(var b=0,c=0,d=this.length;d>c;c++)a(this[c],c,this)&&b++;return b},orderBy:function(a,b){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return b>a?-1:a>b?1:0}),this.slice(0).sort(function(c,d){var e=a(c),f=a(d);return b(e,f)})},orderByDescending:function(a,b){"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return b>a?-1:a>b?1:0});var c=function(){return-1*b.apply(this,arguments)};return LINQ.methods.orderBy.apply(this,[a,c])},groupBy:function(a,b){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Key selector is required");"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return{group:a,values:b}});for(var c={},d=0,e=this.length;e>d;d++){var f=a(this[d],d,this);c[f]||(c[f]=[]),c[f].push(this[d])}var g=[];for(var h in c)c.hasOwnProperty(h)&&g.push(b(h,c[h]));return g},distinct:function(a){"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a});for(var b={},c=[],d=0,e=this.length;e>d;d++){var f=a(this[d],d,this);b[f]||(b[f]=!0,c.push(this[d]))}return c},firstOrDefault:function(a){if("string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(){return!0}),"function"==typeof Array.prototype.find)return this.find(a)||null;for(var b=0,c=this.length;c>b;b++)if(a(this[b],b,this))return this[b];return null},lastOrDefault:function(a){"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(){return!0});for(var b=this.length-1;b>=0;b--)if(a(this[b],b,this))return this[b];return null},joinWith:function(a,b,c,d,e){if("string"==typeof b)b=LINQ.utils.parseExpression(b);else if("function"!=typeof b)throw new Error("Inner key selector is required");if("string"==typeof c)c=LINQ.utils.parseExpression(c);else if("function"!=typeof c)throw new Error("Outer key selector is required");if("string"==typeof d)d=LINQ.utils.parseExpression(d);else if("function"!=typeof d)throw new Error("Results selector is required");"string"==typeof e?e=LINQ.utils.parseExpression(e):"function"!=typeof e&&(e=function(a,b){return a===b});for(var f=[],g=0,h=this.length;h>g;g++)for(var i=0,j=a.length;j>i;i++){var k=c(this[g],g,this),l=b(a[i],i,a);e(l,k)&&f.push(d(a[i],this[g]))}return f},contains:function(a,b){var c;if("string"==typeof b){var d=LINQ.utils.parseExpression(b);c=function(b){return d(b,a)}}else c="function"!=typeof b?function(b){return b===a}:function(c){return b(c,a)};return LINQ.methods.any.apply(this,[c])},aggregate:function(a,b){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Aggregator function is required");if(this.length<=0)return b;var c="undefined"==typeof b?LINQ.utils.getDefaultValue(LINQ.utils.getType(this[0])):b;if("function"==typeof Array.prototype.reduce)return this.reduce(a,c);for(var d=0,e=this.length;e>d;d++)c=a(c,this[d],d,this);return c},sum:function(a,b){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),b="undefined"==typeof b?LINQ.utils.getDefaultValue(LINQ.utils.getType(a(this[0],0,this))):b,LINQ.methods.aggregate.apply(this,[function(b,c,d,e){return b+a(c,d,e)},b])},min:function(a){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),this.length<=0?void 0:LINQ.methods.aggregate.apply(this,[function(b,c,d,e){var f=a(c,d,e);return b>f?f:b},a(this[0],0,this)])},max:function(a){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),this.length<=0?void 0:LINQ.methods.aggregate.apply(this,[function(b,c,d,e){var f=a(c,d,e);return f>b?f:b},a(this[0],0,this)])},skip:function(a){if("number"!=typeof a||0>a)throw new TypeError("Count is required and should be a positive number");return this.slice(a,this.length)},take:function(a){if("number"!=typeof a||0>a)throw new TypeError("Count is required and should be a positive number");return this.slice(0,a)},ofType:function(a){if("string"!=typeof a)throw new TypeError("Type is required.");return LINQ.methods.where.apply(this,[function(b){return typeof b===a}])},union:function(a){return this.concat(a)}}},LINQ.methods.firstOrDefault.finalize=!0,LINQ.methods.lastOrDefault.finalize=!0,LINQ.methods.count.finalize=!0,LINQ.methods.any.finalize=!0,LINQ.methods.contains.finalize=!0,LINQ.methods.all.finalize=!0,LINQ.methods.aggregate.finalize=!0,LINQ.methods.sum.finalize=!0,LINQ.methods.min.finalize=!0,LINQ.methods.max.finalize=!0;for(var key in LINQ.methods)LINQ.methods.hasOwnProperty(key)&&(Array.prototype[key]=LINQ.methods[key])}(),function(a){var b=[function(b,c){if(b.name===c.name&&"where"===c.name){var d=a.utils.parseExpression(b.args[0]),e=a.utils.parseExpression(c.args[0]);return function(c,d){return{name:b.name,args:[function(){return c.apply(this,arguments)&&d.apply(this,arguments)}],fn:a.methods[b.name]}}(d,e)}return!1},function(b,c){if(b.name===c.name&&"select"===c.name){var d=a.utils.parseExpression(b.args[0]),e=a.utils.parseExpression(c.args[0]);return function(c,d){return{name:b.name,args:[function(){return d.apply(this,[c.apply(this,arguments)])}],fn:a.methods[b.name]}}(d,e)}return!1},function(a,b){var c=["orderBy","orderByDescending"];return c.contains(a.name)&&c.contains(b.name)?b:!1},function(a,b){return"skip"==a.name&&"take"==b.name?function(a,b){return{name:"skiptake",args:[a,b],fn:function(a,b){return this.slice(a,a+b)}}}(a.args[0],b.args[0]):!1}],c=function(a){var c=this,d=a;c._modificatorQueue=[];var e=function(){for(var a=c._modificatorQueue.length,b=0;a>b;b++){var e=c._modificatorQueue[b];d=e.fn.apply(d,e.args)}return c._modificatorQueue.splice(0,a),a},f=function(){for(var a=0;a<c._modificatorQueue.length-1;){for(var d=c._modificatorQueue[a],e=c._modificatorQueue[a+1],f=!1,g=0,h=b.length;h>g;g++){var i=b[g],j=i(d,e);j&&(f=!0,c._modificatorQueue.splice(a+1,1),c._modificatorQueue[a]=j)}f||a++}};c.optimize=function(){return f(),c},c.toArray=function(){return d.length>100&&c._modificatorQueue.length>2&&c.optimize(),e(),Array.isArray(d)?d.slice(0):d}};Array.prototype.toLazy=function(){return new c(this)};for(var d in a.methods)a.methods.hasOwnProperty(d)&&(c.prototype[d]=function(b){return function(){var c=a.methods[b];return this._modificatorQueue.push({fn:a.methods[b],args:arguments,name:b}),c.finalize?this.toArray():this}}(d))}(LINQ),function(a){if(ko&&ko.observableArray&&ko.observableArray.fn){Array.prototype.toObservableArray=function(){return ko.observableArray(this)},ko.observableArray.fn.toArray=function(){return this()};for(var b in a.methods)a.methods.hasOwnProperty(b)&&(ko.observableArray.fn[b]=function(b){return function(){return a.methods[b].apply(this(),arguments)}}(b))}}(LINQ);
!function(){var stringTrim=function(a){return"string"!=typeof a||null===a?a:String.prototype.trim?a.trim():a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},expressionCache={};LINQ={utils:{parseExpression:function(a){if("function"==typeof a)return a;if(null==a||"string"!=typeof a||a.indexOf("=>")<0)throw new SyntaxError('Expression "'+a+'" is invalid');if("function"==typeof expressionCache[a])return expressionCache[a];var b,c=a.split("=>"),d=stringTrim(c[0]).replace(/[\(\)\s]/gi,""),e=stringTrim(c[1]);try{e.indexOf("return")<0&&(e="return ("+e+")"),b=new Function(d,e)}catch(f){b=new Function(d,e)}if("function"!=typeof b)throw new SyntaxError('Expression "'+a+'" is invalid');return expressionCache[a]=b,b},getType:function(a){var b=typeof a;if("object"!==b)return b;if(null===a)return"null";var c=a.constructor,d="function"==typeof c&&c.name;return"string"==typeof d&&d.length>0?d:"object"},getDefaultValue:function(type){if("string"!=typeof type)throw new TypeError("Type must be a string.");switch(type){case"boolean":return!1;case"function":return function(){};case"null":return null;case"number":return 0;case"object":return{};case"string":return"";case"symbol":return Symbol();case"undefined":return}try{var ctor="function"==typeof this[type]?this[type]:eval(type);return new ctor}catch(e){return{}}},isArray:function(a){return Array.isArray?Array.isArray(a):"[object Array]"===Object.prototype.toString.call(a)}},methods:{any:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)return this.length>0;if("function"==typeof Array.prototype.some)return this.some(a);for(var b=0,c=this.length;c>b;b++)if(a(this[b],b,this))return!0;return!1},all:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Predicate is required");if("function"==typeof Array.prototype.every)return this.every(a);var b=function(){return!a.apply(this,arguments)};return!LINQ.methods.any.apply(this,[b])},where:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Predicate is required");if("function"==typeof Array.prototype.filter)return this.filter(a);for(var b=[],c=0,d=this.length;d>c;c++)a(this[c],c,this)&&b.push(this[c]);return b},select:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Selector is required");if("function"==typeof Array.prototype.map)return this.map(a);for(var b=[],c=0,d=this.length;d>c;c++)b.push(a(this[c],c,this));return b},selectMany:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Selector is required");for(var b=[],c=0,d=this.length;d>c;c++){var e=a(this[c],c,this);if(LINQ.utils.isArray(e))for(var f=0,g=e.length;g>f;f++)b.push(e[f])}return b},count:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)return this.length;if("function"==typeof Array.prototype.filter)return this.filter(a).length;for(var b=0,c=0,d=this.length;d>c;c++)a(this[c],c,this)&&b++;return b},orderBy:function(a,b){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return b>a?-1:a>b?1:0}),this.slice(0).sort(function(c,d){var e=a(c),f=a(d);return b(e,f)})},orderByDescending:function(a,b){"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return b>a?-1:a>b?1:0});var c=function(){return-1*b.apply(this,arguments)};return LINQ.methods.orderBy.apply(this,[a,c])},groupBy:function(a,b){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Key selector is required");"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return{group:a,values:b}});for(var c={},d=0,e=this.length;e>d;d++){var f=a(this[d],d,this);c[f]||(c[f]=[]),c[f].push(this[d])}var g=[];for(var h in c)c.hasOwnProperty(h)&&g.push(b(h,c[h]));return g},distinct:function(a){"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a});for(var b={},c=[],d=0,e=this.length;e>d;d++){var f=a(this[d],d,this);b[f]||(b[f]=!0,c.push(this[d]))}return c},firstOrDefault:function(a){if("string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(){return!0}),"function"==typeof Array.prototype.find)return this.find(a)||null;for(var b=0,c=this.length;c>b;b++)if(a(this[b],b,this))return this[b];return null},lastOrDefault:function(a){"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(){return!0});for(var b=this.length-1;b>=0;b--)if(a(this[b],b,this))return this[b];return null},joinWith:function(a,b,c,d,e){if("string"==typeof b)b=LINQ.utils.parseExpression(b);else if("function"!=typeof b)throw new Error("Inner key selector is required");if("string"==typeof c)c=LINQ.utils.parseExpression(c);else if("function"!=typeof c)throw new Error("Outer key selector is required");if("string"==typeof d)d=LINQ.utils.parseExpression(d);else if("function"!=typeof d)throw new Error("Results selector is required");"string"==typeof e?e=LINQ.utils.parseExpression(e):"function"!=typeof e&&(e=function(a,b){return a===b});for(var f=[],g=0,h=this.length;h>g;g++)for(var i=0,j=a.length;j>i;i++){var k=c(this[g],g,this),l=b(a[i],i,a);e(l,k)&&f.push(d(a[i],this[g]))}return f},contains:function(a,b){var c;if("string"==typeof b){var d=LINQ.utils.parseExpression(b);c=function(b){return d(b,a)}}else c="function"!=typeof b?function(b){return b===a}:function(c){return b(c,a)};return LINQ.methods.any.apply(this,[c])},aggregate:function(a,b){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Aggregator function is required");if(this.length<=0)return b;var c="undefined"==typeof b?LINQ.utils.getDefaultValue(LINQ.utils.getType(this[0])):b;if("function"==typeof Array.prototype.reduce)return this.reduce(a,c);for(var d=0,e=this.length;e>d;d++)c=a(c,this[d],d,this);return c},sum:function(a,b){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),b="undefined"==typeof b?LINQ.utils.getDefaultValue(LINQ.utils.getType(a(this[0],0,this))):b,LINQ.methods.aggregate.apply(this,[function(b,c,d,e){return b+a(c,d,e)},b])},min:function(a){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),this.length<=0?void 0:LINQ.methods.aggregate.apply(this,[function(b,c,d,e){var f=a(c,d,e);return b>f?f:b},a(this[0],0,this)])},max:function(a){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),this.length<=0?void 0:LINQ.methods.aggregate.apply(this,[function(b,c,d,e){var f=a(c,d,e);return f>b?f:b},a(this[0],0,this)])},skip:function(a){if("number"!=typeof a||0>a)throw new TypeError("Count is required and should be a positive number");return this.slice(a,this.length)},take:function(a){if("number"!=typeof a||0>a)throw new TypeError("Count is required and should be a positive number");return this.slice(0,a)},ofType:function(a){if("string"!=typeof a)throw new TypeError("Type is required.");return LINQ.methods.where.apply(this,[function(b){return typeof b===a}])},union:function(a){return this.concat(a)}}},LINQ.methods.firstOrDefault.finalize=!0,LINQ.methods.lastOrDefault.finalize=!0,LINQ.methods.count.finalize=!0,LINQ.methods.any.finalize=!0,LINQ.methods.contains.finalize=!0,LINQ.methods.all.finalize=!0,LINQ.methods.aggregate.finalize=!0,LINQ.methods.sum.finalize=!0,LINQ.methods.min.finalize=!0,LINQ.methods.max.finalize=!0;for(var key in LINQ.methods)LINQ.methods.hasOwnProperty(key)&&(Array.prototype[key]=LINQ.methods[key])}(),function(a){var b=[function(b,c){if(b.name===c.name&&"where"===c.name){var d=a.utils.parseExpression(b.args[0]),e=a.utils.parseExpression(c.args[0]);return function(c,d){return{name:b.name,args:[function(){return c.apply(this,arguments)&&d.apply(this,arguments)}],fn:a.methods[b.name]}}(d,e)}return!1},function(b,c){if(b.name===c.name&&"select"===c.name){var d=a.utils.parseExpression(b.args[0]),e=a.utils.parseExpression(c.args[0]);return function(c,d){return{name:b.name,args:[function(){return d.apply(this,[c.apply(this,arguments)])}],fn:a.methods[b.name]}}(d,e)}return!1},function(a,b){var c=["orderBy","orderByDescending"];return c.contains(a.name)&&c.contains(b.name)?b:!1},function(a,b){return"skip"==a.name&&"take"==b.name?function(a,b){return{name:"skiptake",args:[a,b],fn:function(a,b){return this.slice(a,a+b)}}}(a.args[0],b.args[0]):!1}],c=function(c){var d=this,e=c;d._modificatorQueue=[];var f=function(){for(var a=d._modificatorQueue.length,b=0;a>b;b++){var c=d._modificatorQueue[b];e=c.fn.apply(e,c.args)}return d._modificatorQueue.splice(0,a),a},g=function(){for(var a=0;a<d._modificatorQueue.length-1;){for(var c=d._modificatorQueue[a],e=d._modificatorQueue[a+1],f=!1,g=0,h=b.length;h>g;g++){var i=b[g],j=i(c,e);j&&(f=!0,d._modificatorQueue.splice(a+1,1),d._modificatorQueue[a]=j)}f||a++}};d.optimize=function(){return g(),d},d.toArray=function(){return e.length>100&&d._modificatorQueue.length>2&&d.optimize(),f(),a.utils.isArray(e)?e.slice(0):e}};Array.prototype.toLazy=function(){return new c(this)};for(var d in a.methods)a.methods.hasOwnProperty(d)&&(c.prototype[d]=function(b){return function(){var c=a.methods[b];return this._modificatorQueue.push({fn:a.methods[b],args:arguments,name:b}),c.finalize?this.toArray():this}}(d))}(LINQ),function(a){if("undefined"!=typeof ko&&ko.observableArray&&ko.observableArray.fn){Array.prototype.toObservableArray=function(){return ko.observableArray(this)},ko.observableArray.fn.toArray=function(){return this()};for(var b in a.methods)a.methods.hasOwnProperty(b)&&(ko.observableArray.fn[b]=function(b){return function(){return a.methods[b].apply(this(),arguments)}}(b))}}(LINQ);

@@ -25,2 +25,2 @@ /* ! https://github.com/akopachov/mini-linq-js */

*/
!function(){var stringTrim=function(a){return"string"!=typeof a||null===a?a:String.prototype.trim?a.trim():a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},expressionCache={};LINQ={utils:{parseExpression:function(a){if("function"==typeof a)return a;if(null==a||"string"!=typeof a||a.indexOf("=>")<0)throw new SyntaxError('Expression "'+a+'" is invalid');if("function"==typeof expressionCache[a])return expressionCache[a];var b,c=a.split("=>"),d=stringTrim(c[0]).replace(/[\(\)\s]/gi,""),e=stringTrim(c[1]);try{e.indexOf("return")<0&&(e="return ("+e+")"),b=new Function(d,e)}catch(f){b=new Function(d,e)}if("function"!=typeof b)throw new SyntaxError('Expression "'+a+'" is invalid');return expressionCache[a]=b,b},getType:function(a){var b=typeof a;if("object"!==b)return b;if(null===a)return"null";var c=a.constructor,d="function"==typeof c&&c.name;return"string"==typeof d&&d.length>0?d:"object"},getDefaultValue:function(type){if("string"!=typeof type)throw new TypeError("Type must be a string.");switch(type){case"boolean":return!1;case"function":return function(){};case"null":return null;case"number":return 0;case"object":return{};case"string":return"";case"symbol":return Symbol();case"undefined":return}try{var ctor="function"==typeof this[type]?this[type]:eval(type);return new ctor}catch(e){return{}}},isArray:function(a){return Array.isArray?Array.isArray(a):"[object Array]"===Object.prototype.toString.call(a)}},methods:{any:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)return this.length>0;if("function"==typeof Array.prototype.some)return this.some(a);for(var b=0,c=this.length;c>b;b++)if(a(this[b],b,this))return!0;return!1},all:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Predicate is required");if("function"==typeof Array.prototype.every)return this.every(a);var b=function(){return!a.apply(this,arguments)};return!LINQ.methods.any.apply(this,[b])},where:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Predicate is required");if("function"==typeof Array.prototype.filter)return this.filter(a);for(var b=[],c=0,d=this.length;d>c;c++)a(this[c],c,this)&&b.push(this[c]);return b},select:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Selector is required");if("function"==typeof Array.prototype.map)return this.map(a);for(var b=[],c=0,d=this.length;d>c;c++)b.push(a(this[c],c,this));return b},selectMany:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Selector is required");for(var b=[],c=0,d=this.length;d>c;c++){var e=a(this[c],c,this);if(LINQ.utils.isArray(e))for(var f=0,g=e.length;g>f;f++)b.push(e[f])}return b},count:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)return this.length;if("function"==typeof Array.prototype.filter)return this.filter(a).length;for(var b=0,c=0,d=this.length;d>c;c++)a(this[c],c,this)&&b++;return b},orderBy:function(a,b){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return b>a?-1:a>b?1:0}),this.slice(0).sort(function(c,d){var e=a(c),f=a(d);return b(e,f)})},orderByDescending:function(a,b){"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return b>a?-1:a>b?1:0});var c=function(){return-1*b.apply(this,arguments)};return LINQ.methods.orderBy.apply(this,[a,c])},groupBy:function(a,b){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Key selector is required");"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return{group:a,values:b}});for(var c={},d=0,e=this.length;e>d;d++){var f=a(this[d],d,this);c[f]||(c[f]=[]),c[f].push(this[d])}var g=[];for(var h in c)c.hasOwnProperty(h)&&g.push(b(h,c[h]));return g},distinct:function(a){"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a});for(var b={},c=[],d=0,e=this.length;e>d;d++){var f=a(this[d],d,this);b[f]||(b[f]=!0,c.push(this[d]))}return c},firstOrDefault:function(a){if("string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(){return!0}),"function"==typeof Array.prototype.find)return this.find(a)||null;for(var b=0,c=this.length;c>b;b++)if(a(this[b],b,this))return this[b];return null},lastOrDefault:function(a){"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(){return!0});for(var b=this.length-1;b>=0;b--)if(a(this[b],b,this))return this[b];return null},joinWith:function(a,b,c,d,e){if("string"==typeof b)b=LINQ.utils.parseExpression(b);else if("function"!=typeof b)throw new Error("Inner key selector is required");if("string"==typeof c)c=LINQ.utils.parseExpression(c);else if("function"!=typeof c)throw new Error("Outer key selector is required");if("string"==typeof d)d=LINQ.utils.parseExpression(d);else if("function"!=typeof d)throw new Error("Results selector is required");"string"==typeof e?e=LINQ.utils.parseExpression(e):"function"!=typeof e&&(e=function(a,b){return a===b});for(var f=[],g=0,h=this.length;h>g;g++)for(var i=0,j=a.length;j>i;i++){var k=c(this[g],g,this),l=b(a[i],i,a);e(l,k)&&f.push(d(a[i],this[g]))}return f},contains:function(a,b){var c;if("string"==typeof b){var d=LINQ.utils.parseExpression(b);c=function(b){return d(b,a)}}else c="function"!=typeof b?function(b){return b===a}:function(c){return b(c,a)};return LINQ.methods.any.apply(this,[c])},aggregate:function(a,b){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Aggregator function is required");if(this.length<=0)return b;var c="undefined"==typeof b?LINQ.utils.getDefaultValue(LINQ.utils.getType(this[0])):b;if("function"==typeof Array.prototype.reduce)return this.reduce(a,c);for(var d=0,e=this.length;e>d;d++)c=a(c,this[d],d,this);return c},sum:function(a,b){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),b="undefined"==typeof b?LINQ.utils.getDefaultValue(LINQ.utils.getType(a(this[0],0,this))):b,LINQ.methods.aggregate.apply(this,[function(b,c,d,e){return b+a(c,d,e)},b])},min:function(a){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),this.length<=0?void 0:LINQ.methods.aggregate.apply(this,[function(b,c,d,e){var f=a(c,d,e);return b>f?f:b},a(this[0],0,this)])},max:function(a){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),this.length<=0?void 0:LINQ.methods.aggregate.apply(this,[function(b,c,d,e){var f=a(c,d,e);return f>b?f:b},a(this[0],0,this)])},skip:function(a){if("number"!=typeof a||0>a)throw new TypeError("Count is required and should be a positive number");return this.slice(a,this.length)},take:function(a){if("number"!=typeof a||0>a)throw new TypeError("Count is required and should be a positive number");return this.slice(0,a)},ofType:function(a){if("string"!=typeof a)throw new TypeError("Type is required.");return LINQ.methods.where.apply(this,[function(b){return typeof b===a}])},union:function(a){return this.concat(a)}}},LINQ.methods.firstOrDefault.finalize=!0,LINQ.methods.lastOrDefault.finalize=!0,LINQ.methods.count.finalize=!0,LINQ.methods.any.finalize=!0,LINQ.methods.contains.finalize=!0,LINQ.methods.all.finalize=!0,LINQ.methods.aggregate.finalize=!0,LINQ.methods.sum.finalize=!0,LINQ.methods.min.finalize=!0,LINQ.methods.max.finalize=!0;for(var key in LINQ.methods)LINQ.methods.hasOwnProperty(key)&&(Array.prototype[key]=LINQ.methods[key])}(),function(a){if(ko&&ko.observableArray&&ko.observableArray.fn){Array.prototype.toObservableArray=function(){return ko.observableArray(this)},ko.observableArray.fn.toArray=function(){return this()};for(var b in a.methods)a.methods.hasOwnProperty(b)&&(ko.observableArray.fn[b]=function(b){return function(){return a.methods[b].apply(this(),arguments)}}(b))}}(LINQ);
!function(){var stringTrim=function(a){return"string"!=typeof a||null===a?a:String.prototype.trim?a.trim():a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},expressionCache={};LINQ={utils:{parseExpression:function(a){if("function"==typeof a)return a;if(null==a||"string"!=typeof a||a.indexOf("=>")<0)throw new SyntaxError('Expression "'+a+'" is invalid');if("function"==typeof expressionCache[a])return expressionCache[a];var b,c=a.split("=>"),d=stringTrim(c[0]).replace(/[\(\)\s]/gi,""),e=stringTrim(c[1]);try{e.indexOf("return")<0&&(e="return ("+e+")"),b=new Function(d,e)}catch(f){b=new Function(d,e)}if("function"!=typeof b)throw new SyntaxError('Expression "'+a+'" is invalid');return expressionCache[a]=b,b},getType:function(a){var b=typeof a;if("object"!==b)return b;if(null===a)return"null";var c=a.constructor,d="function"==typeof c&&c.name;return"string"==typeof d&&d.length>0?d:"object"},getDefaultValue:function(type){if("string"!=typeof type)throw new TypeError("Type must be a string.");switch(type){case"boolean":return!1;case"function":return function(){};case"null":return null;case"number":return 0;case"object":return{};case"string":return"";case"symbol":return Symbol();case"undefined":return}try{var ctor="function"==typeof this[type]?this[type]:eval(type);return new ctor}catch(e){return{}}},isArray:function(a){return Array.isArray?Array.isArray(a):"[object Array]"===Object.prototype.toString.call(a)}},methods:{any:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)return this.length>0;if("function"==typeof Array.prototype.some)return this.some(a);for(var b=0,c=this.length;c>b;b++)if(a(this[b],b,this))return!0;return!1},all:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Predicate is required");if("function"==typeof Array.prototype.every)return this.every(a);var b=function(){return!a.apply(this,arguments)};return!LINQ.methods.any.apply(this,[b])},where:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Predicate is required");if("function"==typeof Array.prototype.filter)return this.filter(a);for(var b=[],c=0,d=this.length;d>c;c++)a(this[c],c,this)&&b.push(this[c]);return b},select:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Selector is required");if("function"==typeof Array.prototype.map)return this.map(a);for(var b=[],c=0,d=this.length;d>c;c++)b.push(a(this[c],c,this));return b},selectMany:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Selector is required");for(var b=[],c=0,d=this.length;d>c;c++){var e=a(this[c],c,this);if(LINQ.utils.isArray(e))for(var f=0,g=e.length;g>f;f++)b.push(e[f])}return b},count:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)return this.length;if("function"==typeof Array.prototype.filter)return this.filter(a).length;for(var b=0,c=0,d=this.length;d>c;c++)a(this[c],c,this)&&b++;return b},orderBy:function(a,b){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return b>a?-1:a>b?1:0}),this.slice(0).sort(function(c,d){var e=a(c),f=a(d);return b(e,f)})},orderByDescending:function(a,b){"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return b>a?-1:a>b?1:0});var c=function(){return-1*b.apply(this,arguments)};return LINQ.methods.orderBy.apply(this,[a,c])},groupBy:function(a,b){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Key selector is required");"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return{group:a,values:b}});for(var c={},d=0,e=this.length;e>d;d++){var f=a(this[d],d,this);c[f]||(c[f]=[]),c[f].push(this[d])}var g=[];for(var h in c)c.hasOwnProperty(h)&&g.push(b(h,c[h]));return g},distinct:function(a){"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a});for(var b={},c=[],d=0,e=this.length;e>d;d++){var f=a(this[d],d,this);b[f]||(b[f]=!0,c.push(this[d]))}return c},firstOrDefault:function(a){if("string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(){return!0}),"function"==typeof Array.prototype.find)return this.find(a)||null;for(var b=0,c=this.length;c>b;b++)if(a(this[b],b,this))return this[b];return null},lastOrDefault:function(a){"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(){return!0});for(var b=this.length-1;b>=0;b--)if(a(this[b],b,this))return this[b];return null},joinWith:function(a,b,c,d,e){if("string"==typeof b)b=LINQ.utils.parseExpression(b);else if("function"!=typeof b)throw new Error("Inner key selector is required");if("string"==typeof c)c=LINQ.utils.parseExpression(c);else if("function"!=typeof c)throw new Error("Outer key selector is required");if("string"==typeof d)d=LINQ.utils.parseExpression(d);else if("function"!=typeof d)throw new Error("Results selector is required");"string"==typeof e?e=LINQ.utils.parseExpression(e):"function"!=typeof e&&(e=function(a,b){return a===b});for(var f=[],g=0,h=this.length;h>g;g++)for(var i=0,j=a.length;j>i;i++){var k=c(this[g],g,this),l=b(a[i],i,a);e(l,k)&&f.push(d(a[i],this[g]))}return f},contains:function(a,b){var c;if("string"==typeof b){var d=LINQ.utils.parseExpression(b);c=function(b){return d(b,a)}}else c="function"!=typeof b?function(b){return b===a}:function(c){return b(c,a)};return LINQ.methods.any.apply(this,[c])},aggregate:function(a,b){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Aggregator function is required");if(this.length<=0)return b;var c="undefined"==typeof b?LINQ.utils.getDefaultValue(LINQ.utils.getType(this[0])):b;if("function"==typeof Array.prototype.reduce)return this.reduce(a,c);for(var d=0,e=this.length;e>d;d++)c=a(c,this[d],d,this);return c},sum:function(a,b){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),b="undefined"==typeof b?LINQ.utils.getDefaultValue(LINQ.utils.getType(a(this[0],0,this))):b,LINQ.methods.aggregate.apply(this,[function(b,c,d,e){return b+a(c,d,e)},b])},min:function(a){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),this.length<=0?void 0:LINQ.methods.aggregate.apply(this,[function(b,c,d,e){var f=a(c,d,e);return b>f?f:b},a(this[0],0,this)])},max:function(a){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),this.length<=0?void 0:LINQ.methods.aggregate.apply(this,[function(b,c,d,e){var f=a(c,d,e);return f>b?f:b},a(this[0],0,this)])},skip:function(a){if("number"!=typeof a||0>a)throw new TypeError("Count is required and should be a positive number");return this.slice(a,this.length)},take:function(a){if("number"!=typeof a||0>a)throw new TypeError("Count is required and should be a positive number");return this.slice(0,a)},ofType:function(a){if("string"!=typeof a)throw new TypeError("Type is required.");return LINQ.methods.where.apply(this,[function(b){return typeof b===a}])},union:function(a){return this.concat(a)}}},LINQ.methods.firstOrDefault.finalize=!0,LINQ.methods.lastOrDefault.finalize=!0,LINQ.methods.count.finalize=!0,LINQ.methods.any.finalize=!0,LINQ.methods.contains.finalize=!0,LINQ.methods.all.finalize=!0,LINQ.methods.aggregate.finalize=!0,LINQ.methods.sum.finalize=!0,LINQ.methods.min.finalize=!0,LINQ.methods.max.finalize=!0;for(var key in LINQ.methods)LINQ.methods.hasOwnProperty(key)&&(Array.prototype[key]=LINQ.methods[key])}(),function(a){if("undefined"!=typeof ko&&ko.observableArray&&ko.observableArray.fn){Array.prototype.toObservableArray=function(){return ko.observableArray(this)},ko.observableArray.fn.toArray=function(){return this()};for(var b in a.methods)a.methods.hasOwnProperty(b)&&(ko.observableArray.fn[b]=function(b){return function(){return a.methods[b].apply(this(),arguments)}}(b))}}(LINQ);

@@ -25,2 +25,2 @@ /* ! https://github.com/akopachov/mini-linq-js */

*/
!function(){var stringTrim=function(a){return"string"!=typeof a||null===a?a:String.prototype.trim?a.trim():a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},expressionCache={};LINQ={utils:{parseExpression:function(a){if("function"==typeof a)return a;if(null==a||"string"!=typeof a||a.indexOf("=>")<0)throw new SyntaxError('Expression "'+a+'" is invalid');if("function"==typeof expressionCache[a])return expressionCache[a];var b,c=a.split("=>"),d=stringTrim(c[0]).replace(/[\(\)\s]/gi,""),e=stringTrim(c[1]);try{e.indexOf("return")<0&&(e="return ("+e+")"),b=new Function(d,e)}catch(f){b=new Function(d,e)}if("function"!=typeof b)throw new SyntaxError('Expression "'+a+'" is invalid');return expressionCache[a]=b,b},getType:function(a){var b=typeof a;if("object"!==b)return b;if(null===a)return"null";var c=a.constructor,d="function"==typeof c&&c.name;return"string"==typeof d&&d.length>0?d:"object"},getDefaultValue:function(type){if("string"!=typeof type)throw new TypeError("Type must be a string.");switch(type){case"boolean":return!1;case"function":return function(){};case"null":return null;case"number":return 0;case"object":return{};case"string":return"";case"symbol":return Symbol();case"undefined":return}try{var ctor="function"==typeof this[type]?this[type]:eval(type);return new ctor}catch(e){return{}}},isArray:function(a){return Array.isArray?Array.isArray(a):"[object Array]"===Object.prototype.toString.call(a)}},methods:{any:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)return this.length>0;if("function"==typeof Array.prototype.some)return this.some(a);for(var b=0,c=this.length;c>b;b++)if(a(this[b],b,this))return!0;return!1},all:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Predicate is required");if("function"==typeof Array.prototype.every)return this.every(a);var b=function(){return!a.apply(this,arguments)};return!LINQ.methods.any.apply(this,[b])},where:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Predicate is required");if("function"==typeof Array.prototype.filter)return this.filter(a);for(var b=[],c=0,d=this.length;d>c;c++)a(this[c],c,this)&&b.push(this[c]);return b},select:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Selector is required");if("function"==typeof Array.prototype.map)return this.map(a);for(var b=[],c=0,d=this.length;d>c;c++)b.push(a(this[c],c,this));return b},selectMany:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Selector is required");for(var b=[],c=0,d=this.length;d>c;c++){var e=a(this[c],c,this);if(LINQ.utils.isArray(e))for(var f=0,g=e.length;g>f;f++)b.push(e[f])}return b},count:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)return this.length;if("function"==typeof Array.prototype.filter)return this.filter(a).length;for(var b=0,c=0,d=this.length;d>c;c++)a(this[c],c,this)&&b++;return b},orderBy:function(a,b){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return b>a?-1:a>b?1:0}),this.slice(0).sort(function(c,d){var e=a(c),f=a(d);return b(e,f)})},orderByDescending:function(a,b){"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return b>a?-1:a>b?1:0});var c=function(){return-1*b.apply(this,arguments)};return LINQ.methods.orderBy.apply(this,[a,c])},groupBy:function(a,b){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Key selector is required");"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return{group:a,values:b}});for(var c={},d=0,e=this.length;e>d;d++){var f=a(this[d],d,this);c[f]||(c[f]=[]),c[f].push(this[d])}var g=[];for(var h in c)c.hasOwnProperty(h)&&g.push(b(h,c[h]));return g},distinct:function(a){"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a});for(var b={},c=[],d=0,e=this.length;e>d;d++){var f=a(this[d],d,this);b[f]||(b[f]=!0,c.push(this[d]))}return c},firstOrDefault:function(a){if("string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(){return!0}),"function"==typeof Array.prototype.find)return this.find(a)||null;for(var b=0,c=this.length;c>b;b++)if(a(this[b],b,this))return this[b];return null},lastOrDefault:function(a){"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(){return!0});for(var b=this.length-1;b>=0;b--)if(a(this[b],b,this))return this[b];return null},joinWith:function(a,b,c,d,e){if("string"==typeof b)b=LINQ.utils.parseExpression(b);else if("function"!=typeof b)throw new Error("Inner key selector is required");if("string"==typeof c)c=LINQ.utils.parseExpression(c);else if("function"!=typeof c)throw new Error("Outer key selector is required");if("string"==typeof d)d=LINQ.utils.parseExpression(d);else if("function"!=typeof d)throw new Error("Results selector is required");"string"==typeof e?e=LINQ.utils.parseExpression(e):"function"!=typeof e&&(e=function(a,b){return a===b});for(var f=[],g=0,h=this.length;h>g;g++)for(var i=0,j=a.length;j>i;i++){var k=c(this[g],g,this),l=b(a[i],i,a);e(l,k)&&f.push(d(a[i],this[g]))}return f},contains:function(a,b){var c;if("string"==typeof b){var d=LINQ.utils.parseExpression(b);c=function(b){return d(b,a)}}else c="function"!=typeof b?function(b){return b===a}:function(c){return b(c,a)};return LINQ.methods.any.apply(this,[c])},aggregate:function(a,b){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Aggregator function is required");if(this.length<=0)return b;var c="undefined"==typeof b?LINQ.utils.getDefaultValue(LINQ.utils.getType(this[0])):b;if("function"==typeof Array.prototype.reduce)return this.reduce(a,c);for(var d=0,e=this.length;e>d;d++)c=a(c,this[d],d,this);return c},sum:function(a,b){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),b="undefined"==typeof b?LINQ.utils.getDefaultValue(LINQ.utils.getType(a(this[0],0,this))):b,LINQ.methods.aggregate.apply(this,[function(b,c,d,e){return b+a(c,d,e)},b])},min:function(a){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),this.length<=0?void 0:LINQ.methods.aggregate.apply(this,[function(b,c,d,e){var f=a(c,d,e);return b>f?f:b},a(this[0],0,this)])},max:function(a){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),this.length<=0?void 0:LINQ.methods.aggregate.apply(this,[function(b,c,d,e){var f=a(c,d,e);return f>b?f:b},a(this[0],0,this)])},skip:function(a){if("number"!=typeof a||0>a)throw new TypeError("Count is required and should be a positive number");return this.slice(a,this.length)},take:function(a){if("number"!=typeof a||0>a)throw new TypeError("Count is required and should be a positive number");return this.slice(0,a)},ofType:function(a){if("string"!=typeof a)throw new TypeError("Type is required.");return LINQ.methods.where.apply(this,[function(b){return typeof b===a}])},union:function(a){return this.concat(a)}}},LINQ.methods.firstOrDefault.finalize=!0,LINQ.methods.lastOrDefault.finalize=!0,LINQ.methods.count.finalize=!0,LINQ.methods.any.finalize=!0,LINQ.methods.contains.finalize=!0,LINQ.methods.all.finalize=!0,LINQ.methods.aggregate.finalize=!0,LINQ.methods.sum.finalize=!0,LINQ.methods.min.finalize=!0,LINQ.methods.max.finalize=!0;for(var key in LINQ.methods)LINQ.methods.hasOwnProperty(key)&&(Array.prototype[key]=LINQ.methods[key])}(),function(a){var b=[function(b,c){if(b.name===c.name&&"where"===c.name){var d=a.utils.parseExpression(b.args[0]),e=a.utils.parseExpression(c.args[0]);return function(c,d){return{name:b.name,args:[function(){return c.apply(this,arguments)&&d.apply(this,arguments)}],fn:a.methods[b.name]}}(d,e)}return!1},function(b,c){if(b.name===c.name&&"select"===c.name){var d=a.utils.parseExpression(b.args[0]),e=a.utils.parseExpression(c.args[0]);return function(c,d){return{name:b.name,args:[function(){return d.apply(this,[c.apply(this,arguments)])}],fn:a.methods[b.name]}}(d,e)}return!1},function(a,b){var c=["orderBy","orderByDescending"];return c.contains(a.name)&&c.contains(b.name)?b:!1},function(a,b){return"skip"==a.name&&"take"==b.name?function(a,b){return{name:"skiptake",args:[a,b],fn:function(a,b){return this.slice(a,a+b)}}}(a.args[0],b.args[0]):!1}],c=function(a){var c=this,d=a;c._modificatorQueue=[];var e=function(){for(var a=c._modificatorQueue.length,b=0;a>b;b++){var e=c._modificatorQueue[b];d=e.fn.apply(d,e.args)}return c._modificatorQueue.splice(0,a),a},f=function(){for(var a=0;a<c._modificatorQueue.length-1;){for(var d=c._modificatorQueue[a],e=c._modificatorQueue[a+1],f=!1,g=0,h=b.length;h>g;g++){var i=b[g],j=i(d,e);j&&(f=!0,c._modificatorQueue.splice(a+1,1),c._modificatorQueue[a]=j)}f||a++}};c.optimize=function(){return f(),c},c.toArray=function(){return d.length>100&&c._modificatorQueue.length>2&&c.optimize(),e(),Array.isArray(d)?d.slice(0):d}};Array.prototype.toLazy=function(){return new c(this)};for(var d in a.methods)a.methods.hasOwnProperty(d)&&(c.prototype[d]=function(b){return function(){var c=a.methods[b];return this._modificatorQueue.push({fn:a.methods[b],args:arguments,name:b}),c.finalize?this.toArray():this}}(d))}(LINQ);
!function(){var stringTrim=function(a){return"string"!=typeof a||null===a?a:String.prototype.trim?a.trim():a.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},expressionCache={};LINQ={utils:{parseExpression:function(a){if("function"==typeof a)return a;if(null==a||"string"!=typeof a||a.indexOf("=>")<0)throw new SyntaxError('Expression "'+a+'" is invalid');if("function"==typeof expressionCache[a])return expressionCache[a];var b,c=a.split("=>"),d=stringTrim(c[0]).replace(/[\(\)\s]/gi,""),e=stringTrim(c[1]);try{e.indexOf("return")<0&&(e="return ("+e+")"),b=new Function(d,e)}catch(f){b=new Function(d,e)}if("function"!=typeof b)throw new SyntaxError('Expression "'+a+'" is invalid');return expressionCache[a]=b,b},getType:function(a){var b=typeof a;if("object"!==b)return b;if(null===a)return"null";var c=a.constructor,d="function"==typeof c&&c.name;return"string"==typeof d&&d.length>0?d:"object"},getDefaultValue:function(type){if("string"!=typeof type)throw new TypeError("Type must be a string.");switch(type){case"boolean":return!1;case"function":return function(){};case"null":return null;case"number":return 0;case"object":return{};case"string":return"";case"symbol":return Symbol();case"undefined":return}try{var ctor="function"==typeof this[type]?this[type]:eval(type);return new ctor}catch(e){return{}}},isArray:function(a){return Array.isArray?Array.isArray(a):"[object Array]"===Object.prototype.toString.call(a)}},methods:{any:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)return this.length>0;if("function"==typeof Array.prototype.some)return this.some(a);for(var b=0,c=this.length;c>b;b++)if(a(this[b],b,this))return!0;return!1},all:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Predicate is required");if("function"==typeof Array.prototype.every)return this.every(a);var b=function(){return!a.apply(this,arguments)};return!LINQ.methods.any.apply(this,[b])},where:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Predicate is required");if("function"==typeof Array.prototype.filter)return this.filter(a);for(var b=[],c=0,d=this.length;d>c;c++)a(this[c],c,this)&&b.push(this[c]);return b},select:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Selector is required");if("function"==typeof Array.prototype.map)return this.map(a);for(var b=[],c=0,d=this.length;d>c;c++)b.push(a(this[c],c,this));return b},selectMany:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Selector is required");for(var b=[],c=0,d=this.length;d>c;c++){var e=a(this[c],c,this);if(LINQ.utils.isArray(e))for(var f=0,g=e.length;g>f;f++)b.push(e[f])}return b},count:function(a){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)return this.length;if("function"==typeof Array.prototype.filter)return this.filter(a).length;for(var b=0,c=0,d=this.length;d>c;c++)a(this[c],c,this)&&b++;return b},orderBy:function(a,b){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return b>a?-1:a>b?1:0}),this.slice(0).sort(function(c,d){var e=a(c),f=a(d);return b(e,f)})},orderByDescending:function(a,b){"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return b>a?-1:a>b?1:0});var c=function(){return-1*b.apply(this,arguments)};return LINQ.methods.orderBy.apply(this,[a,c])},groupBy:function(a,b){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Key selector is required");"string"==typeof b?b=LINQ.utils.parseExpression(b):"function"!=typeof b&&(b=function(a,b){return{group:a,values:b}});for(var c={},d=0,e=this.length;e>d;d++){var f=a(this[d],d,this);c[f]||(c[f]=[]),c[f].push(this[d])}var g=[];for(var h in c)c.hasOwnProperty(h)&&g.push(b(h,c[h]));return g},distinct:function(a){"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a});for(var b={},c=[],d=0,e=this.length;e>d;d++){var f=a(this[d],d,this);b[f]||(b[f]=!0,c.push(this[d]))}return c},firstOrDefault:function(a){if("string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(){return!0}),"function"==typeof Array.prototype.find)return this.find(a)||null;for(var b=0,c=this.length;c>b;b++)if(a(this[b],b,this))return this[b];return null},lastOrDefault:function(a){"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(){return!0});for(var b=this.length-1;b>=0;b--)if(a(this[b],b,this))return this[b];return null},joinWith:function(a,b,c,d,e){if("string"==typeof b)b=LINQ.utils.parseExpression(b);else if("function"!=typeof b)throw new Error("Inner key selector is required");if("string"==typeof c)c=LINQ.utils.parseExpression(c);else if("function"!=typeof c)throw new Error("Outer key selector is required");if("string"==typeof d)d=LINQ.utils.parseExpression(d);else if("function"!=typeof d)throw new Error("Results selector is required");"string"==typeof e?e=LINQ.utils.parseExpression(e):"function"!=typeof e&&(e=function(a,b){return a===b});for(var f=[],g=0,h=this.length;h>g;g++)for(var i=0,j=a.length;j>i;i++){var k=c(this[g],g,this),l=b(a[i],i,a);e(l,k)&&f.push(d(a[i],this[g]))}return f},contains:function(a,b){var c;if("string"==typeof b){var d=LINQ.utils.parseExpression(b);c=function(b){return d(b,a)}}else c="function"!=typeof b?function(b){return b===a}:function(c){return b(c,a)};return LINQ.methods.any.apply(this,[c])},aggregate:function(a,b){if("string"==typeof a)a=LINQ.utils.parseExpression(a);else if("function"!=typeof a)throw new Error("Aggregator function is required");if(this.length<=0)return b;var c="undefined"==typeof b?LINQ.utils.getDefaultValue(LINQ.utils.getType(this[0])):b;if("function"==typeof Array.prototype.reduce)return this.reduce(a,c);for(var d=0,e=this.length;e>d;d++)c=a(c,this[d],d,this);return c},sum:function(a,b){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),b="undefined"==typeof b?LINQ.utils.getDefaultValue(LINQ.utils.getType(a(this[0],0,this))):b,LINQ.methods.aggregate.apply(this,[function(b,c,d,e){return b+a(c,d,e)},b])},min:function(a){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),this.length<=0?void 0:LINQ.methods.aggregate.apply(this,[function(b,c,d,e){var f=a(c,d,e);return b>f?f:b},a(this[0],0,this)])},max:function(a){return"string"==typeof a?a=LINQ.utils.parseExpression(a):"function"!=typeof a&&(a=function(a){return a}),this.length<=0?void 0:LINQ.methods.aggregate.apply(this,[function(b,c,d,e){var f=a(c,d,e);return f>b?f:b},a(this[0],0,this)])},skip:function(a){if("number"!=typeof a||0>a)throw new TypeError("Count is required and should be a positive number");return this.slice(a,this.length)},take:function(a){if("number"!=typeof a||0>a)throw new TypeError("Count is required and should be a positive number");return this.slice(0,a)},ofType:function(a){if("string"!=typeof a)throw new TypeError("Type is required.");return LINQ.methods.where.apply(this,[function(b){return typeof b===a}])},union:function(a){return this.concat(a)}}},LINQ.methods.firstOrDefault.finalize=!0,LINQ.methods.lastOrDefault.finalize=!0,LINQ.methods.count.finalize=!0,LINQ.methods.any.finalize=!0,LINQ.methods.contains.finalize=!0,LINQ.methods.all.finalize=!0,LINQ.methods.aggregate.finalize=!0,LINQ.methods.sum.finalize=!0,LINQ.methods.min.finalize=!0,LINQ.methods.max.finalize=!0;for(var key in LINQ.methods)LINQ.methods.hasOwnProperty(key)&&(Array.prototype[key]=LINQ.methods[key])}(),function(a){var b=[function(b,c){if(b.name===c.name&&"where"===c.name){var d=a.utils.parseExpression(b.args[0]),e=a.utils.parseExpression(c.args[0]);return function(c,d){return{name:b.name,args:[function(){return c.apply(this,arguments)&&d.apply(this,arguments)}],fn:a.methods[b.name]}}(d,e)}return!1},function(b,c){if(b.name===c.name&&"select"===c.name){var d=a.utils.parseExpression(b.args[0]),e=a.utils.parseExpression(c.args[0]);return function(c,d){return{name:b.name,args:[function(){return d.apply(this,[c.apply(this,arguments)])}],fn:a.methods[b.name]}}(d,e)}return!1},function(a,b){var c=["orderBy","orderByDescending"];return c.contains(a.name)&&c.contains(b.name)?b:!1},function(a,b){return"skip"==a.name&&"take"==b.name?function(a,b){return{name:"skiptake",args:[a,b],fn:function(a,b){return this.slice(a,a+b)}}}(a.args[0],b.args[0]):!1}],c=function(c){var d=this,e=c;d._modificatorQueue=[];var f=function(){for(var a=d._modificatorQueue.length,b=0;a>b;b++){var c=d._modificatorQueue[b];e=c.fn.apply(e,c.args)}return d._modificatorQueue.splice(0,a),a},g=function(){for(var a=0;a<d._modificatorQueue.length-1;){for(var c=d._modificatorQueue[a],e=d._modificatorQueue[a+1],f=!1,g=0,h=b.length;h>g;g++){var i=b[g],j=i(c,e);j&&(f=!0,d._modificatorQueue.splice(a+1,1),d._modificatorQueue[a]=j)}f||a++}};d.optimize=function(){return g(),d},d.toArray=function(){return e.length>100&&d._modificatorQueue.length>2&&d.optimize(),f(),a.utils.isArray(e)?e.slice(0):e}};Array.prototype.toLazy=function(){return new c(this)};for(var d in a.methods)a.methods.hasOwnProperty(d)&&(c.prototype[d]=function(b){return function(){var c=a.methods[b];return this._modificatorQueue.push({fn:a.methods[b],args:arguments,name:b}),c.finalize?this.toArray():this}}(d))}(LINQ);
{
"name": "mini-linq-js",
"version": "1.2.3",
"version": "1.2.4",
"description": "LINQ for JavaScript library, which allows to work with arrays in a more easy way and focus on business logic.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/akopachov/mini-linq-js",

@@ -26,3 +26,3 @@ /* ! https://github.com/akopachov/mini-linq-js */

(function(LINQ) {
if (!ko || !ko.observableArray || !ko.observableArray.fn) {
if (typeof(ko) == 'undefined' || !ko.observableArray || !ko.observableArray.fn) {
return;

@@ -29,0 +29,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc