(feature) Add _.flip and _.unary

This commit is contained in:
DomiR
2016-01-23 14:43:48 +01:00
parent ede6c030a1
commit 5919b1b39d
2 changed files with 127 additions and 6 deletions
+55 -2
View File
@@ -4627,8 +4627,7 @@ module TestNow {
/*************
* Functions *
*************/
// _after
// _.after
module TestAfter {
interface Func {
(a: string, b: number): boolean;
@@ -5080,6 +5079,33 @@ module TestDelay {
}
}
// _.flip
module TestFlip {
interface Func {
(a: number, b: string): boolean;
}
let func: Func;
{
let result: Func;
result = _.flip(func);
}
{
let result: _.LoDashImplicitObjectWrapper<Func>;
result = _(func).flip();
}
{
let result: _.LoDashExplicitObjectWrapper<Func>;
result = _(func).chain().flip();
}
}
// _.flow
module TestFlow {
let Fn1: (n: number) => number;
@@ -5395,6 +5421,33 @@ module TestThrottle {
}
}
// _.unary
module TestUnary {
interface Func {
(a: number, b: string): boolean;
}
let func: Func;
{
let result: Func;
result = _.unary(func);
}
{
let result: _.LoDashImplicitObjectWrapper<Func>;
result = _(func).unary();
}
{
let result: _.LoDashExplicitObjectWrapper<Func>;
result = _(func).chain().unary();
}
}
// _.wrap
module TestWrap {
type SampleValue = {a: number; b: string; c: boolean}
+72 -4
View File
@@ -140,12 +140,12 @@ added 4 math methods:
- [ ] _.sumBy
added 2 function methods:
- [ ] _.flip &
- [ ] _.unary
- [x] _.flip
- [x] _.unary
added 2 number methods:
- [ ] _.clamp &
- [ ] _.subtract
- [x] _.clamp
- [x] _.subtract
added chain method:
- [ ] _.next
@@ -8366,6 +8366,41 @@ declare module _ {
): LoDashExplicitWrapper<number>;
}
interface LoDashStatic {
/**
* Creates a function that invokes `func` with arguments reversed.
*
* @static
* @memberOf _
* @category Function
* @param {Function} func The function to flip arguments for.
* @returns {Function} Returns the new function.
* @example
*
* var flipped = _.flip(function() {
* return _.toArray(arguments);
* });
*
* flipped('a', 'b', 'c', 'd');
* // => ['d', 'c', 'b', 'a']
*/
flip<T extends Function>(func: T): T;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.flip
*/
flip(): LoDashImplicitObjectWrapper<T>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.flip
*/
flip(): LoDashExplicitObjectWrapper<T>;
}
//_.flow
interface LoDashStatic {
/**
@@ -8846,6 +8881,39 @@ declare module _ {
): LoDashExplicitObjectWrapper<T & Cancelable>;
}
//_.unary
interface LoDashStatic {
/**
* Creates a function that accepts up to one argument, ignoring any
* additional arguments.
*
* @static
* @memberOf _
* @category Function
* @param {Function} func The function to cap arguments for.
* @returns {Function} Returns the new function.
* @example
*
* _.map(['6', '8', '10'], _.unary(parseInt));
* // => [6, 8, 10]
*/
unary<T extends Function>(func: T): T;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.unary
*/
unary(): LoDashImplicitObjectWrapper<T>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.unary
*/
unary(): LoDashExplicitObjectWrapper<T>;
}
//_.wrap
interface LoDashStatic {
/**