Merge pull request #7998 from chrootsu/lodash-toPairsIn

lodash: added _.toPairsIn
This commit is contained in:
Masahiro Wakame
2016-02-07 02:36:04 +09:00
2 changed files with 144 additions and 76 deletions
+86 -45
View File
@@ -4360,7 +4360,7 @@ module TestInvokeMap {
c: 3,
d: 4
}
let result: string[];
result = _.invokeMap<number, string>(numArray, 'toString');
result = _.invokeMap<number, string>(numArray, 'toString', 2);
@@ -4370,7 +4370,7 @@ module TestInvokeMap {
result = _(numArray).invokeMap<string>('toString', 2).value();
result = _(numArray).chain().invokeMap<string>('toString').value();
result = _(numArray).chain().invokeMap<string>('toString', 2).value();
result = _.invokeMap<number, string>(numArray, Number.prototype.toString);
result = _.invokeMap<number, string>(numArray, Number.prototype.toString, 2);
result = _.invokeMap<string>(numArray, Number.prototype.toString);
@@ -4379,7 +4379,7 @@ module TestInvokeMap {
result = _(numArray).invokeMap<string>(Number.prototype.toString, 2).value();
result = _(numArray).chain().invokeMap<string>(Number.prototype.toString).value();
result = _(numArray).chain().invokeMap<string>(Number.prototype.toString, 2).value();
result = _.invokeMap<number, string>(numDict, 'toString');
result = _.invokeMap<number, string>(numDict, 'toString', 2);
result = _.invokeMap<string>(numDict, 'toString');
@@ -4388,7 +4388,7 @@ module TestInvokeMap {
result = _(numDict).invokeMap<string>('toString', 2).value();
result = _(numDict).chain().invokeMap<string>('toString').value();
result = _(numDict).chain().invokeMap<string>('toString', 2).value();
result = _.invokeMap<number, string>(numDict, Number.prototype.toString);
result = _.invokeMap<number, string>(numDict, Number.prototype.toString, 2);
result = _.invokeMap<string>(numDict, Number.prototype.toString);
@@ -9066,47 +9066,6 @@ module TestOmitBy {
}
}
// _.toPairs
module TestToPairs {
let object: _.Dictionary<string>;
{
let result: any[][];
result = _.toPairs<_.Dictionary<string>>(object);
}
{
let result: string[][];
result = _.toPairs<_.Dictionary<string>, string>(object);
}
{
let result: _.LoDashImplicitArrayWrapper<string[]>;
result = _(object).toPairs<string>();
}
{
let result: _.LoDashImplicitArrayWrapper<any[]>;
result = _(object).toPairs();
}
{
let result: _.LoDashExplicitArrayWrapper<string[]>;
result = _(object).chain().toPairs<string>();
}
{
let result: _.LoDashExplicitArrayWrapper<any[]>;
result = _(object).chain().toPairs();
}
}
// _.pick
module TestPick {
let predicate: (element: any, key: string, collection: any) => boolean;
@@ -9272,6 +9231,88 @@ module TestSetWith {
}
}
// _.toPairs
namespace TestToPairs {
let object: _.Dictionary<string>;
{
let result: any[][];
result = _.toPairs<_.Dictionary<string>>(object);
}
{
let result: string[][];
result = _.toPairs<_.Dictionary<string>, string>(object);
}
{
let result: _.LoDashImplicitArrayWrapper<string[]>;
result = _(object).toPairs<string>();
}
{
let result: _.LoDashImplicitArrayWrapper<any[]>;
result = _(object).toPairs();
}
{
let result: _.LoDashExplicitArrayWrapper<string[]>;
result = _(object).chain().toPairs<string>();
}
{
let result: _.LoDashExplicitArrayWrapper<any[]>;
result = _(object).chain().toPairs();
}
}
// _.toPairsIn
namespace TestToPairsIn {
let object: _.Dictionary<string>;
{
let result: any[][];
result = _.toPairsIn<_.Dictionary<string>>(object);
}
{
let result: string[][];
result = _.toPairsIn<_.Dictionary<string>, string>(object);
}
{
let result: _.LoDashImplicitArrayWrapper<string[]>;
result = _(object).toPairsIn<string>();
}
{
let result: _.LoDashImplicitArrayWrapper<any[]>;
result = _(object).toPairsIn();
}
{
let result: _.LoDashExplicitArrayWrapper<string[]>;
result = _(object).chain().toPairsIn<string>();
}
{
let result: _.LoDashExplicitArrayWrapper<any[]>;
result = _(object).chain().toPairs();
}
}
// _.transform
module TestTransform {
let array: number[];
+58 -31
View File
@@ -7904,7 +7904,7 @@ declare module _ {
method: (...args: any[]) => TResult,
...args: any[]): TResult[];
}
interface LoDashImplicitArrayWrapper<T> {
/**
* @see _.invokeMap
@@ -7920,7 +7920,7 @@ declare module _ {
method: (...args: any[]) => TResult,
...args: any[]): LoDashImplicitArrayWrapper<TResult>;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.invokeMap
@@ -7936,7 +7936,7 @@ declare module _ {
method: (...args: any[]) => TResult,
...args: any[]): LoDashImplicitArrayWrapper<TResult>;
}
interface LoDashExplicitArrayWrapper<T> {
/**
* @see _.invokeMap
@@ -7952,7 +7952,7 @@ declare module _ {
method: (...args: any[]) => TResult,
...args: any[]): LoDashExplicitArrayWrapper<TResult>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.invokeMap
@@ -15504,33 +15504,6 @@ declare module _ {
): LoDashExplicitObjectWrapper<TResult>;
}
//_.toPairs
interface LoDashStatic {
/**
* Creates a two dimensional array of the key-value pairs for object, e.g. [[key1, value1], [key2, value2]].
*
* @param object The object to query.
* @return Returns the new array of key-value pairs.
*/
toPairs<T extends {}>(object?: T): any[][];
toPairs<T extends {}, TResult>(object?: T): TResult[][];
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.toPairs
*/
toPairs<TResult>(): LoDashImplicitArrayWrapper<TResult[]>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.toPairs
*/
toPairs<TResult>(): LoDashExplicitArrayWrapper<TResult[]>;
}
//_.pick
interface LoDashStatic {
/**
@@ -15803,6 +15776,60 @@ declare module _ {
): LoDashExplicitObjectWrapper<TResult>;
}
//_.toPairs
interface LoDashStatic {
/**
* Creates an array of own enumerable key-value pairs for object.
*
* @param object The object to query.
* @return Returns the new array of key-value pairs.
*/
toPairs<T extends {}>(object?: T): any[][];
toPairs<T extends {}, TResult>(object?: T): TResult[][];
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.toPairs
*/
toPairs<TResult>(): LoDashImplicitArrayWrapper<TResult[]>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.toPairs
*/
toPairs<TResult>(): LoDashExplicitArrayWrapper<TResult[]>;
}
//_.toPairsIn
interface LoDashStatic {
/**
* Creates an array of own and inherited enumerable key-value pairs for object.
*
* @param object The object to query.
* @return Returns the new array of key-value pairs.
*/
toPairsIn<T extends {}>(object?: T): any[][];
toPairsIn<T extends {}, TResult>(object?: T): TResult[][];
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.toPairsIn
*/
toPairsIn<TResult>(): LoDashImplicitArrayWrapper<TResult[]>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.toPairsIn
*/
toPairsIn<TResult>(): LoDashExplicitArrayWrapper<TResult[]>;
}
//_.transform
interface LoDashStatic {
/**