lodash: added set() method

This commit is contained in:
Ilya Mochalov
2015-07-21 14:14:50 +05:00
parent 8f51d25ad3
commit d2bdc152ac
2 changed files with 17 additions and 0 deletions
+3
View File
@@ -1080,6 +1080,9 @@ result = <HasName>_.pick({ 'name': 'moe', '_userid': 'moe1' }, function (value,
return key.charAt(0) != '_';
});
result = <{ a: { b: { c: number; }}[]}>_.set({ 'a': [{ 'b': { 'c': 3 } }] }, 'a[0].b.c', 4);
result = <number[]>_.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function (r: number[], num: number) {
num *= num;
if (num % 2) {
+14
View File
@@ -6235,6 +6235,20 @@ declare module _ {
thisArg?: any): Picked;
}
//_.set
interface LoDashStatic {
/**
* Sets the property value of path on object. If a portion of path does not exist it is created.
* @param object The object to augment.
* @param path The path of the property to set.
* @param value The value to set.
* @return Returns object.
**/
set<T>(object: T,
path: string|string[],
value: any): T;
}
//_.transform
interface LoDashStatic {
/**