From 29ef6d0bb7a855fc945d135c0607720890b440d8 Mon Sep 17 00:00:00 2001 From: jbaldwin Date: Sat, 17 May 2014 16:43:01 -0600 Subject: [PATCH] Updated underscore.d.ts to v1.6.0 and tsc 1.0.1 --- underscore/underscore-tests.ts | 12 ++--- underscore/underscore.d.ts | 99 +++++++++++++++++++++++++--------- 2 files changed, 80 insertions(+), 31 deletions(-) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 8e0162b58c..aa35c7a7c6 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -65,18 +65,18 @@ _.countBy([1, 2, 3, 4, 5], (num) => (num % 2 == 0) ? 'even' : 'odd'); _.shuffle([1, 2, 3, 4, 5, 6]); -(function(a, b, c, d){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); +(function (a, b, c, d) { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); _.size({ one: 1, two: 2, three: 3 }); -_.partition([0, 1, 2, 3, 4, 5], (num)=>{return num % 2 ==0}); +_.partition([0, 1, 2, 3, 4, 5], (num) => {return num % 2 == 0 }); interface Family { name: string; - relation : string; + relation: string; } -var isUncleMoe = _.matches({name : 'moe', relation : 'uncle'}); -_.filter([{name: 'larry', relation : 'father'}, {name : 'moe', relation : 'uncle'}], isUncleMoe); +var isUncleMoe = _.matches({ name: 'moe', relation: 'uncle' }); +_.filter([{ name: 'larry', relation: 'father' }, { name: 'moe', relation: 'uncle' }], isUncleMoe); @@ -247,7 +247,7 @@ _.isUndefined((window).missingVariable); /////////////////////////////////////////////////////////////////////////////////////// -var UncleMoe = {name: 'moe'}; +var UncleMoe = { name: 'moe' }; _.constant(UncleMoe)(); typeof _.now() === "number"; diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index cc9a3e6e9d..0344eec070 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -92,7 +92,7 @@ interface UnderscoreStatic { each( list: _.List, iterator: _.ListIterator, - context?: any): void; + context?: any): _.List; /** * @see _.each @@ -103,23 +103,23 @@ interface UnderscoreStatic { each( object: _.Dictionary, iterator: _.ObjectIterator, - context?: any): void; + context?: any): _.Dictionary; /** * @see _.each **/ forEach( list: _.List, - iterator: _.ListIterator, - context?: any): void; + iterator: _.ListIterator, + context?: any): _.List; /** * @see _.each **/ forEach( object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): void; + iterator: _.ObjectIterator, + context?: any): _.Dictionary; /** * Produces a new array of values by mapping each value in list through a transformation function @@ -567,11 +567,11 @@ interface UnderscoreStatic { * @return Number of values in `list`. **/ size(list: _.Collection): number; - + /** * Split array into two arrays: * one whose elements all satisfy predicate and one whose elements all do not satisfy predicate. - * @param array Array to split in two + * @param array Array to split in two. * @param iterator Filter iterator function for each element in `array`. * @param context `this` object in `iterator`, optional. * @return Array where Array[0] are the elements in `array` that satisfies the predicate, and Array[1] the elements that did not. @@ -917,7 +917,8 @@ interface UnderscoreStatic { /** * Partially apply a function by filling in any number of its arguments, without changing its dynamic this value. - * A close cousin of bind. + * A close cousin of bind. You may pass _ in your list of arguments to specify an argument that should not be + * pre-filled, but left open to supply at call-time. * @param fn Function to partially fill in arguments. * @param arguments The partial arguments. * @return `fn` with partially filled in arguments. @@ -1171,13 +1172,6 @@ interface UnderscoreStatic { **/ has(object: any, key: string): boolean; - /** - * Returns a function that will itself return the key property of any passed-in object - * @param key Property of the object - * @return Function which accept an object an returns the value of key in that object - **/ - property(key: string): (object: Object)=> any; - /** * Returns a predicate function that will tell you if a passed in object contains all of the key/value properties present in attrs. * @param attrs Object with key values pair @@ -1185,6 +1179,13 @@ interface UnderscoreStatic { **/ matches(attrs: T): _.ListIterator; + /** + * Returns a function that will itself return the key property of any passed-in object. + * @param key Property of the object. + * @return Function which accept an object an returns the value of key in that object. + **/ + property(key: string): (object: Object) => any; + /** * Performs an optimized deep comparison between the two objects, * to determine if they should be considered equal. @@ -1447,22 +1448,22 @@ interface Underscore { * Wrapped type `any[]`. * @see _.each **/ - each(iterator: _.ListIterator, context?: any): void; + each(iterator: _.ListIterator, context?: any): T[]; /** * @see _.each **/ - each(iterator: _.ObjectIterator, context?: any): void; + each(iterator: _.ObjectIterator, context?: any): T[]; /** * @see _.each **/ - forEach(iterator: _.ListIterator, context?: any): void; + forEach(iterator: _.ListIterator, context?: any): T[]; /** * @see _.each **/ - forEach(iterator: _.ObjectIterator, context?: any): void; + forEach(iterator: _.ObjectIterator, context?: any): T[]; /** * Wrapped type `any[]`. @@ -1800,6 +1801,12 @@ interface Underscore { **/ without(...values: T[]): T[]; + /** + * Wrapped type `any[]`. + * @see _.partition + **/ + partition(iterator: _.ListIterator, context?: any): T[][]; + /** * Wrapped type `any[][]`. * @see _.union @@ -2056,6 +2063,18 @@ interface Underscore { **/ has(key: string): boolean; + /** + * Wrapped type `any[]`. + * @see _.matches + **/ + matches(): _.ListIterator; + + /** + * Wrapped type `string`. + * @see _.property + **/ + property(): (object: Object) => any; + /** * Wrapped type `object`. * @see _.isEqual @@ -2162,6 +2181,12 @@ interface Underscore { **/ identity(): any; + /** + * Wrapped type `any`. + * @see _.constant + **/ + constant(): () => T; + /** * Wrapped type `number`. * @see _.times @@ -2236,22 +2261,22 @@ interface _Chain { * Wrapped type `any[]`. * @see _.each **/ - each(iterator: _.ListIterator, context?: any): _Chain; + each(iterator: _.ListIterator, context?: any): _Chain; /** * @see _.each **/ - each(iterator: _.ObjectIterator, context?: any): _Chain; + each(iterator: _.ObjectIterator, context?: any): _Chain; /** * @see _.each **/ - forEach(iterator: _.ListIterator, context?: any): _Chain; + forEach(iterator: _.ListIterator, context?: any): _Chain; /** * @see _.each **/ - forEach(iterator: _.ObjectIterator, context?: any): _Chain; + forEach(iterator: _.ObjectIterator, context?: any): _Chain; /** * Wrapped type `any[]`. @@ -2270,7 +2295,7 @@ interface _Chain { * @see _.map **/ map(iterator: _.ObjectIterator, context?: any): _ChainOfArrays; - + /** * Wrapped type `any[]`. * @see _.map @@ -2601,6 +2626,12 @@ interface _Chain { **/ without(...values: T[]): _Chain; + /** + * Wrapped type `any[]`. + * @see _.partition + **/ + partition(iterator: _.ListIterator, context?: any): _Chain; + /** * Wrapped type `any[][]`. * @see _.union @@ -2855,6 +2886,18 @@ interface _Chain { **/ has(key: string): _Chain; + /** + * Wrapped type `any[]`. + * @see _.matches + **/ + matches(): _Chain; + + /** + * Wrapped type `string`. + * @see _.property + **/ + property(): _Chain; + /** * Wrapped type `object`. * @see _.isEqual @@ -2961,6 +3004,12 @@ interface _Chain { **/ identity(): _Chain; + /** + * Wrapped type `any`. + * @see _.constant + **/ + constant(): _Chain; + /** * Wrapped type `number`. * @see _.times