1086 lines
14 KiB
HTML
Raw Normal View History

2020-05-19 11:43:42 +03:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Runtime</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: Runtime</h1>
<section>
<header>
<h2>Runtime</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Runtime"><span class="type-signature"></span>new Runtime<span class="signature">(mf)</span><span class="type-signature"></span></h4>
<div class="description">
<p>A set of utility functions that are called by the compiled Javascript
functions, these are included locally in the output of <a href="MessageFormat.html#compile">compile()</a>.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>mf</code></td>
<td class="type">
<span class="param-type"><a href="MessageFormat.html">MessageFormat</a></span>
</td>
<td class="description last"><p>A MessageFormat instance</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="runtime.js.html">runtime.js</a>, <a href="runtime.js.html#line11">line 11</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="number"><span class="type-signature"></span>number<span class="signature">(value, name, offset<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {number|string}</span></h4>
<div class="description">
<p>Utility function for <code>#</code> in plural rules</p>
<p> Will throw an Error if <code>value</code> has a non-numeric value and <code>offset</code> is
non-zero or <a href="MessageFormat.html#setStrictNumberSign">MessageFormat#setStrictNumberSign</a> is set.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>The value to operate on</p></td>
</tr>
<tr>
<td class="name"><code>name</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="default">
</td>
<td class="description last"><p>The name of the argument, used for error reporting</p></td>
</tr>
<tr>
<td class="name"><code>offset</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
0
</td>
<td class="description last"><p>An optional offset, set by the surrounding context</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="runtime.js.html">runtime.js</a>, <a href="runtime.js.html#line19">line 19</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>The result of applying the offset to the input value</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">number</span>
|
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="plural"><span class="type-signature"></span>plural<span class="signature">(value, offset, lcfunc, data, isOrdinal<span class="signature-attributes">nullable</span>)</span><span class="type-signature"> &rarr; {string}</span></h4>
<div class="description">
<p>Utility function for <code>{N, plural|selectordinal, ...}</code></p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The key to use to find a pluralization rule</p></td>
</tr>
<tr>
<td class="name"><code>offset</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>An offset to apply to <code>value</code></p></td>
</tr>
<tr>
<td class="name"><code>lcfunc</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>A locale function from <code>pluralFuncs</code></p></td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Object.&lt;string, string></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The object from which results are looked up</p></td>
</tr>
<tr>
<td class="name"><code>isOrdinal</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last"><p>If true, use ordinal rather than cardinal rules</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="runtime.js.html">runtime.js</a>, <a href="runtime.js.html#line71">line 71</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>The result of the pluralization</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="select"><span class="type-signature"></span>select<span class="signature">(value, data)</span><span class="type-signature"> &rarr; {string}</span></h4>
<div class="description">
<p>Utility function for <code>{N, select, ...}</code></p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>The key to use to find a selection</p></td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Object.&lt;string, string></span>
</td>
<td class="description last"><p>The object from which results are looked up</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="runtime.js.html">runtime.js</a>, <a href="runtime.js.html#line86">line 86</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>The result of the select statement</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h4 class="name" id="setStrictNumber"><span class="type-signature"></span>setStrictNumber<span class="signature">(enable<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
<p>Set how strictly the number method parses its input.</p>
<p> According to the ICU MessageFormat spec, <code>#</code> can only be used to replace a
number input of a <code>plural</code> statement. By default, messageformat.js does not
throw a runtime error if you use non-numeric argument with a <code>plural</code> rule,
unless rule also includes a non-zero <code>offset</code>.</p>
<p> This is called by <a href="MessageFormat.html#setStrictNumberSign">MessageFormat#setStrictNumberSign</a> to follow the
stricter ICU MessageFormat spec.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>enable</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="default">
false
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="runtime.js.html">runtime.js</a>, <a href="runtime.js.html#line57">line 57</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Compiler.html">Compiler</a></li><li><a href="MessageFormat.html">MessageFormat</a></li><li><a href="Runtime.html">Runtime</a></li></ul><h3>Namespaces</h3><ul><li><a href="MessageFormat.formatters.html">formatters</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Tue Sep 27 2016 00:30:24 GMT+0300 (EEST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>