nanoscope
Version:
A Lens Library for Javascript
82 lines (60 loc) • 2.5 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: array/utils.js</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">Source: array/utils.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>var normalizeIndex, isValidIndex;
/**
* Normalize a negative index to pull from the end of an array.
*
* @param arr
* @param index
* @returns {*}
*/
normalizeIndex = function (arr, index) {
if (index < 0) {
return arr.length + index;
}
return index;
};
/**
* Checks if the index being accessed is allowed to be accessed
*
* @param arr
* @param index
* @returns {boolean}
*/
isValidIndex = function (arr, index) {
return index >= 0 && index <= arr.length;
};
module.exports = {
normalizeIndex: normalizeIndex,
isValidIndex: isValidIndex
};</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Compose.html">Compose</a></li><li><a href="Getter.html">Getter</a></li><li><a href="IndexedLens.html">IndexedLens</a></li><li><a href="IndexedLens.Unsafe.html">Unsafe</a></li><li><a href="Lens.html">Lens</a></li><li><a href="MultiLens.html">MultiLens</a></li><li><a href="Optional.html">Optional</a></li><li><a href="PathLens.html">PathLens</a></li><li><a href="PathLens.Unsafe.html">Unsafe</a></li><li><a href="Setter.html">Setter</a></li><li><a href="SliceLens.html">SliceLens</a></li></ul><h3>Global</h3><ul><li><a href="global.html#get">get</a></li><li><a href="global.html#IdLens">IdLens</a></li><li><a href="global.html#isValidIndex">isValidIndex</a></li><li><a href="global.html#normalizeIndex">normalizeIndex</a></li><li><a href="global.html#over">over</a></li></ul>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha11</a> on Thu Dec 11 2014 10:52:43 GMT-0500 (EST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>