You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
16 KiB
30 lines
16 KiB
<!DOCTYPE html><meta charset="UTF-8"><meta http-equiv="Content-Language" content="en" /><title>goog.functions</title><link href="dossier.css" rel="stylesheet" type="text/css"><div id="main-wrapper"><input type="checkbox" id="sidenav-toggle" /><main><header><h1>Namespace goog.functions</h1><a class="source" href="source/lib/goog/functions/functions.js.src.html#l23">code »</a></header><section></section><div id="visibility-controls"><b>Show:</b><label for="show-public"><span><input type="checkbox" id="show-public" checked/></span>Public</label><label for="show-protected"><span><input type="checkbox" id="show-protected"/></span>Protected</label><label for="show-private"><span><input type="checkbox" id="show-private"/></span>Private</label></div><section id="static-functions"><h2>Global Functions</h2><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l43">code »</a><span class="member"><a name="goog.functions.FALSE">goog.functions.FALSE</a> <span class="args">( )</span> ⇒ <code class="type">boolean</code></span></div><p>Always returns false.</summary></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l57">code »</a><span class="member"><a name="goog.functions.NULL">goog.functions.NULL</a> <span class="args">( )</span> ⇒ <code class="type">null</code></span></div><p>Always returns NULL.</summary></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l50">code »</a><span class="member"><a name="goog.functions.TRUE">goog.functions.TRUE</a> <span class="args">( )</span> ⇒ <code class="type">boolean</code></span></div><p>Always returns true.</summary></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l192">code »</a><span class="member"><a name="goog.functions.and">goog.functions.and</a> <span class="args">( var_args )</span> ⇒ <code class="type">function(?): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Creates a function that returns true if each of its components evaluates
|
|
to true. The components are evaluated in order, and the evaluation will be
|
|
short-circuited as soon as a function returns false.
|
|
For example, (goog.functions.and(f, g))(x) is equivalent to f(x) && g(x).</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>var_args: <code class="type">...<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>A list of functions.</dl><tr><th>Returns<tr><td><dl>A function that ANDs its component
|
|
functions.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l295">code »</a><code class="type"><T></code> <span class="member"><a name="goog.functions.cacheReturnValue">goog.functions.cacheReturnValue</a> <span class="args">( fn )</span> ⇒ <code class="type">!function(): T</code></span></div><p>Gives a wrapper function that caches the return value of a parameterless
|
|
function when first called.
|
|
|
|
When called for the first time, the given function is called and its
|
|
return value is cached (thus this is only appropriate for idempotent
|
|
functions). Subsequent calls will return the cached return value. This
|
|
allows the evaluation of expensive functions to be delayed until first used.
|
|
|
|
To cache the return values of functions with parameters, see goog.memoize.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>fn: <code class="type">!function(): T</code><dd>A function to lazily evaluate.</dl><tr><th>Returns<tr><td><dl>A wrapped version the function.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l146">code »</a><code class="type"><T></code> <span class="member"><a name="goog.functions.compose">goog.functions.compose</a> <span class="args">( fn, var_args )</span> ⇒ <code class="type">function(?): T</code></span></div><p>Creates the composition of the functions passed in.
|
|
For example, (goog.functions.compose(f, g))(a) is equivalent to f(g(a)).</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>fn: <code class="type">function(?): T</code><dd>The final function.<dt>var_args: <code class="type">...<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>A list of functions.</dl><tr><th>Returns<tr><td><dl>The composition of all inputs.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l32">code »</a><code class="type"><T></code> <span class="member"><a name="goog.functions.constant">goog.functions.constant</a> <span class="args">( retValue )</span> ⇒ <code class="type">function(): T</code></span></div><p>Creates a function that always returns the same value.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>retValue: <code class="type">T</code><dd>The value to return.</dl><tr><th>Returns<tr><td><dl>The new function.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l253">code »</a><span class="member"><a name="goog.functions.create">goog.functions.create</a> <span class="args">( constructor, var_args )</span> ⇒ <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code></span></div><p>Generic factory function to construct an object given the constructor
|
|
and the arguments. Intended to be bound to create object factories.
|
|
|
|
Callers should cast the result to the appropriate type for proper type
|
|
checking by the compiler.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>constructor: <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The constructor for the Object.<dt>var_args: <code class="type">...*</code><dd>The arguments to be passed to the constructor.</dl><tr><th>Returns<tr><td><dl>A new instance of the class given in <code >constructor</code>.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l78">code »</a><span class="member"><a name="goog.functions.error">goog.functions.error</a> <span class="args">( message )</span> ⇒ <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code></span></div><p>Creates a function that always throws an error with the given message.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>message: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The error message.</dl><tr><th>Returns<tr><td><dl>The error-throwing function.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l90">code »</a><span class="member"><a name="goog.functions.fail">goog.functions.fail</a> <span class="args">( err )</span> ⇒ <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code></span></div><p>Creates a function that throws the given object.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>err: <code class="type">*</code><dd>An object to be thrown.</dl><tr><th>Returns<tr><td><dl>The error-throwing function.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l68">code »</a><code class="type"><T></code> <span class="member"><a name="goog.functions.identity">goog.functions.identity</a> <span class="args">( opt_returnValue, var_args )</span> ⇒ <code class="type">T</code></span></div><p>A simple function that returns the first argument of whatever is passed
|
|
into it.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>opt_returnValue: <code class="type">T=</code><dd>The single value that will be returned.<dt>var_args: <code class="type">...*</code><dd>Optional trailing arguments. These are ignored.</dl><tr><th>Returns<tr><td><dl>The first argument passed in, or undefined if nothing was passed.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l105">code »</a><span class="member"><a name="goog.functions.lock">goog.functions.lock</a> <span class="args">( f, opt_numArgs )</span> ⇒ <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code></span></div><p>Given a function, create a function that keeps opt_numArgs arguments and
|
|
silently discards all additional arguments.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>f: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The original function.<dt>opt_numArgs: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>The number of arguments to keep. Defaults to 0.</dl><tr><th>Returns<tr><td><dl>A version of f that only keeps the first opt_numArgs
|
|
arguments.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l236">code »</a><span class="member"><a name="goog.functions.not">goog.functions.not</a> <span class="args">( f )</span> ⇒ <code class="type">function(?): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Creates a function that returns the Boolean opposite of a provided function.
|
|
For example, (goog.functions.not(f))(x) is equivalent to !f(x).</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>f: <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The original function.</dl><tr><th>Returns<tr><td><dl>A function that delegates to f and returns
|
|
opposite.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l118">code »</a><span class="member"><a name="goog.functions.nth">goog.functions.nth</a> <span class="args">( n )</span> ⇒ <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code></span></div><p>Creates a function that returns its nth argument.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>n: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></code><dd>The position of the return argument.</dl><tr><th>Returns<tr><td><dl>A new function.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l215">code »</a><span class="member"><a name="goog.functions.or">goog.functions.or</a> <span class="args">( var_args )</span> ⇒ <code class="type">function(?): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div><p>Creates a function that returns true if any of its components evaluates
|
|
to true. The components are evaluated in order, and the evaluation will be
|
|
short-circuited as soon as a function returns true.
|
|
For example, (goog.functions.or(f, g))(x) is equivalent to f(x) || g(x).</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>var_args: <code class="type">...<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>A list of functions.</dl><tr><th>Returns<tr><td><dl>A function that ORs its component
|
|
functions.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l170">code »</a><span class="member"><a name="goog.functions.sequence">goog.functions.sequence</a> <span class="args">( var_args )</span> ⇒ <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code></span></div><p>Creates a function that calls the functions passed in in sequence, and
|
|
returns the value of the last function. For example,
|
|
(goog.functions.sequence(f, g))(x) is equivalent to f(x),g(x).</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>var_args: <code class="type">...<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>A list of functions.</dl><tr><th>Returns<tr><td><dl>A function that calls all inputs in sequence.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l133">code »</a><code class="type"><T></code> <span class="member"><a name="goog.functions.withReturnValue">goog.functions.withReturnValue</a> <span class="args">( f, retValue )</span> ⇒ <code class="type">function(?): T</code></span></div><p>Given a function, create a new function that swallows its return value
|
|
and replaces it with a new one.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>f: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>A function.<dt>retValue: <code class="type">T</code><dd>A new return value.</dl><tr><th>Returns<tr><td><dl>A new function.</dl></table></div></details></div></div></section><section id="compiler-constants"><h2>Compiler Constants</h2><div class="wrap-details public"><div><details><summary><div><a class="source" href="source/lib/goog/functions/functions.js.src.html#l277">code »</a><span class="member"><a name="goog.functions.CACHE_RETURN_VALUE">goog.functions.CACHE_RETURN_VALUE</a> : <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></code></span></div></summary></details></div></div></section></main><nav id="topnav"><div><div id="menubutton"><label for="sidenav-toggle">Menu</label></div><form id="searchbox"><div><input type="search" placeholder="Search" tabindex="1"></div></form></div></nav><nav id="sidenav"><input type="checkbox" id="sidenav-types-ctrl" /><input type="checkbox" id="sidenav-files-ctrl" /><input type="checkbox" id="sidenav-modules-ctrl" /><a id="sidenav-overview"><div><h4>Overview</h4></div></a><div id="sidenav-types"><label for="sidenav-types-ctrl"><h4>Types</h4></label><i>No data</i></div><div id="sidenav-modules"><label for="sidenav-modules-ctrl"><h4>Modules</h4></label><i>No data</i></div><div id="sidenav-files"><label for="sidenav-files-ctrl"><h4>Files</h4></label><i>No data</i></div><a href="license.html"><div><h4>License</h4></div></a></nav><div id="push-footer"></div></div><footer><a href="https://github.com/jleyba/js-dossier">Generated by dossier</a></footer><script src="types.js"></script><script src="dossier.js"></script> |