/
underscore-ko.min.js
7 lines (7 loc) · 1.19 KB
/
underscore-ko.min.js
1
2
3
4
5
6
7
// UnderscoreKO Mashup Library v1.1.0
// (c) Kamran Ayub - http://github.com/kamranayub/UnderscoreKO
// License: MIT (http://www.opensource.org/licenses/mit-license.php)
//
// Adds all 45 Underscore.js collection and array methods to
// KO observable arrays.
(function(a,b,c){var d=["each","forEach","map","collect","reduce","inject","foldl","reduceRight","foldr","find","detect","filter","select","filter_","select_","reject","reject_","all","every","any","some","include","contains","invoke","invoke_","pluck","max","min","sortBy","sortBy_","groupBy","groupBy_","sortedIndex","shuffle","shuffle_","size","first","head","initial","last","rest","tail","rest_","tail_","compact","compact_","flatten","flatten_","without","without_","uniq","unique","uniq_","unique_","lastIndexOf","chain"],e=["union","union_","intersection","intersection_","difference","difference_","zip","zip_"];b.each(b.union(d,e),function(c){a.observableArray.fn[c]||(a.observableArray.fn[c]=function(){var a=b.toArray(arguments);return b.include(e,c)&&b.each(a,function(b,d){typeof b=="function"&&b[c]&&(a[d]=b())}),a.splice(0,0,this()),c.substr(c.length-1,1)==="_"?this(b[c.substr(0,c.length-1)].apply(this,a)):b[c].apply(this,a)})})})(ko,_);