diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 69ad40482..af31de6ce 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -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; + + result = _(func).flip(); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + 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; + + result = _(func).unary(); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _(func).chain().unary(); + } +} + // _.wrap module TestWrap { type SampleValue = {a: number; b: string; c: boolean} diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index f36c2c1d7..1f5d7d743 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -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; } + 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(func: T): T; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.flip + */ + flip(): LoDashImplicitObjectWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.flip + */ + flip(): LoDashExplicitObjectWrapper; + } + //_.flow interface LoDashStatic { /** @@ -8846,6 +8881,39 @@ declare module _ { ): LoDashExplicitObjectWrapper; } + //_.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(func: T): T; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.unary + */ + unary(): LoDashImplicitObjectWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.unary + */ + unary(): LoDashExplicitObjectWrapper; + } + //_.wrap interface LoDashStatic { /**