From 1c048a3cf65c5a57e0b0f66a48cd1040fea6e2f2 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 16 Sep 2015 19:52:53 +0500 Subject: [PATCH] lodash: added _.prototype.plant() method --- lodash/lodash-tests.ts | 26 ++++++++++++++++++++++++++ lodash/lodash.d.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index fc36241c5..af1dbe3e8 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -453,6 +453,32 @@ result = _([1, 2]).zipWith([1, 2], [1, 2], [1, 2], [1, 2], [1, result = _({}).commit(); } +// _.prototype.plant +{ + let result: _.LoDashWrapper; + result = _(any).plant(42); +} +{ + let result: _.LoDashStringWrapper; + result = _(any).plant(''); +} +{ + let result: _.LoDashWrapper; + result = _(any).plant(true); +} +{ + let result: _.LoDashNumberArrayWrapper; + result = _(any).plant([42]); +} +{ + let result: _.LoDashArrayWrapper; + result = _(any).plant([]); +} +{ + let result: _.LoDashObjectWrapper<{}>; + result = _(any).plant<{}>({}); +} + /************** * Collection * **************/ diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index db2405580..7ec04214c 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2066,6 +2066,46 @@ declare module _ { commit(): TWrapper; } + //_.prototype.plant + interface LoDashWrapperBase { + /** + * Creates a clone of the chained sequence planting value as the wrapped value. + * @param value The value to plant as the wrapped value. + * @return Returns the new lodash wrapper instance. + */ + plant(value: number): LoDashWrapper; + + /** + * @see _.plant + */ + plant(value: string): LoDashStringWrapper; + + /** + * @see _.plant + */ + plant(value: boolean): LoDashWrapper; + + /** + * @see _.plant + */ + plant(value: number[]): LoDashNumberArrayWrapper; + + /** + * @see _.plant + */ + plant(value: T[]): LoDashArrayWrapper; + + /** + * @see _.plant + */ + plant(value: T): LoDashObjectWrapper; + + /** + * @see _.plant + */ + plant(value: any): LoDashWrapper; + } + /************** * Collection * **************/