From 875c8e1e3c4bbdbee28741c111e083b6bf491318 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Sat, 25 Jul 2015 05:50:51 +0500 Subject: [PATCH] lodash: added _.toPlainObject() method --- lodash/lodash-tests.ts | 18 ++++++++++++++++++ lodash/lodash.d.ts | 20 ++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 627dda565..c1203d102 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -850,6 +850,24 @@ var helloWrap2 = _.wrap(helloWrap, function (func) { }); helloWrap2(); +/******** + * Lang * + ********/ + +// _.toPlainObject +result = _.toPlainObject(); +result = _.toPlainObject(true); +result = _.toPlainObject(1); +result = _.toPlainObject('a'); +result = _.toPlainObject([]); +result = _.toPlainObject({}); +result = _(true).toPlainObject(); +result = _(1).toPlainObject(); +result = _('a').toPlainObject(); +result = _([1]).toPlainObject(); +result = _([]).toPlainObject(); +result = _({}).toPlainObject(); + /********** * Objects * ***********/ diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 7bc1df648..4193d5dc6 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -196,6 +196,11 @@ declare module _ { * @see _.value **/ valueOf(): T; + + /** + * @see _.toPlainObject + */ + toPlainObject(): Object; } interface LoDashWrapper extends LoDashWrapperBase> { } @@ -5304,6 +5309,21 @@ declare module _ { wrapper: (func: Function, ...args: any[]) => any): Function; } + /******** + * Lang * + ********/ + + //_.toPlainObject + interface LoDashStatic { + /** + * Converts value to a plain object flattening inherited enumerable properties of value to own properties + * of the plain object. + * @param value The value to convert. + * @return Returns the converted plain object. + */ + toPlainObject(value?: any): Object; + } + /************* * Objects * *************/