lodash: added _.propertyOf() method

This commit is contained in:
Ilya Mochalov
2015-08-13 01:35:30 +05:00
parent da995655d8
commit 8ccedd8242
2 changed files with 29 additions and 0 deletions
+11
View File
@@ -1439,6 +1439,17 @@ result = <string>_.result(object, 'stuff');
var tempObject = {};
result = <typeof _>_.runInContext(tempObject);
// _.propertyOf
interface TestPropertyOfObject {
a: {
b: number[];
}
}
var testPropertyOfObject: TestPropertyOfObject;
result = <(path: string|string[]) => any>_.propertyOf({});
result = <(path: string|string[]) => any>_.propertyOf<TestPropertyOfObject>(testPropertyOfObject);
result = <(path: string|string[]) => any>_({}).propertyOf().value();
result = <_.TemplateExecutor>_.template('hello <%= name %>');
result = <string>_.template('<b><%- value %></b>', { 'value': '<script>' });
+18
View File
@@ -7242,6 +7242,24 @@ declare module _ {
property<T,RT>(key: string): (obj: T) => RT;
}
//_.propertyOf
interface LoDashStatic {
/**
* The opposite of _.property; this method creates a function that returns the property value at a given path
* on object.
* @param object The object to query.
* @return Returns the new function.
*/
propertyOf<T extends {}>(object: T): (path: string|string[]) => any;
}
interface LoDashObjectWrapper<T> {
/**
* @see _.propertyOf
*/
propertyOf(): LoDashObjectWrapper<(path: string|string[]) => any>;
}
//_.random
interface LoDashStatic {
/**