Merged origin/lodash

This commit is contained in:
Brian Zengel
2013-11-10 12:41:40 -05:00
2 changed files with 389 additions and 277 deletions
+94 -101
View File
@@ -80,46 +80,46 @@ Dog.prototype.bark = function() {
console.log('Woof, woof!');
};
var result;
var result : any;
/*************
* Chaining *
*************/
result = <LoDash.LoDashWrapper<string>>_('test');
result = <LoDash.LoDashWrapper<number>>_(1);
result = <LoDash.LoDashWrapper<boolean>>_(true);
result = <LoDash.LoDashArrayWrapper<string>>_(['test1', 'test2']);
result = <LoDash.LoDashObjectWrapper<LoDash.Dictionary<string>>>_({'key1': 'test1', 'key2': 'test2'});
result = <_.LoDashWrapper<string>>_('test');
result = <_.LoDashWrapper<number>>_(1);
result = <_.LoDashWrapper<boolean>>_(true);
result = <_.LoDashArrayWrapper<string>>_(['test1', 'test2']);
result = <_.LoDashObjectWrapper<_.Dictionary<string>>>_({'key1': 'test1', 'key2': 'test2'});
result = <LoDash.LoDashWrapper<string>>_.chain('test');
result = <LoDash.LoDashWrapper<string>>_('test').chain();
result = <LoDash.LoDashWrapper<number>>_.chain(1);
result = <LoDash.LoDashWrapper<number>>_(1).chain();
result = <LoDash.LoDashWrapper<boolean>>_.chain(true);
result = <LoDash.LoDashWrapper<boolean>>_(true).chain();
result = <LoDash.LoDashArrayWrapper<string>>_.chain(['test1', 'test2']);
result = <LoDash.LoDashArrayWrapper<string>>_(['test1', 'test2']).chain();
result = <LoDash.LoDashObjectWrapper<LoDash.Dictionary<string>>>_.chain({'key1': 'test1', 'key2': 'test2'});
result = <LoDash.LoDashObjectWrapper<LoDash.Dictionary<string>>>_({'key1': 'test1', 'key2': 'test2'}).chain();
result = <_.LoDashWrapper<string>>_.chain('test');
result = <_.LoDashWrapper<string>>_('test').chain();
result = <_.LoDashWrapper<number>>_.chain(1);
result = <_.LoDashWrapper<number>>_(1).chain();
result = <_.LoDashWrapper<boolean>>_.chain(true);
result = <_.LoDashWrapper<boolean>>_(true).chain();
result = <_.LoDashArrayWrapper<string>>_.chain(['test1', 'test2']);
result = <_.LoDashArrayWrapper<string>>_(['test1', 'test2']).chain();
result = <_.LoDashObjectWrapper<_.Dictionary<string>>>_.chain({'key1': 'test1', 'key2': 'test2'});
result = <_.LoDashObjectWrapper<_.Dictionary<string>>>_({'key1': 'test1', 'key2': 'test2'}).chain();
//Wrapped array shortcut methods
result = <LoDash.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).concat(5, 6);
result = <LoDash.LoDashWrapper<string>>_([1, 2, 3, 4]).join(',');
result = <LoDash.LoDashWrapper<number>>_([1, 2, 3, 4]).pop();
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).concat(5, 6);
result = <_.LoDashWrapper<string>>_([1, 2, 3, 4]).join(',');
result = <_.LoDashWrapper<number>>_([1, 2, 3, 4]).pop();
_([1, 2, 3, 4]).push(5, 6, 7);
result = <LoDash.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).reverse();
result = <LoDash.LoDashWrapper<number>>_([1, 2, 3, 4]).shift();
result = <LoDash.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).slice(1, 2);
result = <LoDash.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).slice(2);
result = <LoDash.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).sort((a, b) => 1);
result = <LoDash.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).splice(1);
result = <LoDash.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).splice(1, 2, 5, 6);
result = <LoDash.LoDashWrapper<number>>_([1, 2, 3, 4]).unshift(5, 6);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).reverse();
result = <_.LoDashWrapper<number>>_([1, 2, 3, 4]).shift();
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).slice(1, 2);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).slice(2);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).sort((a, b) => 1);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).splice(1);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).splice(1, 2, 5, 6);
result = <_.LoDashWrapper<number>>_([1, 2, 3, 4]).unshift(5, 6);
result = <number[]>_.tap([1, 2, 3, 4], function(array) { console.log(array); });
result = <LoDash.LoDashWrapper<string>>_('test').tap(function(value) { console.log(value); });
result = <LoDash.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).tap(function(array) { console.log(array); });
result = <LoDash.LoDashObjectWrapper<LoDash.Dictionary<string>>>_({'key1': 'test1', 'key2': 'test2'}).tap(function(array) { console.log(array); });
result = <_.LoDashWrapper<string>>_('test').tap(function(value) { console.log(value); });
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).tap(function(array) { console.log(array); });
result = <_.LoDashObjectWrapper<_.Dictionary<string>>>_({'key1': 'test1', 'key2': 'test2'}).tap(function(array) { console.log(array); });
result = <string>_('test').toString();
result = <string>_([1, 2, 3]).toString();
@@ -127,44 +127,38 @@ result = <string>_({'key1': 'test1', 'key2': 'test2'}).toString();
result = <string>_('test').valueOf();
result = <number[]>_([1, 2, 3]).valueOf();
result = <LoDash.Dictionary<string>>_({'key1': 'test1', 'key2': 'test2'}).valueOf();
result = <_.Dictionary<string>>_({'key1': 'test1', 'key2': 'test2'}).valueOf();
result = <string>_('test').value();
result = <number[]>_([1, 2, 3]).value();
result = <LoDash.Dictionary<string>>_({'key1': 'test1', 'key2': 'test2'}).value();
result = <_.Dictionary<string>>_({'key1': 'test1', 'key2': 'test2'}).value();
// /*************
// * Arrays *
// *************/
result = <any[]>_.compact([0, 1, false, 2, '', 3]);
result = <LoDash.LoDashArrayWrapper<any>>_([0, 1, false, 2, '', 3]).compact();
result = <_.LoDashArrayWrapper<any>>_([0, 1, false, 2, '', 3]).compact();
result = <number[]>_.difference([1, 2, 3, 4, 5], [5, 2, 10]);
result = <LoDash.LoDashArrayWrapper<number>>_([1, 2, 3, 4, 5]).difference([5, 2, 10]);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4, 5]).difference([5, 2, 10]);
result = <number[]>_.rest([1, 2, 3]);
result = <number[]>_.rest([1, 2, 3], 2);
result = <number[]>_.rest([1, 2, 3], function(num) {
return num < 3;
});
result = <number[]>_.rest([1, 2, 3], (num) => num < 3)
result = <IFoodOrganic[]>_.rest(foodsOrganic, 'test');
result = <IFoodType[]>_.rest(foodsType, { 'test': 'value' });
result = <IFoodType[]>_.rest(foodsType, { 'type': 'value' });
result = <number[]>_.drop([1, 2, 3]);
result = <number[]>_.drop([1, 2, 3], 2);
result = <number[]>_.drop([1, 2, 3], function(num) {
return num < 3;
});
result = <IFoodOrganic[]>_.drop(foodsOrganic, 'test');
result = <IFoodType[]>_.drop(foodsType, { 'test': 'value' });
result = <number[]>_.drop([1, 2, 3]);
result = <number[]>_.drop([1, 2, 3], 2);
result = <number[]>_.drop([1, 2, 3], (num) => num < 3)
result = <IFoodOrganic[]>_.drop(foodsOrganic, 'test');
result = <IFoodType[]>_.drop(foodsType, { 'type': 'value' });
result = <number[]>_.tail([1, 2, 3]);
result = <number[]>_.tail([1, 2, 3], 2);
result = <number[]>_.tail([1, 2, 3], function(num) {
return num < 3;
});
result = <IFoodOrganic[]>_.tail(foodsOrganic, 'test');
result = <IFoodType[]>_.tail(foodsType, { 'test': 'value' });
result = <number[]>_.tail([1, 2, 3])
result = <number[]>_.tail([1, 2, 3], 2)
result = <number[]>_.tail([1, 2, 3], (num) => num < 3)
result = <IFoodOrganic[]>_.tail(foodsOrganic, 'test')
result = <IFoodType[]> _.tail(foodsType, { 'type': 'value' })
result = <number>_.findIndex(['apple', 'banana', 'beet'], function(f) {
return /^b/.test(f);
@@ -196,19 +190,18 @@ result = <IFoodType[]>_.first(foodsType, { 'type': 'fruit' });
result = <number>_.take([1, 2, 3]);
result = <number[]>_.take([1, 2, 3], 2);
result = <number[]>_.take([1, 2, 3], function(num) {
return num < 3;
});
result = <number[]>_.take([1, 2, 3], (num) => num < 3);
result = <IFoodOrganic[]>_.take(foodsOrganic, 'organic');
result = <IFoodType[]>_.take(foodsType, { 'type': 'fruit' });
result = <number[]>_.flatten([1, [2], [3, [[4]]]]);
result = <any[]>_.flatten([1, [2], [3, [[4]]]], true);
var result: any
result = <string[]>_.flatten(stoogesQuotes, 'quotes');
result = <LoDash.LoDashArrayWrapper<number>>_([1, [2], [3, [[4]]]]).flatten();
result = <LoDash.LoDashArrayWrapper<number>>_([1, [2], [3, [[4]]]]).flatten(true);
result = <LoDash.LoDashArrayWrapper<string>>_(stoogesQuotes).flatten('quotes');
result = <_.LoDashArrayWrapper<number>>_([1, [2], [3, [[4]]]]).flatten();
result = <_.LoDashArrayWrapper<number>>_([1, [2], [3, [[4]]]]).flatten(true);
result = <_.LoDashArrayWrapper<string>>_(stoogesQuotes).flatten('quotes');
result = <number>_.indexOf([1, 2, 3, 1, 2, 3], 2);
result = <number>_.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
@@ -303,13 +296,13 @@ result = <boolean>_.contains('curly', 'ur');
result = <boolean>_.include({ 'name': 'moe', 'age': 40 }, 'moe');
result = <boolean>_.include('curly', 'ur');
result = <LoDash.Dictionary<number>>_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
result = <LoDash.Dictionary<number>>_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
result = <LoDash.Dictionary<number>>_.countBy(['one', 'two', 'three'], 'length');
result = <_.Dictionary<number>>_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
result = <_.Dictionary<number>>_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
result = <_.Dictionary<number>>_.countBy(['one', 'two', 'three'], 'length');
result = <LoDash.LoDashObjectWrapper<LoDash.Dictionary<number>>>_([4.3, 6.1, 6.4]).countBy(function(num) { return Math.floor(num); });
result = <LoDash.LoDashObjectWrapper<LoDash.Dictionary<number>>>_([4.3, 6.1, 6.4]).countBy(function(num) { return this.floor(num); }, Math);
result = <LoDash.LoDashObjectWrapper<LoDash.Dictionary<number>>>_(['one', 'two', 'three']).countBy('length');
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_([4.3, 6.1, 6.4]).countBy(function(num) { return Math.floor(num); });
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_([4.3, 6.1, 6.4]).countBy(function(num) { return this.floor(num); }, Math);
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_(['one', 'two', 'three']).countBy('length');
result = <boolean>_.every([true, 1, null, 'yes'], Boolean);
result = <boolean>_.every(stoogesAges, 'age');
@@ -360,36 +353,36 @@ result = <IFoodCombined>_.findLast(foodsCombined, { 'type': 'vegetable' });
result = <IFoodCombined>_.findLast(foodsCombined, 'organic');
result = <number[]>_.forEach([1, 2, 3], function(num) { console.log(num); });
result = <LoDash.Dictionary<number>>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); });
result = <_.Dictionary<number>>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); });
result = <number[]>_.each([1, 2, 3], function(num) { console.log(num); });
result = <LoDash.Dictionary<number>>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); });
result = <_.Dictionary<number>>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); });
result = <LoDash.LoDashArrayWrapper<number>>_([1, 2, 3]).forEach(function(num) { console.log(num); });
result = <LoDash.LoDashObjectWrapper<LoDash.Dictionary<number>>>_({ 'one': 1, 'two': 2, 'three': 3 }).forEach(function(num) { console.log(num); });
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3]).forEach(function(num) { console.log(num); });
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_({ 'one': 1, 'two': 2, 'three': 3 }).forEach(function(num) { console.log(num); });
result = <LoDash.LoDashArrayWrapper<number>>_([1, 2, 3]).each(function(num) { console.log(num); });
result = <LoDash.LoDashObjectWrapper<LoDash.Dictionary<number>>>_({ 'one': 1, 'two': 2, 'three': 3 }).each(function(num) { console.log(num); });
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3]).each(function(num) { console.log(num); });
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_({ 'one': 1, 'two': 2, 'three': 3 }).each(function(num) { console.log(num); });
result = <number[]>_.forEachRight([1, 2, 3], function(num) { console.log(num); });
result = <LoDash.Dictionary<number>>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); });
result = <_.Dictionary<number>>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); });
result = <number[]>_.eachRight([1, 2, 3], function(num) { console.log(num); });
result = <LoDash.Dictionary<number>>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); });
result = <_.Dictionary<number>>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); });
result = <LoDash.LoDashArrayWrapper<number>>_([1, 2, 3]).forEachRight(function(num) { console.log(num); });
result = <LoDash.LoDashObjectWrapper<LoDash.Dictionary<number>>>_({ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function(num) { console.log(num); });
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3]).forEachRight(function(num) { console.log(num); });
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_({ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function(num) { console.log(num); });
result = <LoDash.LoDashArrayWrapper<number>>_([1, 2, 3]).eachRight(function(num) { console.log(num); });
result = <LoDash.LoDashObjectWrapper<LoDash.Dictionary<number>>>_({ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function(num) { console.log(num); });
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3]).eachRight(function(num) { console.log(num); });
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_({ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function(num) { console.log(num); });
result = <LoDash.Dictionary<number[]>>_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
result = <LoDash.Dictionary<number[]>>_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
result = <LoDash.Dictionary<string[]>>_.groupBy(['one', 'two', 'three'], 'length');
result = <_.Dictionary<number[]>>_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
result = <_.Dictionary<number[]>>_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
result = <_.Dictionary<string[]>>_.groupBy(['one', 'two', 'three'], 'length');
result = <LoDash.Dictionary<IKey>>_.indexBy(keys, 'dir');
result = <LoDash.Dictionary<IKey>>_.indexBy(keys, function(key) { return String.fromCharCode(key.code); });
result = <LoDash.Dictionary<IKey>>_.indexBy(keys, function(key) { this.fromCharCode(key.code); }, String);
result = <_.Dictionary<IKey>>_.indexBy(keys, 'dir');
result = <_.Dictionary<IKey>>_.indexBy(keys, function(key) { return String.fromCharCode(key.code); });
result = <_.Dictionary<IKey>>_.indexBy(keys, function(key) { this.fromCharCode(key.code); }, String);
result = <any[]>_.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
result = <any[]>_.invoke([123, 456], String.prototype.split, '');
@@ -543,19 +536,19 @@ var greet = function(formatted) {
};
result = <Function>_.compose(greet, format);
result = <LoDash.LoDashObjectWrapper<Function>>_(greet).compose(format);
result = <_.LoDashObjectWrapper<Function>>_(greet).compose(format);
var createCallbackObj = { name: 'Joe' };
result = <() => any>_.createCallback('name');
result = <() => boolean>_.createCallback(createCallbackObj);
result = <LoDash.LoDashObjectWrapper<() => any>>_('name').createCallback();
result = <LoDash.LoDashObjectWrapper<() => boolean>>_(createCallbackObj).createCallback();
result = <_.LoDashObjectWrapper<() => any>>_('name').createCallback();
result = <_.LoDashObjectWrapper<() => boolean>>_(createCallbackObj).createCallback();
result = <Function>_.curry(function(a, b, c) {
console.log(a + b + c);
});
result = <LoDash.LoDashObjectWrapper<Function>>_(function(a, b, c) {
result = <_.LoDashObjectWrapper<Function>>_(function(a, b, c) {
console.log(a + b + c);
}).curry();
@@ -571,23 +564,23 @@ source.addEventListener('message', <Function>_.debounce(function() {}, 250, {
'maxWait': 1000
}), false);
result = <LoDash.LoDashObjectWrapper<Function>>_(function() {}).debounce(150);
result = <_.LoDashObjectWrapper<Function>>_(function() {}).debounce(150);
jQuery('#postbox').on('click', <LoDash.LoDashObjectWrapper<Function>>_(function() {}).debounce(300, {
jQuery('#postbox').on('click', <_.LoDashObjectWrapper<Function>>_(function() {}).debounce(300, {
'leading': true,
'trailing': false
}));
source.addEventListener('message', <LoDash.LoDashObjectWrapper<Function>>_(function() {}).debounce(250, {
source.addEventListener('message', <_.LoDashObjectWrapper<Function>>_(function() {}).debounce(250, {
'maxWait': 1000
}), false);
result = <number>_.defer(function() { console.log('deferred'); });
result = <LoDash.LoDashWrapper<number>>_(function() { console.log('deferred'); }).defer();
result = <_.LoDashWrapper<number>>_(function() { console.log('deferred'); }).defer();
var log = _.bind(console.log, console);
result = <number>_.delay(log, 1000, 'logged later');
result = <LoDash.LoDashWrapper<number>>_(log).delay(1000, 'logged later');
result = <_.LoDashWrapper<number>>_(log).delay(1000, 'logged later');
var fibonacci = <Function>_.memoize(function(n) {
return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
@@ -642,8 +635,8 @@ result = <any>_.assign({ 'name': 'moe' }, { 'age': 40 }, function(a, b) {
return typeof a == 'undefined' ? b : a;
});
result = <LoDash.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).assign({ 'age': 40 });
result = <LoDash.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a, b) {
result = <_.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).assign({ 'age': 40 });
result = <_.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a, b) {
return typeof a == 'undefined' ? b : a;
});
@@ -652,8 +645,8 @@ result = <LoDash.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).assign({ 'age': 4
return typeof a == 'undefined' ? b : a;
});
result = <LoDash.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).extend({ 'age': 40 });
result = <LoDash.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a, b) {
result = <_.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).extend({ 'age': 40 });
result = <_.LoDashObjectWrapper<any>>_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a, b) {
return typeof a == 'undefined' ? b : a;
});
@@ -867,7 +860,7 @@ result = <any>_.result(object, 'stuff');
var tempObject = {};
result = <typeof _>_.runInContext(tempObject);
result = <LoDash.TemplateExecutor>_.template('hello <%= name %>');
result = <_.TemplateExecutor>_.template('hello <%= name %>');
result = <string>_.template('<b><%- value %></b>', { 'value': '<script>' });
var listTemplate = '<% _.forEach(people, function(name) { %><li><%- name %></li><% }); %>';
@@ -877,10 +870,10 @@ result = <string>_.template('<% print("hello " + name); %>!', { 'name': 'larry'
var listTemplate = '<% $.each(people, function(name) { %><li><%- name %></li><% }); %>';
result = <string>_.template(listTemplate, { 'people': ['moe', 'larry'] }, { 'imports': { '$': jQuery } });
result = <LoDash.TemplateExecutor>_.template('hello <%= name %>', null, { 'sourceURL': '/basic/greeting.jst' });
result = <_.TemplateExecutor>_.template('hello <%= name %>', null, { 'sourceURL': '/basic/greeting.jst' });
result = <LoDash.TemplateExecutor>_.template('hi <%= data.name %>!', null, { 'variable': 'data' });
result = <string>(<LoDash.TemplateExecutor>result).source;
result = <_.TemplateExecutor>_.template('hi <%= data.name %>!', null, { 'variable': 'data' });
result = <string>(<_.TemplateExecutor>result).source;
function Mage() {
this.castSpell = (n:number) => n;
@@ -901,5 +894,5 @@ result = <string>_.uniqueId();
***********/
result = <string>_.VERSION;
result = <LoDash.Support>_.support;
result = <LoDash.TemplateSettings>_.templateSettings;
result = <_.Support>_.support;
result = <_.TemplateSettings>_.templateSettings;
+295 -176
View File
@@ -3,9 +3,9 @@
// Definitions by: Brian Zengel <https://github.com/bczengel>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare var _: LoDash.LoDashStatic;
declare var _: _.LoDashStatic;
declare module LoDash {
declare module _ {
interface LoDashStatic {
/**
* Creates a lodash object which wraps the given value to enable intuitive method chaining.
@@ -316,16 +316,14 @@ declare module LoDash {
**/
findIndex<T>(
array: List<T>,
pluckValue: string,
thisArg?: any): number;
pluckValue: string): number;
/**
* @see _.findIndex
**/
findIndex<T>(
findIndex<W, T extends W>(
array: List<T>,
whereDictionary: Dictionary<any>,
thisArg?: any): number;
whereDictionary: W): number;
}
//_.findLastIndex
@@ -406,9 +404,9 @@ declare module LoDash {
* @see _.first
* @param whereValue "_.where" style callback value
**/
first<T>(
first<W, T extends W>(
array: List<T>,
whereValue: Dictionary<string>): T[];
whereValue: W): T[];
/**
* @see _.first
@@ -440,9 +438,9 @@ declare module LoDash {
/**
* @see _.first
**/
head<T>(
head<W, T extends W>(
array: List<T>,
whereValue: Dictionary<string>): T[];
whereValue: W): T[];
/**
* @see _.first
@@ -474,9 +472,9 @@ declare module LoDash {
/**
* @see _.first
**/
take<T>(
take<W, T extends W>(
array: List<T>,
whereValue: Dictionary<string>): T[];
whereValue: W): T[];
}
//_.flatten
@@ -496,21 +494,66 @@ declare module LoDash {
* @param shallow If true then only flatten one level, optional, default = false.
* @return `array` flattened.
**/
flatten<T>(array: List<any>, isShallow?: boolean): T[]
flatten<T>(
array: List<T>,
isShallow?,
callback?: ListIterator<T, any>,
thisArg?: any): any[];
array: List<any>,
isShallow: boolean,
callback: ListIterator<any, T>,
thisArg?: any): T[];
flatten<T>(
array: List<any>,
callback: ListIterator<any, T>,
thisArg?: any): T[];
flatten<W, T extends W>(
array: List<any>,
isShallow: boolean,
whereValue: W): T[];
flatten<W, T extends W>(
array: List<any>,
whereValue: W): T[];
flatten<T>(
array: List<any>,
isShallow: boolean,
pluckValue: string): T[];
flatten<T>(
array: List<any>,
pluckValue: string): T[];
}
interface LoDashArrayWrapper<T> {
/**
* @see _.flatten
**/
flatten(
isShallow?,
callback?: ListIterator<T, any>,
thisArg?: any): LoDashArrayWrapper<any>;
flatten<Flat>(isShallow?: boolean): LoDashArrayWrapper<Flat>;
flatten<Flat>(
isShallow: boolean,
callback: ListIterator<T, Flat>,
thisArg?: any): LoDashArrayWrapper<Flat>;
flatten<Flat>(
callback: ListIterator<T, Flat>,
thisArg?: any): LoDashArrayWrapper<Flat>;
flatten<Flat>(
isShallow: boolean,
pluckValue: string): LoDashArrayWrapper<Flat>;
flatten<Flat>(
pluckValue: string): LoDashArrayWrapper<Flat>;
flatten<Flat, W extends Flat>(
isShallow: boolean,
whereValue: W): LoDashArrayWrapper<Flat>;
flatten<Flat, W extends Flat>(
whereValue: W): LoDashArrayWrapper<Flat>;
}
//_.indexOf
@@ -595,9 +638,9 @@ declare module LoDash {
* @see _.initial
* @param whereValue _.where style callback
**/
initial<T>(
initial<W, T extends W>(
array: List<T>,
whereValue: Dictionary<any>): T[];
whereValue: W): T[];
}
//_.intersection
@@ -657,9 +700,9 @@ declare module LoDash {
* @see _.last
* @param whereValue _.where style callback
**/
last<T>(
last<W, T extends W>(
array: List<T>,
whereValue: Dictionary<any>): T[];
whereValue: W): T[];
}
//_.lastIndexOf
@@ -778,9 +821,14 @@ declare module LoDash {
* @param {*} [thisArg] The this binding of callback.
* @return Returns a slice of array.
**/
rest<T>(array: List<T>): T[];
/**
* @see _.rest
**/
rest<T>(
array: List<T>,
callback: (num: number) => boolean,
callback: ListIterator<T, boolean>,
thisArg?: any): T[];
/**
@@ -788,88 +836,89 @@ declare module LoDash {
**/
rest<T>(
array: List<T>,
n?: number,
thisArg?: any): T[];
n: number): T[];
/**
* @see _.rest
**/
rest<T>(
array: List<T>,
pluckValue: string,
thisArg?: any): T[];
pluckValue: string): T[];
/**
* @see _.rest
**/
rest<T>(
rest<W, T extends W>(
array: List<T>,
whereValue: Dictionary<any>,
thisArg?: any): T[];
whereValue: W): T[];
/**
* @see _.rest
**/
drop<T>(
array: List<T>,
callback: (num: number) => boolean,
thisArg?: any): T[];
/**
* @see _.rest
**/
drop<T>(
array: List<T>,
n?: number,
thisArg?: any): T[];
/**
* @see _.rest
**/
drop<T>(
array: List<T>,
pluckValue: string,
thisArg?: any): T[];
/**
* @see _.rest
**/
drop<T>(
array: List<T>,
whereValue: Dictionary<any>,
thisArg?: any): T[];
/**
* @see _.rest
**/
drop<T>(array: List<T>): T[];
/**
* @see _.rest
**/
tail<T>(
array: List<T>,
callback: (num: number) => boolean,
thisArg?: any): T[];
/**
* @see _.rest
**/
tail<T>(
array: List<T>,
n?: number,
thisArg?: any): T[];
/**
* @see _.rest
**/
tail<T>(
array: List<T>,
pluckValue: string,
thisArg?: any): T[];
/**
* @see _.rest
**/
tail<T>(
array: List<T>,
whereValue: Dictionary<any>,
thisArg?: any): T[];
/**
* @see _.rest
**/
drop<T>(
array: List<T>,
callback: ListIterator<T, boolean>,
thisArg?: any): T[];
/**
* @see _.rest
**/
drop<T>(
array: List<T>,
n: number): T[];
/**
* @see _.rest
**/
drop<T>(
array: List<T>,
pluckValue: string): T[];
/**
* @see _.rest
**/
drop<W, T extends W>(
array: List<T>,
whereValue: W): T[];
/**
* @see _.rest
**/
tail<T>(array: List<T>): T[];
/**
* @see _.rest
**/
tail<T>(
array: List<T>,
callback: ListIterator<T, boolean>,
thisArg?: any): T[];
/**
* @see _.rest
**/
tail<T>(
array: List<T>,
n: number): T[];
/**
* @see _.rest
**/
tail<T>(
array: List<T>,
pluckValue: string): T[];
/**
* @see _.rest
**/
tail<W, T extends W>(
array: List<T>,
whereValue: W): T[];
}
//_.sortedIndex
@@ -900,7 +949,7 @@ declare module LoDash {
* @see _.sortedIndex
* @param pluckValue the _.pluck style callback
**/
sortedIndex<T, TSort>(
sortedIndex<T>(
array: List<T>,
value: T,
pluckValue: string): number;
@@ -909,10 +958,10 @@ declare module LoDash {
* @see _.sortedIndex
* @param pluckValue the _.where style callback
**/
sortedIndex<T, TSort>(
sortedIndex<W, T extends W>(
array: List<T>,
value: T,
whereValue: Dictionary<any>): number;
whereValue: W): number;
}
//_.union
@@ -946,10 +995,12 @@ declare module LoDash {
* @param context 'this' object in `iterator`, optional.
* @return Copy of `array` where all elements are unique.
**/
uniq<T, TSort>(array: List<T>, isSorted?: boolean): T[];
uniq<T, TSort>(
array: List<T>,
isSorted?: boolean,
callback?: ListIterator<T, TSort>,
isSorted: boolean,
callback: ListIterator<T, TSort>,
thisArg?: any): T[];
/**
@@ -957,32 +1008,43 @@ declare module LoDash {
**/
uniq<T, TSort>(
array: List<T>,
callback?: ListIterator<T, TSort>,
callback: ListIterator<T, TSort>,
thisArg?: any): T[];
/**
* @see _.uniq
* @param pluckValue _.pluck style callback
**/
uniq<T, TSort>(
uniq<T>(
array: List<T>,
isSorted?: boolean,
pluckValue?: string): T[];
isSorted: boolean,
pluckValue: string): T[];
uniq<T>(
array: List<T>,
pluckValue: string): T[];
/**
* @see _.uniq
* @param whereValue _.where style callback
**/
uniq<T, TSort>(
uniq<W, T extends W>(
array: List<T>,
whereValue?: Dictionary<any>): T[];
isSorted: boolean,
whereValue: W): T[];
uniq<W, T extends W>(
array: List<T>,
whereValue: W): T[];
/**
* @see _.uniq
**/
unique<T>(array: List<T>, isSorted?: boolean): T[];
unique<T, TSort>(
array: List<T>,
callback?: ListIterator<T, TSort>,
callback: ListIterator<T, TSort>,
thisArg?: any): T[];
/**
@@ -990,26 +1052,35 @@ declare module LoDash {
**/
unique<T, TSort>(
array: List<T>,
isSorted?: boolean,
callback?: ListIterator<T, TSort>,
isSorted: boolean,
callback: ListIterator<T, TSort>,
thisArg?: any): T[];
/**
* @see _.uniq
* @param pluckValue _.pluck style callback
**/
unique<T, TSort>(
unique<T>(
array: List<T>,
isSorted?: boolean,
pluckValue?: string): T[];
isSorted: boolean,
pluckValue: string): T[];
unique<T>(
array: List<T>,
pluckValue: string): T[];
/**
* @see _.uniq
* @param whereValue _.where style callback
**/
unique<T, TSort>(
unique<W, T extends W>(
array: List<T>,
whereValue?: Dictionary<any>): T[];
whereValue?: W): T[];
unique<W, T extends W>(
array: List<T>,
isSorted: boolean,
whereValue?: W): T[];
}
//_.without
@@ -1244,9 +1315,9 @@ declare module LoDash {
* @see _.every
* @param whereValue _.where style callback
**/
every<T>(
every<W, T extends W>(
collection: Collection<T>,
whereValue: Dictionary<any>): boolean;
whereValue: W): boolean;
/**
* @see _.every
@@ -1268,9 +1339,9 @@ declare module LoDash {
* @see _.every
* @param whereValue _.where style callback
**/
all<T>(
all<W, T extends W>(
collection: Collection<T>,
whereValue: Dictionary<any>): boolean;
whereValue: W): boolean;
}
//_.filter
@@ -1307,9 +1378,9 @@ declare module LoDash {
* @see _.filter
* @param pluckValue _.pluck style callback
**/
filter<T>(
filter<W, T extends W>(
collection: Collection<T>,
whereValue: Dictionary<any>): T[];
whereValue: W): T[];
/**
* @see _.filter
@@ -1331,9 +1402,9 @@ declare module LoDash {
* @see _.filter
* @param pluckValue _.pluck style callback
**/
select<T>(
select<W, T extends W>(
collection: Collection<T>,
whereValue: Dictionary<any>): T[];
whereValue: W): T[];
}
interface LoDashArrayWrapper<T> {
@@ -1355,8 +1426,8 @@ declare module LoDash {
* @see _.filter
* @param pluckValue _.pluck style callback
**/
filter<T>(
whereValue: Dictionary<any>): T[];
filter<W, T extends W>(
whereValue: W): T[];
/**
* @see _.filter
@@ -1376,8 +1447,8 @@ declare module LoDash {
* @see _.filter
* @param pluckValue _.pluck style callback
**/
select<T>(
whereValue: Dictionary<any>): T[];
select<W, T extends W>(
whereValue: W): T[];
}
//_.find
@@ -1406,9 +1477,9 @@ declare module LoDash {
* @see _.find
* @param _.pluck style callback
**/
find<T>(
find<W, T extends W>(
collection: Collection<T>,
whereValue: Dictionary<any>): T;
whereValue: W): T;
/**
* @see _.find
@@ -1430,9 +1501,9 @@ declare module LoDash {
* @see _.find
* @param _.pluck style callback
**/
detect<T>(
detect<W, T extends W>(
collection: Collection<T>,
whereValue: Dictionary<any>): T;
whereValue: W): T;
/**
* @see _.find
@@ -1454,9 +1525,9 @@ declare module LoDash {
* @see _.find
* @param _.pluck style callback
**/
findWhere<T>(
findWhere<W, T extends W>(
collection: Collection<T>,
whereValue: Dictionary<any>): T;
whereValue: W): T;
/**
* @see _.find
@@ -1486,9 +1557,9 @@ declare module LoDash {
* @see _.find
* @param _.pluck style callback
**/
findLast<T>(
findLast<W, T extends W>(
collection: Collection<T>,
whereValue: Dictionary<any>): T;
whereValue: W): T;
/**
* @see _.find
@@ -1685,9 +1756,9 @@ declare module LoDash {
* @see _.groupBy
* @param whereValue _.where style callback
**/
groupBy<T>(
groupBy<W, T extends W>(
collection: List<T>,
whereValue: Dictionary<any>): Dictionary<T[]>;
whereValue: W): Dictionary<T[]>;
}
//_.indexBy
@@ -1725,9 +1796,9 @@ declare module LoDash {
* @see _.indexBy
* @param whereValue _.where style callback
**/
indexBy<T>(
indexBy<W, T extends W>(
collection: List<T>,
whereValue: Dictionary<any>): Dictionary<T>;
whereValue: W): Dictionary<T>;
}
//_.invoke
@@ -1856,9 +1927,9 @@ declare module LoDash {
* @see _.max
* @param whereValue _.where style callback
**/
max<T>(
max<W, T extends W>(
collection: Collection<T>,
whereValue: Dictionary<any>): T;
whereValue: W): T;
}
//_.min
@@ -1896,9 +1967,9 @@ declare module LoDash {
* @see _.min
* @param whereValue _.where style callback
**/
min<T>(
min<W, T extends W>(
collection: Collection<T>,
whereValue: Dictionary<any>): T;
whereValue: W): T;
}
//_.pluck
@@ -1934,6 +2005,14 @@ declare module LoDash {
accumulator?: TResult,
thisArg?: any): TResult;
/**
* @see _.reduce
**/
reduce<T, TResult>(
collection: Collection<T>,
callback: MemoIterator<T, TResult>,
thisArg?: any): TResult;
/**
* @see _.reduce
**/
@@ -1943,6 +2022,14 @@ declare module LoDash {
accumulator?: TResult,
thisArg?: any): TResult;
/**
* @see _.reduce
**/
inject<T, TResult>(
collection: Collection<T>,
callback: MemoIterator<T, TResult>,
thisArg?: any): TResult;
/**
* @see _.reduce
**/
@@ -1951,6 +2038,14 @@ declare module LoDash {
callback: MemoIterator<T, TResult>,
accumulator?: TResult,
thisArg?: any): TResult;
/**
* @see _.reduce
**/
foldl<T, TResult>(
collection: Collection<T>,
callback: MemoIterator<T, TResult>,
thisArg?: any): TResult;
}
//_.reduceRight
@@ -1970,6 +2065,14 @@ declare module LoDash {
accumulator?: TResult,
thisArg?: any): TResult;
/**
* @see _.reduceRight
**/
reduceRight<T, TResult>(
collection: Collection<T>,
callback: MemoIterator<T, TResult>,
thisArg?: any): TResult;
/**
* @see _.reduceRight
**/
@@ -1978,6 +2081,14 @@ declare module LoDash {
callback: MemoIterator<T, TResult>,
accumulator?: TResult,
thisArg?: any): TResult;
/**
* @see _.reduceRight
**/
foldr<T, TResult>(
collection: Collection<T>,
callback: MemoIterator<T, TResult>,
thisArg?: any): TResult;
}
//_.reject
@@ -2013,9 +2124,9 @@ declare module LoDash {
* @see _.reject
* @param whereValue _.where style callback
**/
reject<T>(
reject<W, T extends W>(
collection: Collection<T>,
whereValue: Dictionary<any>): T[];
whereValue: W): T[];
}
//_.sample
@@ -2104,9 +2215,9 @@ declare module LoDash {
* @see _.some
* @param whereValue _.where style callback
**/
some<T>(
some<W, T extends W>(
collection: Collection<T>,
whereValue: Dictionary<any>): boolean;
whereValue: W): boolean;
/**
* @see _.some
@@ -2128,9 +2239,9 @@ declare module LoDash {
* @see _.some
* @param whereValue _.where style callback
**/
any<T>(
any<W, T extends W>(
collection: Collection<T>,
whereValue: Dictionary<any>): boolean;
whereValue: W): boolean;
}
//_.sortBy
@@ -2168,9 +2279,9 @@ declare module LoDash {
* @see _.sortBy
* @param whereValue _.where style callback
**/
sortBy<T>(
sortBy<W, T extends W>(
collection: List<T>,
whereValue: Dictionary<any>): T[];
whereValue: W): T[];
}
//_.toArray
@@ -3082,9 +3193,9 @@ declare module LoDash {
* @see _.findKey
* @param whereValue _.where style callback
**/
findKey(
object: any,
whereValue: Dictionary<any>): string;
findKey<W extends Dictionary<any>, T extends W>(
object: T,
whereValue: W): string;
}
//_.findLastKey
@@ -3113,9 +3224,9 @@ declare module LoDash {
* @see _.findLastKey
* @param whereValue _.where style callback
**/
findLastKey(
object: any,
whereValue: Dictionary<any>): string;
findLastKey<W extends Dictionary<any>, T extends W>(
object: T,
whereValue: W): string;
}
//_.forIn
@@ -3309,7 +3420,7 @@ declare module LoDash {
isEqual(
a: any,
b: any,
callback?: (a, b) => boolean,
callback?: (a: any, b: any) => boolean,
thisArg?: any): boolean;
}
@@ -3557,24 +3668,24 @@ declare module LoDash {
* @param keys The properties to omit.
* @return An object without the omitted properties.
**/
omit(
object: any,
...keys: string[]): any;
omit<Omitted, T extends Omitted>(
object: T,
...keys: string[]): Omitted;
/**
* @see _.omit
**/
omit(
object: any,
keys: string[]): any;
omit<Omitted, T extends Omitted>(
object: T,
keys: string[]): Omitted;
/**
* @see _.omit
**/
omit<T>(
object: any,
callback: ObjectIterator<T, boolean>,
thisArg?: any): any;
omit<Omitted, T extends Omitted>(
object: T,
callback: ObjectIterator<any, boolean>,
thisArg?: any): Omitted;
}
//_.pairs
@@ -3600,24 +3711,24 @@ declare module LoDash {
* @param keys Property names to pick
* @return An object composed of the picked properties.
**/
pick(
object: any,
...keys: string[]): any;
pick<Picked, T extends Picked>(
object: T,
...keys: string[]): Picked;
/**
* @see _.pick
**/
pick(
object: any,
keys: string[]): any;
pick<Picked, T extends Picked>(
object: T,
keys: string[]): Picked;
/**
* @see _.pick
**/
pick(
object: any,
pick<Picked, T extends Picked>(
object: T,
callback: ObjectIterator<any, boolean>,
thisArg?: any): any;
thisArg?: any): Picked;
}
//_.transform
@@ -3639,6 +3750,14 @@ declare module LoDash {
callback?: MemoIterator<T, any>,
accumulator?: any,
thisArg?: any): any;
/**
* @see _.transform
**/
transform<T>(
collection: Collection<T>,
callback?: MemoIterator<T, any>,
thisArg?: any): any;
}
//_.values