diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 0fadd6ca0..ff41747fc 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -80,46 +80,46 @@ Dog.prototype.bark = function() { console.log('Woof, woof!'); }; -var result; +var result : any; /************* * Chaining * *************/ -result = >_('test'); -result = >_(1); -result = >_(true); -result = >_(['test1', 'test2']); -result = >>_({'key1': 'test1', 'key2': 'test2'}); +result = <_.LoDashWrapper>_('test'); +result = <_.LoDashWrapper>_(1); +result = <_.LoDashWrapper>_(true); +result = <_.LoDashArrayWrapper>_(['test1', 'test2']); +result = <_.LoDashObjectWrapper<_.Dictionary>>_({'key1': 'test1', 'key2': 'test2'}); -result = >_.chain('test'); -result = >_('test').chain(); -result = >_.chain(1); -result = >_(1).chain(); -result = >_.chain(true); -result = >_(true).chain(); -result = >_.chain(['test1', 'test2']); -result = >_(['test1', 'test2']).chain(); -result = >>_.chain({'key1': 'test1', 'key2': 'test2'}); -result = >>_({'key1': 'test1', 'key2': 'test2'}).chain(); +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({'key1': 'test1', 'key2': 'test2'}); +result = <_.LoDashObjectWrapper<_.Dictionary>>_({'key1': 'test1', 'key2': 'test2'}).chain(); //Wrapped array shortcut methods -result = >_([1, 2, 3, 4]).concat(5, 6); -result = >_([1, 2, 3, 4]).join(','); -result = >_([1, 2, 3, 4]).pop(); +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 = >_([1, 2, 3, 4]).reverse(); -result = >_([1, 2, 3, 4]).shift(); -result = >_([1, 2, 3, 4]).slice(1, 2); -result = >_([1, 2, 3, 4]).slice(2); -result = >_([1, 2, 3, 4]).sort((a, b) => 1); -result = >_([1, 2, 3, 4]).splice(1); -result = >_([1, 2, 3, 4]).splice(1, 2, 5, 6); -result = >_([1, 2, 3, 4]).unshift(5, 6); +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 = >_('test').tap(function(value) { console.log(value); }); -result = >_([1, 2, 3, 4]).tap(function(array) { console.log(array); }); -result = >>_({'key1': 'test1', 'key2': 'test2'}).tap(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 = _('test').toString(); result = _([1, 2, 3]).toString(); @@ -127,44 +127,38 @@ result = _({'key1': 'test1', 'key2': 'test2'}).toString(); result = _('test').valueOf(); result = _([1, 2, 3]).valueOf(); -result = >_({'key1': 'test1', 'key2': 'test2'}).valueOf(); +result = <_.Dictionary>_({'key1': 'test1', 'key2': 'test2'}).valueOf(); result = _('test').value(); result = _([1, 2, 3]).value(); -result = >_({'key1': 'test1', 'key2': 'test2'}).value(); +result = <_.Dictionary>_({'key1': 'test1', 'key2': 'test2'}).value(); // /************* // * Arrays * // *************/ result = _.compact([0, 1, false, 2, '', 3]); - result = >_([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 = >_([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); -result = _.rest([1, 2, 3], function(num) { - return num < 3; -}); +result = _.rest([1, 2, 3], (num) => num < 3) result = _.rest(foodsOrganic, 'test'); -result = _.rest(foodsType, { 'test': 'value' }); +result = _.rest(foodsType, { 'type': 'value' }); - result = _.drop([1, 2, 3]); - result = _.drop([1, 2, 3], 2); - result = _.drop([1, 2, 3], function(num) { - return num < 3; - }); - result = _.drop(foodsOrganic, 'test'); - result = _.drop(foodsType, { 'test': '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], function(num) { - return num < 3; - }); - result = _.tail(foodsOrganic, 'test'); - result = _.tail(foodsType, { 'test': '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); @@ -196,19 +190,18 @@ result = _.first(foodsType, { 'type': 'fruit' }); result = _.take([1, 2, 3]); result = _.take([1, 2, 3], 2); - result = _.take([1, 2, 3], function(num) { - return num < 3; - }); + 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 = >_([1, [2], [3, [[4]]]]).flatten(); - result = >_([1, [2], [3, [[4]]]]).flatten(true); - result = >_(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); @@ -303,13 +296,13 @@ result = _.contains('curly', 'ur'); result = _.include({ 'name': 'moe', 'age': 40 }, 'moe'); result = _.include('curly', 'ur'); -result = >_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); -result = >_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); -result = >_.countBy(['one', 'two', 'three'], 'length'); +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 = >>_([4.3, 6.1, 6.4]).countBy(function(num) { return Math.floor(num); }); - result = >>_([4.3, 6.1, 6.4]).countBy(function(num) { return this.floor(num); }, Math); - result = >>_(['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'); @@ -360,36 +353,36 @@ result = _.findLast(foodsCombined, { 'type': 'vegetable' }); result = _.findLast(foodsCombined, 'organic'); result = _.forEach([1, 2, 3], function(num) { console.log(num); }); -result = >_.forEach({ 'one': 1, 'two': 2, 'three': 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 = >_.each({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); + result = <_.Dictionary>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); - result = >_([1, 2, 3]).forEach(function(num) { console.log(num); }); - result = >>_({ '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>>_({ 'one': 1, 'two': 2, 'three': 3 }).forEach(function(num) { console.log(num); }); - result = >_([1, 2, 3]).each(function(num) { console.log(num); }); - result = >>_({ '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>>_({ 'one': 1, 'two': 2, 'three': 3 }).each(function(num) { console.log(num); }); result = _.forEachRight([1, 2, 3], function(num) { console.log(num); }); -result = >_.forEachRight({ 'one': 1, 'two': 2, 'three': 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 = >_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); + result = <_.Dictionary>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); - result = >_([1, 2, 3]).forEachRight(function(num) { console.log(num); }); - result = >>_({ '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>>_({ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function(num) { console.log(num); }); - result = >_([1, 2, 3]).eachRight(function(num) { console.log(num); }); - result = >>_({ '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>>_({ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function(num) { console.log(num); }); -result = >_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); -result = >_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); -result = >_.groupBy(['one', 'two', 'three'], 'length'); +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 = >_.indexBy(keys, 'dir'); -result = >_.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); -result = >_.indexBy(keys, function(key) { this.fromCharCode(key.code); }, String); +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, ''); @@ -543,19 +536,19 @@ var greet = function(formatted) { }; result = _.compose(greet, format); -result = >_(greet).compose(format); +result = <_.LoDashObjectWrapper>_(greet).compose(format); var createCallbackObj = { name: 'Joe' }; result = <() => any>_.createCallback('name'); result = <() => boolean>_.createCallback(createCallbackObj); -result = any>>_('name').createCallback(); -result = boolean>>_(createCallbackObj).createCallback(); +result = <_.LoDashObjectWrapper<() => any>>_('name').createCallback(); +result = <_.LoDashObjectWrapper<() => boolean>>_(createCallbackObj).createCallback(); result = _.curry(function(a, b, c) { console.log(a + b + c); }); -result = >_(function(a, b, c) { +result = <_.LoDashObjectWrapper>_(function(a, b, c) { console.log(a + b + c); }).curry(); @@ -571,23 +564,23 @@ source.addEventListener('message', _.debounce(function() {}, 250, { 'maxWait': 1000 }), false); -result = >_(function() {}).debounce(150); +result = <_.LoDashObjectWrapper>_(function() {}).debounce(150); -jQuery('#postbox').on('click', >_(function() {}).debounce(300, { +jQuery('#postbox').on('click', <_.LoDashObjectWrapper>_(function() {}).debounce(300, { 'leading': true, 'trailing': false })); -source.addEventListener('message', >_(function() {}).debounce(250, { +source.addEventListener('message', <_.LoDashObjectWrapper>_(function() {}).debounce(250, { 'maxWait': 1000 }), false); result = _.defer(function() { console.log('deferred'); }); -result = >_(function() { console.log('deferred'); }).defer(); +result = <_.LoDashWrapper>_(function() { console.log('deferred'); }).defer(); var log = _.bind(console.log, console); result = _.delay(log, 1000, 'logged later'); -result = >_(log).delay(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); @@ -642,8 +635,8 @@ result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { return typeof a == 'undefined' ? b : a; }); -result = >_({ 'name': 'moe' }).assign({ 'age': 40 }); -result = >_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a, b) { +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }); +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a, b) { return typeof a == 'undefined' ? b : a; }); @@ -652,8 +645,8 @@ result = >_({ 'name': 'moe' }).assign({ 'age': 4 return typeof a == 'undefined' ? b : a; }); - result = >_({ 'name': 'moe' }).extend({ 'age': 40 }); - result = >_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a, b) { + result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }); + result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a, b) { return typeof a == 'undefined' ? b : a; }); @@ -867,7 +860,7 @@ result = _.result(object, 'stuff'); var tempObject = {}; result = _.runInContext(tempObject); -result = _.template('hello <%= name %>'); +result = <_.TemplateExecutor>_.template('hello <%= name %>'); result = _.template('<%- value %>', { 'value': '