d2-utilizr
Advanced tools
Comparing version 0.0.14 to 0.0.15
121
index.js
@@ -12,4 +12,5 @@ 'use strict'; | ||
exports.isPrimitive = isPrimitive; | ||
exports.isEmpty = isEmpty; | ||
exports.isIE = isIE; | ||
exports.isEmpty = isEmpty; | ||
exports.stringReplaceAll = stringReplaceAll; | ||
exports.numberConstrain = numberConstrain; | ||
@@ -23,7 +24,10 @@ exports.arrayPluck = arrayPluck; | ||
exports.arraySort = arraySort; | ||
exports.clone = clone; | ||
exports.uuid = uuid; | ||
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } | ||
// type | ||
// TYPE | ||
// isString | ||
function isString(param) { | ||
@@ -33,2 +37,3 @@ return typeof param === 'string'; | ||
// isNumber | ||
function isNumber(param) { | ||
@@ -38,2 +43,3 @@ return typeof param === 'number' && isFinite(param); | ||
// isNumeric | ||
function isNumeric(param) { | ||
@@ -43,4 +49,6 @@ return !isNaN(parseFloat(param)) && isFinite(param); | ||
// isArray | ||
var isArray = exports.isArray = Array.isArray; | ||
// isObject | ||
var isObject = exports.isObject = (function () { | ||
@@ -54,2 +62,3 @@ return toString.call(null) === '[object Object]' ? function (param) { | ||
// isFunction | ||
var isFunction = exports.isFunction = (function () { | ||
@@ -63,2 +72,3 @@ return typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function' ? function (value) { | ||
// isBoolean | ||
function isBoolean(param) { | ||
@@ -68,2 +78,3 @@ return typeof param === 'boolean'; | ||
// isDefined | ||
function isDefined(param) { | ||
@@ -73,2 +84,3 @@ return typeof param !== 'undefined'; | ||
// isPrimitive | ||
function isPrimitive(param) { | ||
@@ -79,2 +91,8 @@ var type = typeof param === 'undefined' ? 'undefined' : _typeof(param); | ||
// isEmpty (dependency: isArray) | ||
function isEmpty(array, allowEmptyString) { | ||
return array == null || (!allowEmptyString ? array === '' : false) || isArray(array) && array.length === 0; | ||
} | ||
// isIE | ||
function isIE() { | ||
@@ -111,9 +129,12 @@ var ua = window.navigator.userAgent; | ||
// dependency: isArray | ||
function isEmpty(array, allowEmptyString) { | ||
return array == null || (!allowEmptyString ? array === '' : false) || isArray(array) && array.length === 0; | ||
// STRING | ||
// stringReplaceAll | ||
function stringReplaceAll(str1, str2, ignore) { | ||
return this.replace(new RegExp(str1.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g, "\\$&"), ignore ? "gi" : "g"), typeof str2 == "string" ? str2.replace(/\$/g, "$$$$") : str2); | ||
} | ||
// number | ||
// NUMBER | ||
// numberConstrain | ||
function numberConstrain(number, min, max) { | ||
@@ -131,2 +152,3 @@ number = parseFloat(number); | ||
// numberToFixed | ||
var numberToFixed = exports.numberToFixed = (function () { | ||
@@ -142,4 +164,5 @@ return 0.9.toFixed() !== '1' ? function (value, precision) { | ||
// array | ||
// ARRAY | ||
// arrayPluck | ||
function arrayPluck(array, propertyName) { | ||
@@ -160,2 +183,3 @@ var newArray = []; | ||
// arrayUnique | ||
function arrayUnique(array) { | ||
@@ -178,2 +202,3 @@ var newArray = []; | ||
// arrayContains | ||
function arrayContains(array, item) { | ||
@@ -183,3 +208,3 @@ return Array.prototype.indexOf.call(array, item) !== -1; | ||
// dependency: isArray | ||
// arrayFrom (dependency: isArray) | ||
function arrayFrom(param, isNewRef) { | ||
@@ -228,3 +253,3 @@ var toArray = function toArray(iterable, start, end) { | ||
// dependency: isString, isArray, isObject | ||
// arrayTo (dependency: isString, isArray, isObject) | ||
function arrayTo(param) { | ||
@@ -252,3 +277,3 @@ if (isArray(param)) { | ||
// dependency: isEmpty | ||
// arrayClean (dependency: isEmpty) | ||
function arrayClean(array) { | ||
@@ -271,3 +296,3 @@ var results = [], | ||
// dependency: isString, isNumber, isArray | ||
// arraySort (dependency: isString, isNumber, isArray) | ||
function arraySort(array, direction, key, emptyFirst) { | ||
@@ -323,2 +348,76 @@ // supports [number], [string], [{key: number}], [{key: string}], [[string]], [[number]] | ||
// MISC | ||
// clone | ||
var enumerables = (function () { | ||
var enu = ['valueOf', 'toLocaleString', 'toString', 'constructor']; | ||
for (var i in { toString: 1 }) { | ||
enu = null; | ||
} | ||
return enu; | ||
})(); | ||
var cloneFn = function cloneFn(item) { | ||
if (item === null || item === undefined) { | ||
return item; | ||
} | ||
if (item.nodeType && item.cloneNode) { | ||
return item.cloneNode(true); | ||
} | ||
var type = toString.call(item), | ||
i, | ||
j, | ||
k, | ||
clone, | ||
key; | ||
if (type === '[object Date]') { | ||
return new Date(item.getTime()); | ||
} | ||
if (type === '[object Array]') { | ||
i = item.length; | ||
clone = []; | ||
while (i--) { | ||
clone[i] = fn(item[i]); | ||
} | ||
} else if (type === '[object Object]' && item.constructor === Object) { | ||
clone = {}; | ||
for (key in item) { | ||
clone[key] = fn(item[key]); | ||
} | ||
if (enumerables) { | ||
for (j = enumerables.length; j--;) { | ||
k = enumerables[j]; | ||
if (item.hasOwnProperty(k)) { | ||
clone[k] = item[k]; | ||
} | ||
} | ||
} | ||
} | ||
return clone || item; | ||
}; | ||
function clone(item) { | ||
return cloneFn(item); | ||
} | ||
// uuid | ||
function uuid() { | ||
var s4 = function s4() { | ||
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); | ||
}; | ||
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "d2-utilizr", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
19512
614