mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Merge pull request #8757 from chrootsu/lodash-memoize
lodash: changed _.memoize
This commit is contained in:
commit
e12c8e3bcd
@ -6162,20 +6162,42 @@ namespace TestFlowRight {
|
||||
|
||||
// _.memoize
|
||||
namespace TestMemoize {
|
||||
var testMemoizedFunction: _.MemoizedFunction;
|
||||
var cache = <_.MapCache>testMemoizedFunction.cache;
|
||||
interface TestMemoizedResultFn extends _.MemoizedFunction {
|
||||
{
|
||||
let memoizedFunction: _.MemoizedFunction;
|
||||
let cache: _.MapCache = memoizedFunction.cache;
|
||||
}
|
||||
|
||||
interface MemoizedResultFn extends _.MemoizedFunction {
|
||||
(a1: string, a2: number): boolean;
|
||||
}
|
||||
var testMemoizeFn = (a1: string, a2: number) => a1.length > a2;
|
||||
var testMemoizeResolverFn = (a1: string, a2: number) => a1 + a2;
|
||||
var result: TestMemoizedResultFn;
|
||||
result = _.memoize(testMemoizeFn);
|
||||
result = _.memoize(testMemoizeFn, testMemoizeResolverFn);
|
||||
result = _(testMemoizeFn).memoize().value();
|
||||
result = _(testMemoizeFn).memoize(testMemoizeResolverFn).value();
|
||||
result('foo', 1);
|
||||
result.cache.get('foo1');
|
||||
|
||||
let memoizeFn: (a1: string, a2: number) => boolean;
|
||||
let memoizeResolverFn: (a1: string, a2: number) => string;
|
||||
|
||||
{
|
||||
let result: MemoizedResultFn;
|
||||
|
||||
result = _.memoize(memoizeFn);
|
||||
result = _.memoize(memoizeFn, memoizeResolverFn);
|
||||
|
||||
result('foo', 1);
|
||||
result.cache.get('foo1');
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitObjectWrapper<MemoizedResultFn>;
|
||||
|
||||
result = _(memoizeFn).memoize();
|
||||
result = _(memoizeFn).memoize(memoizeResolverFn);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitObjectWrapper<MemoizedResultFn>;
|
||||
|
||||
result = _(memoizeFn).chain().memoize();
|
||||
result = _(memoizeFn).chain().memoize(memoizeResolverFn);
|
||||
}
|
||||
|
||||
_.memoize.Cache = {
|
||||
delete: key => false,
|
||||
get: key => undefined,
|
||||
|
||||
8
lodash/lodash-3.10.d.ts
vendored
8
lodash/lodash-3.10.d.ts
vendored
@ -9820,6 +9820,7 @@ declare module _ {
|
||||
* storing the result based on the arguments provided to the memoized function. By default, the first argument
|
||||
* provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with
|
||||
* the this binding of the memoized function.
|
||||
*
|
||||
* @param func The function to have its output memoized.
|
||||
* @param resolver The function to resolve the cache key.
|
||||
* @return Returns the new memoizing function.
|
||||
@ -9837,6 +9838,13 @@ declare module _ {
|
||||
memoize(resolver?: Function): LoDashImplicitObjectWrapper<T & MemoizedFunction>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.memoize
|
||||
*/
|
||||
memoize(resolver?: Function): LoDashExplicitObjectWrapper<T & MemoizedFunction>;
|
||||
}
|
||||
|
||||
//_.modArgs
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
@ -6066,20 +6066,42 @@ namespace TestFlowRight {
|
||||
|
||||
// _.memoize
|
||||
namespace TestMemoize {
|
||||
var testMemoizedFunction: _.MemoizedFunction;
|
||||
var cache = <_.MapCache>testMemoizedFunction.cache;
|
||||
interface TestMemoizedResultFn extends _.MemoizedFunction {
|
||||
{
|
||||
let memoizedFunction: _.MemoizedFunction;
|
||||
let cache: _.MapCache = memoizedFunction.cache;
|
||||
}
|
||||
|
||||
interface MemoizedResultFn extends _.MemoizedFunction {
|
||||
(a1: string, a2: number): boolean;
|
||||
}
|
||||
var testMemoizeFn = (a1: string, a2: number) => a1.length > a2;
|
||||
var testMemoizeResolverFn = (a1: string, a2: number) => a1 + a2;
|
||||
var result: TestMemoizedResultFn;
|
||||
result = _.memoize(testMemoizeFn);
|
||||
result = _.memoize(testMemoizeFn, testMemoizeResolverFn);
|
||||
result = _(testMemoizeFn).memoize().value();
|
||||
result = _(testMemoizeFn).memoize(testMemoizeResolverFn).value();
|
||||
result('foo', 1);
|
||||
result.cache.get('foo1');
|
||||
|
||||
let memoizeFn: (a1: string, a2: number) => boolean;
|
||||
let memoizeResolverFn: (a1: string, a2: number) => string;
|
||||
|
||||
{
|
||||
let result: MemoizedResultFn;
|
||||
|
||||
result = _.memoize(memoizeFn);
|
||||
result = _.memoize(memoizeFn, memoizeResolverFn);
|
||||
|
||||
result('foo', 1);
|
||||
result.cache.get('foo1');
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitObjectWrapper<MemoizedResultFn>;
|
||||
|
||||
result = _(memoizeFn).memoize();
|
||||
result = _(memoizeFn).memoize(memoizeResolverFn);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitObjectWrapper<MemoizedResultFn>;
|
||||
|
||||
result = _(memoizeFn).chain().memoize();
|
||||
result = _(memoizeFn).chain().memoize(memoizeResolverFn);
|
||||
}
|
||||
|
||||
_.memoize.Cache = {
|
||||
delete: key => false,
|
||||
get: key => undefined,
|
||||
|
||||
8
lodash/lodash.d.ts
vendored
8
lodash/lodash.d.ts
vendored
@ -10545,6 +10545,7 @@ declare module _ {
|
||||
* storing the result based on the arguments provided to the memoized function. By default, the first argument
|
||||
* provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with
|
||||
* the this binding of the memoized function.
|
||||
*
|
||||
* @param func The function to have its output memoized.
|
||||
* @param resolver The function to resolve the cache key.
|
||||
* @return Returns the new memoizing function.
|
||||
@ -10562,6 +10563,13 @@ declare module _ {
|
||||
memoize(resolver?: Function): LoDashImplicitObjectWrapper<T & MemoizedFunction>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.memoize
|
||||
*/
|
||||
memoize(resolver?: Function): LoDashExplicitObjectWrapper<T & MemoizedFunction>;
|
||||
}
|
||||
|
||||
//_.overArgs (was _.modArgs)
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user