Merge pull request #6026 from chrootsu/lodash-matchesProperty

lodash: added _.matchesProperty() method
This commit is contained in:
Masahiro Wakame
2015-10-06 23:20:10 +09:00
2 changed files with 60 additions and 0 deletions
+18
View File
@@ -2696,6 +2696,24 @@ module TestMatches {
}
}
// _.matchesProperty
module TestMatches {
let path: {toString(): string;}|{toString(): string;}[];
let source: TResult;
{
let result: (value: any) => boolean;
result = _.matchesProperty<TResult>(path, source);
result = _(path).matchesProperty<TResult>(source).value();
}
{
let result: (value: TResult) => boolean;
result = _.matchesProperty<TResult, TResult>(path, source);
result = _(path).matchesProperty<TResult, TResult>(source).value();
}
}
// _.method
class TestMethod {
a = {
+42
View File
@@ -8654,6 +8654,48 @@ declare module _ {
matches<V>(): LoDashObjectWrapper<(value: V) => boolean>;
}
//_.matchesProperty
interface LoDashStatic {
/**
* Creates a function that compares the property value of path on a given object to value.
*
* Note: This method supports comparing arrays, booleans, Date objects, numbers, Object objects, regexes, and
* strings. Objects are compared by their own, not inherited, enumerable properties.
*
* @param path The path of the property to get.
* @param srcValue The value to match.
* @return Returns the new function.
*/
matchesProperty<T>(
path: StringRepresentable|StringRepresentable[],
srcValue: T
): (value: any) => boolean;
/**
* @see _.matchesProperty
*/
matchesProperty<T, V>(
path: StringRepresentable|StringRepresentable[],
srcValue: T
): (value: V) => boolean;
}
interface LoDashWrapperBase<T, TWrapper> {
/**
* @see _.matchesProperty
*/
matchesProperty<SrcValue>(
srcValue: SrcValue
): LoDashObjectWrapper<(value: any) => boolean>;
/**
* @see _.matchesProperty
*/
matchesProperty<SrcValue, Value>(
srcValue: SrcValue
): LoDashObjectWrapper<(value: Value) => boolean>;
}
//_.method
interface LoDashStatic {
/**