added _.pick definitions

This commit is contained in:
Brian Zengel
2013-10-20 17:32:13 -04:00
parent d7b332ac7c
commit 50121d7a01
2 changed files with 34 additions and 10 deletions
+6
View File
@@ -693,6 +693,12 @@ result = <any>_.omit({ 'name': 'moe', 'age': 40 }, function(value) {
result = <any[][]>_.pairs({ 'moe': 30, 'larry': 40 });
result = <any>_.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name');
result = <any>_.pick({ 'name': 'moe', '_userid': 'moe1' }, ['name']);
result = <any>_.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) {
return key.charAt(0) != '_';
});
////////////////////////////////////////////////////////////////////////////////////////
//WHAT'S LEFT
////////////////////////////////////////////////////////////////////////////////////////
+28 -10
View File
@@ -2649,7 +2649,34 @@ declare module _ {
**/
export function pairs(object: any): any[][];
/**
* Creates a shallow clone of object composed of the specified properties. Property names may be
* specified as individual arguments or as arrays of property names. If a callback is provided
* it will be executed for each property of object picking the properties the callback returns
* truey for. The callback is bound to thisArg and invoked with three arguments; (value, key,
* object).
* @param object Object to strip unwanted key/value pairs.
* @param keys Property names to pick
* @return An object composed of the picked properties.
**/
export function pick(
object: any,
...keys: string[]): any;
/**
* @see _.pick
**/
export function pick(
object: any,
keys: string[]): any;
/**
* @see _.pick
**/
export function pick(
object: any,
callback: ObjectIterator<any, boolean>,
thisArg?: any): any;
@@ -2702,16 +2729,7 @@ declare module _ {
/**
* Return a copy of the object, filtered to only have values for the whitelisted keys
* (or array of valid keys).
* @param object Object to strip unwanted key/value pairs.
* @keys The key/value pairs to keep on `object`.
* @return Copy of `object` with only the `keys` properties.
**/
export function pick(
object: any,
...keys: string[]): any;