From da61ddf7e774815f3caa3a3e273f525fb43b201b Mon Sep 17 00:00:00 2001 From: Brian Zengel Date: Sun, 13 Oct 2013 01:33:52 -0400 Subject: [PATCH] Aliases for _.first: head and take --- lodash/lodash-tests.ts | 16 +++++++++++++++ lodash/lodash.d.ts | 44 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index a7afd3ee5..915b1c96f 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -72,6 +72,22 @@ result = _.first([1, 2, 3], function(num) { 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], function(num) { + return num < 3; +}); +result = _.take(foodsOrganic, 'organic'); +result = _.take(foodsType, { 'type': 'fruit' }); + //////////////////////////////////////////////////////////////////////////////////////// //WHAT'S LEFT diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 4d85483c5..43b8a774c 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -653,6 +653,28 @@ declare module _ { array: List, n: number): T[]; + /** + * @see _.first + **/ + export function head( + array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.first + **/ + export function head( + array: List, + pluckValue: string): T[]; + + /** + * @see _.first + **/ + export function head( + array: List, + whereValue: Dictionary): T[]; + /** * @see _.first **/ @@ -665,6 +687,28 @@ declare module _ { array: List, n: number): T[]; + /** + * @see _.first + **/ + export function take( + array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.first + **/ + export function take( + array: List, + pluckValue: string): T[]; + + /** + * @see _.first + **/ + export function take( + array: List, + whereValue: Dictionary): T[]; + /** * Returns everything but the last entry of the array. Especially useful on the arguments object. * Pass n to exclude the last n elements from the result.