From 155c6de20b6f7416dde3418b6914c3e4a25afa2c Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Tue, 28 Jul 2015 06:44:22 +0500 Subject: [PATCH] lodash: changed _.constant() method (added to a chainable wrapper, added tests) --- lodash/lodash-tests.ts | 12 ++++++++++++ lodash/lodash.d.ts | 13 +++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 627dda565..d089787a0 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1255,6 +1255,18 @@ result = _.words('fred, barney, & pebbles', /[^, ]+/g); * Utilities * ***********/ +// _.constant +result = <() => number>_.constant(1); +result = <() => string>_.constant('a'); +result = <() => boolean>_.constant(true); +result = <() => any[]>_.constant([]); +result = <() => {}>_.constant<{}>({}); +result = <() => number>_(1).constant(); +result = <() => string>_('a').constant(); +result = <() => boolean>_(true).constant(); +result = <() => any[]>_(['a']).constant(); +result = <() => {}>_({}).constant<{}>(); + result = _.VERSION; result = <_.Support>_.support; result = <_.TemplateSettings>_.templateSettings; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 7bc1df648..c16106ea6 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6626,11 +6626,20 @@ declare module _ { //_.constant interface LoDashStatic { /** - * Creates a function that returns value.. - **/ + * Creates a function that returns value. + * @param value The value to return from the new function. + * @return Returns the new function. + */ constant(value: T): () => T; } + interface LoDashWrapperBase { + /** + * @see _.constant + */ + constant(): () => TResult; + } + //_.create interface LoDashStatic { /**