From d9539f82c479ecb68987724159a8332ae7ce3a2b Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Tue, 15 Apr 2014 15:12:23 -0400 Subject: [PATCH] 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 97c270940..de96b3d97 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 3c4b572c1..80b1940c9 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;