lodash: signatures of the method _.shuffle have been changed

This commit is contained in:
Ilya Mochalov
2015-11-06 02:42:18 +05:00
parent 35989a3ab4
commit 33ee27f8f8
2 changed files with 86 additions and 18 deletions
+48 -3
View File
@@ -3056,9 +3056,54 @@ result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).sample(2);
result = <number>_([1, 2, 3, 4]).sample().value();
result = <number[]>_([1, 2, 3, 4]).sample(2).value();
result = <number[]>_.shuffle([1, 2, 3, 4, 5, 6]);
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3]).shuffle();
result = <_.LoDashImplicitArrayWrapper<_.Dictionary<string>>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).shuffle();
// _.shuffle
module TestShuffle {
let array: TResult[];
let list: _.List<TResult>;
let dictionary: _.Dictionary<TResult>;
{
let result: string[];
result = _.shuffle('abc');
}
{
let result: TResult[];
result = _.shuffle<TResult>(array);
result = _.shuffle<TResult>(list);
result = _.shuffle<TResult>(dictionary);
}
{
let result: _.LoDashImplicitArrayWrapper<string>;
result = _('abc').shuffle();
}
{
let result: _.LoDashImplicitArrayWrapper<TResult>;
result = _(array).shuffle();
result = _(list).shuffle<TResult>();
result = _(dictionary).shuffle<TResult>();
}
{
let result: _.LoDashExplicitArrayWrapper<string>;
result = _('abc').chain().shuffle();
}
{
let result: _.LoDashExplicitArrayWrapper<TResult>;
result = _(array).chain().shuffle();
result = _(list).chain().shuffle<TResult>();
result = _(dictionary).chain().shuffle<TResult>();
}
}
result = <number>_.size([1, 2]);
result = <number>_([1, 2]).size();
+38 -15
View File
@@ -6176,36 +6176,59 @@ declare module _ {
//_.shuffle
interface LoDashStatic {
/**
* Creates an array of shuffled values, using a version of the Fisher-Yates shuffle.
* See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
* @param collection The collection to shuffle.
* @return Returns a new shuffled collection.
**/
shuffle<T>(collection: Array<T>): T[];
* Creates an array of shuffled values, using a version of the Fisher-Yates shuffle.
*
* @param collection The collection to shuffle.
* @return Returns the new shuffled array.
*/
shuffle<T>(collection: List<T>|Dictionary<T>): T[];
/**
* @see _.shuffle
**/
shuffle<T>(collection: List<T>): T[];
* @see _.shuffle
*/
shuffle(collection: string): string[];
}
interface LoDashImplicitWrapper<T> {
/**
* @see _.shuffle
**/
shuffle<T>(collection: Dictionary<T>): T[];
* @see _.shuffle
*/
shuffle(): LoDashImplicitArrayWrapper<string>;
}
interface LoDashImplicitArrayWrapper<T> {
/**
* @see _.shuffle
**/
*/
shuffle(): LoDashImplicitArrayWrapper<T>;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.shuffle
**/
shuffle(): LoDashImplicitArrayWrapper<T>;
*/
shuffle<T>(): LoDashImplicitArrayWrapper<T>;
}
interface LoDashExplicitWrapper<T> {
/**
* @see _.shuffle
*/
shuffle(): LoDashExplicitArrayWrapper<string>;
}
interface LoDashExplicitArrayWrapper<T> {
/**
* @see _.shuffle
*/
shuffle(): LoDashExplicitArrayWrapper<T>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.shuffle
*/
shuffle<T>(): LoDashExplicitArrayWrapper<T>;
}
//_.size