node-query/docs/helpers.js.html

255 lines
5.5 KiB
HTML
Raw Normal View History

2014-10-20 16:56:45 -04:00
<!DOCTYPE html>
2014-10-23 10:53:16 -04:00
2014-10-20 16:56:45 -04:00
<html lang="en">
<head>
2014-10-23 10:53:16 -04:00
<meta charset="utf-8">
<title>DocStrap Source: helpers.js</title>
2014-10-20 16:56:45 -04:00
2014-10-23 10:53:16 -04:00
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
2014-10-20 16:56:45 -04:00
2014-10-23 10:53:16 -04:00
<link type="text/css" rel="stylesheet" href="styles/site.cosmo.css">
2014-10-20 16:56:45 -04:00
2014-10-23 10:53:16 -04:00
</head>
2014-10-20 16:56:45 -04:00
2014-10-23 10:53:16 -04:00
<body>
<div class="container-fluid">
<div class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<a class="brand" href="index.html">DocStrap</a>
<ul class="nav">
<li class="dropdown">
<a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li>
<a href="module-adapter.html">adapter</a>
</li>
<li>
<a href="module-driver.html">driver</a>
</li>
<li>
<a href="module-helpers.html">helpers</a>
</li>
<li>
<a href="module-node-query.html">node-query</a>
</li>
<li>
<a href="module-query-builder.html">query-builder</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<div id="main">
<h1 class="page-title">Source: helpers.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
2014-10-20 16:56:45 -04:00
/** @module helpers */
2014-10-20 16:56:45 -04:00
2014-10-23 10:53:16 -04:00
require('./es6-polyfill');
/** @alias module:helpers */
2014-10-23 10:53:16 -04:00
var h = {
/**
* Wrap String.prototype.trim in a way that is easily mappable
*
* @param {String} str - The string to trim
* @return {String} - The trimmed string
*/
stringTrim: function(str) {
return str.trim();
},
2014-10-20 16:56:45 -04:00
/**
* Split a string by a character, trim the string
* and rejoin the string
*
* @param {String} char
* @param {String} string
* @return {String}
*/
splitTrim: function(char, string) {
2014-10-23 10:53:16 -04:00
return string.split(char).map(h.stringTrim).join(char);
2014-10-20 16:56:45 -04:00
},
/**
2014-10-23 10:53:16 -04:00
* Get the type of the variable passed
*
* @see https://techblog.badoo.com/blog/2013/11/01/type-checking-in-javascript/
* @see http://toddmotto.com/understanding-javascript-types-and-reliable-type-checking/
* @param {mixed} o
* @return {String}
2014-10-20 16:56:45 -04:00
*/
2014-10-23 10:53:16 -04:00
type: function (o) {
var type = Object.prototype.toString.call(o).slice(8, -1).toLowerCase();
// handle NaN and Infinity
if (type === 'number') {
if (isNaN(o)) {
return 'nan';
}
if (!isFinite(o)) {
return 'infinity';
}
}
return type;
2014-10-20 16:56:45 -04:00
},
/**
2014-10-23 10:53:16 -04:00
* Determine whether an object is scalar
*
2014-10-20 16:56:45 -04:00
* @param {mixed} obj
* @return {bool}
*/
2014-10-23 10:53:16 -04:00
isScalar: function(obj) {
var scalar = ['string', 'number', 'boolean'];
return scalar.indexOf(h.type(obj)) !== -1;
2014-10-20 16:56:45 -04:00
}
};
2014-10-23 10:53:16 -04:00
// Define an 'is' method for each type
var types = ['Null','Undefined','Object','Array','String','Number','Boolean','Function','RegExp','NaN','Infinite'];
types.forEach(function (t) {
/**
* Determine whether a variable is of the type specified in the
* function name, eg isNumber
*
* Types available are Null, Undefined, Object, Array, String, Number, Boolean, Function, RegExp, NaN and Infinite
*
* @name is[type]
* @param {mixed} o
* @return {Boolean}
*/
2014-10-23 10:53:16 -04:00
h['is' + t] = function (o) {
return h.type(o) === t.toLowerCase();
};
});
module.exports = h;</pre>
</article>
</section>
</div>
<div class="clearfix"></div>
<footer>
<span class="copyright">
DocStrap Copyright © 2012-2014 The contributors to the JSDoc3 and DocStrap projects.
</span>
<br />
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a>
on Thu Oct 23rd 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
<br clear="both">
</div>
</div>
<!--<script src="scripts/sunlight.js"></script>-->
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/bootstrap-dropdown.js"></script>
<script src="scripts/toc.js"></script>
<script>
$( function () {
$( "[id*='$']" ).each( function () {
var $this = $( this );
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
} );
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
return $( heading ).attr( "id" ) || ( prefix + i );
},
selectors : "h1,h2,h3,h4",
showAndHide : false,
scrollTo : "100px"
} );
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
$( '.dropdown-toggle' ).dropdown();
// $( ".tutorial-section pre, .readme-section pre" ).addClass( "sunlight-highlight-javascript" ).addClass( "linenums" );
$( ".tutorial-section pre, .readme-section pre" ).each( function () {
var $this = $( this );
var example = $this.find( "code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html( exampleText );
lang = lang[1];
} else {
lang = "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : true,
showMenu : true,
enableDoclinks : true
} );
} );
</script>
<!--Navigation and Symbol Display-->
<!--Google Analytics-->
2014-10-20 16:56:45 -04:00
</body>
</html>