nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / jqTree / lib / util.js
1 var _indexOf, getBoolString, html_escape, indexOf, isFunction, isInt;
2
3 _indexOf = function(array, item) {
4   var i, j, len, value;
5   for (i = j = 0, len = array.length; j < len; i = ++j) {
6     value = array[i];
7     if (value === item) {
8       return i;
9     }
10   }
11   return -1;
12 };
13
14 indexOf = function(array, item) {
15   if (array.indexOf) {
16     return array.indexOf(item);
17   } else {
18     return _indexOf(array, item);
19   }
20 };
21
22 isInt = function(n) {
23   return typeof n === 'number' && n % 1 === 0;
24 };
25
26 isFunction = function(v) {
27   return typeof v === 'function';
28 };
29
30 html_escape = function(string) {
31   return ('' + string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g, '&#x2F;');
32 };
33
34 getBoolString = function(value) {
35   if (value) {
36     return 'true';
37   } else {
38     return 'false';
39   }
40 };
41
42 module.exports = {
43   _indexOf: _indexOf,
44   getBoolString: getBoolString,
45   html_escape: html_escape,
46   indexOf: indexOf,
47   isInt: isInt,
48   isFunction: isFunction
49 };