From b5fb5ecf07dbe61d81bda07d4ecaaca537f813b1 Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Tue, 1 Apr 2014 21:40:57 -0400 Subject: [PATCH 1/3] Fixed up lodash with support for Array, List, Dictionary. Some test cases are still failing, this seems to due to inference of result types, like for use in the accumulator methods (foldl for example). Most of these could be resolved by using the correct generic type. I was trying to avoid this type of fix for the tests. --- lodash/lodash-tests.disabled.ts | 633 +++--- lodash/lodash.d.ts | 3305 ++++++++++++++++++++++++------- 2 files changed, 2899 insertions(+), 1039 deletions(-) diff --git a/lodash/lodash-tests.disabled.ts b/lodash/lodash-tests.disabled.ts index aca0bbdf0b..97c2709405 100644 --- a/lodash/lodash-tests.disabled.ts +++ b/lodash/lodash-tests.disabled.ts @@ -41,16 +41,16 @@ interface IKey { var foodsOrganic: IFoodOrganic[] = [ { name: 'banana', organic: true }, - { name: 'beet', organic: false }, + { name: 'beet', organic: false }, ]; var foodsType: IFoodType[] = [ - { name: 'apple', type: 'fruit' }, + { name: 'apple', type: 'fruit' }, { name: 'banana', type: 'fruit' }, - { name: 'beet', type: 'vegetable' } + { name: 'beet', type: 'vegetable' } ]; var foodsCombined: IFoodCombined[] = [ - { 'name': 'apple', 'organic': false, 'type': 'fruit' }, - { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } + { 'name': 'apple', 'organic': false, 'type': 'fruit' }, + { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } ]; var stoogesQuotes: IStoogesQuote[] = [ @@ -63,24 +63,24 @@ var stoogesAges: IStoogesAge[] = [ ]; var stoogesCombined: IStoogesCombined[] = [ - { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, - { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } + { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, + { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } ]; var keys: IKey[] = [ - { 'dir': 'left', 'code': 97 }, - { 'dir': 'right', 'code': 100 } + { 'dir': 'left', 'code': 97 }, + { 'dir': 'right', 'code': 100 } ]; class Dog { - constructor(public name: string) {} + constructor(public name: string) { } public bark() { - console.log('Woof, woof!'); + console.log('Woof, woof!'); } } -var result : any; +var result: any; /************* * Chaining * @@ -89,7 +89,10 @@ result = <_.LoDashWrapper>_('test'); result = <_.LoDashWrapper>_(1); result = <_.LoDashWrapper>_(true); result = <_.LoDashArrayWrapper>_(['test1', 'test2']); -result = <_.LoDashObjectWrapper<_.Dictionary>>_({'key1': 'test1', 'key2': 'test2'}); +// Appears to be a change in the compiler, if the type explicity implements the object indexer. +// Looking at: https://typescript.codeplex.com/wikipage?title=Known%20breaking%20changes%20between%200.8%20and%200.9&referringTitle=Documentation +// "The ‘noimplicitany’ option now warns on the use of the hidden default indexer" +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }); result = <_.LoDashWrapper>_.chain('test'); result = <_.LoDashWrapper>_('test').chain(); @@ -99,8 +102,8 @@ result = <_.LoDashWrapper>_.chain(true); result = <_.LoDashWrapper>_(true).chain(); result = <_.LoDashArrayWrapper>_.chain(['test1', 'test2']); result = <_.LoDashArrayWrapper>_(['test1', 'test2']).chain(); -result = <_.LoDashObjectWrapper<_.Dictionary>>_.chain({'key1': 'test1', 'key2': 'test2'}); -result = <_.LoDashObjectWrapper<_.Dictionary>>_({'key1': 'test1', 'key2': 'test2'}).chain(); +result = <_.LoDashObjectWrapper<_.Dictionary>>_.chain(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).chain(); //Wrapped array shortcut methods result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).concat(5, 6); @@ -116,31 +119,31 @@ result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1); result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1, 2, 5, 6); result = <_.LoDashWrapper>_([1, 2, 3, 4]).unshift(5, 6); -result = _.tap([1, 2, 3, 4], function(array) { console.log(array); }); -result = <_.LoDashWrapper>_('test').tap(function(value) { console.log(value); }); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).tap(function(array) { console.log(array); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_({'key1': 'test1', 'key2': 'test2'}).tap(function(array) { console.log(array); }); +result = _.tap([1, 2, 3, 4], function (array) { console.log(array); }); +result = <_.LoDashWrapper>_('test').tap(function (value) { console.log(value); }); +result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).tap(function (array) { console.log(array); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).tap(function (array) { console.log(array); }); result = _('test').toString(); result = _([1, 2, 3]).toString(); -result = _({'key1': 'test1', 'key2': 'test2'}).toString(); +result = _({ 'key1': 'test1', 'key2': 'test2' }).toString(); result = _('test').valueOf(); result = _([1, 2, 3]).valueOf(); -result = <_.Dictionary>_({'key1': 'test1', 'key2': 'test2'}).valueOf(); +result = <_.Dictionary>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).valueOf(); result = _('test').value(); result = _([1, 2, 3]).value(); -result = <_.Dictionary>_({'key1': 'test1', 'key2': 'test2'}).value(); +result = <_.Dictionary>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).value(); // /************* // * Arrays * // *************/ result = _.compact([0, 1, false, 2, '', 3]); - result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); +result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); result = _.difference([1, 2, 3, 4, 5], [5, 2, 10]); - result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).difference([5, 2, 10]); +result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).difference([5, 2, 10]); result = _.rest([1, 2, 3]); result = _.rest([1, 2, 3], 2); @@ -160,48 +163,48 @@ result = _.tail([1, 2, 3], (num) => num < 3) result = _.tail(foodsOrganic, 'test') result = _.tail(foodsType, { 'type': 'value' }) -result = _.findIndex(['apple', 'banana', 'beet'], function(f) { - return /^b/.test(f); +result = _.findIndex(['apple', 'banana', 'beet'], function (f) { + return /^b/.test(f); }); result = _.findIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple'}); +result = _.findIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple' }); -result = _.findLastIndex(['apple', 'banana', 'beet'], function(f: string) { - return /^b/.test(f); +result = _.findLastIndex(['apple', 'banana', 'beet'], function (f: string) { + return /^b/.test(f); }); result = _.findLastIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findLastIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple'}); +result = _.findLastIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple' }); result = _.first([1, 2, 3]); result = _.first([1, 2, 3], 2); -result = _.first([1, 2, 3], function(num) { - return num < 3; +result = _.first([1, 2, 3], function (num) { + return num < 3; }); result = _.first(foodsOrganic, 'organic'); result = _.first(foodsType, { 'type': 'fruit' }); - result = _.head([1, 2, 3]); - result = _.head([1, 2, 3], 2); - result = _.head([1, 2, 3], function(num) { - return num < 3; - }); - result = _.head(foodsOrganic, 'organic'); - result = _.head(foodsType, { 'type': 'fruit' }); +result = _.head([1, 2, 3]); +result = _.head([1, 2, 3], 2); +result = _.head([1, 2, 3], function (num) { + return num < 3; +}); +result = _.head(foodsOrganic, 'organic'); +result = _.head(foodsType, { 'type': 'fruit' }); - result = _.take([1, 2, 3]); - result = _.take([1, 2, 3], 2); - result = _.take([1, 2, 3], (num) => num < 3); - result = _.take(foodsOrganic, 'organic'); - result = _.take(foodsType, { 'type': 'fruit' }); +result = _.take([1, 2, 3]); +result = _.take([1, 2, 3], 2); +result = _.take([1, 2, 3], (num) => num < 3); +result = _.take(foodsOrganic, 'organic'); +result = _.take(foodsType, { 'type': 'fruit' }); result = _.flatten([1, [2], [3, [[4]]]]); result = _.flatten([1, [2], [3, [[4]]]], true); var result: any result = _.flatten(stoogesQuotes, 'quotes'); - result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(); - result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(true); - result = <_.LoDashArrayWrapper>_(stoogesQuotes).flatten('quotes'); +result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(); +result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(true); +result = <_.LoDashArrayWrapper>_(stoogesQuotes).flatten('quotes'); result = _.indexOf([1, 2, 3, 1, 2, 3], 2); result = _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); @@ -209,8 +212,8 @@ result = _.indexOf([1, 1, 2, 2, 3, 3], 2, true); result = _.initial([1, 2, 3]); result = _.initial([1, 2, 3], 2); -result = _.initial([1, 2, 3], function(num) { - return num > 1; +result = _.initial([1, 2, 3], function (num) { + return num > 1; }); result = _.initial(foodsOrganic, 'organic'); result = _.initial(foodsType, { 'type': 'vegetable' }); @@ -219,8 +222,8 @@ result = _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); result = _.last([1, 2, 3]); result = _.last([1, 2, 3], 2); -result = _.last([1, 2, 3], function(num) { - return num > 1; +result = _.last([1, 2, 3], function (num) { + return num > 1; }); result = _.last(foodsOrganic, 'organic'); result = _.last(foodsType, { 'type': 'vegetable' }); @@ -228,8 +231,8 @@ result = _.last(foodsType, { 'type': 'vegetable' }); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); -result = <{[key: string]: any}>_.zipObject(['moe', 'larry'], [30, 40]); -result = <{[key: string]: any}>_.object(['moe', 'larry'], [30, 40]); +result = <{ [key: string]: any }>_.zipObject(['moe', 'larry'], [30, 40]); +result = <{ [key: string]: any }>_.object(['moe', 'larry'], [30, 40]); result = _.pull([1, 2, 3, 1, 2, 3], 2, 3); @@ -240,39 +243,39 @@ result = _.range(0, -10, -1); result = _.range(1, 4, 0); result = _.range(0); -result = _.remove([1, 2, 3, 4, 5, 6], function(num: number) { return num % 2 == 0; }); +result = _.remove([1, 2, 3, 4, 5, 6], function (num: number) { return num % 2 == 0; }); result = _.remove(foodsOrganic, 'organic'); -result = _.remove(foodsType, { 'type': 'vegetable'}); +result = _.remove(foodsType, { 'type': 'vegetable' }); result = _.sortedIndex([20, 30, 50], 40); result = _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); var sortedIndexDict = { - 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } + 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } }; -result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - return sortedIndexDict.wordToNumber[word]; +result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function (word) { + return sortedIndexDict.wordToNumber[word]; }); -result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - return this.wordToNumber[word]; +result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function (word) { + return this.wordToNumber[word]; }, sortedIndexDict); result = _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); result = _.uniq([1, 2, 1, 3, 1]); result = _.uniq([1, 1, 2, 2, 3], true); -result = _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { - return letter.toLowerCase(); +result = _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) { + return letter.toLowerCase(); }); -result = _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); -result = <{x: number;}[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); +result = _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math); +result = <{ x: number; }[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - result = _.unique([1, 2, 1, 3, 1]); - result = _.unique([1, 1, 2, 2, 3], true); - result = _.unique(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { - return letter.toLowerCase(); - }); - result = _.unique([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); - result = <{x: number;}[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); +result = _.unique([1, 2, 1, 3, 1]); +result = _.unique([1, 1, 2, 2, 3], true); +result = _.unique(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) { + return letter.toLowerCase(); +}); +result = _.unique([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math); +result = <{ x: number; }[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); result = _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); @@ -291,165 +294,165 @@ result = _.contains([1, 2, 3], 1, 2); result = _.contains({ 'name': 'moe', 'age': 40 }, 'moe'); result = _.contains('curly', 'ur'); - result = _.include([1, 2, 3], 1); - result = _.include([1, 2, 3], 1, 2); - result = _.include({ 'name': 'moe', 'age': 40 }, 'moe'); - result = _.include('curly', 'ur'); +result = _.include([1, 2, 3], 1); +result = _.include([1, 2, 3], 1, 2); +result = _.include({ 'name': 'moe', 'age': 40 }, 'moe'); +result = _.include('curly', 'ur'); -result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); -result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); +result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function (num) { return Math.floor(num); }); +result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function (num) { return this.floor(num); }, Math); result = <_.Dictionary>_.countBy(['one', 'two', 'three'], 'length'); - result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function(num) { return Math.floor(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function(num) { return this.floor(num); }, Math); - result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).countBy('length'); +result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function (num) { return Math.floor(num); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function (num) { return this.floor(num); }, Math); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).countBy('length'); result = _.every([true, 1, null, 'yes'], Boolean); result = _.every(stoogesAges, 'age'); result = _.every(stoogesAges, { 'age': 50 }); - result = _.all([true, 1, null, 'yes'], Boolean); - result = _.all(stoogesAges, 'age'); - result = _.all(stoogesAges, { 'age': 50 }); +result = _.all([true, 1, null, 'yes'], Boolean); +result = _.all(stoogesAges, 'age'); +result = _.all(stoogesAges, { 'age': 50 }); -result = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); +result = _.filter([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); result = _.filter(foodsCombined, 'organic'); result = _.filter(foodsCombined, { 'type': 'fruit' }); - result = _([1, 2, 3, 4, 5, 6]).filter(function(num) { return num % 2 == 0; }).value(); - result = _(foodsCombined).filter('organic').value(); - result = _(foodsCombined).filter({ 'type': 'fruit' }).value(); +result = _([1, 2, 3, 4, 5, 6]).filter(function (num) { return num % 2 == 0; }).value(); +result = _(foodsCombined).filter('organic').value(); +result = _(foodsCombined).filter({ 'type': 'fruit' }).value(); - result = _.select([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); - result = _.select(foodsCombined, 'organic'); - result = _.select(foodsCombined, { 'type': 'fruit' }); +result = _.select([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); +result = _.select(foodsCombined, 'organic'); +result = _.select(foodsCombined, { 'type': 'fruit' }); - result = _([1, 2, 3, 4, 5, 6]).select(function(num) { return num % 2 == 0; }).value(); - result = _(foodsCombined).select('organic').value(); - result = _(foodsCombined).select({ 'type': 'fruit' }).value(); +result = _([1, 2, 3, 4, 5, 6]).select(function (num) { return num % 2 == 0; }).value(); +result = _(foodsCombined).select('organic').value(); +result = _(foodsCombined).select({ 'type': 'fruit' }).value(); -result = _.find([1, 2, 3, 4], function(num) { - return num % 2 == 0; +result = _.find([1, 2, 3, 4], function (num) { + return num % 2 == 0; }); result = _.find(foodsCombined, { 'type': 'vegetable' }); result = _.find(foodsCombined, 'organic'); - result = _.detect([1, 2, 3, 4], function(num) { - return num % 2 == 0; - }); - result = _.detect(foodsCombined, { 'type': 'vegetable' }); - result = _.detect(foodsCombined, 'organic'); +result = _.detect([1, 2, 3, 4], function (num) { + return num % 2 == 0; +}); +result = _.detect(foodsCombined, { 'type': 'vegetable' }); +result = _.detect(foodsCombined, 'organic'); - result = _.findWhere([1, 2, 3, 4], function(num) { - return num % 2 == 0; - }); - result = _.findWhere(foodsCombined, { 'type': 'vegetable' }); - result = _.findWhere(foodsCombined, 'organic'); +result = _.findWhere([1, 2, 3, 4], function (num) { + return num % 2 == 0; +}); +result = _.findWhere(foodsCombined, { 'type': 'vegetable' }); +result = _.findWhere(foodsCombined, 'organic'); -result = _.findLast([1, 2, 3, 4], function(num) { - return num % 2 == 0; +result = _.findLast([1, 2, 3, 4], function (num) { + return num % 2 == 0; }); result = _.findLast(foodsCombined, { 'type': 'vegetable' }); result = _.findLast(foodsCombined, 'organic'); -result = _.forEach([1, 2, 3], function(num) { console.log(num); }); -result = <_.Dictionary>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); +result = _.forEach([1, 2, 3], function (num) { console.log(num); }); +result = <_.Dictionary>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); - result = _.each([1, 2, 3], function(num) { console.log(num); }); - result = <_.Dictionary>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); +result = _.each([1, 2, 3], function (num) { console.log(num); }); +result = <_.Dictionary>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); - result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEach(function(num) { console.log(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_({ 'one': 1, 'two': 2, 'three': 3 }).forEach(function(num) { console.log(num); }); +result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEach(function (num) { console.log(num); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEach(function (num) { console.log(num); }); - result = <_.LoDashArrayWrapper>_([1, 2, 3]).each(function(num) { console.log(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_({ 'one': 1, 'two': 2, 'three': 3 }).each(function(num) { console.log(num); }); +result = <_.LoDashArrayWrapper>_([1, 2, 3]).each(function (num) { console.log(num); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).each(function (num) { console.log(num); }); -result = _.forEachRight([1, 2, 3], function(num) { console.log(num); }); -result = <_.Dictionary>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); +result = _.forEachRight([1, 2, 3], function (num) { console.log(num); }); +result = <_.Dictionary>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); - result = _.eachRight([1, 2, 3], function(num) { console.log(num); }); - result = <_.Dictionary>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); +result = _.eachRight([1, 2, 3], function (num) { console.log(num); }); +result = <_.Dictionary>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); - result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEachRight(function(num) { console.log(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_({ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function(num) { console.log(num); }); +result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEachRight(function (num) { console.log(num); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function (num) { console.log(num); }); - result = <_.LoDashArrayWrapper>_([1, 2, 3]).eachRight(function(num) { console.log(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_({ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function(num) { console.log(num); }); +result = <_.LoDashArrayWrapper>_([1, 2, 3]).eachRight(function (num) { console.log(num); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function (num) { console.log(num); }); -result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); -result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); +result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function (num) { return Math.floor(num); }); +result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function (num) { return this.floor(num); }, Math); result = <_.Dictionary>_.groupBy(['one', 'two', 'three'], 'length'); - result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function(num) { return Math.floor(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function(num) { return this.floor(num); }, Math); - result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).groupBy('length'); +result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return Math.floor(num); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return this.floor(num); }, Math); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).groupBy('length'); result = <_.Dictionary>_.indexBy(keys, 'dir'); -result = <_.Dictionary>_.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); -result = <_.Dictionary>_.indexBy(keys, function(key) { this.fromCharCode(key.code); }, String); +result = <_.Dictionary>_.indexBy(keys, function (key) { return String.fromCharCode(key.code); }); +result = <_.Dictionary>_.indexBy(keys, function (key) { this.fromCharCode(key.code); }, String); result = _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); result = _.invoke([123, 456], String.prototype.split, ''); -result = _.map([1, 2, 3], function(num) { return num * 3; }); -result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); +result = _.map([1, 2, 3], function (num) { return num * 3; }); +result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { return num * 3; }); result = _.map(stoogesAges, 'name'); - result = _([1, 2, 3]).map(function(num) { return num * 3; }).value(); - result = _({ 'one': 1, 'two': 2, 'three': 3 }).map(function(num) { return num * 3; }).value(); - result = _(stoogesAges).map('name').value(); +result = _([1, 2, 3]).map(function (num) { return num * 3; }).value(); +result = _({ 'one': 1, 'two': 2, 'three': 3 }).map(function (num) { return num * 3; }).value(); +result = _(stoogesAges).map('name').value(); -result = _.collect([1, 2, 3], function(num) { return num * 3; }); -result = _.collect({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); +result = _.collect([1, 2, 3], function (num) { return num * 3; }); +result = _.collect({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { return num * 3; }); result = _.collect(stoogesAges, 'name'); - result = _([1, 2, 3]).collect(function(num) { return num * 3; }).value(); - result = _({ 'one': 1, 'two': 2, 'three': 3 }).collect(function(num) { return num * 3; }).value(); - result = _(stoogesAges).collect('name').value(); +result = _([1, 2, 3]).collect(function (num) { return num * 3; }).value(); +result = _({ 'one': 1, 'two': 2, 'three': 3 }).collect(function (num) { return num * 3; }).value(); +result = _(stoogesAges).collect('name').value(); result = _.max([4, 2, 8, 6]); -result = _.max(stoogesAges, function(stooge) { return stooge.age; }); +result = _.max(stoogesAges, function (stooge) { return stooge.age; }); result = _.max(stoogesAges, 'age'); result = _.min([4, 2, 8, 6]); -result = _.min(stoogesAges, function(stooge) { return stooge.age; }); +result = _.min(stoogesAges, function (stooge) { return stooge.age; }); result = _.min(stoogesAges, 'age'); result = _.pluck(stoogesAges, 'name'); -result = _.reduce([1, 2, 3], function(sum: number, num: number) { - return sum + num; +result = _.reduce([1, 2, 3], function (sum: number, num: number) { + return sum + num; }); interface ABC { - a: number; - b: number; - c: number; + a: number; + b: number; + c: number; } -result = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { - r[key] = num * 3; - return r; +result = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num, key) { + r[key] = num * 3; + return r; }, {}); -result = _.foldl([1, 2, 3], function(sum, num) { - return sum + num; +result = _.foldl([1, 2, 3], function (sum, num) { + return sum + num; }); -result = _.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { - r[key] = num * 3; - return r; +result = _.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num, key) { + r[key] = num * 3; + return r; }, {}); -result = _.inject([1, 2, 3], function(sum, num) { - return sum + num; +result = _.inject([1, 2, 3], function (sum, num) { + return sum + num; }); -result = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { - r[key] = num * 3; - return r; +result = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num, key) { + r[key] = num * 3; + return r; }, {}); -result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); -result = _.foldr([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); +result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); +result = _.foldr([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); -result = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); +result = _.reject([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); result = _.reject(foodsCombined, 'organic'); result = _.reject(foodsCombined, { 'type': 'fruit' }); @@ -465,20 +468,20 @@ result = _.size('curly'); result = _.some([null, 0, 'yes', false], Boolean); result = _.some(foodsCombined, 'organic'); result = _.some(foodsCombined, { 'type': 'meat' }); - + result = _.any([null, 0, 'yes', false], Boolean); result = _.any(foodsCombined, 'organic'); result = _.any(foodsCombined, { 'type': 'meat' }); - -result = _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); -result = _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); + +result = _.sortBy([1, 2, 3], function (num) { return Math.sin(num); }); +result = _.sortBy([1, 2, 3], function (num) { return this.sin(num); }, Math); result = _.sortBy(['banana', 'strawberry', 'apple'], 'length'); -(function(a: number, b: number, c: number, d: number){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); +(function (a: number, b: number, c: number, d: number) { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); result = _.where(stoogesCombined, { 'age': 40 }); result = _.where(stoogesCombined, { 'quotes': ['Poifect!'] }); - + /************* * Functions * *************/ @@ -486,20 +489,20 @@ var saves = ['profile', 'settings']; var asyncSave = (obj: any) => obj.done(); var done: Function; -done = _.after(saves.length, function() { - console.log('Done saving!'); +done = _.after(saves.length, function () { + console.log('Done saving!'); }); -_.forEach(saves, function(type) { - asyncSave({ 'type': type, 'complete': done }); +_.forEach(saves, function (type) { + asyncSave({ 'type': type, 'complete': done }); }); -done = _(saves.length).after(function() { - console.log('Done saving!'); +done = _(saves.length).after(function () { + console.log('Done saving!'); }).value(); -_.forEach(saves, function(type) { - asyncSave({ 'type': type, 'complete': done }); +_.forEach(saves, function (type) { + asyncSave({ 'type': type, 'complete': done }); }); var funcBind = function (greeting: string) { return greeting + ' ' + this.name }; @@ -510,8 +513,8 @@ var funcBind3: () => any = _(funcBind).bind({ 'name': 'moe' }, 'hi').value(); funcBind3(); var view = { - 'label': 'docs', - 'onClick': function() { console.log('clicked ' + this.label); } + 'label': 'docs', + 'onClick': function () { console.log('clicked ' + this.label); } }; view = _.bindAll(view); @@ -521,17 +524,17 @@ view = _(view).bindAll().value(); jQuery('#docs').on('click', view.onClick); var objectBindKey = { - 'name': 'moe', - 'greet': function(greeting: string) { - return greeting + ' ' + this.name; - } + 'name': 'moe', + 'greet': function (greeting: string) { + return greeting + ' ' + this.name; + } }; var funcBindKey: Function = _.bindKey(objectBindKey, 'greet', 'hi'); funcBindKey(); -objectBindKey.greet = function(greeting) { - return greeting + ', ' + this.name + '!'; +objectBindKey.greet = function (greeting) { + return greeting + ', ' + this.name + '!'; }; funcBindKey(); @@ -540,78 +543,78 @@ funcBindKey = _(objectBindKey).bindKey('greet', 'hi').value(); funcBindKey(); var realNameMap = { - 'curly': 'jerome' + 'curly': 'jerome' }; -var format = function(name: string) { - name = realNameMap[name.toLowerCase()] || name; - return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); +var format = function (name: string) { + name = realNameMap[name.toLowerCase()] || name; + return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); }; -var greet = function(formatted: string) { - return 'Hiya ' + formatted + '!'; +var greet = function (formatted: string) { + return 'Hiya ' + formatted + '!'; }; result = _.compose(greet, format); result = <_.LoDashObjectWrapper>_(greet).compose(format); -var createCallbackObj = { name: 'Joe' }; +var createCallbackObj: { [index: string]: string; } = { name: 'Joe' }; result = <() => any>_.createCallback('name'); result = <() => boolean>_.createCallback(createCallbackObj); result = <_.LoDashObjectWrapper<() => any>>_('name').createCallback(); result = <_.LoDashObjectWrapper<() => boolean>>_(createCallbackObj).createCallback(); -result = _.curry(function(a, b, c) { - console.log(a + b + c); +result = _.curry(function (a, b, c) { + console.log(a + b + c); }); -result = <_.LoDashObjectWrapper>_(function(a, b, c) { - console.log(a + b + c); +result = <_.LoDashObjectWrapper>_(function (a, b, c) { + console.log(a + b + c); }).curry(); declare var source: any; -result = _.debounce(function() {}, 150); +result = _.debounce(function () { }, 150); -jQuery('#postbox').on('click', _.debounce(function() {}, 300, { - 'leading': true, - 'trailing': false +jQuery('#postbox').on('click', _.debounce(function () { }, 300, { + 'leading': true, + 'trailing': false })); -source.addEventListener('message', _.debounce(function() {}, 250, { - 'maxWait': 1000 +source.addEventListener('message', _.debounce(function () { }, 250, { + 'maxWait': 1000 }), false); -result = <_.LoDashObjectWrapper>_(function() {}).debounce(150); +result = <_.LoDashObjectWrapper>_(function () { }).debounce(150); -jQuery('#postbox').on('click', <_.LoDashObjectWrapper>_(function() {}).debounce(300, { - 'leading': true, - 'trailing': false +jQuery('#postbox').on('click', <_.LoDashObjectWrapper>_(function () { }).debounce(300, { + 'leading': true, + 'trailing': false })); -source.addEventListener('message', <_.LoDashObjectWrapper>_(function() {}).debounce(250, { - 'maxWait': 1000 +source.addEventListener('message', <_.LoDashObjectWrapper>_(function () { }).debounce(250, { + 'maxWait': 1000 }), false); var returnedDebounce = _.throttle(function (a) { return a * 5; }, 5); returnedThrottled(4); -result = _.defer(function() { console.log('deferred'); }); -result = <_.LoDashWrapper>_(function() { console.log('deferred'); }).defer(); +result = _.defer(function () { console.log('deferred'); }); +result = <_.LoDashWrapper>_(function () { console.log('deferred'); }).defer(); var log = _.bind(console.log, console); result = _.delay(log, 1000, 'logged later'); result = <_.LoDashWrapper>_(log).delay(1000, 'logged later'); -var fibonacci = _.memoize(function(n) { - return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); +var fibonacci = _.memoize(function (n) { + return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); }); var data = { - 'moe': { 'name': 'moe', 'age': 40 }, - 'curly': { 'name': 'curly', 'age': 60 } + 'moe': { 'name': 'moe', 'age': 40 }, + 'curly': { 'name': 'curly', 'age': 60 } }; -var stooge = _.memoize(function(name: string) { return data[name]; }, _.identity); +var stooge = _.memoize(function (name: string) { return data[name]; }, _.identity); stooge('curly'); stooge['cache']['curly'].name = 'jerome'; @@ -620,21 +623,21 @@ stooge('curly'); var returnedMemoize = _.throttle(function (a) { return a * 5; }, 5); returnedMemoize(4); -var initialize = _.once(function(){ }); +var initialize = _.once(function () { }); initialize(); initialize();'' var returnedOnce = _.throttle(function (a) { return a * 5; }, 5); returnedOnce(4); -var greetPartial = function(greeting: string, name: string) { return greeting + ' ' + name; }; +var greetPartial = function (greeting: string, name: string) { return greeting + ' ' + name; }; var hi = _.partial(greetPartial, 'hi'); hi('moe'); var defaultsDeep = _.partialRight(_.merge, _.defaults); var optionsPartialRight = { - 'variable': 'data', - 'imports': { 'jq': $ } + 'variable': 'data', + 'imports': { 'jq': $ } }; defaultsDeep(optionsPartialRight, _.templateSettings); @@ -642,16 +645,16 @@ defaultsDeep(optionsPartialRight, _.templateSettings); var throttled = _.throttle(function () { }, 100); jQuery(window).on('scroll', throttled); -jQuery('.interactive').on('click', _.throttle(function() { }, 300000, { - 'trailing': false +jQuery('.interactive').on('click', _.throttle(function () { }, 300000, { + 'trailing': false })); -var returnedThrottled = _.throttle(function (a) { return a*5; }, 5); +var returnedThrottled = _.throttle(function (a) { return a * 5; }, 5); returnedThrottled(4); -var helloWrap = function(name: string) { return 'hello ' + name; }; -var helloWrap2 = _.wrap(helloWrap, function(func) { - return 'before, ' + func('moe') + ', after'; +var helloWrap = function (name: string) { return 'hello ' + name; }; +var helloWrap2 = _.wrap(helloWrap, function (func) { + return 'before, ' + func('moe') + ', after'; }); helloWrap2(); @@ -659,93 +662,93 @@ helloWrap2(); * Objects * ***********/ interface NameAge { - name: string; - age: number; + name: string; + age: number; } result = _.assign({ 'name': 'moe' }, { 'age': 40 }); -result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; +result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function (a, b) { + return typeof a == 'undefined' ? b : a; }); result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }, function (a, b) { + return typeof a == 'undefined' ? b : a; }); result = _.extend({ 'name': 'moe' }, { 'age': 40 }); -result = _.extend({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; +result = _.extend({ 'name': 'moe' }, { 'age': 40 }, function (a, b) { + return typeof a == 'undefined' ? b : a; }); result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }, function (a, b) { + return typeof a == 'undefined' ? b : a; }); result = _.clone(stoogesAges); result = _.clone(stoogesAges, true); -result = _.clone(stoogesAges, true, function(value) { - return _.isElement(value) ? value.cloneNode(false) : undefined; +result = _.clone(stoogesAges, true, function (value) { + return _.isElement(value) ? value.cloneNode(false) : undefined; }); result = _.cloneDeep(stoogesAges); -result = _.cloneDeep(stoogesAges, function(value) { - return _.isElement(value) ? value.cloneNode(false) : undefined; +result = _.cloneDeep(stoogesAges, function (value) { + return _.isElement(value) ? value.cloneNode(false) : undefined; }); interface Food { - name: string; - type: string; + name: string; + type: string; } var foodDefaults = { 'name': 'apple' }; result = _.defaults(foodDefaults, { 'name': 'banana', 'type': 'fruit' }); - result = <_.LoDashObjectWrapper>_(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' }); +result = <_.LoDashObjectWrapper>_(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' }); -result = _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { - return num % 2 == 0; +result = _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) { + return num % 2 == 0; }); -result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { - return num % 2 == 1; +result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) { + return num % 2 == 1; }); -result = _.forIn(new Dog('Dagny'), function(value, key) { - console.log(key); +result = _.forIn(new Dog('Dagny'), function (value, key) { + console.log(key); }); -result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forIn(function(value, key) { - console.log(key); +result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forIn(function (value, key) { + console.log(key); }); -result = _.forInRight(new Dog('Dagny'), function(value, key) { - console.log(key); +result = _.forInRight(new Dog('Dagny'), function (value, key) { + console.log(key); }); -result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forInRight(function(value, key) { - console.log(key); +result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forInRight(function (value, key) { + console.log(key); }); interface ZeroOne { - 0: string; - 1: string; - one: string; + 0: string; + 1: string; + one: string; } -result = _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - console.log(key); +result = _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function (num, key) { + console.log(key); }); - result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function(num, key) { - console.log(key); - }); - -result = _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - console.log(key); +result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function (num, key) { + console.log(key); }); - result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function(num, key) { - console.log(key); - }); +result = _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function (num, key) { + console.log(key); +}); + +result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function (num, key) { + console.log(key); +}); result = _.functions(_); result = _.methods(_); @@ -756,12 +759,12 @@ result = <_.LoDashArrayWrapper>_(_).methods(); result = _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); interface FirstSecond { - first: string; - second: string; + first: string; + second: string; } result = _.invert({ 'first': 'moe', 'second': 'larry' }); -(function(...args: any[]) { return _.isArguments(arguments); })(1, 2, 3); +(function (...args: any[]) { return _.isArguments(arguments); })(1, 2, 3); (function () { return _.isArray(arguments); })(); result = _.isArray([1, 2, 3]); @@ -784,12 +787,12 @@ result = _.isEqual(moe, copy); var words = ['hello', 'goodbye']; var otherWords = ['hi', 'goodbye']; -result = _.isEqual(words, otherWords, function(a, b) { - var reGreet = /^(?:hello|hi)$/i, - aGreet = _.isString(a) && reGreet.test(a), - bGreet = _.isString(b) && reGreet.test(b); +result = _.isEqual(words, otherWords, function (a, b) { + var reGreet = /^(?:hello|hi)$/i, + aGreet = _.isString(a) && reGreet.test(a), + bGreet = _.isString(b) && reGreet.test(b); - return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; + return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; }); result = _.isFinite(-101); @@ -817,7 +820,7 @@ class Stooge { constructor( public name: string, public age: number - ) {} + ) { } } result = _.isPlainObject(new Stooge('moe', 40)); @@ -833,67 +836,67 @@ result = _.isUndefined(void 0); result = _.keys({ 'one': 1, 'two': 2, 'three': 3 }); var mergeNames = { - 'stooges': [ - { 'name': 'moe' }, - { 'name': 'larry' } - ] + 'stooges': [ + { 'name': 'moe' }, + { 'name': 'larry' } + ] }; var mergeAges = { - 'stooges': [ - { 'age': 40 }, - { 'age': 50 } - ] + 'stooges': [ + { 'age': 40 }, + { 'age': 50 } + ] }; result = _.merge(mergeNames, mergeAges); var mergeFood = { - 'fruits': ['apple'], - 'vegetables': ['beet'] + 'fruits': ['apple'], + 'vegetables': ['beet'] }; var mergeOtherFood = { - 'fruits': ['banana'], - 'vegetables': ['carrot'] + 'fruits': ['banana'], + 'vegetables': ['carrot'] }; interface FruitVeg { - fruits: string[]; - vegetables: string[] + fruits: string[]; + vegetables: string[] }; -result = _.merge(mergeFood, mergeOtherFood, function(a, b) { - return _.isArray(a) ? a.concat(b) : undefined; +result = _.merge(mergeFood, mergeOtherFood, function (a, b) { + return _.isArray(a) ? a.concat(b) : undefined; }); interface HasName { - name: string; + name: string; } result = _.omit({ 'name': 'moe', 'age': 40 }, 'age'); result = _.omit({ 'name': 'moe', 'age': 40 }, ['age']); -result = _.omit({ 'name': 'moe', 'age': 40 }, function(value) { - return typeof value == 'number'; +result = _.omit({ 'name': 'moe', 'age': 40 }, function (value) { + return typeof value == 'number'; }); result = _.pairs({ 'moe': 30, 'larry': 40 }); result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name'); result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, ['name']); -result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { - return key.charAt(0) != '_'; +result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, function (value, key) { + return key.charAt(0) != '_'; }); -result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(r, num) { - num *= num; - if (num % 2) { - return r.push(num) < 3; - } +result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function (r, num) { + num *= num; + if (num % 2) { + return r.push(num) < 3; + } }); // → [1, 9, 25] -result = <{a:number;b:number;c:number;}>_.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(r, num, key) { - r[key] = num * 3; +result = <{ a: number; b: number; c: number; }>_.transform({ 'a': 1, 'b': 2, 'c': 3 }, function (r, num, key) { + r[key] = num * 3; }); result = _.values({ 'one': 1, 'two': 2, 'three': 3 }); @@ -907,9 +910,9 @@ result = _.escape('Moe, Larry & Curly'); result = <{ name: string }>_.identity({ 'name': 'moe' }); _.mixin({ - 'capitalize': function(string) { - return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); - } + 'capitalize': function (string) { + return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); + } }); var lodash = _.noConflict(); @@ -923,10 +926,10 @@ result = _.random(1.2, 5.2); result = _.random(0, 5, true); var object = { - 'cheese': 'crumpets', - 'stuff': function() { - return 'nonsense'; - } + 'cheese': 'crumpets', + 'stuff': function () { + return 'nonsense'; + } }; result = _.result(object, 'cheese'); @@ -960,10 +963,10 @@ class Mage { } } -var mage = new Mage(); +var mage = new Mage(); result = _.times(3, <() => number>_.partial(_.random, 1, 6)); -result = _.times(3, function(n: number) { mage.castSpell(n); }); -result = _.times(3, function(n: number) { this.cast(n); }, mage); +result = _.times(3, function (n: number) { mage.castSpell(n); }); +result = _.times(3, function (n: number) { this.cast(n); }, mage); result = _.unescape('Moe, Larry & Curly'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b48f7e6034..3c4b572c15 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -181,15 +181,15 @@ declare module _ { **/ valueOf(): T; - /** - * @see valueOf - **/ - value(): T; - } + /** + * @see valueOf + **/ + value(): T; + } - interface LoDashWrapper extends LoDashWrapperBase> {} + interface LoDashWrapper extends LoDashWrapperBase> { } - interface LoDashObjectWrapper extends LoDashWrapperBase> {} + interface LoDashObjectWrapper extends LoDashWrapperBase> { } interface LoDashArrayWrapper extends LoDashWrapperBase> { concat(...items: T[]): LoDashArrayWrapper; @@ -263,6 +263,11 @@ declare module _ { * @param array Array to compact. * @return (Array) Returns a new array of filtered values. **/ + compact(array: Array): T[]; + + /** + * @see _.compact + **/ compact(array: List): T[]; } @@ -270,8 +275,8 @@ declare module _ { /** * @see _.compact **/ - compact(): LoDashArrayWrapper; - } + compact(): LoDashArrayWrapper; + } //_.difference interface LoDashStatic { @@ -282,6 +287,12 @@ declare module _ { * @param others The arrays of values to exclude. * @return Returns a new array of filtered values. **/ + difference( + array: Array, + ...others: Array[]): T[]; + /** + * @see _.difference + **/ difference( array: List, ...others: List[]): T[]; @@ -291,6 +302,11 @@ declare module _ { /** * @see _.difference **/ + difference( + ...others: Array[]): LoDashArrayWrapper; + /** + * @see _.difference + **/ difference( ...others: List[]): LoDashArrayWrapper; } @@ -307,7 +323,7 @@ declare module _ { * @return Returns the index of the found element, else -1. **/ findIndex( - array: List, + array: Array, callback: ListIterator, thisArg?: any): number; @@ -316,8 +332,30 @@ declare module _ { **/ findIndex( array: List, + callback: ListIterator, + thisArg?: any): number; + + /** + * @see _.findIndex + **/ + findIndex( + array: Array, pluckValue: string): number; - + + /** + * @see _.findIndex + **/ + findIndex( + array: List, + pluckValue: string): number; + + /** + * @see _.findIndex + **/ + findIndex( + array: Array, + whereDictionary: W): number; + /** * @see _.findIndex **/ @@ -336,18 +374,40 @@ declare module _ { * @param thisArg The this binding of callback. * @return Returns the index of the found element, else -1. **/ + findLastIndex( + array: Array, + callback: ListIterator, + thisArg?: any): number; + + /** + * @see _.findLastIndex + **/ findLastIndex( array: List, callback: ListIterator, thisArg?: any): number; - + + /** + * @see _.findLastIndex + **/ + findLastIndex( + array: Array, + pluckValue: string): number; + /** * @see _.findLastIndex **/ findLastIndex( array: List, pluckValue: string): number; - + + /** + * @see _.findLastIndex + **/ + findLastIndex( + array: Array, + whereDictionary: Dictionary): number; + /** * @see _.findLastIndex **/ @@ -372,8 +432,21 @@ declare module _ { * @param array Retrieves the first element of this array. * @return Returns the first element of `array`. **/ + first(array: Array): T; + + /** + * @see _.first + **/ first(array: List): T; + /** + * @see _.first + * @param n The number of elements to return. + **/ + first( + array: Array, + n: number): T[]; + /** * @see _.first * @param n The number of elements to return. @@ -382,6 +455,16 @@ declare module _ { array: List, n: number): T[]; + /** + * @see _.first + * @param callback The function called per element. + * @param [thisArg] The this binding of callback. + **/ + first( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + /** * @see _.first * @param callback The function called per element. @@ -392,6 +475,14 @@ declare module _ { callback: ListIterator, thisArg?: any): T[]; + /** + * @see _.first + * @param pluckValue "_.pluck" style callback value + **/ + first( + array: Array, + pluckValue: string): T[]; + /** * @see _.first * @param pluckValue "_.pluck" style callback value @@ -400,6 +491,14 @@ declare module _ { array: List, pluckValue: string): T[]; + /** + * @see _.first + * @param whereValue "_.where" style callback value + **/ + first( + array: Array, + whereValue: W): T[]; + /** * @see _.first * @param whereValue "_.where" style callback value @@ -408,73 +507,141 @@ declare module _ { array: List, whereValue: W): T[]; - /** - * @see _.first - **/ - head(array: List): T; + /** + * @see _.first + **/ + head(array: Array): T; - /** - * @see _.first - **/ - head( - array: List, - n: number): T[]; + /** + * @see _.first + **/ + head(array: List): T; - /** - * @see _.first - **/ - head( - array: List, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.first + **/ + head( + array: Array, + n: number): T[]; - /** - * @see _.first - **/ - head( - array: List, - pluckValue: string): T[]; + /** + * @see _.first + **/ + head( + array: List, + n: number): T[]; - /** - * @see _.first - **/ - head( - array: List, - whereValue: W): T[]; + /** + * @see _.first + **/ + head( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; - /** - * @see _.first - **/ - take(array: List): T; + /** + * @see _.first + **/ + head( + array: List, + callback: ListIterator, + thisArg?: any): T[]; - /** - * @see _.first - **/ - take( - array: List, - n: number): T[]; + /** + * @see _.first + **/ + head( + array: Array, + pluckValue: string): T[]; - /** - * @see _.first - **/ - take( - array: List, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.first + **/ + head( + array: List, + pluckValue: string): T[]; - /** - * @see _.first - **/ - take( - array: List, - pluckValue: string): T[]; + /** + * @see _.first + **/ + head( + array: Array, + whereValue: W): T[]; - /** - * @see _.first - **/ - take( - array: List, - whereValue: W): T[]; + /** + * @see _.first + **/ + head( + array: List, + whereValue: W): T[]; + + /** + * @see _.first + **/ + take(array: Array): T; + + /** + * @see _.first + **/ + take(array: List): T; + + /** + * @see _.first + **/ + take( + array: Array, + n: number): T[]; + + /** + * @see _.first + **/ + take( + array: List, + n: number): T[]; + + /** + * @see _.first + **/ + take( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.first + **/ + take( + array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.first + **/ + take( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.first + **/ + take( + array: List, + pluckValue: string): T[]; + + /** + * @see _.first + **/ + take( + array: Array, + whereValue: W): T[]; + + /** + * @see _.first + **/ + take( + array: List, + whereValue: W): T[]; } //_.flatten @@ -494,65 +661,153 @@ declare module _ { * @param shallow If true then only flatten one level, optional, default = false. * @return `array` flattened. **/ + flatten(array: Array, isShallow?: boolean): T[]; + + /** + * @see _.flatten + **/ flatten(array: List, isShallow?: boolean): T[]; + /** + * @see _.flatten + **/ + flatten( + array: Array, + isShallow: boolean, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.flatten + **/ flatten( array: List, isShallow: boolean, callback: ListIterator, - thisArg?: any): T[]; + thisArg?: any): T[]; + /** + * @see _.flatten + **/ + flatten( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.flatten + **/ flatten( array: List, callback: ListIterator, - thisArg?: any): T[]; + thisArg?: any): T[]; + /** + * @see _.flatten + **/ + flatten( + array: Array, + isShallow: boolean, + whereValue: W): T[]; + + /** + * @see _.flatten + **/ flatten( array: List, isShallow: boolean, - whereValue: W): T[]; + whereValue: W): T[]; + /** + * @see _.flatten + **/ + flatten( + array: Array, + whereValue: W): T[]; + + /** + * @see _.flatten + **/ flatten( array: List, - whereValue: W): T[]; + whereValue: W): T[]; + /** + * @see _.flatten + **/ + flatten( + array: Array, + isShallow: boolean, + pluckValue: string): T[]; + + /** + * @see _.flatten + **/ flatten( array: List, isShallow: boolean, - pluckValue: string): T[]; + pluckValue: string): T[]; + /** + * @see _.flatten + **/ + flatten( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.flatten + **/ flatten( array: List, - pluckValue: string): T[]; + pluckValue: string): T[]; } interface LoDashArrayWrapper { /** * @see _.flatten **/ - flatten(isShallow?: boolean): LoDashArrayWrapper; + flatten(isShallow?: boolean): LoDashArrayWrapper; - flatten( + /** + * @see _.flatten + **/ + flatten( isShallow: boolean, callback: ListIterator, thisArg?: any): LoDashArrayWrapper; - flatten( + /** + * @see _.flatten + **/ + flatten( callback: ListIterator, thisArg?: any): LoDashArrayWrapper; - flatten( + /** + * @see _.flatten + **/ + flatten( isShallow: boolean, pluckValue: string): LoDashArrayWrapper; - flatten( + /** + * @see _.flatten + **/ + flatten( pluckValue: string): LoDashArrayWrapper; - flatten( + /** + * @see _.flatten + **/ + flatten( isShallow: boolean, whereValue: W): LoDashArrayWrapper; - flatten( + /** + * @see _.flatten + **/ + flatten( whereValue: W): LoDashArrayWrapper; } @@ -567,10 +822,26 @@ declare module _ { * @param fromIndex The index to search from. * @return The index of `value` within `array`. **/ + indexOf( + array: Array, + value: T): number; + + /** + * @see _.indexOf + **/ indexOf( array: List, value: T): number; + /** + * @see _.indexOf + * @param fromIndex The index to search from + **/ + indexOf( + array: Array, + value: T, + fromIndex: number): number; + /** * @see _.indexOf * @param fromIndex The index to search from @@ -580,6 +851,15 @@ declare module _ { value: T, fromIndex: number): number; + /** + * @see _.indexOf + * @param isSorted True to perform a binary search on a sorted array. + **/ + indexOf( + array: Array, + value: T, + isSorted: boolean): number; + /** * @see _.indexOf * @param isSorted True to perform a binary search on a sorted array. @@ -607,9 +887,23 @@ declare module _ { * @param n Leaves this many elements behind, optional. * @return Returns everything but the last `n` elements of `array`. **/ + initial( + array: Array): T[]; + + /** + * @see _.initial + **/ initial( array: List): T[]; + /** + * @see _.initial + * @param n The number of elements to exclude. + **/ + initial( + array: Array, + n: number): T[]; + /** * @see _.initial * @param n The number of elements to exclude. @@ -618,6 +912,14 @@ declare module _ { array: List, n: number): T[]; + /** + * @see _.initial + * @param callback The function called per element + **/ + initial( + array: Array, + callback: ListIterator): T[]; + /** * @see _.initial * @param callback The function called per element @@ -626,6 +928,14 @@ declare module _ { array: List, callback: ListIterator): T[]; + /** + * @see _.initial + * @param pluckValue _.pluck style callback + **/ + initial( + array: Array, + pluckValue: string): T[]; + /** * @see _.initial * @param pluckValue _.pluck style callback @@ -634,6 +944,14 @@ declare module _ { array: List, pluckValue: string): T[]; + /** + * @see _.initial + * @param whereValue _.where style callback + **/ + initial( + array: Array, + whereValue: W): T[]; + /** * @see _.initial * @param whereValue _.where style callback @@ -651,6 +969,11 @@ declare module _ { * @param arrays The arrays to inspect. * @return Returns an array of composite values. **/ + intersection(...arrays: Array[]): T[]; + + /** + * @see _.intersection + **/ intersection(...arrays: List[]): T[]; } @@ -669,8 +992,21 @@ declare module _ { * @param array The array to query. * @return Returns the last element(s) of array. **/ + last(array: Array): T; + + /** + * @see _.last + **/ last(array: List): T; + /** + * @see _.last + * @param n The number of elements to return + **/ + last( + array: Array, + n: number): T[]; + /** * @see _.last * @param n The number of elements to return @@ -679,6 +1015,15 @@ declare module _ { array: List, n: number): T[]; + /** + * @see _.last + * @param callback The function called per element + **/ + last( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + /** * @see _.last * @param callback The function called per element @@ -688,6 +1033,14 @@ declare module _ { callback: ListIterator, thisArg?: any): T[]; + /** + * @see _.last + * @param pluckValue _.pluck style callback + **/ + last( + array: Array, + pluckValue: string): T[]; + /** * @see _.last * @param pluckValue _.pluck style callback @@ -696,6 +1049,14 @@ declare module _ { array: List, pluckValue: string): T[]; + /** + * @see _.last + * @param whereValue _.where style callback + **/ + last( + array: Array, + whereValue: W): T[]; + /** * @see _.last * @param whereValue _.where style callback @@ -716,12 +1077,20 @@ declare module _ { * @param fromIndex The index to search from. * @return The index of the matched value or -1. **/ + lastIndexOf( + array: Array, + value: T, + fromIndex?: number): number; + + /** + * @see _.lastIndexOf + **/ lastIndexOf( array: List, value: T, fromIndex?: number): number; } - + //_.pull interface LoDashStatic { /** @@ -731,6 +1100,13 @@ declare module _ { * @param values The values to remove. * @return array. **/ + pull( + array: Array, + ...values: any[]): any[]; + + /** + * @see _.pull + **/ pull( array: List, ...values: any[]): any[]; @@ -747,12 +1123,11 @@ declare module _ { * @param step The value to increment or decrement by. * @return Returns a new range array. **/ - range( start: number, stop: number, step?: number): number[]; - + /** * @see _.range * @param end The end of the range. @@ -779,11 +1154,27 @@ declare module _ { * @param thisArg The this binding of callback. * @return A new array of removed elements. **/ + remove( + array: Array, + callback?: ListIterator, + thisArg?: any): any[]; + + /** + * @see _.remove + **/ remove( array: List, callback?: ListIterator, thisArg?: any): any[]; + /** + * @see _.remove + * @param pluckValue _.pluck style callback + **/ + remove( + array: Array, + pluckValue?: string): any[]; + /** * @see _.remove * @param pluckValue _.pluck style callback @@ -792,6 +1183,14 @@ declare module _ { array: List, pluckValue?: string): any[]; + /** + * @see _.remove + * @param whereValue _.where style callback + **/ + remove( + array: Array, + wherealue?: Dictionary): any[]; + /** * @see _.remove * @param whereValue _.where style callback @@ -821,14 +1220,19 @@ declare module _ { * @param {*} [thisArg] The this binding of callback. * @return Returns a slice of array. **/ + rest(array: Array): T[]; + + /** + * @see _.rest + **/ rest(array: List): T[]; /** * @see _.rest **/ rest( - array: List, - callback: ListIterator, + array: Array, + callback: ListIterator, thisArg?: any): T[]; /** @@ -836,89 +1240,186 @@ declare module _ { **/ rest( array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.rest + **/ + rest( + array: Array, n: number): T[]; - + + /** + * @see _.rest + **/ + rest( + array: List, + n: number): T[]; + + /** + * @see _.rest + **/ + rest( + array: Array, + pluckValue: string): T[]; + /** * @see _.rest **/ rest( array: List, pluckValue: string): T[]; - + /** * @see _.rest **/ - rest( + rest( + array: Array, + whereValue: W): T[]; + + /** + * @see _.rest + **/ + rest( array: List, whereValue: W): T[]; - /** - * @see _.rest - **/ - drop(array: List): T[]; + /** + * @see _.rest + **/ + drop(array: Array): T[]; - /** - * @see _.rest - **/ - drop( - array: List, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.rest + **/ + drop(array: List): T[]; - /** - * @see _.rest - **/ - drop( - array: List, - n: number): T[]; - - /** - * @see _.rest - **/ - drop( - array: List, - pluckValue: string): T[]; - - /** - * @see _.rest - **/ - drop( - array: List, - whereValue: W): T[]; + /** + * @see _.rest + **/ + drop( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; - /** - * @see _.rest - **/ - tail(array: List): T[]; + /** + * @see _.rest + **/ + drop( + array: List, + callback: ListIterator, + thisArg?: any): T[]; - /** - * @see _.rest - **/ - tail( - array: List, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.rest + **/ + drop( + array: Array, + n: number): T[]; - /** - * @see _.rest - **/ - tail( - array: List, - n: number): T[]; - - /** - * @see _.rest - **/ - tail( - array: List, - pluckValue: string): T[]; - - /** - * @see _.rest - **/ - tail( - array: List, - whereValue: W): T[]; + /** + * @see _.rest + **/ + drop( + array: List, + n: number): T[]; + + /** + * @see _.rest + **/ + drop( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + drop( + array: List, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + drop( + array: Array, + whereValue: W): T[]; + + /** + * @see _.rest + **/ + drop( + array: List, + whereValue: W): T[]; + + /** + * @see _.rest + **/ + tail(array: Array): T[]; + + /** + * @see _.rest + **/ + tail(array: List): T[]; + + /** + * @see _.rest + **/ + tail( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.rest + **/ + tail( + array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.rest + **/ + tail( + array: Array, + n: number): T[]; + + /** + * @see _.rest + **/ + tail( + array: List, + n: number): T[]; + + /** + * @see _.rest + **/ + tail( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + tail( + array: List, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + tail( + array: Array, + whereValue: W): T[]; + + /** + * @see _.rest + **/ + tail( + array: List, + whereValue: W): T[]; } //_.sortedIndex @@ -939,12 +1440,30 @@ declare module _ { * @param callback Iterator to compute the sort ranking of each value, optional. * @return The index at which value should be inserted into array. **/ + sortedIndex( + array: Array, + value: T, + callback?: (x: T) => TSort, + thisArg?: any): number; + + /** + * @see _.sortedIndex + **/ sortedIndex( array: List, value: T, - callback?: (x: T) => TSort, + callback?: (x: T) => TSort, thisArg?: any): number; + /** + * @see _.sortedIndex + * @param pluckValue the _.pluck style callback + **/ + sortedIndex( + array: Array, + value: T, + pluckValue: string): number; + /** * @see _.sortedIndex * @param pluckValue the _.pluck style callback @@ -954,6 +1473,15 @@ declare module _ { value: T, pluckValue: string): number; + /** + * @see _.sortedIndex + * @param pluckValue the _.where style callback + **/ + sortedIndex( + array: Array, + value: T, + whereValue: W): number; + /** * @see _.sortedIndex * @param pluckValue the _.where style callback @@ -972,6 +1500,11 @@ declare module _ { * @param arrays The arrays to inspect. * @return Returns an array of composite values. **/ + union(...arrays: Array[]): T[]; + + /** + * @see _.union + **/ union(...arrays: List[]): T[]; } @@ -995,14 +1528,39 @@ declare module _ { * @param context 'this' object in `iterator`, optional. * @return Copy of `array` where all elements are unique. **/ + uniq(array: Array, isSorted?: boolean): T[]; + + /** + * @see _.uniq + **/ uniq(array: List, isSorted?: boolean): T[]; + /** + * @see _.uniq + **/ + uniq( + array: Array, + isSorted: boolean, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.uniq + **/ uniq( array: List, isSorted: boolean, callback: ListIterator, thisArg?: any): T[]; + /** + * @see _.uniq + **/ + uniq( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + /** * @see _.uniq **/ @@ -1011,6 +1569,15 @@ declare module _ { callback: ListIterator, thisArg?: any): T[]; + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + uniq( + array: Array, + isSorted: boolean, + pluckValue: string): T[]; + /** * @see _.uniq * @param pluckValue _.pluck style callback @@ -1020,10 +1587,31 @@ declare module _ { isSorted: boolean, pluckValue: string): T[]; + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + uniq( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ uniq( array: List, pluckValue: string): T[]; + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + uniq( + array: Array, + isSorted: boolean, + whereValue: W): T[]; + /** * @see _.uniq * @param whereValue _.where style callback @@ -1033,54 +1621,133 @@ declare module _ { isSorted: boolean, whereValue: W): T[]; + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + uniq( + array: Array, + whereValue: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ uniq( array: List, whereValue: W): T[]; - /** - * @see _.uniq - **/ - unique(array: List, isSorted?: boolean): T[]; + /** + * @see _.uniq + **/ + unique(array: Array, isSorted?: boolean): T[]; - unique( - array: List, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.uniq + **/ + unique(array: List, isSorted?: boolean): T[]; - /** - * @see _.uniq - **/ - unique( - array: List, - isSorted: boolean, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.uniq + **/ + unique( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; - /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - unique( - array: List, - isSorted: boolean, - pluckValue: string): T[]; + /** + * @see _.uniq + **/ + unique( + array: List, + callback: ListIterator, + thisArg?: any): T[]; - unique( - array: List, - pluckValue: string): T[]; + /** + * @see _.uniq + **/ + unique( + array: Array, + isSorted: boolean, + callback: ListIterator, + thisArg?: any): T[]; - /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( - array: List, - whereValue?: W): T[]; + /** + * @see _.uniq + **/ + unique( + array: List, + isSorted: boolean, + callback: ListIterator, + thisArg?: any): T[]; - unique( - array: List, - isSorted: boolean, - whereValue?: W): T[]; + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + array: Array, + isSorted: boolean, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + array: List, + isSorted: boolean, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + array: List, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + array: Array, + whereValue?: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + array: List, + whereValue?: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + array: Array, + isSorted: boolean, + whereValue?: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + array: List, + isSorted: boolean, + whereValue?: W): T[]; } //_.without @@ -1091,6 +1758,13 @@ declare module _ { * @param values The value(s) to exclude. * @return A new array of filtered values. **/ + without( + array: Array, + ...values: T[]): T[]; + + /** + * @see _.without + **/ without( array: List, ...values: T[]): T[]; @@ -1112,15 +1786,15 @@ declare module _ { **/ zip(...arrays: any[]): any[]; - /** - * @see _.zip - **/ - unzip(...arrays: any[][]): any[][]; + /** + * @see _.zip + **/ + unzip(...arrays: any[][]): any[][]; - /** - * @see _.zip - **/ - unzip(...arrays: any[]): any[]; + /** + * @see _.zip + **/ + unzip(...arrays: any[]): any[]; } //_.zipObject @@ -1137,12 +1811,12 @@ declare module _ { keys: List, values: List): TResult; - /** - * @see _.object - **/ - object( - keys: List, - values: List): TResult; + /** + * @see _.object + **/ + object( + keys: List, + values: List): TResult; } /* ************* @@ -1160,14 +1834,42 @@ declare module _ { * @return A new array of elements corresponding to the provided indexes. **/ at( - collection: Collection, + collection: Array, indexes: number[]): T[]; /** * @see _.at **/ at( - collection: Collection, + collection: List, + indexes: number[]): T[]; + + /** + * @see _.at + **/ + at( + collection: Dictionary, + indexes: number[]): T[]; + + /** + * @see _.at + **/ + at( + collection: Array, + ...indexes: number[]): T[]; + + /** + * @see _.at + **/ + at( + collection: List, + ...indexes: number[]): T[]; + + /** + * @see _.at + **/ + at( + collection: Dictionary, ...indexes: number[]): T[]; } @@ -1182,7 +1884,15 @@ declare module _ { * @return True if the target element is found, else false. **/ contains( - collection: Collection, + collection: Array, + target: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + contains( + collection: List, target: T, fromIndex?: number): boolean; @@ -1206,29 +1916,37 @@ declare module _ { targetString: string, fromIndex?: number): boolean; - /** - * @see _.contains - **/ - include( - collection: Collection, - target: T, - fromIndex?: number): boolean; + /** + * @see _.contains + **/ + include( + collection: Array, + target: T, + fromIndex?: number): boolean; - /** - * @see _.contains - **/ - include( - dictionary: Dictionary, - key: string, - fromIndex?: number): boolean; + /** + * @see _.contains + **/ + include( + collection: List, + target: T, + fromIndex?: number): boolean; - /** - * @see _.contains - **/ - include( - searchString: string, - targetString: string, - fromIndex?: number): boolean; + /** + * @see _.contains + **/ + include( + dictionary: Dictionary, + key: string, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + include( + searchString: string, + targetString: string, + fromIndex?: number): boolean; } //_.countBy @@ -1250,7 +1968,7 @@ declare module _ { * @return Returns the composed aggregate object. **/ countBy( - collection: Collection, + collection: Array, callback?: ListIterator, thisArg?: any): Dictionary; @@ -1259,16 +1977,52 @@ declare module _ { * @param callback Function name **/ countBy( - collection: Collection, + collection: List, + callback?: ListIterator, + thisArg?: any): Dictionary; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + collection: Dictionary, + callback?: ListIterator, + thisArg?: any): Dictionary; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + collection: Array, callback: string, - thisArg?: any): Dictionary; + thisArg?: any): Dictionary; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + collection: List, + callback: string, + thisArg?: any): Dictionary; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + collection: Dictionary, + callback: string, + thisArg?: any): Dictionary; } interface LoDashArrayWrapper { /** * @see _.countBy **/ - countBy( + countBy( callback?: ListIterator, thisArg?: any): LoDashObjectWrapper>; @@ -1276,7 +2030,7 @@ declare module _ { * @see _.countBy * @param callback Function name **/ - countBy( + countBy( callback: string, thisArg?: any): LoDashObjectWrapper>; } @@ -1299,7 +2053,7 @@ declare module _ { * @return True if all elements passed the callback check, else false. **/ every( - collection: Collection, + collection: Array, callback?: ListIterator, thisArg?: any): boolean; @@ -1308,7 +2062,41 @@ declare module _ { * @param pluckValue _.pluck style callback **/ every( - collection: Collection, + collection: List, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + every( + collection: Dictionary, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + every( + collection: Array, + pluckValue: string): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + every( + collection: List, + pluckValue: string): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + every( + collection: Dictionary, pluckValue: string): boolean; /** @@ -1316,32 +2104,96 @@ declare module _ { * @param whereValue _.where style callback **/ every( - collection: Collection, + collection: Array, whereValue: W): boolean; - /** - * @see _.every - **/ - all( - collection: Collection, - callback?: ListIterator, - thisArg?: any): boolean; + /** + * @see _.every + * @param whereValue _.where style callback + **/ + every( + collection: List, + whereValue: W): boolean; - /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ - all( - collection: Collection, - pluckValue: string): boolean; + /** + * @see _.every + * @param whereValue _.where style callback + **/ + every( + collection: Dictionary, + whereValue: W): boolean; - /** - * @see _.every - * @param whereValue _.where style callback - **/ - all( - collection: Collection, - whereValue: W): boolean; + /** + * @see _.every + **/ + all( + collection: Array, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + **/ + all( + collection: List, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + **/ + all( + collection: Dictionary, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + all( + collection: Array, + pluckValue: string): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + all( + collection: List, + pluckValue: string): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + all( + collection: Dictionary, + pluckValue: string): boolean; + + /** + * @see _.every + * @param whereValue _.where style callback + **/ + all( + collection: Array, + whereValue: W): boolean; + + /** + * @see _.every + * @param whereValue _.where style callback + **/ + all( + collection: List, + whereValue: W): boolean; + + /** + * @see _.every + * @param whereValue _.where style callback + **/ + all( + collection: Dictionary, + whereValue: W): boolean; } //_.filter @@ -1362,7 +2214,23 @@ declare module _ { * @return Returns a new array of elements that passed the callback check. **/ filter( - collection: Collection, + collection: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + **/ + filter( + collection: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + **/ + filter( + collection: Dictionary, callback: ListIterator, thisArg?: any): T[]; @@ -1371,47 +2239,127 @@ declare module _ { * @param pluckValue _.pluck style callback **/ filter( - collection: Collection, + collection: Array, pluckValue: string): T[]; /** * @see _.filter * @param pluckValue _.pluck style callback **/ - filter( - collection: Collection, - whereValue: W): T[]; + filter( + collection: List, + pluckValue: string): T[]; - /** - * @see _.filter - **/ - select( - collection: Collection, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: Dictionary, + pluckValue: string): T[]; - /** - * @see _.filter - * @param pluckValue _.pluck style callback - **/ - select( - collection: Collection, - pluckValue: string): T[]; + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: Array, + whereValue: W): T[]; - /** - * @see _.filter - * @param pluckValue _.pluck style callback - **/ - select( - collection: Collection, - whereValue: W): T[]; + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: List, + whereValue: W): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: Dictionary, + whereValue: W): T[]; + + /** + * @see _.filter + **/ + select( + collection: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + **/ + select( + collection: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + **/ + select( + collection: Dictionary, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: Array, + pluckValue: string): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: List, + pluckValue: string): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: Dictionary, + pluckValue: string): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: Array, + whereValue: W): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: List, + whereValue: W): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: Dictionary, + whereValue: W): T[]; } interface LoDashArrayWrapper { /** * @see _.filter **/ - filter( + filter( callback: ListIterator, thisArg?: any): LoDashArrayWrapper; @@ -1419,36 +2367,36 @@ declare module _ { * @see _.filter * @param pluckValue _.pluck style callback **/ - filter( + filter( pluckValue: string): LoDashArrayWrapper; /** * @see _.filter * @param pluckValue _.pluck style callback **/ - filter( + filter( whereValue: W): LoDashArrayWrapper; - /** - * @see _.filter - **/ - select( - callback: ListIterator, - thisArg?: any): LoDashArrayWrapper; + /** + * @see _.filter + **/ + select( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; - /** - * @see _.filter - * @param pluckValue _.pluck style callback - **/ - select( - pluckValue: string): LoDashArrayWrapper; + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + pluckValue: string): LoDashArrayWrapper; - /** - * @see _.filter - * @param pluckValue _.pluck style callback - **/ - select( - whereValue: W): LoDashArrayWrapper; + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + whereValue: W): LoDashArrayWrapper; } //_.find @@ -1469,7 +2417,23 @@ declare module _ { * @return The found element, else undefined. **/ find( - collection: Collection, + collection: Array, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + find( + collection: List, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + find( + collection: Dictionary, callback: ListIterator, thisArg?: any): T; @@ -1478,7 +2442,23 @@ declare module _ { * @param _.pluck style callback **/ find( - collection: Collection, + collection: Array, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + find( + collection: List, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + find( + collection: Dictionary, whereValue: W): T; /** @@ -1486,56 +2466,168 @@ declare module _ { * @param _.where style callback **/ find( - collection: Collection, + collection: Array, pluckValue: string): T; - /** - * @see _.find - **/ - detect( - collection: Collection, - callback: ListIterator, - thisArg?: any): T; + /** + * @see _.find + * @param _.where style callback + **/ + find( + collection: List, + pluckValue: string): T; - /** - * @see _.find - * @param _.pluck style callback - **/ - detect( - collection: Collection, - whereValue: W): T; + /** + * @see _.find + * @param _.where style callback + **/ + find( + collection: Dictionary, + pluckValue: string): T; - /** - * @see _.find - * @param _.where style callback - **/ - detect( - collection: Collection, - pluckValue: string): T; + /** + * @see _.find + **/ + detect( + collection: Array, + callback: ListIterator, + thisArg?: any): T; - /** - * @see _.find - **/ - findWhere( - collection: Collection, - callback: ListIterator, - thisArg?: any): T; + /** + * @see _.find + **/ + detect( + collection: List, + callback: ListIterator, + thisArg?: any): T; - /** - * @see _.find - * @param _.pluck style callback - **/ - findWhere( - collection: Collection, - whereValue: W): T; + /** + * @see _.find + **/ + detect( + collection: Dictionary, + callback: ListIterator, + thisArg?: any): T; - /** - * @see _.find - * @param _.where style callback - **/ - findWhere( - collection: Collection, - pluckValue: string): T; + /** + * @see _.find + * @param _.pluck style callback + **/ + detect( + collection: Array, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + detect( + collection: List, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + detect( + collection: Dictionary, + whereValue: W): T; + + /** + * @see _.find + * @param _.where style callback + **/ + detect( + collection: Array, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + detect( + collection: List, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + detect( + collection: Dictionary, + pluckValue: string): T; + + /** + * @see _.find + **/ + findWhere( + collection: Array, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + findWhere( + collection: List, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + findWhere( + collection: Dictionary, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + findWhere( + collection: Array, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + findWhere( + collection: List, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + findWhere( + collection: Dictionary, + whereValue: W): T; + + /** + * @see _.find + * @param _.where style callback + **/ + findWhere( + collection: Array, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + findWhere( + collection: List, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + findWhere( + collection: Dictionary, + pluckValue: string): T; } //_.findLast @@ -1549,7 +2641,23 @@ declare module _ { * @return The found element, else undefined. **/ findLast( - collection: Collection, + collection: Array, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + findLast( + collection: List, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + findLast( + collection: Dictionary, callback: ListIterator, thisArg?: any): T; @@ -1558,7 +2666,23 @@ declare module _ { * @param _.pluck style callback **/ findLast( - collection: Collection, + collection: Array, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + findLast( + collection: List, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + findLast( + collection: Dictionary, whereValue: W): T; /** @@ -1566,7 +2690,23 @@ declare module _ { * @param _.where style callback **/ findLast( - collection: Collection, + collection: Array, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + findLast( + collection: List, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + findLast( + collection: Dictionary, pluckValue: string): T; } @@ -1580,9 +2720,17 @@ declare module _ { * @param callback The function called per iteration. * @param thisArg The this binding of callback. **/ + forEach( + collection: Array, + callback: ListIterator, + thisArg?: any): Array; + + /** + * @see _.forEach + **/ forEach( collection: List, - callback: ListIterator, + callback: ListIterator, thisArg?: any): List; /** @@ -1590,43 +2738,51 @@ declare module _ { **/ forEach( object: Dictionary, - callback: ObjectIterator, + callback: ObjectIterator, thisArg?: any): Dictionary; - /** - * @see _.forEach - **/ - each( - collection: List, - callback: ListIterator, - thisArg?: any): List; + /** + * @see _.forEach + **/ + each( + collection: Array, + callback: ListIterator, + thisArg?: any): Array; - /** - * @see _.forEach - * @param object The object to iterate over - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - **/ - each( - object: Dictionary, - callback: ObjectIterator, - thisArg?: any): Dictionary; + /** + * @see _.forEach + **/ + each( + collection: List, + callback: ListIterator, + thisArg?: any): List; + + /** + * @see _.forEach + * @param object The object to iterate over + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + **/ + each( + object: Dictionary, + callback: ObjectIterator, + thisArg?: any): Dictionary; } interface LoDashArrayWrapper { /** * @see _.forEach **/ - forEach( - callback: ListIterator, + forEach( + callback: ListIterator, thisArg?: any): LoDashArrayWrapper; - /** - * @see _.forEach - **/ - each( - callback: ListIterator, - thisArg?: any): LoDashArrayWrapper; + /** + * @see _.forEach + **/ + each( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; } interface LoDashObjectWrapper { @@ -1634,15 +2790,15 @@ declare module _ { * @see _.forEach **/ forEach( - callback: ObjectIterator, + callback: ObjectIterator, thisArg?: any): LoDashObjectWrapper; - /** - * @see _.forEach - **/ - each( - callback: ObjectIterator, - thisArg?: any): LoDashObjectWrapper; + /** + * @see _.forEach + **/ + each( + callback: ObjectIterator, + thisArg?: any): LoDashObjectWrapper; } //_.forEachRight @@ -1654,9 +2810,17 @@ declare module _ { * @param callback The function called per iteration. * @param thisArg The this binding of callback. **/ + forEachRight( + collection: Array, + callback: ListIterator, + thisArg?: any): Array; + + /** + * @see _.forEachRight + **/ forEachRight( collection: List, - callback: ListIterator, + callback: ListIterator, thisArg?: any): List; /** @@ -1664,43 +2828,51 @@ declare module _ { **/ forEachRight( object: Dictionary, - callback: ObjectIterator, + callback: ObjectIterator, thisArg?: any): Dictionary; - /** - * @see _.forEachRight - **/ - eachRight( - collection: List, - callback: ListIterator, - thisArg?: any): List; + /** + * @see _.forEachRight + **/ + eachRight( + collection: Array, + callback: ListIterator, + thisArg?: any): Array; - /** - * @see _.forEachRight - * @param object The object to iterate over - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - **/ - eachRight( - object: Dictionary, - callback: ObjectIterator, - thisArg?: any): Dictionary; + /** + * @see _.forEachRight + **/ + eachRight( + collection: List, + callback: ListIterator, + thisArg?: any): List; + + /** + * @see _.forEachRight + * @param object The object to iterate over + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + **/ + eachRight( + object: Dictionary, + callback: ObjectIterator, + thisArg?: any): Dictionary; } interface LoDashArrayWrapper { /** * @see _.forEachRight **/ - forEachRight( - callback: ListIterator, + forEachRight( + callback: ListIterator, thisArg?: any): LoDashArrayWrapper; - /** - * @see _.forEachRight - **/ - eachRight( - callback: ListIterator, - thisArg?: any): LoDashArrayWrapper; + /** + * @see _.forEachRight + **/ + eachRight( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; } interface LoDashObjectWrapper { @@ -1708,18 +2880,18 @@ declare module _ { * @see _.forEachRight **/ forEachRight( - callback: ObjectIterator, + callback: ObjectIterator, thisArg?: any): LoDashObjectWrapper>; - /** - * @see _.forEachRight - * @param object The object to iterate over - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - **/ - eachRight( - callback: ObjectIterator, - thisArg?: any): LoDashObjectWrapper>; + /** + * @see _.forEachRight + * @param object The object to iterate over + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + **/ + eachRight( + callback: ObjectIterator, + thisArg?: any): LoDashObjectWrapper>; } //_.groupBy @@ -1739,11 +2911,27 @@ declare module _ { * @param thisArg The this binding of callback. * @return Returns the composed aggregate object. **/ + groupBy( + collection: Array, + callback?: ListIterator, + thisArg?: any): Dictionary; + + /** + * @see _.groupBy + **/ groupBy( collection: List, callback?: ListIterator, thisArg?: any): Dictionary; + /** + * @see _.groupBy + * @param pluckValue _.pluck style callback + **/ + groupBy( + collection: Array, + pluckValue: string): Dictionary; + /** * @see _.groupBy * @param pluckValue _.pluck style callback @@ -1752,6 +2940,14 @@ declare module _ { collection: List, pluckValue: string): Dictionary; + /** + * @see _.groupBy + * @param whereValue _.where style callback + **/ + groupBy( + collection: Array, + whereValue: W): Dictionary; + /** * @see _.groupBy * @param whereValue _.where style callback @@ -1761,24 +2957,24 @@ declare module _ { whereValue: W): Dictionary; } - interface LoDashArrayWrapper { + interface LoDashArrayWrapper { /** * @see _.groupBy **/ - groupBy( + groupBy( callback: ListIterator, thisArg?: any): _.LoDashObjectWrapper>; /** * @see _.groupBy **/ - groupBy( + groupBy( pluckValue: string): _.LoDashObjectWrapper>; /** * @see _.groupBy **/ - groupBy( + groupBy( whereValue: W): _.LoDashObjectWrapper>; } @@ -1800,11 +2996,27 @@ declare module _ { * @param thisArg The this binding of callback. * @return Returns the composed aggregate object. **/ + indexBy( + list: Array, + iterator: ListIterator, + context?: any): Dictionary; + + /** + * @see _.indexBy + **/ indexBy( list: List, iterator: ListIterator, context?: any): Dictionary; + /** + * @see _.indexBy + * @param pluckValue _.pluck style callback + **/ + indexBy( + collection: Array, + pluckValue: string): Dictionary; + /** * @see _.indexBy * @param pluckValue _.pluck style callback @@ -1813,6 +3025,14 @@ declare module _ { collection: List, pluckValue: string): Dictionary; + /** + * @see _.indexBy + * @param whereValue _.where style callback + **/ + indexBy( + collection: Array, + whereValue: W): Dictionary; + /** * @see _.indexBy * @param whereValue _.where style callback @@ -1834,7 +3054,7 @@ declare module _ { * @param args Arguments to invoke the method with. **/ invoke( - collection: Collection, + collection: Array, methodName: string, ...args: any[]): any; @@ -1842,7 +3062,39 @@ declare module _ { * @see _.invoke **/ invoke( - collection: Collection, + collection: List, + methodName: string, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + invoke( + collection: Dictionary, + methodName: string, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + invoke( + collection: Array, + method: Function, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + invoke( + collection: List, + method: Function, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + invoke( + collection: Dictionary, method: Function, ...args: any[]): any; } @@ -1864,6 +3116,14 @@ declare module _ { * @param theArg The this binding of callback. * @return The mapped array result. **/ + map( + collection: Array, + callback: ListIterator, + thisArg?: any): TResult[]; + + /** + * @see _.map + **/ map( collection: List, callback: ListIterator, @@ -1881,6 +3141,14 @@ declare module _ { callback: ObjectIterator, thisArg?: any): TResult[]; + /** + * @see _.map + * @param pluckValue _.pluck style callback + **/ + map( + collection: Array, + pluckValue: string): TResult[]; + /** * @see _.map * @param pluckValue _.pluck style callback @@ -1889,35 +3157,50 @@ declare module _ { collection: List, pluckValue: string): TResult[]; - /** - * @see _.map - **/ - collect( - collection: List, - callback: ListIterator, - thisArg?: any): TResult[]; + /** + * @see _.map + **/ + collect( + collection: Array, + callback: ListIterator, + thisArg?: any): TResult[]; - /** - * @see _.map - **/ - collect( - object: Dictionary, - callback: ObjectIterator, - thisArg?: any): TResult[]; + /** + * @see _.map + **/ + collect( + collection: List, + callback: ListIterator, + thisArg?: any): TResult[]; - /** - * @see _.map - **/ - collect( - collection: List, - pluckValue: string): TResult[]; + /** + * @see _.map + **/ + collect( + object: Dictionary, + callback: ObjectIterator, + thisArg?: any): TResult[]; + + /** + * @see _.map + **/ + collect( + collection: Array, + pluckValue: string): TResult[]; + + /** + * @see _.map + **/ + collect( + collection: List, + pluckValue: string): TResult[]; } interface LoDashArrayWrapper { /** * @see _.map **/ - map( + map( callback: ListIterator, thisArg?: any): LoDashArrayWrapper; @@ -1925,21 +3208,21 @@ declare module _ { * @see _.map * @param pluckValue _.pluck style callback **/ - map( + map( pluckValue: string): LoDashArrayWrapper; - /** - * @see _.map - **/ - collect( - callback: ListIterator, - thisArg?: any): LoDashArrayWrapper; + /** + * @see _.map + **/ + collect( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; - /** - * @see _.map - **/ - collect( - pluckValue: string): LoDashArrayWrapper; + /** + * @see _.map + **/ + collect( + pluckValue: string): LoDashArrayWrapper; } interface LoDashObjectWrapper { @@ -1948,14 +3231,14 @@ declare module _ { **/ map( callback: ObjectIterator, - thisArg?: any): LoDashObjectWrapper; + thisArg?: any): LoDashArrayWrapper; - /** - * @see _.map - **/ - collect( - callback: ObjectIterator, - thisArg?: any): LoDashObjectWrapper; + /** + * @see _.map + **/ + collect( + callback: ObjectIterator, + thisArg?: any): LoDashArrayWrapper; } //_.max @@ -1977,7 +3260,23 @@ declare module _ { * @return Returns the maximum value. **/ max( - collection: Collection, + collection: Array, + callback?: ListIterator, + thisArg?: any): T; + + /** + * @see _.max + **/ + max( + collection: List, + callback?: ListIterator, + thisArg?: any): T; + + /** + * @see _.max + **/ + max( + collection: Dictionary, callback?: ListIterator, thisArg?: any): T; @@ -1986,7 +3285,23 @@ declare module _ { * @param pluckValue _.pluck style callback **/ max( - collection: Collection, + collection: Array, + pluckValue: string): T; + + /** + * @see _.max + * @param pluckValue _.pluck style callback + **/ + max( + collection: List, + pluckValue: string): T; + + /** + * @see _.max + * @param pluckValue _.pluck style callback + **/ + max( + collection: Dictionary, pluckValue: string): T; /** @@ -1994,7 +3309,23 @@ declare module _ { * @param whereValue _.where style callback **/ max( - collection: Collection, + collection: Array, + whereValue: W): T; + + /** + * @see _.max + * @param whereValue _.where style callback + **/ + max( + collection: List, + whereValue: W): T; + + /** + * @see _.max + * @param whereValue _.where style callback + **/ + max( + collection: Dictionary, whereValue: W): T; } @@ -2017,7 +3348,23 @@ declare module _ { * @return Returns the maximum value. **/ min( - collection: Collection, + collection: Array, + callback?: ListIterator, + thisArg?: any): T; + + /** + * @see _.min + **/ + min( + collection: List, + callback?: ListIterator, + thisArg?: any): T; + + /** + * @see _.min + **/ + min( + collection: Dictionary, callback?: ListIterator, thisArg?: any): T; @@ -2026,7 +3373,23 @@ declare module _ { * @param pluckValue _.pluck style callback **/ min( - collection: Collection, + collection: Array, + pluckValue: string): T; + + /** + * @see _.min + * @param pluckValue _.pluck style callback + **/ + min( + collection: List, + pluckValue: string): T; + + /** + * @see _.min + * @param pluckValue _.pluck style callback + **/ + min( + collection: Dictionary, pluckValue: string): T; /** @@ -2034,7 +3397,23 @@ declare module _ { * @param whereValue _.where style callback **/ min( - collection: Collection, + collection: Array, + whereValue: W): T; + + /** + * @see _.min + * @param whereValue _.where style callback + **/ + min( + collection: List, + whereValue: W): T; + + /** + * @see _.min + * @param whereValue _.where style callback + **/ + min( + collection: Dictionary, whereValue: W): T; } @@ -2047,7 +3426,21 @@ declare module _ { * @return A new array of property values. **/ pluck( - collection: Collection, + collection: Array, + property: string): any[]; + + /** + * @see _.pluck + **/ + pluck( + collection: List, + property: string): any[]; + + /** + * @see _.pluck + **/ + pluck( + collection: Dictionary, property: string): any[]; } @@ -2066,52 +3459,154 @@ declare module _ { * @return Returns the accumulated value. **/ reduce( - collection: Collection, + collection: Array, callback: MemoIterator, accumulator: TResult, thisArg?: any): TResult; - /** - * @see _.reduce - **/ + /** + * @see _.reduce + **/ reduce( - collection: Collection, + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + collection: Array, callback: MemoIterator, thisArg?: any): TResult; - /** - * @see _.reduce - **/ - inject( - collection: Collection, - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; + /** + * @see _.reduce + **/ + reduce( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; - /** - * @see _.reduce - **/ - inject( - collection: Collection, - callback: MemoIterator, - thisArg?: any): TResult; + /** + * @see _.reduce + **/ + reduce( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; - /** - * @see _.reduce - **/ - foldl( - collection: Collection, - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; + /** + * @see _.reduce + **/ + inject( + collection: Array, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; - /** - * @see _.reduce - **/ - foldl( - collection: Collection, - callback: MemoIterator, - thisArg?: any): TResult; + /** + * @see _.reduce + **/ + inject( + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: Array, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: Array, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: Array, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; } //_.reduceRight @@ -2126,35 +3621,103 @@ declare module _ { * @return The accumulated value. **/ reduceRight( - collection: Collection, + collection: Array, callback: MemoIterator, accumulator: TResult, thisArg?: any): TResult; - /** - * @see _.reduceRight - **/ + /** + * @see _.reduceRight + **/ reduceRight( - collection: Collection, + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + reduceRight( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + reduceRight( + collection: Array, callback: MemoIterator, thisArg?: any): TResult; - /** - * @see _.reduceRight - **/ - foldr( - collection: Collection, - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; + /** + * @see _.reduceRight + **/ + reduceRight( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; - /** - * @see _.reduceRight - **/ - foldr( - collection: Collection, - callback: MemoIterator, - thisArg?: any): TResult; + /** + * @see _.reduceRight + **/ + reduceRight( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: Array, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: Array, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; } //_.reject @@ -2174,7 +3737,23 @@ declare module _ { * @return A new array of elements that failed the callback check. **/ reject( - collection: Collection, + collection: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.reject + **/ + reject( + collection: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.reject + **/ + reject( + collection: Dictionary, callback: ListIterator, thisArg?: any): T[]; @@ -2183,7 +3762,23 @@ declare module _ { * @param pluckValue _.pluck style callback **/ reject( - collection: Collection, + collection: Array, + pluckValue: string): T[]; + + /** + * @see _.reject + * @param pluckValue _.pluck style callback + **/ + reject( + collection: List, + pluckValue: string): T[]; + + /** + * @see _.reject + * @param pluckValue _.pluck style callback + **/ + reject( + collection: Dictionary, pluckValue: string): T[]; /** @@ -2191,7 +3786,23 @@ declare module _ { * @param whereValue _.where style callback **/ reject( - collection: Collection, + collection: Array, + whereValue: W): T[]; + + /** + * @see _.reject + * @param whereValue _.where style callback + **/ + reject( + collection: List, + whereValue: W): T[]; + + /** + * @see _.reject + * @param whereValue _.where style callback + **/ + reject( + collection: Dictionary, whereValue: W): T[]; } @@ -2202,13 +3813,35 @@ declare module _ { * @param collection The collection to sample. * @return Returns the random sample(s) of collection. **/ - sample(collection: Collection): T; + sample(collection: Array): T; + + /** + * @see _.sample + **/ + sample(collection: List): T; + + /** + * @see _.sample + **/ + sample(collection: Dictionary): T; /** * @see _.sample * @param n The number of elements to sample. **/ - sample(collection: Collection, n: number): T[]; + sample(collection: Array, n: number): T[]; + + /** + * @see _.sample + * @param n The number of elements to sample. + **/ + sample(collection: List, n: number): T[]; + + /** + * @see _.sample + * @param n The number of elements to sample. + **/ + sample(collection: Dictionary, n: number): T[]; } //_.shuffle @@ -2219,7 +3852,17 @@ declare module _ { * @param collection The collection to shuffle. * @return Returns a new shuffled collection. **/ - shuffle(collection: Collection): T[]; + shuffle(collection: Array): T[]; + + /** + * @see _.shuffle + **/ + shuffle(collection: List): T[]; + + /** + * @see _.shuffle + **/ + shuffle(collection: Dictionary): T[]; } //_.size @@ -2230,6 +3873,11 @@ declare module _ { * @param collection The collection to inspect. * @return collection.length **/ + size(collection: Array): number; + + /** + * @see _.size + **/ size(collection: List): number; /** @@ -2265,7 +3913,23 @@ declare module _ { * @return True if any element passed the callback check, else false. **/ some( - collection: Collection, + collection: Array, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + some( + collection: List, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + some( + collection: Dictionary, callback?: ListIterator, thisArg?: any): boolean; @@ -2274,7 +3938,23 @@ declare module _ { * @param pluckValue _.pluck style callback **/ some( - collection: Collection, + collection: Array, + pluckValue: string): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + some( + collection: List, + pluckValue: string): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + some( + collection: Dictionary, pluckValue: string): boolean; /** @@ -2282,32 +3962,96 @@ declare module _ { * @param whereValue _.where style callback **/ some( - collection: Collection, + collection: Array, whereValue: W): boolean; - /** - * @see _.some - **/ - any( - collection: Collection, - callback?: ListIterator, - thisArg?: any): boolean; + /** + * @see _.some + * @param whereValue _.where style callback + **/ + some( + collection: List, + whereValue: W): boolean; - /** - * @see _.some - * @param pluckValue _.pluck style callback - **/ - any( - collection: Collection, - pluckValue: string): boolean; + /** + * @see _.some + * @param whereValue _.where style callback + **/ + some( + collection: Dictionary, + whereValue: W): boolean; - /** - * @see _.some - * @param whereValue _.where style callback - **/ - any( - collection: Collection, - whereValue: W): boolean; + /** + * @see _.some + **/ + any( + collection: Array, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + any( + collection: List, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + any( + collection: Dictionary, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + any( + collection: Array, + pluckValue: string): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + any( + collection: List, + pluckValue: string): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + any( + collection: Dictionary, + pluckValue: string): boolean; + + /** + * @see _.some + * @param whereValue _.where style callback + **/ + any( + collection: Array, + whereValue: W): boolean; + + /** + * @see _.some + * @param whereValue _.where style callback + **/ + any( + collection: List, + whereValue: W): boolean; + + /** + * @see _.some + * @param whereValue _.where style callback + **/ + any( + collection: Dictionary, + whereValue: W): boolean; } //_.sortBy @@ -2328,11 +4072,27 @@ declare module _ { * @param thisArg The this binding of callback. * @return A new array of sorted elements. **/ + sortBy( + collection: Array, + callback?: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.sortBy + **/ sortBy( collection: List, callback?: ListIterator, thisArg?: any): T[]; + /** + * @see _.sortBy + * @param pluckValue _.pluck style callback + **/ + sortBy( + collection: Array, + pluckValue: string): T[]; + /** * @see _.sortBy * @param pluckValue _.pluck style callback @@ -2341,6 +4101,14 @@ declare module _ { collection: List, pluckValue: string): T[]; + /** + * @see _.sortBy + * @param whereValue _.where style callback + **/ + sortBy( + collection: Array, + whereValue: W): T[]; + /** * @see _.sortBy * @param whereValue _.where style callback @@ -2357,7 +4125,17 @@ declare module _ { * @param collection The collection to convert. * @return The new converted array. **/ - toArray(collection: Collection): T[]; + toArray(collection: Array): T[]; + + /** + * @see _.toArray + **/ + toArray(collection: List): T[]; + + /** + * @see _.toArray + **/ + toArray(collection: Dictionary): T[]; } //_.where @@ -2370,7 +4148,21 @@ declare module _ { * @return A new array of elements that have the given properties. **/ where( - list: Collection, + list: Array, + properties: U): T[]; + + /** + * @see _.where + **/ + where( + list: List, + properties: U): T[]; + + /** + * @see _.where + **/ + where( + list: Dictionary, properties: U): T[]; } @@ -2389,7 +4181,7 @@ declare module _ { **/ after( n: number, - func: Function): Function; + func: Function): Function; } interface LoDashWrapper { @@ -2412,7 +4204,7 @@ declare module _ { bind( func: Function, thisArg: any, - ...args: any[]): () => any; + ...args: any[]): () => any; } interface LoDashObjectWrapper { @@ -2437,14 +4229,14 @@ declare module _ { **/ bindAll( object: T, - ...methodNames: string[]): T; + ...methodNames: string[]): T; } interface LoDashObjectWrapper { /** * @see _.bindAll **/ - bindAll(...methodNames: string[]): LoDashWrapper; + bindAll(...methodNames: string[]): LoDashWrapper; } //_.bindKey @@ -2462,7 +4254,7 @@ declare module _ { bindKey( object: T, key: string, - ...args: any[]): Function; + ...args: any[]): Function; } interface LoDashObjectWrapper { @@ -2484,7 +4276,7 @@ declare module _ { * @param funcs Functions to compose. * @return The new composed function. **/ - compose(...funcs: Function[]): Function; + compose(...funcs: Function[]): Function; } interface LoDashObjectWrapper { @@ -2517,7 +4309,7 @@ declare module _ { createCallback( func: Dictionary, thisArg?: any, - argCount?: number): () => boolean; + argCount?: number): () => boolean; } interface LoDashWrapper { @@ -2551,7 +4343,7 @@ declare module _ { **/ curry( func: Function, - arity?: number): Function; + arity?: number): Function; } interface LoDashObjectWrapper { @@ -2583,7 +4375,7 @@ declare module _ { debounce( func: T, wait: number, - options?: DebounceSettings): T; + options?: DebounceSettings): T; } interface LoDashObjectWrapper { @@ -2600,7 +4392,7 @@ declare module _ { * Specify execution on the leading edge of the timeout. **/ leading?: boolean; - + /** * The maximum time func is allowed to be delayed before it’s called. **/ @@ -2623,7 +4415,7 @@ declare module _ { **/ defer( func: Function, - ...args: any[]): number; + ...args: any[]): number; } interface LoDashObjectWrapper { @@ -2646,7 +4438,7 @@ declare module _ { delay( func: Function, wait: number, - ...args: any[]): number; + ...args: any[]): number; } interface LoDashObjectWrapper { @@ -2670,7 +4462,7 @@ declare module _ { * @param resolver Hash function for storing the result of `fn`. * @return Returns the new memoizing function. **/ - memoize( + memoize( func: T, resolver?: Function): T; } @@ -2684,7 +4476,7 @@ declare module _ { * @param func Function to only execute once. * @return The new restricted function. **/ - once(func: T): T; + once(func: T): T; } //_.partial @@ -2733,7 +4525,7 @@ declare module _ { * @param options.trailing Specify execution on the trailing edge of the timeout. * @return The new throttled function. **/ - throttle( + throttle( func: T, wait: number, options?: ThrottleSettings): T; @@ -2784,86 +4576,86 @@ declare module _ { * @param thisArg The this binding of callback. * @return The destination object. **/ - assign( - object: T, - s1: S1, + assign( + object: T, + s1: S1, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - assign( - object: T, - s1: S1, - s2: S2, + assign( + object: T, + s1: S1, + s2: S2, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - assign( - object: T, - s1: S1, - s2: S2, - s3: S3, + assign( + object: T, + s1: S1, + s2: S2, + s3: S3, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - assign( - object: T, - s1: S1, - s2: S2, - s3: S3, - s4: S4, + assign( + object: T, + s1: S1, + s2: S2, + s3: S3, + s4: S4, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - extend( - object: T, - s1: S1, + extend( + object: T, + s1: S1, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - extend( - object: T, - s1: S1, - s2: S2, + extend( + object: T, + s1: S1, + s2: S2, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - extend( - object: T, - s1: S1, - s2: S2, - s3: S3, + extend( + object: T, + s1: S1, + s2: S2, + s3: S3, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - extend( - object: T, - s1: S1, - s2: S2, - s3: S3, - s4: S4, + extend( + object: T, + s1: S1, + s2: S2, + s3: S3, + s4: S4, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; } interface LoDashObjectWrapper { @@ -2914,52 +4706,52 @@ declare module _ { callback?: (objectValue: Value, sourceValue: Value) => Value, thisArg?: any): TResult; - /** - * @see _.assign - **/ - extend( - s1: S1, - callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; - /** - * @see _.assign - **/ - extend( - s1: S1, - s2: S2, - callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): TResult; - /** - * @see _.assign - **/ - extend( - s1: S1, - s2: S2, - s3: S3, - callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): TResult; - /** - * @see _.assign - **/ - extend( - s1: S1, - s2: S2, - s3: S3, - s4: S4, - callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): TResult; - /** - * @see _.assign - **/ - extend( - s1: S1, - s2: S2, - s3: S3, - s4: S4, - s5: S5, - callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + s3: S3, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + s3: S3, + s4: S4, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + s3: S3, + s4: S4, + s5: S5, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; } @@ -3017,7 +4809,7 @@ declare module _ { **/ defaults( object: T, - ...sources: any[]): TResult; + ...sources: any[]): TResult; } interface LoDashObjectWrapper { @@ -3054,7 +4846,7 @@ declare module _ { * @see _.findKey * @param whereValue _.where style callback **/ - findKey, T>( + findKey, T>( object: T, whereValue: W): string; } @@ -3085,7 +4877,7 @@ declare module _ { * @see _.findLastKey * @param whereValue _.where style callback **/ - findLastKey, T>( + findLastKey, T>( object: T, whereValue: W): string; } @@ -3105,9 +4897,17 @@ declare module _ { object: Dictionary, callback?: ObjectIterator, thisArg?: any): Dictionary; + + /** + * @see _.forIn + **/ + forIn( + object: T, + callback?: ObjectIterator, + thisArg?: any): T; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.forIn **/ @@ -3130,9 +4930,17 @@ declare module _ { object: Dictionary, callback?: ObjectIterator, thisArg?: any): Dictionary; + + /** + * @see _.forInRight + **/ + forInRight( + object: T, + callback?: ObjectIterator, + thisArg?: any): T; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.forInRight **/ @@ -3156,9 +4964,17 @@ declare module _ { object: Dictionary, callback?: ObjectIterator, thisArg?: any): Dictionary; + + /** + * @see _.forOwn + **/ + forOwn( + object: T, + callback?: ObjectIterator, + thisArg?: any): T; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.forOwn **/ @@ -3181,9 +4997,16 @@ declare module _ { object: Dictionary, callback?: ObjectIterator, thisArg?: any): Dictionary; + /** + * @see _.forOwnRight + **/ + forOwnRight( + object: T, + callback?: ObjectIterator, + thisArg?: any): T; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.forOwnRight **/ @@ -3202,22 +5025,22 @@ declare module _ { **/ functions(object: any): string[]; - /** - * @see _functions - **/ - methods(object: any): string[]; + /** + * @see _functions + **/ + methods(object: any): string[]; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.functions **/ functions(): _.LoDashArrayWrapper; - /** - * @see _.functions - **/ - methods(): _.LoDashArrayWrapper; + /** + * @see _.functions + **/ + methods(): _.LoDashArrayWrapper; } //_.has @@ -3311,7 +5134,7 @@ declare module _ { * @see _.isEmpty **/ isEmpty(value: string): boolean; - + /** * @see _.isEmpty **/ @@ -3472,44 +5295,44 @@ declare module _ { * @param thisArg The this binding of callback. * @return The destination object. **/ - merge( - object: T, - s1: S1, + merge( + object: T, + s1: S1, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.merge **/ - merge( - object: T, - s1: S1, - s2: S2, + merge( + object: T, + s1: S1, + s2: S2, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.merge **/ - merge( - object: T, - s1: S1, - s2: S2, - s3: S3, + merge( + object: T, + s1: S1, + s2: S2, + s3: S3, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.merge **/ - merge( - object: T, - s1: S1, - s2: S2, - s3: S3, - s4: S4, + merge( + object: T, + s1: S1, + s2: S2, + s3: S3, + s4: S4, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; } //_.omit @@ -3524,7 +5347,7 @@ declare module _ { * @param keys The properties to omit. * @return An object without the omitted properties. **/ - omit( + omit( object: T, ...keys: string[]): Omitted; @@ -3567,7 +5390,7 @@ declare module _ { * @param keys Property names to pick * @return An object composed of the picked properties. **/ - pick( + pick( object: T, ...keys: string[]): Picked; @@ -3602,7 +5425,7 @@ declare module _ { * @return The accumulated value. **/ transform( - collection: Collection, + collection: Array, callback: MemoVoidIterator, accumulator: Acc, thisArg?: any): Acc; @@ -3611,7 +5434,41 @@ declare module _ { * @see _.transform **/ transform( - collection: Collection, + collection: List, + callback: MemoVoidIterator, + accumulator: Acc, + thisArg?: any): Acc; + + /** + * @see _.transform + **/ + transform( + collection: Dictionary, + callback: MemoVoidIterator, + accumulator: Acc, + thisArg?: any): Acc; + + /** + * @see _.transform + **/ + transform( + collection: Array, + callback?: MemoVoidIterator, + thisArg?: any): Acc; + + /** + * @see _.transform + **/ + transform( + collection: List, + callback?: MemoVoidIterator, + thisArg?: any): Acc; + + /** + * @see _.transform + **/ + transform( + collection: Dictionary, callback?: MemoVoidIterator, thisArg?: any): Acc; } @@ -3693,7 +5550,7 @@ declare module _ { * @return A random number. **/ random(max: number, floating?: boolean): number; - + /** * @see _.random * @param min The minimum possible value. @@ -3752,13 +5609,13 @@ declare module _ { **/ template( text: string): TemplateExecutor; - + /** * @see _.template **/ template( text: string, - data: any, + data: any, options?: TemplateSettings, sourceURL?: string, variable?: string): any /* string or TemplateExecutor*/; @@ -3768,7 +5625,7 @@ declare module _ { (...data: any[]): string; source: string; } - + //_.times interface LoDashStatic { /** @@ -3779,8 +5636,8 @@ declare module _ { * @param thisArg The this binding of callback. **/ times( - n: number, - callback: (num: number) => TResult, + n: number, + callback: (num: number) => TResult, context?: any): TResult[]; } @@ -3820,24 +5677,24 @@ declare module _ { interface MemoIterator { (prev: TResult, curr: T, indexOrKey: any, list?: T[]): TResult; } - /* + /* interface MemoListIterator { (prev: TResult, curr: T, index: number, list?: T[]): TResult; } interface MemoObjectIterator { (prev: TResult, curr: T, index: string, object?: Dictionary): TResult; } - */ + */ - interface Collection { } + //interface Collection {} // Common interface between Arrays and jQuery objects - interface List extends Collection { + interface List { [index: number]: T; length: number; } - interface Dictionary extends Collection { + interface Dictionary { [index: string]: T; } } From d9539f82c479ecb68987724159a8332ae7ce3a2b Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Tue, 15 Apr 2014 15:12:23 -0400 Subject: [PATCH 2/3] Reduce text differences with the old version (Visual Studio being mean!) --- lodash/lodash-tests.disabled.ts | 588 ++++++++++++++++---------------- lodash/lodash.d.ts | 14 +- 2 files changed, 301 insertions(+), 301 deletions(-) diff --git a/lodash/lodash-tests.disabled.ts b/lodash/lodash-tests.disabled.ts index 97c2709405..de96b3d978 100644 --- a/lodash/lodash-tests.disabled.ts +++ b/lodash/lodash-tests.disabled.ts @@ -41,16 +41,16 @@ interface IKey { var foodsOrganic: IFoodOrganic[] = [ { name: 'banana', organic: true }, - { name: 'beet', organic: false }, + { name: 'beet', organic: false }, ]; var foodsType: IFoodType[] = [ - { name: 'apple', type: 'fruit' }, + { name: 'apple', type: 'fruit' }, { name: 'banana', type: 'fruit' }, - { name: 'beet', type: 'vegetable' } + { name: 'beet', type: 'vegetable' } ]; var foodsCombined: IFoodCombined[] = [ - { 'name': 'apple', 'organic': false, 'type': 'fruit' }, - { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } + { 'name': 'apple', 'organic': false, 'type': 'fruit' }, + { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } ]; var stoogesQuotes: IStoogesQuote[] = [ @@ -63,24 +63,24 @@ var stoogesAges: IStoogesAge[] = [ ]; var stoogesCombined: IStoogesCombined[] = [ - { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, - { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } + { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, + { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } ]; var keys: IKey[] = [ - { 'dir': 'left', 'code': 97 }, - { 'dir': 'right', 'code': 100 } + { 'dir': 'left', 'code': 97 }, + { 'dir': 'right', 'code': 100 } ]; class Dog { - constructor(public name: string) { } + constructor(public name: string) {} public bark() { - console.log('Woof, woof!'); + console.log('Woof, woof!'); } } -var result: any; +var result : any; /************* * Chaining * @@ -119,14 +119,14 @@ result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1); result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1, 2, 5, 6); result = <_.LoDashWrapper>_([1, 2, 3, 4]).unshift(5, 6); -result = _.tap([1, 2, 3, 4], function (array) { console.log(array); }); -result = <_.LoDashWrapper>_('test').tap(function (value) { console.log(value); }); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).tap(function (array) { console.log(array); }); +result = _.tap([1, 2, 3, 4], function(array) { console.log(array); }); +result = <_.LoDashWrapper>_('test').tap(function(value) { console.log(value); }); +result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).tap(function(array) { console.log(array); }); result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).tap(function (array) { console.log(array); }); result = _('test').toString(); result = _([1, 2, 3]).toString(); -result = _({ 'key1': 'test1', 'key2': 'test2' }).toString(); +result = _({'key1': 'test1', 'key2': 'test2'}).toString(); result = _('test').valueOf(); result = _([1, 2, 3]).valueOf(); @@ -140,10 +140,10 @@ result = <_.Dictionary>_(<{ [index: string]: string; }>{ 'key1': 'test1' // * Arrays * // *************/ result = _.compact([0, 1, false, 2, '', 3]); -result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); + result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); result = _.difference([1, 2, 3, 4, 5], [5, 2, 10]); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).difference([5, 2, 10]); + result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).difference([5, 2, 10]); result = _.rest([1, 2, 3]); result = _.rest([1, 2, 3], 2); @@ -163,48 +163,48 @@ result = _.tail([1, 2, 3], (num) => num < 3) result = _.tail(foodsOrganic, 'test') result = _.tail(foodsType, { 'type': 'value' }) -result = _.findIndex(['apple', 'banana', 'beet'], function (f) { - return /^b/.test(f); +result = _.findIndex(['apple', 'banana', 'beet'], function(f) { + return /^b/.test(f); }); result = _.findIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple' }); +result = _.findIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple'}); -result = _.findLastIndex(['apple', 'banana', 'beet'], function (f: string) { - return /^b/.test(f); +result = _.findLastIndex(['apple', 'banana', 'beet'], function(f: string) { + return /^b/.test(f); }); result = _.findLastIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findLastIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple' }); +result = _.findLastIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple'}); result = _.first([1, 2, 3]); result = _.first([1, 2, 3], 2); -result = _.first([1, 2, 3], function (num) { - return num < 3; +result = _.first([1, 2, 3], function(num) { + return num < 3; }); result = _.first(foodsOrganic, 'organic'); result = _.first(foodsType, { 'type': 'fruit' }); -result = _.head([1, 2, 3]); -result = _.head([1, 2, 3], 2); -result = _.head([1, 2, 3], function (num) { - return num < 3; -}); -result = _.head(foodsOrganic, 'organic'); -result = _.head(foodsType, { 'type': 'fruit' }); + result = _.head([1, 2, 3]); + result = _.head([1, 2, 3], 2); + result = _.head([1, 2, 3], function(num) { + return num < 3; + }); + result = _.head(foodsOrganic, 'organic'); + result = _.head(foodsType, { 'type': 'fruit' }); -result = _.take([1, 2, 3]); -result = _.take([1, 2, 3], 2); -result = _.take([1, 2, 3], (num) => num < 3); -result = _.take(foodsOrganic, 'organic'); -result = _.take(foodsType, { 'type': 'fruit' }); + result = _.take([1, 2, 3]); + result = _.take([1, 2, 3], 2); + result = _.take([1, 2, 3], (num) => num < 3); + result = _.take(foodsOrganic, 'organic'); + result = _.take(foodsType, { 'type': 'fruit' }); result = _.flatten([1, [2], [3, [[4]]]]); result = _.flatten([1, [2], [3, [[4]]]], true); var result: any result = _.flatten(stoogesQuotes, 'quotes'); -result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(); -result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(true); -result = <_.LoDashArrayWrapper>_(stoogesQuotes).flatten('quotes'); + result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(); + result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(true); + result = <_.LoDashArrayWrapper>_(stoogesQuotes).flatten('quotes'); result = _.indexOf([1, 2, 3, 1, 2, 3], 2); result = _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); @@ -212,8 +212,8 @@ result = _.indexOf([1, 1, 2, 2, 3, 3], 2, true); result = _.initial([1, 2, 3]); result = _.initial([1, 2, 3], 2); -result = _.initial([1, 2, 3], function (num) { - return num > 1; +result = _.initial([1, 2, 3], function(num) { + return num > 1; }); result = _.initial(foodsOrganic, 'organic'); result = _.initial(foodsType, { 'type': 'vegetable' }); @@ -222,8 +222,8 @@ result = _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); result = _.last([1, 2, 3]); result = _.last([1, 2, 3], 2); -result = _.last([1, 2, 3], function (num) { - return num > 1; +result = _.last([1, 2, 3], function(num) { + return num > 1; }); result = _.last(foodsOrganic, 'organic'); result = _.last(foodsType, { 'type': 'vegetable' }); @@ -231,8 +231,8 @@ result = _.last(foodsType, { 'type': 'vegetable' }); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); -result = <{ [key: string]: any }>_.zipObject(['moe', 'larry'], [30, 40]); -result = <{ [key: string]: any }>_.object(['moe', 'larry'], [30, 40]); +result = <{[key: string]: any}>_.zipObject(['moe', 'larry'], [30, 40]); +result = <{[key: string]: any}>_.object(['moe', 'larry'], [30, 40]); result = _.pull([1, 2, 3, 1, 2, 3], 2, 3); @@ -243,39 +243,39 @@ result = _.range(0, -10, -1); result = _.range(1, 4, 0); result = _.range(0); -result = _.remove([1, 2, 3, 4, 5, 6], function (num: number) { return num % 2 == 0; }); +result = _.remove([1, 2, 3, 4, 5, 6], function(num: number) { return num % 2 == 0; }); result = _.remove(foodsOrganic, 'organic'); -result = _.remove(foodsType, { 'type': 'vegetable' }); +result = _.remove(foodsType, { 'type': 'vegetable'}); result = _.sortedIndex([20, 30, 50], 40); result = _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); var sortedIndexDict = { - 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } + 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } }; -result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function (word) { - return sortedIndexDict.wordToNumber[word]; +result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { + return sortedIndexDict.wordToNumber[word]; }); -result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function (word) { - return this.wordToNumber[word]; +result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { + return this.wordToNumber[word]; }, sortedIndexDict); result = _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); result = _.uniq([1, 2, 1, 3, 1]); result = _.uniq([1, 1, 2, 2, 3], true); -result = _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) { - return letter.toLowerCase(); +result = _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { + return letter.toLowerCase(); }); -result = _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math); -result = <{ x: number; }[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); +result = _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); +result = <{x: number;}[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); -result = _.unique([1, 2, 1, 3, 1]); -result = _.unique([1, 1, 2, 2, 3], true); -result = _.unique(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) { - return letter.toLowerCase(); -}); -result = _.unique([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math); -result = <{ x: number; }[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); + result = _.unique([1, 2, 1, 3, 1]); + result = _.unique([1, 1, 2, 2, 3], true); + result = _.unique(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { + return letter.toLowerCase(); + }); + result = _.unique([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); + result = <{x: number;}[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); result = _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); @@ -294,13 +294,13 @@ result = _.contains([1, 2, 3], 1, 2); result = _.contains({ 'name': 'moe', 'age': 40 }, 'moe'); result = _.contains('curly', 'ur'); -result = _.include([1, 2, 3], 1); -result = _.include([1, 2, 3], 1, 2); -result = _.include({ 'name': 'moe', 'age': 40 }, 'moe'); -result = _.include('curly', 'ur'); + result = _.include([1, 2, 3], 1); + result = _.include([1, 2, 3], 1, 2); + result = _.include({ 'name': 'moe', 'age': 40 }, 'moe'); + result = _.include('curly', 'ur'); -result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function (num) { return Math.floor(num); }); -result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function (num) { return this.floor(num); }, Math); +result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); +result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); result = <_.Dictionary>_.countBy(['one', 'two', 'three'], 'length'); result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function (num) { return Math.floor(num); }); @@ -311,55 +311,55 @@ result = _.every([true, 1, null, 'yes'], Boolean); result = _.every(stoogesAges, 'age'); result = _.every(stoogesAges, { 'age': 50 }); -result = _.all([true, 1, null, 'yes'], Boolean); -result = _.all(stoogesAges, 'age'); -result = _.all(stoogesAges, { 'age': 50 }); + result = _.all([true, 1, null, 'yes'], Boolean); + result = _.all(stoogesAges, 'age'); + result = _.all(stoogesAges, { 'age': 50 }); -result = _.filter([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); +result = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); result = _.filter(foodsCombined, 'organic'); result = _.filter(foodsCombined, { 'type': 'fruit' }); -result = _([1, 2, 3, 4, 5, 6]).filter(function (num) { return num % 2 == 0; }).value(); -result = _(foodsCombined).filter('organic').value(); -result = _(foodsCombined).filter({ 'type': 'fruit' }).value(); + result = _([1, 2, 3, 4, 5, 6]).filter(function(num) { return num % 2 == 0; }).value(); + result = _(foodsCombined).filter('organic').value(); + result = _(foodsCombined).filter({ 'type': 'fruit' }).value(); -result = _.select([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); -result = _.select(foodsCombined, 'organic'); -result = _.select(foodsCombined, { 'type': 'fruit' }); + result = _.select([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); + result = _.select(foodsCombined, 'organic'); + result = _.select(foodsCombined, { 'type': 'fruit' }); -result = _([1, 2, 3, 4, 5, 6]).select(function (num) { return num % 2 == 0; }).value(); -result = _(foodsCombined).select('organic').value(); -result = _(foodsCombined).select({ 'type': 'fruit' }).value(); + result = _([1, 2, 3, 4, 5, 6]).select(function(num) { return num % 2 == 0; }).value(); + result = _(foodsCombined).select('organic').value(); + result = _(foodsCombined).select({ 'type': 'fruit' }).value(); -result = _.find([1, 2, 3, 4], function (num) { - return num % 2 == 0; +result = _.find([1, 2, 3, 4], function(num) { + return num % 2 == 0; }); result = _.find(foodsCombined, { 'type': 'vegetable' }); result = _.find(foodsCombined, 'organic'); -result = _.detect([1, 2, 3, 4], function (num) { - return num % 2 == 0; -}); -result = _.detect(foodsCombined, { 'type': 'vegetable' }); -result = _.detect(foodsCombined, 'organic'); + result = _.detect([1, 2, 3, 4], function(num) { + return num % 2 == 0; + }); + result = _.detect(foodsCombined, { 'type': 'vegetable' }); + result = _.detect(foodsCombined, 'organic'); -result = _.findWhere([1, 2, 3, 4], function (num) { - return num % 2 == 0; -}); -result = _.findWhere(foodsCombined, { 'type': 'vegetable' }); -result = _.findWhere(foodsCombined, 'organic'); + result = _.findWhere([1, 2, 3, 4], function(num) { + return num % 2 == 0; + }); + result = _.findWhere(foodsCombined, { 'type': 'vegetable' }); + result = _.findWhere(foodsCombined, 'organic'); -result = _.findLast([1, 2, 3, 4], function (num) { - return num % 2 == 0; +result = _.findLast([1, 2, 3, 4], function(num) { + return num % 2 == 0; }); result = _.findLast(foodsCombined, { 'type': 'vegetable' }); result = _.findLast(foodsCombined, 'organic'); -result = _.forEach([1, 2, 3], function (num) { console.log(num); }); -result = <_.Dictionary>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); +result = _.forEach([1, 2, 3], function(num) { console.log(num); }); +result = <_.Dictionary>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); -result = _.each([1, 2, 3], function (num) { console.log(num); }); -result = <_.Dictionary>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); + result = _.each([1, 2, 3], function(num) { console.log(num); }); + result = <_.Dictionary>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEach(function (num) { console.log(num); }); result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEach(function (num) { console.log(num); }); @@ -367,11 +367,11 @@ result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: numb result = <_.LoDashArrayWrapper>_([1, 2, 3]).each(function (num) { console.log(num); }); result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).each(function (num) { console.log(num); }); -result = _.forEachRight([1, 2, 3], function (num) { console.log(num); }); -result = <_.Dictionary>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); +result = _.forEachRight([1, 2, 3], function(num) { console.log(num); }); +result = <_.Dictionary>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); -result = _.eachRight([1, 2, 3], function (num) { console.log(num); }); -result = <_.Dictionary>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); + result = _.eachRight([1, 2, 3], function(num) { console.log(num); }); + result = <_.Dictionary>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEachRight(function (num) { console.log(num); }); result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function (num) { console.log(num); }); @@ -379,80 +379,80 @@ result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: numb result = <_.LoDashArrayWrapper>_([1, 2, 3]).eachRight(function (num) { console.log(num); }); result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function (num) { console.log(num); }); -result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function (num) { return Math.floor(num); }); -result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function (num) { return this.floor(num); }, Math); +result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); +result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); result = <_.Dictionary>_.groupBy(['one', 'two', 'three'], 'length'); -result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return Math.floor(num); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return this.floor(num); }, Math); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).groupBy('length'); + result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function(num) { return Math.floor(num); }); + result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function(num) { return this.floor(num); }, Math); + result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).groupBy('length'); result = <_.Dictionary>_.indexBy(keys, 'dir'); -result = <_.Dictionary>_.indexBy(keys, function (key) { return String.fromCharCode(key.code); }); -result = <_.Dictionary>_.indexBy(keys, function (key) { this.fromCharCode(key.code); }, String); +result = <_.Dictionary>_.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); +result = <_.Dictionary>_.indexBy(keys, function(key) { this.fromCharCode(key.code); }, String); result = _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); result = _.invoke([123, 456], String.prototype.split, ''); -result = _.map([1, 2, 3], function (num) { return num * 3; }); -result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { return num * 3; }); +result = _.map([1, 2, 3], function(num) { return num * 3; }); +result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); result = _.map(stoogesAges, 'name'); -result = _([1, 2, 3]).map(function (num) { return num * 3; }).value(); -result = _({ 'one': 1, 'two': 2, 'three': 3 }).map(function (num) { return num * 3; }).value(); -result = _(stoogesAges).map('name').value(); + result = _([1, 2, 3]).map(function(num) { return num * 3; }).value(); + result = _({ 'one': 1, 'two': 2, 'three': 3 }).map(function(num) { return num * 3; }).value(); + result = _(stoogesAges).map('name').value(); -result = _.collect([1, 2, 3], function (num) { return num * 3; }); -result = _.collect({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { return num * 3; }); +result = _.collect([1, 2, 3], function(num) { return num * 3; }); +result = _.collect({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); result = _.collect(stoogesAges, 'name'); -result = _([1, 2, 3]).collect(function (num) { return num * 3; }).value(); -result = _({ 'one': 1, 'two': 2, 'three': 3 }).collect(function (num) { return num * 3; }).value(); -result = _(stoogesAges).collect('name').value(); + result = _([1, 2, 3]).collect(function(num) { return num * 3; }).value(); + result = _({ 'one': 1, 'two': 2, 'three': 3 }).collect(function(num) { return num * 3; }).value(); + result = _(stoogesAges).collect('name').value(); result = _.max([4, 2, 8, 6]); -result = _.max(stoogesAges, function (stooge) { return stooge.age; }); +result = _.max(stoogesAges, function(stooge) { return stooge.age; }); result = _.max(stoogesAges, 'age'); result = _.min([4, 2, 8, 6]); -result = _.min(stoogesAges, function (stooge) { return stooge.age; }); +result = _.min(stoogesAges, function(stooge) { return stooge.age; }); result = _.min(stoogesAges, 'age'); result = _.pluck(stoogesAges, 'name'); -result = _.reduce([1, 2, 3], function (sum: number, num: number) { - return sum + num; +result = _.reduce([1, 2, 3], function(sum: number, num: number) { + return sum + num; }); interface ABC { - a: number; - b: number; - c: number; + a: number; + b: number; + c: number; } -result = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num, key) { - r[key] = num * 3; - return r; +result = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { + r[key] = num * 3; + return r; }, {}); -result = _.foldl([1, 2, 3], function (sum, num) { - return sum + num; +result = _.foldl([1, 2, 3], function(sum, num) { + return sum + num; }); -result = _.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num, key) { - r[key] = num * 3; - return r; +result = _.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { + r[key] = num * 3; + return r; }, {}); -result = _.inject([1, 2, 3], function (sum, num) { - return sum + num; +result = _.inject([1, 2, 3], function(sum, num) { + return sum + num; }); -result = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num, key) { - r[key] = num * 3; - return r; +result = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { + r[key] = num * 3; + return r; }, {}); -result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); -result = _.foldr([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); +result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); +result = _.foldr([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); -result = _.reject([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); +result = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); result = _.reject(foodsCombined, 'organic'); result = _.reject(foodsCombined, { 'type': 'fruit' }); @@ -473,11 +473,11 @@ result = _.any([null, 0, 'yes', false], Boolean); result = _.any(foodsCombined, 'organic'); result = _.any(foodsCombined, { 'type': 'meat' }); -result = _.sortBy([1, 2, 3], function (num) { return Math.sin(num); }); -result = _.sortBy([1, 2, 3], function (num) { return this.sin(num); }, Math); +result = _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); +result = _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); result = _.sortBy(['banana', 'strawberry', 'apple'], 'length'); -(function (a: number, b: number, c: number, d: number) { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); +(function(a: number, b: number, c: number, d: number){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); result = _.where(stoogesCombined, { 'age': 40 }); result = _.where(stoogesCombined, { 'quotes': ['Poifect!'] }); @@ -489,20 +489,20 @@ var saves = ['profile', 'settings']; var asyncSave = (obj: any) => obj.done(); var done: Function; -done = _.after(saves.length, function () { - console.log('Done saving!'); +done = _.after(saves.length, function() { + console.log('Done saving!'); }); -_.forEach(saves, function (type) { - asyncSave({ 'type': type, 'complete': done }); +_.forEach(saves, function(type) { + asyncSave({ 'type': type, 'complete': done }); }); -done = _(saves.length).after(function () { - console.log('Done saving!'); +done = _(saves.length).after(function() { + console.log('Done saving!'); }).value(); -_.forEach(saves, function (type) { - asyncSave({ 'type': type, 'complete': done }); +_.forEach(saves, function(type) { + asyncSave({ 'type': type, 'complete': done }); }); var funcBind = function (greeting: string) { return greeting + ' ' + this.name }; @@ -513,8 +513,8 @@ var funcBind3: () => any = _(funcBind).bind({ 'name': 'moe' }, 'hi').value(); funcBind3(); var view = { - 'label': 'docs', - 'onClick': function () { console.log('clicked ' + this.label); } + 'label': 'docs', + 'onClick': function() { console.log('clicked ' + this.label); } }; view = _.bindAll(view); @@ -524,17 +524,17 @@ view = _(view).bindAll().value(); jQuery('#docs').on('click', view.onClick); var objectBindKey = { - 'name': 'moe', - 'greet': function (greeting: string) { - return greeting + ' ' + this.name; - } + 'name': 'moe', + 'greet': function(greeting: string) { + return greeting + ' ' + this.name; + } }; var funcBindKey: Function = _.bindKey(objectBindKey, 'greet', 'hi'); funcBindKey(); -objectBindKey.greet = function (greeting) { - return greeting + ', ' + this.name + '!'; +objectBindKey.greet = function(greeting) { + return greeting + ', ' + this.name + '!'; }; funcBindKey(); @@ -543,16 +543,16 @@ funcBindKey = _(objectBindKey).bindKey('greet', 'hi').value(); funcBindKey(); var realNameMap = { - 'curly': 'jerome' + 'curly': 'jerome' }; -var format = function (name: string) { - name = realNameMap[name.toLowerCase()] || name; - return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); +var format = function(name: string) { + name = realNameMap[name.toLowerCase()] || name; + return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); }; -var greet = function (formatted: string) { - return 'Hiya ' + formatted + '!'; +var greet = function(formatted: string) { + return 'Hiya ' + formatted + '!'; }; result = _.compose(greet, format); @@ -564,57 +564,57 @@ result = <() => boolean>_.createCallback(createCallbackObj); result = <_.LoDashObjectWrapper<() => any>>_('name').createCallback(); result = <_.LoDashObjectWrapper<() => boolean>>_(createCallbackObj).createCallback(); -result = _.curry(function (a, b, c) { - console.log(a + b + c); +result = _.curry(function(a, b, c) { + console.log(a + b + c); }); -result = <_.LoDashObjectWrapper>_(function (a, b, c) { - console.log(a + b + c); +result = <_.LoDashObjectWrapper>_(function(a, b, c) { + console.log(a + b + c); }).curry(); declare var source: any; -result = _.debounce(function () { }, 150); +result = _.debounce(function() {}, 150); -jQuery('#postbox').on('click', _.debounce(function () { }, 300, { - 'leading': true, - 'trailing': false +jQuery('#postbox').on('click', _.debounce(function() {}, 300, { + 'leading': true, + 'trailing': false })); -source.addEventListener('message', _.debounce(function () { }, 250, { - 'maxWait': 1000 +source.addEventListener('message', _.debounce(function() {}, 250, { + 'maxWait': 1000 }), false); -result = <_.LoDashObjectWrapper>_(function () { }).debounce(150); +result = <_.LoDashObjectWrapper>_(function() {}).debounce(150); -jQuery('#postbox').on('click', <_.LoDashObjectWrapper>_(function () { }).debounce(300, { - 'leading': true, - 'trailing': false +jQuery('#postbox').on('click', <_.LoDashObjectWrapper>_(function() {}).debounce(300, { + 'leading': true, + 'trailing': false })); -source.addEventListener('message', <_.LoDashObjectWrapper>_(function () { }).debounce(250, { - 'maxWait': 1000 +source.addEventListener('message', <_.LoDashObjectWrapper>_(function() {}).debounce(250, { + 'maxWait': 1000 }), false); var returnedDebounce = _.throttle(function (a) { return a * 5; }, 5); returnedThrottled(4); -result = _.defer(function () { console.log('deferred'); }); -result = <_.LoDashWrapper>_(function () { console.log('deferred'); }).defer(); +result = _.defer(function() { console.log('deferred'); }); +result = <_.LoDashWrapper>_(function() { console.log('deferred'); }).defer(); var log = _.bind(console.log, console); result = _.delay(log, 1000, 'logged later'); result = <_.LoDashWrapper>_(log).delay(1000, 'logged later'); -var fibonacci = _.memoize(function (n) { - return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); +var fibonacci = _.memoize(function(n) { + return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); }); var data = { - 'moe': { 'name': 'moe', 'age': 40 }, - 'curly': { 'name': 'curly', 'age': 60 } + 'moe': { 'name': 'moe', 'age': 40 }, + 'curly': { 'name': 'curly', 'age': 60 } }; -var stooge = _.memoize(function (name: string) { return data[name]; }, _.identity); +var stooge = _.memoize(function(name: string) { return data[name]; }, _.identity); stooge('curly'); stooge['cache']['curly'].name = 'jerome'; @@ -623,21 +623,21 @@ stooge('curly'); var returnedMemoize = _.throttle(function (a) { return a * 5; }, 5); returnedMemoize(4); -var initialize = _.once(function () { }); +var initialize = _.once(function(){ }); initialize(); initialize();'' var returnedOnce = _.throttle(function (a) { return a * 5; }, 5); returnedOnce(4); -var greetPartial = function (greeting: string, name: string) { return greeting + ' ' + name; }; +var greetPartial = function(greeting: string, name: string) { return greeting + ' ' + name; }; var hi = _.partial(greetPartial, 'hi'); hi('moe'); var defaultsDeep = _.partialRight(_.merge, _.defaults); var optionsPartialRight = { - 'variable': 'data', - 'imports': { 'jq': $ } + 'variable': 'data', + 'imports': { 'jq': $ } }; defaultsDeep(optionsPartialRight, _.templateSettings); @@ -645,16 +645,16 @@ defaultsDeep(optionsPartialRight, _.templateSettings); var throttled = _.throttle(function () { }, 100); jQuery(window).on('scroll', throttled); -jQuery('.interactive').on('click', _.throttle(function () { }, 300000, { - 'trailing': false +jQuery('.interactive').on('click', _.throttle(function() { }, 300000, { + 'trailing': false })); -var returnedThrottled = _.throttle(function (a) { return a * 5; }, 5); +var returnedThrottled = _.throttle(function (a) { return a*5; }, 5); returnedThrottled(4); -var helloWrap = function (name: string) { return 'hello ' + name; }; -var helloWrap2 = _.wrap(helloWrap, function (func) { - return 'before, ' + func('moe') + ', after'; +var helloWrap = function(name: string) { return 'hello ' + name; }; +var helloWrap2 = _.wrap(helloWrap, function(func) { + return 'before, ' + func('moe') + ', after'; }); helloWrap2(); @@ -662,93 +662,93 @@ helloWrap2(); * Objects * ***********/ interface NameAge { - name: string; - age: number; + name: string; + age: number; } result = _.assign({ 'name': 'moe' }, { 'age': 40 }); -result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function (a, b) { - return typeof a == 'undefined' ? b : a; +result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { + return typeof a == 'undefined' ? b : a; }); result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }, function (a, b) { - return typeof a == 'undefined' ? b : a; +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a, b) { + return typeof a == 'undefined' ? b : a; }); result = _.extend({ 'name': 'moe' }, { 'age': 40 }); -result = _.extend({ 'name': 'moe' }, { 'age': 40 }, function (a, b) { - return typeof a == 'undefined' ? b : a; +result = _.extend({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { + return typeof a == 'undefined' ? b : a; }); result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }, function (a, b) { - return typeof a == 'undefined' ? b : a; +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a, b) { + return typeof a == 'undefined' ? b : a; }); result = _.clone(stoogesAges); result = _.clone(stoogesAges, true); -result = _.clone(stoogesAges, true, function (value) { - return _.isElement(value) ? value.cloneNode(false) : undefined; +result = _.clone(stoogesAges, true, function(value) { + return _.isElement(value) ? value.cloneNode(false) : undefined; }); result = _.cloneDeep(stoogesAges); -result = _.cloneDeep(stoogesAges, function (value) { - return _.isElement(value) ? value.cloneNode(false) : undefined; +result = _.cloneDeep(stoogesAges, function(value) { + return _.isElement(value) ? value.cloneNode(false) : undefined; }); interface Food { - name: string; - type: string; + name: string; + type: string; } var foodDefaults = { 'name': 'apple' }; result = _.defaults(foodDefaults, { 'name': 'banana', 'type': 'fruit' }); -result = <_.LoDashObjectWrapper>_(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' }); + result = <_.LoDashObjectWrapper>_(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' }); -result = _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) { - return num % 2 == 0; +result = _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { + return num % 2 == 0; }); -result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) { - return num % 2 == 1; +result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { + return num % 2 == 1; }); -result = _.forIn(new Dog('Dagny'), function (value, key) { - console.log(key); +result = _.forIn(new Dog('Dagny'), function(value, key) { + console.log(key); }); -result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forIn(function (value, key) { - console.log(key); +result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forIn(function(value, key) { + console.log(key); }); -result = _.forInRight(new Dog('Dagny'), function (value, key) { - console.log(key); +result = _.forInRight(new Dog('Dagny'), function(value, key) { + console.log(key); }); -result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forInRight(function (value, key) { - console.log(key); +result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forInRight(function(value, key) { + console.log(key); }); interface ZeroOne { - 0: string; - 1: string; - one: string; + 0: string; + 1: string; + one: string; } -result = _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function (num, key) { - console.log(key); +result = _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + console.log(key); }); -result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function (num, key) { - console.log(key); + result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function(num, key) { + console.log(key); + }); + +result = _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + console.log(key); }); -result = _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function (num, key) { - console.log(key); -}); - -result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function (num, key) { - console.log(key); -}); + result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function(num, key) { + console.log(key); + }); result = _.functions(_); result = _.methods(_); @@ -759,12 +759,12 @@ result = <_.LoDashArrayWrapper>_(_).methods(); result = _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); interface FirstSecond { - first: string; - second: string; + first: string; + second: string; } result = _.invert({ 'first': 'moe', 'second': 'larry' }); -(function (...args: any[]) { return _.isArguments(arguments); })(1, 2, 3); +(function(...args: any[]) { return _.isArguments(arguments); })(1, 2, 3); (function () { return _.isArray(arguments); })(); result = _.isArray([1, 2, 3]); @@ -787,12 +787,12 @@ result = _.isEqual(moe, copy); var words = ['hello', 'goodbye']; var otherWords = ['hi', 'goodbye']; -result = _.isEqual(words, otherWords, function (a, b) { - var reGreet = /^(?:hello|hi)$/i, - aGreet = _.isString(a) && reGreet.test(a), - bGreet = _.isString(b) && reGreet.test(b); +result = _.isEqual(words, otherWords, function(a, b) { + var reGreet = /^(?:hello|hi)$/i, + aGreet = _.isString(a) && reGreet.test(a), + bGreet = _.isString(b) && reGreet.test(b); - return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; + return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; }); result = _.isFinite(-101); @@ -820,7 +820,7 @@ class Stooge { constructor( public name: string, public age: number - ) { } + ) {} } result = _.isPlainObject(new Stooge('moe', 40)); @@ -836,67 +836,67 @@ result = _.isUndefined(void 0); result = _.keys({ 'one': 1, 'two': 2, 'three': 3 }); var mergeNames = { - 'stooges': [ - { 'name': 'moe' }, - { 'name': 'larry' } - ] + 'stooges': [ + { 'name': 'moe' }, + { 'name': 'larry' } + ] }; var mergeAges = { - 'stooges': [ - { 'age': 40 }, - { 'age': 50 } - ] + 'stooges': [ + { 'age': 40 }, + { 'age': 50 } + ] }; result = _.merge(mergeNames, mergeAges); var mergeFood = { - 'fruits': ['apple'], - 'vegetables': ['beet'] + 'fruits': ['apple'], + 'vegetables': ['beet'] }; var mergeOtherFood = { - 'fruits': ['banana'], - 'vegetables': ['carrot'] + 'fruits': ['banana'], + 'vegetables': ['carrot'] }; interface FruitVeg { - fruits: string[]; - vegetables: string[] + fruits: string[]; + vegetables: string[] }; -result = _.merge(mergeFood, mergeOtherFood, function (a, b) { - return _.isArray(a) ? a.concat(b) : undefined; +result = _.merge(mergeFood, mergeOtherFood, function(a, b) { + return _.isArray(a) ? a.concat(b) : undefined; }); interface HasName { - name: string; + name: string; } result = _.omit({ 'name': 'moe', 'age': 40 }, 'age'); result = _.omit({ 'name': 'moe', 'age': 40 }, ['age']); -result = _.omit({ 'name': 'moe', 'age': 40 }, function (value) { - return typeof value == 'number'; +result = _.omit({ 'name': 'moe', 'age': 40 }, function(value) { + return typeof value == 'number'; }); result = _.pairs({ 'moe': 30, 'larry': 40 }); result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name'); result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, ['name']); -result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, function (value, key) { - return key.charAt(0) != '_'; +result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { + return key.charAt(0) != '_'; }); -result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function (r, num) { - num *= num; - if (num % 2) { - return r.push(num) < 3; - } +result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(r, num) { + num *= num; + if (num % 2) { + return r.push(num) < 3; + } }); // → [1, 9, 25] -result = <{ a: number; b: number; c: number; }>_.transform({ 'a': 1, 'b': 2, 'c': 3 }, function (r, num, key) { - r[key] = num * 3; +result = <{a:number;b:number;c:number;}>_.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(r, num, key) { + r[key] = num * 3; }); result = _.values({ 'one': 1, 'two': 2, 'three': 3 }); @@ -910,9 +910,9 @@ result = _.escape('Moe, Larry & Curly'); result = <{ name: string }>_.identity({ 'name': 'moe' }); _.mixin({ - 'capitalize': function (string) { - return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); - } + 'capitalize': function(string) { + return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); + } }); var lodash = _.noConflict(); @@ -926,10 +926,10 @@ result = _.random(1.2, 5.2); result = _.random(0, 5, true); var object = { - 'cheese': 'crumpets', - 'stuff': function () { - return 'nonsense'; - } + 'cheese': 'crumpets', + 'stuff': function() { + return 'nonsense'; + } }; result = _.result(object, 'cheese'); @@ -963,10 +963,10 @@ class Mage { } } -var mage = new Mage(); +var mage = new Mage(); result = _.times(3, <() => number>_.partial(_.random, 1, 6)); -result = _.times(3, function (n: number) { mage.castSpell(n); }); -result = _.times(3, function (n: number) { this.cast(n); }, mage); +result = _.times(3, function(n: number) { mage.castSpell(n); }); +result = _.times(3, function(n: number) { this.cast(n); }, mage); result = _.unescape('Moe, Larry & Curly'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 3c4b572c15..80b1940c98 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -181,15 +181,15 @@ declare module _ { **/ valueOf(): T; - /** - * @see valueOf - **/ - value(): T; - } + /** + * @see valueOf + **/ + value(): T; + } - interface LoDashWrapper extends LoDashWrapperBase> { } + interface LoDashWrapper extends LoDashWrapperBase> {} - interface LoDashObjectWrapper extends LoDashWrapperBase> { } + interface LoDashObjectWrapper extends LoDashWrapperBase> {} interface LoDashArrayWrapper extends LoDashWrapperBase> { concat(...items: T[]): LoDashArrayWrapper; From 657277a43c05d721641f880b646354eb452394c5 Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Sun, 4 May 2014 20:16:10 -0400 Subject: [PATCH 3/3] Renamed tests file. Fixed remaining tests. --- ...dash-tests.disabled.ts => lodash-tests.ts} | 1963 ++- lodash/lodash.d.ts | 11432 ++++++++-------- 2 files changed, 6697 insertions(+), 6698 deletions(-) rename lodash/{lodash-tests.disabled.ts => lodash-tests.ts} (56%) diff --git a/lodash/lodash-tests.disabled.ts b/lodash/lodash-tests.ts similarity index 56% rename from lodash/lodash-tests.disabled.ts rename to lodash/lodash-tests.ts index de96b3d978..953d32d379 100644 --- a/lodash/lodash-tests.disabled.ts +++ b/lodash/lodash-tests.ts @@ -1,982 +1,981 @@ -/// - -declare var $: any, jQuery: any; - -interface IFoodOrganic { - name: string; - organic: boolean; -} - -interface IFoodType { - name: string; - type: string; -} - -interface IFoodCombined { - name: string; - organic: boolean; - type: string; -} - -interface IStoogesQuote { - name: string; - quotes: string[]; -} - -interface IStoogesAge { - name: string; - age: number; -} - -interface IStoogesCombined { - name: string; - age: number; - quotes: string[]; -} - -interface IKey { - dir: string; - code: number; -} - -var foodsOrganic: IFoodOrganic[] = [ - { name: 'banana', organic: true }, - { name: 'beet', organic: false }, -]; -var foodsType: IFoodType[] = [ - { name: 'apple', type: 'fruit' }, - { name: 'banana', type: 'fruit' }, - { name: 'beet', type: 'vegetable' } -]; -var foodsCombined: IFoodCombined[] = [ - { 'name': 'apple', 'organic': false, 'type': 'fruit' }, - { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } -]; - -var stoogesQuotes: IStoogesQuote[] = [ - { 'name': 'curly', 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, - { 'name': 'moe', 'quotes': ['Spread out!', 'You knucklehead!'] } -]; -var stoogesAges: IStoogesAge[] = [ - { 'name': 'moe', 'age': 40 }, - { 'name': 'larry', 'age': 50 } -]; - -var stoogesCombined: IStoogesCombined[] = [ - { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, - { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } -]; - -var keys: IKey[] = [ - { 'dir': 'left', 'code': 97 }, - { 'dir': 'right', 'code': 100 } -]; - -class Dog { - constructor(public name: string) {} - - public bark() { - console.log('Woof, woof!'); - } -} - -var result : any; - -/************* - * Chaining * - *************/ -result = <_.LoDashWrapper>_('test'); -result = <_.LoDashWrapper>_(1); -result = <_.LoDashWrapper>_(true); -result = <_.LoDashArrayWrapper>_(['test1', 'test2']); -// Appears to be a change in the compiler, if the type explicity implements the object indexer. -// Looking at: https://typescript.codeplex.com/wikipage?title=Known%20breaking%20changes%20between%200.8%20and%200.9&referringTitle=Documentation -// "The ‘noimplicitany’ option now warns on the use of the hidden default indexer" -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }); - -result = <_.LoDashWrapper>_.chain('test'); -result = <_.LoDashWrapper>_('test').chain(); -result = <_.LoDashWrapper>_.chain(1); -result = <_.LoDashWrapper>_(1).chain(); -result = <_.LoDashWrapper>_.chain(true); -result = <_.LoDashWrapper>_(true).chain(); -result = <_.LoDashArrayWrapper>_.chain(['test1', 'test2']); -result = <_.LoDashArrayWrapper>_(['test1', 'test2']).chain(); -result = <_.LoDashObjectWrapper<_.Dictionary>>_.chain(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).chain(); - -//Wrapped array shortcut methods -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).concat(5, 6); -result = <_.LoDashWrapper>_([1, 2, 3, 4]).join(','); -result = <_.LoDashWrapper>_([1, 2, 3, 4]).pop(); -_([1, 2, 3, 4]).push(5, 6, 7); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).reverse(); -result = <_.LoDashWrapper>_([1, 2, 3, 4]).shift(); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).slice(1, 2); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).slice(2); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).sort((a, b) => 1); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1, 2, 5, 6); -result = <_.LoDashWrapper>_([1, 2, 3, 4]).unshift(5, 6); - -result = _.tap([1, 2, 3, 4], function(array) { console.log(array); }); -result = <_.LoDashWrapper>_('test').tap(function(value) { console.log(value); }); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).tap(function(array) { console.log(array); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).tap(function (array) { console.log(array); }); - -result = _('test').toString(); -result = _([1, 2, 3]).toString(); -result = _({'key1': 'test1', 'key2': 'test2'}).toString(); - -result = _('test').valueOf(); -result = _([1, 2, 3]).valueOf(); -result = <_.Dictionary>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).valueOf(); - -result = _('test').value(); -result = _([1, 2, 3]).value(); -result = <_.Dictionary>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).value(); - -// /************* -// * Arrays * -// *************/ -result = _.compact([0, 1, false, 2, '', 3]); - result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); - -result = _.difference([1, 2, 3, 4, 5], [5, 2, 10]); - result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).difference([5, 2, 10]); - -result = _.rest([1, 2, 3]); -result = _.rest([1, 2, 3], 2); -result = _.rest([1, 2, 3], (num) => num < 3) -result = _.rest(foodsOrganic, 'test'); -result = _.rest(foodsType, { 'type': 'value' }); - -result = _.drop([1, 2, 3]); -result = _.drop([1, 2, 3], 2); -result = _.drop([1, 2, 3], (num) => num < 3) -result = _.drop(foodsOrganic, 'test'); -result = _.drop(foodsType, { 'type': 'value' }); - -result = _.tail([1, 2, 3]) -result = _.tail([1, 2, 3], 2) -result = _.tail([1, 2, 3], (num) => num < 3) -result = _.tail(foodsOrganic, 'test') -result = _.tail(foodsType, { 'type': 'value' }) - -result = _.findIndex(['apple', 'banana', 'beet'], function(f) { - return /^b/.test(f); -}); -result = _.findIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple'}); - -result = _.findLastIndex(['apple', 'banana', 'beet'], function(f: string) { - return /^b/.test(f); -}); -result = _.findLastIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findLastIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple'}); - -result = _.first([1, 2, 3]); -result = _.first([1, 2, 3], 2); -result = _.first([1, 2, 3], function(num) { - return num < 3; -}); -result = _.first(foodsOrganic, 'organic'); -result = _.first(foodsType, { 'type': 'fruit' }); - - result = _.head([1, 2, 3]); - result = _.head([1, 2, 3], 2); - result = _.head([1, 2, 3], function(num) { - return num < 3; - }); - result = _.head(foodsOrganic, 'organic'); - result = _.head(foodsType, { 'type': 'fruit' }); - - result = _.take([1, 2, 3]); - result = _.take([1, 2, 3], 2); - result = _.take([1, 2, 3], (num) => num < 3); - result = _.take(foodsOrganic, 'organic'); - result = _.take(foodsType, { 'type': 'fruit' }); - -result = _.flatten([1, [2], [3, [[4]]]]); -result = _.flatten([1, [2], [3, [[4]]]], true); -var result: any -result = _.flatten(stoogesQuotes, 'quotes'); - - result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(); - result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(true); - result = <_.LoDashArrayWrapper>_(stoogesQuotes).flatten('quotes'); - -result = _.indexOf([1, 2, 3, 1, 2, 3], 2); -result = _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); -result = _.indexOf([1, 1, 2, 2, 3, 3], 2, true); - -result = _.initial([1, 2, 3]); -result = _.initial([1, 2, 3], 2); -result = _.initial([1, 2, 3], function(num) { - return num > 1; -}); -result = _.initial(foodsOrganic, 'organic'); -result = _.initial(foodsType, { 'type': 'vegetable' }); - -result = _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); - -result = _.last([1, 2, 3]); -result = _.last([1, 2, 3], 2); -result = _.last([1, 2, 3], function(num) { - return num > 1; -}); -result = _.last(foodsOrganic, 'organic'); -result = _.last(foodsType, { 'type': 'vegetable' }); - -result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); -result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); - -result = <{[key: string]: any}>_.zipObject(['moe', 'larry'], [30, 40]); -result = <{[key: string]: any}>_.object(['moe', 'larry'], [30, 40]); - -result = _.pull([1, 2, 3, 1, 2, 3], 2, 3); - -result = _.range(10); -result = _.range(1, 11); -result = _.range(0, 30, 5); -result = _.range(0, -10, -1); -result = _.range(1, 4, 0); -result = _.range(0); - -result = _.remove([1, 2, 3, 4, 5, 6], function(num: number) { return num % 2 == 0; }); -result = _.remove(foodsOrganic, 'organic'); -result = _.remove(foodsType, { 'type': 'vegetable'}); - -result = _.sortedIndex([20, 30, 50], 40); -result = _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); -var sortedIndexDict = { - 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } -}; -result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - return sortedIndexDict.wordToNumber[word]; -}); -result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - return this.wordToNumber[word]; -}, sortedIndexDict); - -result = _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); - -result = _.uniq([1, 2, 1, 3, 1]); -result = _.uniq([1, 1, 2, 2, 3], true); -result = _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { - return letter.toLowerCase(); -}); -result = _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); -result = <{x: number;}[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - - result = _.unique([1, 2, 1, 3, 1]); - result = _.unique([1, 1, 2, 2, 3], true); - result = _.unique(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { - return letter.toLowerCase(); - }); - result = _.unique([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); - result = <{x: number;}[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - -result = _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); - -result = _.zip(['moe', 'larry'], [30, 40], [true, false]); -result = _.unzip(['moe', 'larry'], [30, 40], [true, false]); - -// /* ************* -// * Collections * -// ************* */ - -result = _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]); -result = _.at(['moe', 'larry', 'curly'], 0, 2); - -result = _.contains([1, 2, 3], 1); -result = _.contains([1, 2, 3], 1, 2); -result = _.contains({ 'name': 'moe', 'age': 40 }, 'moe'); -result = _.contains('curly', 'ur'); - - result = _.include([1, 2, 3], 1); - result = _.include([1, 2, 3], 1, 2); - result = _.include({ 'name': 'moe', 'age': 40 }, 'moe'); - result = _.include('curly', 'ur'); - -result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); -result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); -result = <_.Dictionary>_.countBy(['one', 'two', 'three'], 'length'); - -result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function (num) { return Math.floor(num); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function (num) { return this.floor(num); }, Math); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).countBy('length'); - -result = _.every([true, 1, null, 'yes'], Boolean); -result = _.every(stoogesAges, 'age'); -result = _.every(stoogesAges, { 'age': 50 }); - - result = _.all([true, 1, null, 'yes'], Boolean); - result = _.all(stoogesAges, 'age'); - result = _.all(stoogesAges, { 'age': 50 }); - -result = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); -result = _.filter(foodsCombined, 'organic'); -result = _.filter(foodsCombined, { 'type': 'fruit' }); - - result = _([1, 2, 3, 4, 5, 6]).filter(function(num) { return num % 2 == 0; }).value(); - result = _(foodsCombined).filter('organic').value(); - result = _(foodsCombined).filter({ 'type': 'fruit' }).value(); - - result = _.select([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); - result = _.select(foodsCombined, 'organic'); - result = _.select(foodsCombined, { 'type': 'fruit' }); - - result = _([1, 2, 3, 4, 5, 6]).select(function(num) { return num % 2 == 0; }).value(); - result = _(foodsCombined).select('organic').value(); - result = _(foodsCombined).select({ 'type': 'fruit' }).value(); - -result = _.find([1, 2, 3, 4], function(num) { - return num % 2 == 0; -}); -result = _.find(foodsCombined, { 'type': 'vegetable' }); -result = _.find(foodsCombined, 'organic'); - - result = _.detect([1, 2, 3, 4], function(num) { - return num % 2 == 0; - }); - result = _.detect(foodsCombined, { 'type': 'vegetable' }); - result = _.detect(foodsCombined, 'organic'); - - result = _.findWhere([1, 2, 3, 4], function(num) { - return num % 2 == 0; - }); - result = _.findWhere(foodsCombined, { 'type': 'vegetable' }); - result = _.findWhere(foodsCombined, 'organic'); - -result = _.findLast([1, 2, 3, 4], function(num) { - return num % 2 == 0; -}); -result = _.findLast(foodsCombined, { 'type': 'vegetable' }); -result = _.findLast(foodsCombined, 'organic'); - -result = _.forEach([1, 2, 3], function(num) { console.log(num); }); -result = <_.Dictionary>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); - - result = _.each([1, 2, 3], function(num) { console.log(num); }); - result = <_.Dictionary>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); - -result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEach(function (num) { console.log(num); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEach(function (num) { console.log(num); }); - -result = <_.LoDashArrayWrapper>_([1, 2, 3]).each(function (num) { console.log(num); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).each(function (num) { console.log(num); }); - -result = _.forEachRight([1, 2, 3], function(num) { console.log(num); }); -result = <_.Dictionary>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); - - result = _.eachRight([1, 2, 3], function(num) { console.log(num); }); - result = <_.Dictionary>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); - -result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEachRight(function (num) { console.log(num); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function (num) { console.log(num); }); - -result = <_.LoDashArrayWrapper>_([1, 2, 3]).eachRight(function (num) { console.log(num); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function (num) { console.log(num); }); - -result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); -result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); -result = <_.Dictionary>_.groupBy(['one', 'two', 'three'], 'length'); - - result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function(num) { return Math.floor(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function(num) { return this.floor(num); }, Math); - result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).groupBy('length'); - -result = <_.Dictionary>_.indexBy(keys, 'dir'); -result = <_.Dictionary>_.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); -result = <_.Dictionary>_.indexBy(keys, function(key) { this.fromCharCode(key.code); }, String); - -result = _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); -result = _.invoke([123, 456], String.prototype.split, ''); - -result = _.map([1, 2, 3], function(num) { return num * 3; }); -result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); -result = _.map(stoogesAges, 'name'); - - result = _([1, 2, 3]).map(function(num) { return num * 3; }).value(); - result = _({ 'one': 1, 'two': 2, 'three': 3 }).map(function(num) { return num * 3; }).value(); - result = _(stoogesAges).map('name').value(); - -result = _.collect([1, 2, 3], function(num) { return num * 3; }); -result = _.collect({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); -result = _.collect(stoogesAges, 'name'); - - result = _([1, 2, 3]).collect(function(num) { return num * 3; }).value(); - result = _({ 'one': 1, 'two': 2, 'three': 3 }).collect(function(num) { return num * 3; }).value(); - result = _(stoogesAges).collect('name').value(); - -result = _.max([4, 2, 8, 6]); -result = _.max(stoogesAges, function(stooge) { return stooge.age; }); -result = _.max(stoogesAges, 'age'); - -result = _.min([4, 2, 8, 6]); -result = _.min(stoogesAges, function(stooge) { return stooge.age; }); -result = _.min(stoogesAges, 'age'); - -result = _.pluck(stoogesAges, 'name'); - -result = _.reduce([1, 2, 3], function(sum: number, num: number) { - return sum + num; -}); -interface ABC { - a: number; - b: number; - c: number; -} -result = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { - r[key] = num * 3; - return r; -}, {}); - -result = _.foldl([1, 2, 3], function(sum, num) { - return sum + num; -}); -result = _.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { - r[key] = num * 3; - return r; -}, {}); - -result = _.inject([1, 2, 3], function(sum, num) { - return sum + num; -}); -result = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { - r[key] = num * 3; - return r; -}, {}); - -result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); -result = _.foldr([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); - -result = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); -result = _.reject(foodsCombined, 'organic'); -result = _.reject(foodsCombined, { 'type': 'fruit' }); - -result = _.sample([1, 2, 3, 4]); -result = _.sample([1, 2, 3, 4], 2); - -result = _.shuffle([1, 2, 3, 4, 5, 6]); - -result = _.size([1, 2]); -result = _.size({ 'one': 1, 'two': 2, 'three': 3 }); -result = _.size('curly'); - -result = _.some([null, 0, 'yes', false], Boolean); -result = _.some(foodsCombined, 'organic'); -result = _.some(foodsCombined, { 'type': 'meat' }); - -result = _.any([null, 0, 'yes', false], Boolean); -result = _.any(foodsCombined, 'organic'); -result = _.any(foodsCombined, { 'type': 'meat' }); - -result = _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); -result = _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); -result = _.sortBy(['banana', 'strawberry', 'apple'], 'length'); - -(function(a: number, b: number, c: number, d: number){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); - -result = _.where(stoogesCombined, { 'age': 40 }); -result = _.where(stoogesCombined, { 'quotes': ['Poifect!'] }); - -/************* - * Functions * - *************/ -var saves = ['profile', 'settings']; -var asyncSave = (obj: any) => obj.done(); -var done: Function; - -done = _.after(saves.length, function() { - console.log('Done saving!'); -}); - -_.forEach(saves, function(type) { - asyncSave({ 'type': type, 'complete': done }); -}); - -done = _(saves.length).after(function() { - console.log('Done saving!'); -}).value(); - -_.forEach(saves, function(type) { - asyncSave({ 'type': type, 'complete': done }); -}); - -var funcBind = function (greeting: string) { return greeting + ' ' + this.name }; -var funcBind2: () => any = _.bind(funcBind, { 'name': 'moe' }, 'hi'); -funcBind2(); - -var funcBind3: () => any = _(funcBind).bind({ 'name': 'moe' }, 'hi').value(); -funcBind3(); - -var view = { - 'label': 'docs', - 'onClick': function() { console.log('clicked ' + this.label); } -}; - -view = _.bindAll(view); -jQuery('#docs').on('click', view.onClick); - -view = _(view).bindAll().value(); -jQuery('#docs').on('click', view.onClick); - -var objectBindKey = { - 'name': 'moe', - 'greet': function(greeting: string) { - return greeting + ' ' + this.name; - } -}; - -var funcBindKey: Function = _.bindKey(objectBindKey, 'greet', 'hi'); -funcBindKey(); - -objectBindKey.greet = function(greeting) { - return greeting + ', ' + this.name + '!'; -}; - -funcBindKey(); - -funcBindKey = _(objectBindKey).bindKey('greet', 'hi').value(); -funcBindKey(); - -var realNameMap = { - 'curly': 'jerome' -}; - -var format = function(name: string) { - name = realNameMap[name.toLowerCase()] || name; - return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); -}; - -var greet = function(formatted: string) { - return 'Hiya ' + formatted + '!'; -}; - -result = _.compose(greet, format); -result = <_.LoDashObjectWrapper>_(greet).compose(format); - -var createCallbackObj: { [index: string]: string; } = { name: 'Joe' }; -result = <() => any>_.createCallback('name'); -result = <() => boolean>_.createCallback(createCallbackObj); -result = <_.LoDashObjectWrapper<() => any>>_('name').createCallback(); -result = <_.LoDashObjectWrapper<() => boolean>>_(createCallbackObj).createCallback(); - -result = _.curry(function(a, b, c) { - console.log(a + b + c); -}); - -result = <_.LoDashObjectWrapper>_(function(a, b, c) { - console.log(a + b + c); -}).curry(); - -declare var source: any; -result = _.debounce(function() {}, 150); - -jQuery('#postbox').on('click', _.debounce(function() {}, 300, { - 'leading': true, - 'trailing': false -})); - -source.addEventListener('message', _.debounce(function() {}, 250, { - 'maxWait': 1000 -}), false); - -result = <_.LoDashObjectWrapper>_(function() {}).debounce(150); - -jQuery('#postbox').on('click', <_.LoDashObjectWrapper>_(function() {}).debounce(300, { - 'leading': true, - 'trailing': false -})); - -source.addEventListener('message', <_.LoDashObjectWrapper>_(function() {}).debounce(250, { - 'maxWait': 1000 -}), false); - -var returnedDebounce = _.throttle(function (a) { return a * 5; }, 5); -returnedThrottled(4); - -result = _.defer(function() { console.log('deferred'); }); -result = <_.LoDashWrapper>_(function() { console.log('deferred'); }).defer(); - -var log = _.bind(console.log, console); -result = _.delay(log, 1000, 'logged later'); -result = <_.LoDashWrapper>_(log).delay(1000, 'logged later'); - -var fibonacci = _.memoize(function(n) { - return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); -}); - -var data = { - 'moe': { 'name': 'moe', 'age': 40 }, - 'curly': { 'name': 'curly', 'age': 60 } -}; - -var stooge = _.memoize(function(name: string) { return data[name]; }, _.identity); -stooge('curly'); - -stooge['cache']['curly'].name = 'jerome'; -stooge('curly'); - -var returnedMemoize = _.throttle(function (a) { return a * 5; }, 5); -returnedMemoize(4); - -var initialize = _.once(function(){ }); -initialize(); -initialize();'' -var returnedOnce = _.throttle(function (a) { return a * 5; }, 5); -returnedOnce(4); - -var greetPartial = function(greeting: string, name: string) { return greeting + ' ' + name; }; -var hi = _.partial(greetPartial, 'hi'); -hi('moe'); - -var defaultsDeep = _.partialRight(_.merge, _.defaults); - -var optionsPartialRight = { - 'variable': 'data', - 'imports': { 'jq': $ } -}; - -defaultsDeep(optionsPartialRight, _.templateSettings); - -var throttled = _.throttle(function () { }, 100); -jQuery(window).on('scroll', throttled); - -jQuery('.interactive').on('click', _.throttle(function() { }, 300000, { - 'trailing': false -})); - -var returnedThrottled = _.throttle(function (a) { return a*5; }, 5); -returnedThrottled(4); - -var helloWrap = function(name: string) { return 'hello ' + name; }; -var helloWrap2 = _.wrap(helloWrap, function(func) { - return 'before, ' + func('moe') + ', after'; -}); -helloWrap2(); - -/********** -* Objects * -***********/ -interface NameAge { - name: string; - age: number; -} -result = _.assign({ 'name': 'moe' }, { 'age': 40 }); -result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; -}); - -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; -}); - -result = _.extend({ 'name': 'moe' }, { 'age': 40 }); -result = _.extend({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; -}); - -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; -}); - -result = _.clone(stoogesAges); -result = _.clone(stoogesAges, true); -result = _.clone(stoogesAges, true, function(value) { - return _.isElement(value) ? value.cloneNode(false) : undefined; -}); - -result = _.cloneDeep(stoogesAges); -result = _.cloneDeep(stoogesAges, function(value) { - return _.isElement(value) ? value.cloneNode(false) : undefined; -}); - -interface Food { - name: string; - type: string; -} -var foodDefaults = { 'name': 'apple' }; -result = _.defaults(foodDefaults, { 'name': 'banana', 'type': 'fruit' }); - result = <_.LoDashObjectWrapper>_(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' }); - -result = _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { - return num % 2 == 0; -}); - -result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { - return num % 2 == 1; -}); - -result = _.forIn(new Dog('Dagny'), function(value, key) { - console.log(key); -}); - -result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forIn(function(value, key) { - console.log(key); -}); - -result = _.forInRight(new Dog('Dagny'), function(value, key) { - console.log(key); -}); - -result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forInRight(function(value, key) { - console.log(key); -}); - -interface ZeroOne { - 0: string; - 1: string; - one: string; -} - -result = _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - console.log(key); -}); - - result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function(num, key) { - console.log(key); - }); - -result = _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - console.log(key); -}); - - result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function(num, key) { - console.log(key); - }); - -result = _.functions(_); -result = _.methods(_); - -result = <_.LoDashArrayWrapper>_(_).functions(); -result = <_.LoDashArrayWrapper>_(_).methods(); - -result = _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); - -interface FirstSecond { - first: string; - second: string; -} -result = _.invert({ 'first': 'moe', 'second': 'larry' }); - -(function(...args: any[]) { return _.isArguments(arguments); })(1, 2, 3); - -(function () { return _.isArray(arguments); })(); -result = _.isArray([1, 2, 3]); - -result = _.isBoolean(null); - -result = _.isDate(new Date()); - -result = _.isElement(document.body); - -result = _.isEmpty([1, 2, 3]); -result = _.isEmpty({}); -result = _.isEmpty(''); - -var moe = { 'name': 'moe', 'age': 40 }; -var copy = { 'name': 'moe', 'age': 40 }; - -result = _.isEqual(moe, copy); - -var words = ['hello', 'goodbye']; -var otherWords = ['hi', 'goodbye']; - -result = _.isEqual(words, otherWords, function(a, b) { - var reGreet = /^(?:hello|hi)$/i, - aGreet = _.isString(a) && reGreet.test(a), - bGreet = _.isString(b) && reGreet.test(b); - - return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; -}); - -result = _.isFinite(-101); -result = _.isFinite('10'); -result = _.isFinite(true); -result = _.isFinite(''); -result = _.isFinite(Infinity); - -result = _.isFunction(_); - -result = _.isNaN(NaN); -result = _.isNaN(new Number(NaN)); -result = _.isNaN(undefined); - -result = _.isNull(null); -result = _.isNull(undefined); - -result = _.isNumber(8.4 * 5); - -result = _.isObject({}); -result = _.isObject([1, 2, 3]); -result = _.isObject(1); - -class Stooge { - constructor( - public name: string, - public age: number - ) {} -} - -result = _.isPlainObject(new Stooge('moe', 40)); -result = _.isPlainObject([1, 2, 3]); -result = _.isPlainObject({ 'name': 'moe', 'age': 40 }); - -result = _.isRegExp(/moe/); - -result = _.isString('moe'); - -result = _.isUndefined(void 0); - -result = _.keys({ 'one': 1, 'two': 2, 'three': 3 }); - -var mergeNames = { - 'stooges': [ - { 'name': 'moe' }, - { 'name': 'larry' } - ] -}; - -var mergeAges = { - 'stooges': [ - { 'age': 40 }, - { 'age': 50 } - ] -}; - -result = _.merge(mergeNames, mergeAges); - -var mergeFood = { - 'fruits': ['apple'], - 'vegetables': ['beet'] -}; - -var mergeOtherFood = { - 'fruits': ['banana'], - 'vegetables': ['carrot'] -}; - -interface FruitVeg { - fruits: string[]; - vegetables: string[] -}; - -result = _.merge(mergeFood, mergeOtherFood, function(a, b) { - return _.isArray(a) ? a.concat(b) : undefined; -}); - -interface HasName { - name: string; -} -result = _.omit({ 'name': 'moe', 'age': 40 }, 'age'); -result = _.omit({ 'name': 'moe', 'age': 40 }, ['age']); -result = _.omit({ 'name': 'moe', 'age': 40 }, function(value) { - return typeof value == 'number'; -}); - -result = _.pairs({ 'moe': 30, 'larry': 40 }); - -result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name'); -result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, ['name']); -result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { - return key.charAt(0) != '_'; -}); - -result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(r, num) { - num *= num; - if (num % 2) { - return r.push(num) < 3; - } -}); -// → [1, 9, 25] - -result = <{a:number;b:number;c:number;}>_.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(r, num, key) { - r[key] = num * 3; -}); - -result = _.values({ 'one': 1, 'two': 2, 'three': 3 }); - -/********** -* Utilities * -***********/ - -result = _.escape('Moe, Larry & Curly'); - -result = <{ name: string }>_.identity({ 'name': 'moe' }); - -_.mixin({ - 'capitalize': function(string) { - return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); - } -}); - -var lodash = _.noConflict(); - -result = _.parseInt('08'); - -result = _.random(0, 5); -result = _.random(5); -result = _.random(5, true); -result = _.random(1.2, 5.2); -result = _.random(0, 5, true); - -var object = { - 'cheese': 'crumpets', - 'stuff': function() { - return 'nonsense'; - } -}; - -result = _.result(object, 'cheese'); -result = _.result(object, 'stuff'); - -var tempObject = {}; -result = _.runInContext(tempObject); - -result = <_.TemplateExecutor>_.template('hello <%= name %>'); -result = _.template('<%- value %>', { 'value': '