Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Util.js v0.5 and above.

Syntax

Code Block
themeEclipse
languagejavascript
linenumberstrue
// create new function based on existing one with one or more pre-defined arguments
var fNew = fExisting.uCurry(cArgs);
 
// use the new function optionally specifying additional arguments
fNew(args);

Where fExisting is any existing function.

...

ValueTypeDescriptionUtil.js version
<fNew>FunctionA new function which will automatically set the cArgs arguments for fExisting and then append any additional arguments passed in to fNew.0.5
<fExisting>FunctionIf you do not specify cArgs then the existing function will be returned.0.5

Example

Code Block
themeEclipse
languagejavascript
titleBasic example - pre-defining "not" and "a" params of a "booler" function
linenumberstrue
function booler(not,a,b) {
  return (not) ? a!=b : a==b;
}
var isMe = booler.uCurry(false,me); // not == false, a = me
isMe(7); // true if me == 7, false if me != 7
 
var isNotMe = booler.uCurry(true,me);
isMe(7); // true if me != 7, false if me == 7

A good better example is shown in Object.uAddProperty() example using a curried allianceExistsBetween() function.

...