docs/more.html
<!DOCTYPE html>
<html>
<head>
<title>more.js</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To …</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page">
<a class="source" href="ajax.html">
ajax.js
</a>
<a class="source" href="anim.html">
anim.js
</a>
<a class="source" href="core.html">
core.js
</a>
<a class="source" href="detect.html">
detect.js
</a>
<a class="source" href="dom.html">
dom.js
</a>
<a class="source" href="end.html">
end.js
</a>
<a class="source" href="evt.html">
evt.js
</a>
<a class="source" href="fx.html">
fx.js
</a>
<a class="source" href="legacy.html">
legacy.js
</a>
<a class="source" href="misc.html">
misc.js
</a>
<a class="source" href="more.html">
more.js
</a>
<a class="source" href="polyfill.html">
polyfill.js
</a>
<a class="source" href="sizzle.html">
sizzle.js
</a>
<a class="source" href="start.html">
start.js
</a>
<a class="source" href="test.html">
test.js
</a>
<a class="source" href="util.html">
util.js
</a>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>more.js</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">¶</a>
</div>
</div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">¶</a>
</div>
<hr>
</div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">¶</a>
</div>
<h2 id="more-functionality">More Functionality</h2>
</div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">¶</a>
</div>
</div>
<div class="content"><div class='highlight'><pre>
<span class="hljs-comment">/**
* NumberObject Class
*
* @constructor
* @class NumberObject
* @param {Number} num Number
* @example
* <div class="code"><pre class="prettyprint">
* new NumberObject(2);
* </pre></div>
* <div class="code"><pre class="prettyprint">
* new NumberObject(Math.PI);
* </pre></div>
* @since 0.1.0
*/</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">NumberObject</span> <span class="hljs-params">(num)</span> </span>{
<span class="hljs-keyword">this</span>.num = num;
}
extend(NumberObject.prototype, {
<span class="hljs-comment">/**
* NumberObject.MAX_INTEGER = 9007199254740991
* The maximum value of a JavaScript integer
*
* @for NumberObject
* @property MAX_INTEGER
* @type Number
* @since 0.1.0
*/</span>
MAX_INTEGER: <span class="hljs-number">9007199254740991</span>,
<span class="hljs-comment">/**
* Epsilon
*
* @for NumberObject
* @property EPSILON
* @type Number
* @since 0.1.0
*/</span>
EPSILON: <span class="hljs-number">2.220446049250313e-16</span>,
<span class="hljs-comment">/**
* Parses integer value from a string or number
*
* @for NumberObject
* @method parseInt
* @return {Number}
* @example
* <div class="code"><pre class="prettyprint">
* new NumberObject(3.5).parseInt() // 3
* </pre></div>
* @since 0.1.0
*/</span>
<span class="hljs-built_in">parseInt</span>: <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">()</span> </span>{
<span class="hljs-built_in">parseInt</span>.call(<span class="hljs-keyword">this</span>, <span class="hljs-keyword">this</span>.num);
},
<span class="hljs-comment">/**
* Parses float point number value from a string or number
*
* @for NumberObject
* @method parseFloat
* @return {Number}
* @example
* <div class="code"><pre class="prettyprint">
* new NumberObject("5.3").parseFloat() // 5.3
* </pre></div>
* @since 0.1.0
*/</span>
<span class="hljs-built_in">parseFloat</span>: <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">()</span> </span>{
<span class="hljs-built_in">parseFloat</span>.call(<span class="hljs-keyword">this</span>, <span class="hljs-keyword">this</span>.num);
},
<span class="hljs-comment">/**
* Returns true if a number is a finite value
*
* @for NumberObject
* @method isFinite
* @return {Bolean} Whether the number is finite
* @example
* <div class="code"><pre class="prettyprint">
* new NumberObject(NaN).isFinite() // false
* new NumberObject(3).isFinite() // true
* </pre></div>
* @since 0.1.0
*/</span>
<span class="hljs-built_in">isFinite</span>: <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> </span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">typeof</span> <span class="hljs-keyword">this</span>.num === <span class="hljs-string">'number'</span> && <span class="hljs-built_in">isFinite</span>(<span class="hljs-keyword">this</span>.num);
},
<span class="hljs-comment">/**
* If the number is an integer
*
* @for NumberObject
* @method isInteger
* @return {Number} Whether the number is an integer
* @example
* <div class="code"><pre class="prettyprint">
* new NumberObject(5.3).isInteger() // false
* new NumberObject(4).isInteger() // true
* </pre></div>
* @since 0.1.0
*/</span>
isInteger: <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> </span>{
<span class="hljs-keyword">return</span> <span class="hljs-keyword">typeof</span> <span class="hljs-keyword">this</span>.num === <span class="hljs-string">'number'</span> &&
!<span class="hljs-built_in">isNaN</span>(<span class="hljs-keyword">this</span>.num) &&
<span class="hljs-built_in">isFinite</span>(<span class="hljs-keyword">this</span>.num) &&
<span class="hljs-built_in">parseInt</span>(<span class="hljs-keyword">this</span>.num, <span class="hljs-number">10</span>) === <span class="hljs-keyword">this</span>.num;
},
<span class="hljs-comment">/**
* Returns if the number is NaN (Not a number)
*
* @for NumberObject
* @method isNan
* @return {Number} Whether the number is not a number (NaN)
* @example
* <div class="code"><pre class="prettyprint">
* new NumberObject(5).isNan() // false
* new NumberObject(NaN).isNan() // true
* </pre></div>
* @since 0.1.0
*/</span>
<span class="hljs-built_in">isNaN</span>: <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> </span>{</pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">¶</a>
</div>
<p>NaN !== NaN, but they are identical.
NaNs are the only non-reflexive value, i.e., if x !== x,
then x is NaN.
isNaN is broken: it converts its argument to number, so
isNaN(‘foo’) => true</p>
</div>
<div class="content"><div class='highlight'><pre> <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>.num !== <span class="hljs-keyword">this</span>.num;
},
<span class="hljs-comment">/**
* Converts ant value to an integer
*
* @for NumberObject
* @method toInteger
* @return {Number} The converted integer
* @example
* <div class="code"><pre class="prettyprint">
* new NumberObject(5).toInteger() // 5
* new NumberObject(NaN).toInteger() // 0
* </pre></div>
* @since 0.1.0
*/</span>
toInteger: <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> </span>{
<span class="hljs-keyword">var</span> number = +<span class="hljs-keyword">this</span>.num;
<span class="hljs-keyword">if</span> (<span class="hljs-built_in">isNaN</span>(number)) {
<span class="hljs-keyword">return</span> <span class="hljs-number">0</span>;
}
<span class="hljs-keyword">if</span> (number === <span class="hljs-number">0</span> || !<span class="hljs-built_in">isFinite</span>(number)) {
<span class="hljs-keyword">return</span> number;
}
<span class="hljs-keyword">return</span> sign.call(<span class="hljs-keyword">this</span>, number) * <span class="hljs-built_in">Math</span>.floor(<span class="hljs-built_in">Math</span>.abs(number));
},
sign: <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">(value)</span> </span>{
sign.call(<span class="hljs-keyword">this</span>, <span class="hljs-keyword">this</span>.num, value);
},
<span class="hljs-comment">/**
* Call a function n times
*
* @for NumberObject
* @method times
* @param {Function} fn The function to be called
* @param {Array} args The arguments to be passed
* @return {Number} The converted integer
* @example
* <div class="code"><pre class="prettyprint">
* var i = 0;
* new NumberObject(100).times(function () {
* console.log(i++);
* });
* </pre></div>
* <div class="code"><pre class="prettyprint">
* new NumberObject(100).times(function () {
* consolee.log
* });
* </pre></div>
* @since 0.1.0
*/</span>
times: <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">(fn, args)</span> </span>{
<span class="hljs-keyword">var</span> _i = <span class="hljs-number">0</span>;
<span class="hljs-keyword">while</span> (_i < <span class="hljs-keyword">this</span>.num) {
fn.apply(<span class="hljs-keyword">this</span>, args);
_i += <span class="hljs-number">1</span>;
}
}
});</pre></div></div>
</li>
</ul>
</div>
</body>
</html>