mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-06 16:20:26 +08:00
(feature) Split _.omit & _.pick into _.omitBy & _.pickBy
This commit is contained in:
+46
-12
@@ -8640,8 +8640,6 @@ module TestOmit {
|
||||
result = _.omit<TResult, Object>({}, 0, 'a');
|
||||
result = _.omit<TResult, Object>({}, true, 0, 'a');
|
||||
result = _.omit<TResult, Object>({}, ['b', 1, false], true, 0, 'a');
|
||||
result = _.omit<TResult, Object>({}, predicate);
|
||||
result = _.omit<TResult, Object>({}, predicate, any);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -8651,8 +8649,6 @@ module TestOmit {
|
||||
result = _({}).omit<TResult>(0, 'a');
|
||||
result = _({}).omit<TResult>(true, 0, 'a');
|
||||
result = _({}).omit<TResult>(['b', 1, false], true, 0, 'a');
|
||||
result = _({}).omit<TResult>(predicate);
|
||||
result = _({}).omit<TResult>(predicate, any);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -8662,8 +8658,29 @@ module TestOmit {
|
||||
result = _({}).chain().omit<TResult>(0, 'a');
|
||||
result = _({}).chain().omit<TResult>(true, 0, 'a');
|
||||
result = _({}).chain().omit<TResult>(['b', 1, false], true, 0, 'a');
|
||||
result = _({}).chain().omit<TResult>(predicate);
|
||||
result = _({}).chain().omit<TResult>(predicate, any);
|
||||
}
|
||||
}
|
||||
|
||||
// _.omitBy
|
||||
module TestOmitBy {
|
||||
let predicate: (element: any, key: string, collection: any) => boolean;
|
||||
|
||||
{
|
||||
let result: TResult;
|
||||
|
||||
result = _.omitBy<TResult, Object>({}, predicate);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitObjectWrapper<TResult>;
|
||||
|
||||
result = _({}).omitBy<TResult>(predicate);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitObjectWrapper<TResult>;
|
||||
|
||||
result = _({}).chain().omitBy<TResult>(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8719,8 +8736,6 @@ module TestPick {
|
||||
result = _.pick<TResult, Object>({}, 0, 'a');
|
||||
result = _.pick<TResult, Object>({}, true, 0, 'a');
|
||||
result = _.pick<TResult, Object>({}, ['b', 1, false], true, 0, 'a');
|
||||
result = _.pick<TResult, Object>({}, predicate);
|
||||
result = _.pick<TResult, Object>({}, predicate, any);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -8730,8 +8745,6 @@ module TestPick {
|
||||
result = _({}).pick<TResult>(0, 'a');
|
||||
result = _({}).pick<TResult>(true, 0, 'a');
|
||||
result = _({}).pick<TResult>(['b', 1, false], true, 0, 'a');
|
||||
result = _({}).pick<TResult>(predicate);
|
||||
result = _({}).pick<TResult>(predicate, any);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -8741,8 +8754,29 @@ module TestPick {
|
||||
result = _({}).chain().pick<TResult>(0, 'a');
|
||||
result = _({}).chain().pick<TResult>(true, 0, 'a');
|
||||
result = _({}).chain().pick<TResult>(['b', 1, false], true, 0, 'a');
|
||||
result = _({}).chain().pick<TResult>(predicate);
|
||||
result = _({}).chain().pick<TResult>(predicate, any);
|
||||
}
|
||||
}
|
||||
|
||||
// _.pickBy
|
||||
module TestPickBy {
|
||||
let predicate: (element: any, key: string, collection: any) => boolean;
|
||||
|
||||
{
|
||||
let result: TResult;
|
||||
|
||||
result = _.pickBy<TResult, Object>({}, predicate);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitObjectWrapper<TResult>;
|
||||
|
||||
result = _({}).pickBy<TResult>(predicate);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitObjectWrapper<TResult>;
|
||||
|
||||
result = _({}).chain().pickBy<TResult>(predicate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+117
-64
@@ -30,7 +30,7 @@ TODO:
|
||||
|
||||
- [x] Split _.indexOf & _.lastIndexOf into _.sortedIndexOf & _.sortedLastIndexOf
|
||||
- [x] Split _.max & _.min into _.maxBy & _.minBy
|
||||
- [ ] Split _.omit & _.pick into _.omitBy & _.pickBy
|
||||
- [x] Split _.omit & _.pick into _.omitBy & _.pickBy
|
||||
- [ ] Split _.sample into _.sampleSize
|
||||
- [ ] Split _.sortedIndex into _.sortedIndexBy
|
||||
- [ ] Split _.sortedLastIndex into _.sortedLastIndexBy
|
||||
@@ -13334,24 +13334,24 @@ declare module _ {
|
||||
//_.omit
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* The opposite of _.pick; this method creates an object composed of the own and inherited enumerable
|
||||
* properties of object that are not omitted.
|
||||
* The opposite of `_.pick`; this method creates an object composed of the
|
||||
* own and inherited enumerable properties of `object` that are not omitted.
|
||||
*
|
||||
* @param object The source object.
|
||||
* @param predicate The function invoked per iteration or property names to omit, specified as individual
|
||||
* property names or arrays of property names.
|
||||
* @param thisArg The this binding of predicate.
|
||||
* @return Returns the new object.
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {Object} object The source object.
|
||||
* @param {...(string|string[])} [props] The property names to omit, specified
|
||||
* individually or in arrays..
|
||||
* @returns {Object} Returns the new object.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1, 'b': '2', 'c': 3 };
|
||||
*
|
||||
* _.omit(object, ['a', 'c']);
|
||||
* // => { 'b': '2' }
|
||||
*/
|
||||
omit<TResult extends {}, T extends {}>(
|
||||
object: T,
|
||||
predicate: ObjectIterator<any, boolean>,
|
||||
thisArg?: any
|
||||
): TResult;
|
||||
|
||||
/**
|
||||
* @see _.omit
|
||||
*/
|
||||
omit<TResult extends {}, T extends {}>(
|
||||
object: T,
|
||||
...predicate: (StringRepresentable|StringRepresentable[])[]
|
||||
@@ -13359,13 +13359,6 @@ declare module _ {
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.omit
|
||||
*/
|
||||
omit<TResult extends {}>(
|
||||
predicate: ObjectIterator<any, boolean>,
|
||||
thisArg?: any
|
||||
): LoDashImplicitObjectWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.omit
|
||||
@@ -13376,13 +13369,6 @@ declare module _ {
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.omit
|
||||
*/
|
||||
omit<TResult extends {}>(
|
||||
predicate: ObjectIterator<any, boolean>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitObjectWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.omit
|
||||
@@ -13392,6 +13378,50 @@ declare module _ {
|
||||
): LoDashExplicitObjectWrapper<TResult>;
|
||||
}
|
||||
|
||||
//_.omitBy
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* The opposite of `_.pickBy`; this method creates an object composed of the
|
||||
* own and inherited enumerable properties of `object` that `predicate`
|
||||
* doesn't return truthy for.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {Object} object The source object.
|
||||
* @param {Function|Object|string} [predicate=_.identity] The function invoked per property.
|
||||
* @returns {Object} Returns the new object.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1, 'b': '2', 'c': 3 };
|
||||
*
|
||||
* _.omitBy(object, _.isNumber);
|
||||
* // => { 'b': '2' }
|
||||
*/
|
||||
omitBy<TResult extends {}, T extends {}>(
|
||||
object: T,
|
||||
predicate: ObjectIterator<any, boolean>
|
||||
): TResult;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.omitBy
|
||||
*/
|
||||
omitBy<TResult extends {}>(
|
||||
predicate: ObjectIterator<any, boolean>
|
||||
): LoDashImplicitObjectWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.omitBy
|
||||
*/
|
||||
omitBy<TResult extends {}>(
|
||||
predicate: ObjectIterator<any, boolean>
|
||||
): LoDashExplicitObjectWrapper<TResult>;
|
||||
}
|
||||
|
||||
//_.toPairs
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
@@ -13422,25 +13452,21 @@ declare module _ {
|
||||
//_.pick
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Creates an object composed of the picked object properties. Property names may be specified as individual
|
||||
* arguments or as arrays of property names. If predicate is provided it’s invoked for each property of object
|
||||
* picking the properties predicate returns truthy for. The predicate is bound to thisArg and invoked with
|
||||
* three arguments: (value, key, object).
|
||||
* Creates an object composed of the picked `object` properties.
|
||||
*
|
||||
* @param object The source object.
|
||||
* @param predicate The function invoked per iteration or property names to pick, specified as individual
|
||||
* property names or arrays of property names.
|
||||
* @param thisArg The this binding of predicate.
|
||||
* @return Returns the new object.
|
||||
*/
|
||||
pick<TResult extends {}, T extends {}>(
|
||||
object: T,
|
||||
predicate: ObjectIterator<any, boolean>,
|
||||
thisArg?: any
|
||||
): TResult;
|
||||
|
||||
/**
|
||||
* @see _.pick
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {Object} object The source object.
|
||||
* @param {...(string|string[])} [props] The property names to pick, specified
|
||||
* individually or in arrays.
|
||||
* @returns {Object} Returns the new object.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1, 'b': '2', 'c': 3 };
|
||||
*
|
||||
* _.pick(object, ['a', 'c']);
|
||||
* // => { 'a': 1, 'c': 3 }
|
||||
*/
|
||||
pick<TResult extends {}, T extends {}>(
|
||||
object: T,
|
||||
@@ -13449,14 +13475,6 @@ declare module _ {
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.pick
|
||||
*/
|
||||
pick<TResult extends {}>(
|
||||
predicate: ObjectIterator<any, boolean>,
|
||||
thisArg?: any
|
||||
): LoDashImplicitObjectWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.pick
|
||||
*/
|
||||
@@ -13466,14 +13484,6 @@ declare module _ {
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.pick
|
||||
*/
|
||||
pick<TResult extends {}>(
|
||||
predicate: ObjectIterator<any, boolean>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitObjectWrapper<TResult>;
|
||||
|
||||
/**
|
||||
* @see _.pick
|
||||
*/
|
||||
@@ -13482,6 +13492,49 @@ declare module _ {
|
||||
): LoDashExplicitObjectWrapper<TResult>;
|
||||
}
|
||||
|
||||
//_.pickBy
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Creates an object composed of the `object` properties `predicate` returns
|
||||
* truthy for. The predicate is invoked with one argument: (value).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {Object} object The source object.
|
||||
* @param {Function|Object|string} [predicate=_.identity] The function invoked per property.
|
||||
* @returns {Object} Returns the new object.
|
||||
* @example
|
||||
*
|
||||
* var object = { 'a': 1, 'b': '2', 'c': 3 };
|
||||
*
|
||||
* _.pickBy(object, _.isNumber);
|
||||
* // => { 'a': 1, 'c': 3 }
|
||||
*/
|
||||
pickBy<TResult extends {}, T extends {}>(
|
||||
object: T,
|
||||
predicate: ObjectIterator<any, boolean>
|
||||
): TResult;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.pickBy
|
||||
*/
|
||||
pickBy<TResult extends {}>(
|
||||
predicate: ObjectIterator<any, boolean>
|
||||
): LoDashImplicitObjectWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.pickBy
|
||||
*/
|
||||
pickBy<TResult extends {}>(
|
||||
predicate: ObjectIterator<any, boolean>
|
||||
): LoDashExplicitObjectWrapper<TResult>;
|
||||
}
|
||||
|
||||
//_.result
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user