mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
added _.partial definitions, more forgotten type castings in tests
This commit is contained in:
@@ -469,7 +469,7 @@ result = <number>_.defer(function() { console.log('deferred'); });
|
||||
var log = _.bind(console.log, console);
|
||||
result = <number>_.delay(log, 1000, 'logged later');
|
||||
|
||||
var fibonacci = _.memoize(function(n) {
|
||||
var fibonacci = <Function>_.memoize(function(n) {
|
||||
return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
|
||||
});
|
||||
|
||||
@@ -478,16 +478,20 @@ var data = {
|
||||
'curly': { 'name': 'curly', 'age': 60 }
|
||||
};
|
||||
|
||||
var stooge = _.memoize(function(name) { return data[name]; }, _.identity);
|
||||
var stooge = <Function>_.memoize(function(name) { return data[name]; }, _.identity);
|
||||
stooge('curly');
|
||||
|
||||
stooge['cache']['curly'].name = 'jerome';
|
||||
stooge('curly');
|
||||
|
||||
var initialize = _.once(function(){ });
|
||||
var initialize = <Function>_.once(function(){ });
|
||||
initialize();
|
||||
initialize();
|
||||
|
||||
var greetPartial = function(greeting, name) { return greeting + ' ' + name; };
|
||||
var hi = <Function>_.partial(greetPartial, 'hi');
|
||||
hi('moe');
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
//WHAT'S LEFT
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Vendored
+63
-62
@@ -1868,74 +1868,75 @@ declare module _ {
|
||||
**/
|
||||
export function once(func: Function): Function;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Partially apply a function by filling in any number of its arguments, without changing its dynamic this value.
|
||||
* A close cousin of bind.
|
||||
* @param fn Function to partially fill in arguments.
|
||||
* @param arguments The partial arguments.
|
||||
* @return `fn` with partially filled in arguments.
|
||||
* Creates a function that, when called, invokes func with any additional partial arguments
|
||||
* prepended to those provided to the new function. This method is similar to _.bind except
|
||||
* it does not alter the this binding.
|
||||
* @param func The function to partially apply arguments to.
|
||||
* @param args Arguments to be partially applied.
|
||||
* @return The new partially applied function.
|
||||
**/
|
||||
export function partial(
|
||||
fn: Function,
|
||||
...arguments: any[]): Function;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly,
|
||||
* will only actually call the original function at most once per every wait milliseconds. Useful for
|
||||
|
||||
Reference in New Issue
Block a user