From 1e057a85a2a50ffa350bcca05b5fb918445157a4 Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Fri, 5 Feb 2016 23:10:32 +0500 Subject: [PATCH] lodash: changed _.unset --- lodash/lodash-tests.ts | 28 +++++++++++++++++++++++++ lodash/lodash.d.ts | 46 ++++++++++++++++++++++++++++-------------- 2 files changed, 59 insertions(+), 15 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 66f0bf2cab..92ee8330b0 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -8919,6 +8919,34 @@ module TestTransform { } } +// _.unset +namespace TestUnset { + type SampleObject = {a: {b: string; c: boolean}}; + + let object: SampleObject; + + { + let result: boolean; + + _.unset(object, 'a.b'); + _.unset(object, ['a', 'b']); + } + + { + let result: _.LoDashImplicitWrapper; + + result = _(object).unset('a.b'); + result = _(object).unset(['a', 'b']); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(object).chain().unset('a.b'); + result = _(object).chain().unset(['a', 'b']); + } +} + // _.values module TestValues { let object: _.Dictionary; diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index aaa8dc7e3c..bb428ffb55 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -4270,21 +4270,6 @@ declare module _ { ): any[]; } - //_.unset - interface LoDashStatic { - /** - * Removes the property at path of object. - * - * @param object The object to modify. - * @param path The path of the property to unset. - * @return Returns true if the property is deleted, else false. - */ - unset( - object: T, - path: StringRepresentable | StringRepresentable[] - ): boolean; - } - //_.unzip interface LoDashStatic { /** @@ -14826,6 +14811,37 @@ declare module _ { ): LoDashImplicitArrayWrapper; } + //_.unset + interface LoDashStatic { + /** + * Removes the property at path of object. + * + * Note: This method mutates object. + * + * @param object The object to modify. + * @param path The path of the property to unset. + * @return Returns true if the property is deleted, else false. + */ + unset( + object: T, + path: StringRepresentable|StringRepresentable[] + ): boolean; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.unset + */ + unset(path: StringRepresentable|StringRepresentable[]): LoDashImplicitWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.unset + */ + unset(path: StringRepresentable|StringRepresentable[]): LoDashExplicitWrapper; + } + //_.values interface LoDashStatic { /**