Comparing version 5.1.2 to 5.2.0
154
dist/cjs.js
@@ -13,86 +13,86 @@ 'use strict'; | ||
function noop() { } | ||
function toString(obj) { | ||
return Object.prototype.toString.call(obj); | ||
function toString(value) { | ||
return Object.prototype.toString.call(value); | ||
} | ||
function getType(obj) { | ||
var str = toString(obj); | ||
function getType(value) { | ||
var str = toString(value); | ||
return /^\[object (.+)\]$/i.exec(str)[1]; | ||
} | ||
function isNull(obj) { | ||
return obj === undefined || obj === null; | ||
function isNull(value) { | ||
return value === undefined || value === null; | ||
} | ||
function isFunction(obj) { | ||
if (isNull(obj)) | ||
function isFunction(value) { | ||
if (isNull(value)) | ||
return false; | ||
return typeof obj === "function"; | ||
return typeof value === "function"; | ||
} | ||
function isAsyncFunction(obj) { | ||
if (isNull(obj)) | ||
function isAsyncFunction(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "AsyncFunction"; | ||
return getType(value) === "AsyncFunction"; | ||
} | ||
function isGeneratorFunction(obj) { | ||
if (isNull(obj)) | ||
function isGeneratorFunction(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "GeneratorFunction"; | ||
return getType(value) === "GeneratorFunction"; | ||
} | ||
function isString(obj) { | ||
if (isNull(obj)) | ||
function isString(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "String"; | ||
return getType(value) === "String"; | ||
} | ||
function isNumber(obj) { | ||
if (isNull(obj)) | ||
function isNumber(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "Number"; | ||
return getType(value) === "Number"; | ||
} | ||
function isBoolean(obj) { | ||
if (isNull(obj)) | ||
function isBoolean(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "Boolean"; | ||
return getType(value) === "Boolean"; | ||
} | ||
function isElement(obj) { | ||
if (isNull(obj)) | ||
function isElement(value) { | ||
if (isNull(value)) | ||
return false; | ||
if (typeof Element !== "undefined") { | ||
return obj instanceof Element; | ||
return value instanceof Element; | ||
} | ||
else { | ||
return (obj.tagName && | ||
obj.nodeType && | ||
obj.nodeName && | ||
obj.attributes && | ||
obj.ownerDocument); | ||
return (value.tagName && | ||
value.nodeType && | ||
value.nodeName && | ||
value.attributes && | ||
value.ownerDocument); | ||
} | ||
} | ||
function isText(obj) { | ||
if (isNull(obj)) | ||
function isText(value) { | ||
if (isNull(value)) | ||
return false; | ||
return obj instanceof Text; | ||
return value instanceof Text; | ||
} | ||
function isObject(obj) { | ||
if (isNull(obj)) | ||
function isObject(value) { | ||
if (isNull(value)) | ||
return false; | ||
var type = getType(obj); | ||
var type = getType(value); | ||
return type === "Object" || type === "Array"; | ||
} | ||
function isArray(obj) { | ||
if (isNull(obj)) | ||
function isArray(value) { | ||
if (isNull(value)) | ||
return false; | ||
var v1 = getType(obj) === "Array"; | ||
var v2 = obj instanceof Array; | ||
var v3 = !isString(obj) && isNumber(obj.length) && isFunction(obj.splice); | ||
var v4 = !isString(obj) && isNumber(obj.length) && obj[0]; | ||
var v1 = getType(value) === "Array"; | ||
var v2 = value instanceof Array; | ||
var v3 = !isString(value) && isNumber(value.length) && isFunction(value.splice); | ||
var v4 = !isString(value) && isNumber(value.length) && value[0]; | ||
return v1 || v2 || v3 || v4; | ||
} | ||
function isTypedArray(obj) { | ||
return ArrayBuffer.isView(obj) && !(obj instanceof DataView); | ||
function isTypedArray(value) { | ||
return ArrayBuffer.isView(value) && !(value instanceof DataView); | ||
} | ||
function isDate(val) { | ||
if (isNull(val)) | ||
function isDate(value) { | ||
if (isNull(value)) | ||
return false; | ||
return val instanceof Date; | ||
return value instanceof Date; | ||
} | ||
function isRegExp(val) { | ||
return val instanceof RegExp; | ||
function isRegExp(value) { | ||
return value instanceof RegExp; | ||
} | ||
@@ -104,11 +104,11 @@ function toArray(array) { | ||
} | ||
function toDate(val) { | ||
if (isNumber(val)) { | ||
return new Date(val); | ||
function toDate(value) { | ||
if (isNumber(value)) { | ||
return new Date(value); | ||
} | ||
else if (isDate(val)) { | ||
return val; | ||
else if (isDate(value)) { | ||
return value; | ||
} | ||
else if (isString(val)) { | ||
return new Date(replace(replace(val, "-", "/"), "T", " ")); | ||
else if (isString(value)) { | ||
return new Date(replace(replace(value, "-", "/"), "T", " ")); | ||
} | ||
@@ -172,6 +172,6 @@ else { | ||
} | ||
function copy(src, dst, igonres) { | ||
function copy(src, dst, ignores) { | ||
dst = dst || (isArray(src) ? [] : {}); | ||
Object.keys(src).forEach(function (key) { | ||
if (igonres && igonres.indexOf(key) > -1) | ||
if (ignores && ignores.indexOf(key) > -1) | ||
return; | ||
@@ -193,3 +193,3 @@ delete dst[key]; | ||
} | ||
function clone(src, igonres) { | ||
function clone(src, ignores) { | ||
if (isNull(src) || | ||
@@ -214,5 +214,5 @@ isString(src) || | ||
var value = src[key]; | ||
if (objClone[key] !== value && !igonres.includes(key)) { | ||
if (objClone[key] !== value && !ignores.includes(key)) { | ||
if (isObject(value)) { | ||
objClone[key] = clone(value, igonres); | ||
objClone[key] = clone(value, ignores); | ||
} | ||
@@ -225,3 +225,3 @@ else { | ||
["toString", "valueOf"].forEach(function (key) { | ||
if (igonres.includes(key)) | ||
if (ignores.includes(key)) | ||
return; | ||
@@ -232,14 +232,14 @@ final(objClone, key, src[key]); | ||
} | ||
function mix(dst, src, igonres, mode, igonreNull) { | ||
function mix(dst, src, ignores, mode, ignoreNull) { | ||
if (mode) { | ||
switch (mode) { | ||
case 1: | ||
return mix(dst.prototype, src.prototype, igonres, 0); | ||
return mix(dst.prototype, src.prototype, ignores, 0); | ||
case 2: | ||
mix(dst.prototype, src.prototype, igonres, 0); | ||
mix(dst.prototype, src.prototype, ignores, 0); | ||
break; | ||
case 3: | ||
return mix(dst, src.prototype, igonres, 0); | ||
return mix(dst, src.prototype, ignores, 0); | ||
case 4: | ||
return mix(dst.prototype, src, igonres, 0); | ||
return mix(dst.prototype, src, ignores, 0); | ||
} | ||
@@ -250,5 +250,5 @@ } | ||
Object.keys(src).forEach(function (key) { | ||
if (igonres.includes(key)) | ||
if (ignores.includes(key)) | ||
return; | ||
if (igonreNull && isNull(src[key])) | ||
if (ignoreNull && isNull(src[key])) | ||
return; | ||
@@ -259,3 +259,3 @@ if (isObject(src[key]) && | ||
src[key].constructor === null)) { | ||
dst[key] = mix(dst[key], src[key], igonres, 0, igonreNull); | ||
dst[key] = mix(dst[key], src[key], ignores, 0, ignoreNull); | ||
} | ||
@@ -445,7 +445,7 @@ else { | ||
} | ||
function htmlPrefilter(html) { | ||
function filterHTML(html) { | ||
if (!html) | ||
return ""; | ||
var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi; | ||
return html.replace(rxhtmlTag, "<$1></$2>"); | ||
var tagRegExp = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi; | ||
return html.replace(tagRegExp, "<$1></$2>"); | ||
} | ||
@@ -455,3 +455,3 @@ function parseHTML(str) { | ||
var parent = document.createElement("div"); | ||
parent.innerHTML = htmlPrefilter(str); | ||
parent.innerHTML = filterHTML(str); | ||
var childNodes = toArray(parent.childNodes); | ||
@@ -468,2 +468,3 @@ childNodes.forEach(function (childNode) { return parent.removeChild(childNode); }); | ||
exports.escapeRegExp = escapeRegExp; | ||
exports.filterHTML = filterHTML; | ||
exports.final = final; | ||
@@ -476,3 +477,2 @@ exports.firstUpper = firstUpper; | ||
exports.getType = getType; | ||
exports.htmlPrefilter = htmlPrefilter; | ||
exports.isArray = isArray; | ||
@@ -479,0 +479,0 @@ exports.isAsyncFunction = isAsyncFunction; |
152
dist/es.js
@@ -9,86 +9,86 @@ var __spreadArrays = (this && this.__spreadArrays) || function () { | ||
export function noop() { } | ||
export function toString(obj) { | ||
return Object.prototype.toString.call(obj); | ||
export function toString(value) { | ||
return Object.prototype.toString.call(value); | ||
} | ||
export function getType(obj) { | ||
var str = toString(obj); | ||
export function getType(value) { | ||
var str = toString(value); | ||
return /^\[object (.+)\]$/i.exec(str)[1]; | ||
} | ||
export function isNull(obj) { | ||
return obj === undefined || obj === null; | ||
export function isNull(value) { | ||
return value === undefined || value === null; | ||
} | ||
export function isFunction(obj) { | ||
if (isNull(obj)) | ||
export function isFunction(value) { | ||
if (isNull(value)) | ||
return false; | ||
return typeof obj === "function"; | ||
return typeof value === "function"; | ||
} | ||
export function isAsyncFunction(obj) { | ||
if (isNull(obj)) | ||
export function isAsyncFunction(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "AsyncFunction"; | ||
return getType(value) === "AsyncFunction"; | ||
} | ||
export function isGeneratorFunction(obj) { | ||
if (isNull(obj)) | ||
export function isGeneratorFunction(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "GeneratorFunction"; | ||
return getType(value) === "GeneratorFunction"; | ||
} | ||
export function isString(obj) { | ||
if (isNull(obj)) | ||
export function isString(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "String"; | ||
return getType(value) === "String"; | ||
} | ||
export function isNumber(obj) { | ||
if (isNull(obj)) | ||
export function isNumber(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "Number"; | ||
return getType(value) === "Number"; | ||
} | ||
export function isBoolean(obj) { | ||
if (isNull(obj)) | ||
export function isBoolean(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "Boolean"; | ||
return getType(value) === "Boolean"; | ||
} | ||
export function isElement(obj) { | ||
if (isNull(obj)) | ||
export function isElement(value) { | ||
if (isNull(value)) | ||
return false; | ||
if (typeof Element !== "undefined") { | ||
return obj instanceof Element; | ||
return value instanceof Element; | ||
} | ||
else { | ||
return (obj.tagName && | ||
obj.nodeType && | ||
obj.nodeName && | ||
obj.attributes && | ||
obj.ownerDocument); | ||
return (value.tagName && | ||
value.nodeType && | ||
value.nodeName && | ||
value.attributes && | ||
value.ownerDocument); | ||
} | ||
} | ||
export function isText(obj) { | ||
if (isNull(obj)) | ||
export function isText(value) { | ||
if (isNull(value)) | ||
return false; | ||
return obj instanceof Text; | ||
return value instanceof Text; | ||
} | ||
export function isObject(obj) { | ||
if (isNull(obj)) | ||
export function isObject(value) { | ||
if (isNull(value)) | ||
return false; | ||
var type = getType(obj); | ||
var type = getType(value); | ||
return type === "Object" || type === "Array"; | ||
} | ||
export function isArray(obj) { | ||
if (isNull(obj)) | ||
export function isArray(value) { | ||
if (isNull(value)) | ||
return false; | ||
var v1 = getType(obj) === "Array"; | ||
var v2 = obj instanceof Array; | ||
var v3 = !isString(obj) && isNumber(obj.length) && isFunction(obj.splice); | ||
var v4 = !isString(obj) && isNumber(obj.length) && obj[0]; | ||
var v1 = getType(value) === "Array"; | ||
var v2 = value instanceof Array; | ||
var v3 = !isString(value) && isNumber(value.length) && isFunction(value.splice); | ||
var v4 = !isString(value) && isNumber(value.length) && value[0]; | ||
return v1 || v2 || v3 || v4; | ||
} | ||
export function isTypedArray(obj) { | ||
return ArrayBuffer.isView(obj) && !(obj instanceof DataView); | ||
export function isTypedArray(value) { | ||
return ArrayBuffer.isView(value) && !(value instanceof DataView); | ||
} | ||
export function isDate(val) { | ||
if (isNull(val)) | ||
export function isDate(value) { | ||
if (isNull(value)) | ||
return false; | ||
return val instanceof Date; | ||
return value instanceof Date; | ||
} | ||
export function isRegExp(val) { | ||
return val instanceof RegExp; | ||
export function isRegExp(value) { | ||
return value instanceof RegExp; | ||
} | ||
@@ -100,11 +100,11 @@ export function toArray(array) { | ||
} | ||
export function toDate(val) { | ||
if (isNumber(val)) { | ||
return new Date(val); | ||
export function toDate(value) { | ||
if (isNumber(value)) { | ||
return new Date(value); | ||
} | ||
else if (isDate(val)) { | ||
return val; | ||
else if (isDate(value)) { | ||
return value; | ||
} | ||
else if (isString(val)) { | ||
return new Date(replace(replace(val, "-", "/"), "T", " ")); | ||
else if (isString(value)) { | ||
return new Date(replace(replace(value, "-", "/"), "T", " ")); | ||
} | ||
@@ -168,6 +168,6 @@ else { | ||
} | ||
export function copy(src, dst, igonres) { | ||
export function copy(src, dst, ignores) { | ||
dst = dst || (isArray(src) ? [] : {}); | ||
Object.keys(src).forEach(function (key) { | ||
if (igonres && igonres.indexOf(key) > -1) | ||
if (ignores && ignores.indexOf(key) > -1) | ||
return; | ||
@@ -189,3 +189,3 @@ delete dst[key]; | ||
} | ||
export function clone(src, igonres) { | ||
export function clone(src, ignores) { | ||
if (isNull(src) || | ||
@@ -210,5 +210,5 @@ isString(src) || | ||
var value = src[key]; | ||
if (objClone[key] !== value && !igonres.includes(key)) { | ||
if (objClone[key] !== value && !ignores.includes(key)) { | ||
if (isObject(value)) { | ||
objClone[key] = clone(value, igonres); | ||
objClone[key] = clone(value, ignores); | ||
} | ||
@@ -221,3 +221,3 @@ else { | ||
["toString", "valueOf"].forEach(function (key) { | ||
if (igonres.includes(key)) | ||
if (ignores.includes(key)) | ||
return; | ||
@@ -228,14 +228,14 @@ final(objClone, key, src[key]); | ||
} | ||
export function mix(dst, src, igonres, mode, igonreNull) { | ||
export function mix(dst, src, ignores, mode, ignoreNull) { | ||
if (mode) { | ||
switch (mode) { | ||
case 1: | ||
return mix(dst.prototype, src.prototype, igonres, 0); | ||
return mix(dst.prototype, src.prototype, ignores, 0); | ||
case 2: | ||
mix(dst.prototype, src.prototype, igonres, 0); | ||
mix(dst.prototype, src.prototype, ignores, 0); | ||
break; | ||
case 3: | ||
return mix(dst, src.prototype, igonres, 0); | ||
return mix(dst, src.prototype, ignores, 0); | ||
case 4: | ||
return mix(dst.prototype, src, igonres, 0); | ||
return mix(dst.prototype, src, ignores, 0); | ||
default: | ||
@@ -247,5 +247,5 @@ } | ||
Object.keys(src).forEach(function (key) { | ||
if (igonres.includes(key)) | ||
if (ignores.includes(key)) | ||
return; | ||
if (igonreNull && isNull(src[key])) | ||
if (ignoreNull && isNull(src[key])) | ||
return; | ||
@@ -256,3 +256,3 @@ if (isObject(src[key]) && | ||
src[key].constructor === null)) { | ||
dst[key] = mix(dst[key], src[key], igonres, 0, igonreNull); | ||
dst[key] = mix(dst[key], src[key], ignores, 0, ignoreNull); | ||
} | ||
@@ -442,7 +442,7 @@ else { | ||
} | ||
export function htmlPrefilter(html) { | ||
export function filterHTML(html) { | ||
if (!html) | ||
return ""; | ||
var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi; | ||
return html.replace(rxhtmlTag, "<$1></$2>"); | ||
var tagRegExp = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi; | ||
return html.replace(tagRegExp, "<$1></$2>"); | ||
} | ||
@@ -452,3 +452,3 @@ export function parseHTML(str) { | ||
var parent = document.createElement("div"); | ||
parent.innerHTML = htmlPrefilter(str); | ||
parent.innerHTML = filterHTML(str); | ||
var childNodes = toArray(parent.childNodes); | ||
@@ -455,0 +455,0 @@ childNodes.forEach(function (childNode) { return parent.removeChild(childNode); }); |
154
dist/iife.js
@@ -12,86 +12,86 @@ var ntils = (function (exports) { | ||
function noop() { } | ||
function toString(obj) { | ||
return Object.prototype.toString.call(obj); | ||
function toString(value) { | ||
return Object.prototype.toString.call(value); | ||
} | ||
function getType(obj) { | ||
var str = toString(obj); | ||
function getType(value) { | ||
var str = toString(value); | ||
return /^\[object (.+)\]$/i.exec(str)[1]; | ||
} | ||
function isNull(obj) { | ||
return obj === undefined || obj === null; | ||
function isNull(value) { | ||
return value === undefined || value === null; | ||
} | ||
function isFunction(obj) { | ||
if (isNull(obj)) | ||
function isFunction(value) { | ||
if (isNull(value)) | ||
return false; | ||
return typeof obj === "function"; | ||
return typeof value === "function"; | ||
} | ||
function isAsyncFunction(obj) { | ||
if (isNull(obj)) | ||
function isAsyncFunction(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "AsyncFunction"; | ||
return getType(value) === "AsyncFunction"; | ||
} | ||
function isGeneratorFunction(obj) { | ||
if (isNull(obj)) | ||
function isGeneratorFunction(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "GeneratorFunction"; | ||
return getType(value) === "GeneratorFunction"; | ||
} | ||
function isString(obj) { | ||
if (isNull(obj)) | ||
function isString(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "String"; | ||
return getType(value) === "String"; | ||
} | ||
function isNumber(obj) { | ||
if (isNull(obj)) | ||
function isNumber(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "Number"; | ||
return getType(value) === "Number"; | ||
} | ||
function isBoolean(obj) { | ||
if (isNull(obj)) | ||
function isBoolean(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "Boolean"; | ||
return getType(value) === "Boolean"; | ||
} | ||
function isElement(obj) { | ||
if (isNull(obj)) | ||
function isElement(value) { | ||
if (isNull(value)) | ||
return false; | ||
if (typeof Element !== "undefined") { | ||
return obj instanceof Element; | ||
return value instanceof Element; | ||
} | ||
else { | ||
return (obj.tagName && | ||
obj.nodeType && | ||
obj.nodeName && | ||
obj.attributes && | ||
obj.ownerDocument); | ||
return (value.tagName && | ||
value.nodeType && | ||
value.nodeName && | ||
value.attributes && | ||
value.ownerDocument); | ||
} | ||
} | ||
function isText(obj) { | ||
if (isNull(obj)) | ||
function isText(value) { | ||
if (isNull(value)) | ||
return false; | ||
return obj instanceof Text; | ||
return value instanceof Text; | ||
} | ||
function isObject(obj) { | ||
if (isNull(obj)) | ||
function isObject(value) { | ||
if (isNull(value)) | ||
return false; | ||
var type = getType(obj); | ||
var type = getType(value); | ||
return type === "Object" || type === "Array"; | ||
} | ||
function isArray(obj) { | ||
if (isNull(obj)) | ||
function isArray(value) { | ||
if (isNull(value)) | ||
return false; | ||
var v1 = getType(obj) === "Array"; | ||
var v2 = obj instanceof Array; | ||
var v3 = !isString(obj) && isNumber(obj.length) && isFunction(obj.splice); | ||
var v4 = !isString(obj) && isNumber(obj.length) && obj[0]; | ||
var v1 = getType(value) === "Array"; | ||
var v2 = value instanceof Array; | ||
var v3 = !isString(value) && isNumber(value.length) && isFunction(value.splice); | ||
var v4 = !isString(value) && isNumber(value.length) && value[0]; | ||
return v1 || v2 || v3 || v4; | ||
} | ||
function isTypedArray(obj) { | ||
return ArrayBuffer.isView(obj) && !(obj instanceof DataView); | ||
function isTypedArray(value) { | ||
return ArrayBuffer.isView(value) && !(value instanceof DataView); | ||
} | ||
function isDate(val) { | ||
if (isNull(val)) | ||
function isDate(value) { | ||
if (isNull(value)) | ||
return false; | ||
return val instanceof Date; | ||
return value instanceof Date; | ||
} | ||
function isRegExp(val) { | ||
return val instanceof RegExp; | ||
function isRegExp(value) { | ||
return value instanceof RegExp; | ||
} | ||
@@ -103,11 +103,11 @@ function toArray(array) { | ||
} | ||
function toDate(val) { | ||
if (isNumber(val)) { | ||
return new Date(val); | ||
function toDate(value) { | ||
if (isNumber(value)) { | ||
return new Date(value); | ||
} | ||
else if (isDate(val)) { | ||
return val; | ||
else if (isDate(value)) { | ||
return value; | ||
} | ||
else if (isString(val)) { | ||
return new Date(replace(replace(val, "-", "/"), "T", " ")); | ||
else if (isString(value)) { | ||
return new Date(replace(replace(value, "-", "/"), "T", " ")); | ||
} | ||
@@ -171,6 +171,6 @@ else { | ||
} | ||
function copy(src, dst, igonres) { | ||
function copy(src, dst, ignores) { | ||
dst = dst || (isArray(src) ? [] : {}); | ||
Object.keys(src).forEach(function (key) { | ||
if (igonres && igonres.indexOf(key) > -1) | ||
if (ignores && ignores.indexOf(key) > -1) | ||
return; | ||
@@ -192,3 +192,3 @@ delete dst[key]; | ||
} | ||
function clone(src, igonres) { | ||
function clone(src, ignores) { | ||
if (isNull(src) || | ||
@@ -213,5 +213,5 @@ isString(src) || | ||
var value = src[key]; | ||
if (objClone[key] !== value && !igonres.includes(key)) { | ||
if (objClone[key] !== value && !ignores.includes(key)) { | ||
if (isObject(value)) { | ||
objClone[key] = clone(value, igonres); | ||
objClone[key] = clone(value, ignores); | ||
} | ||
@@ -224,3 +224,3 @@ else { | ||
["toString", "valueOf"].forEach(function (key) { | ||
if (igonres.includes(key)) | ||
if (ignores.includes(key)) | ||
return; | ||
@@ -231,14 +231,14 @@ final(objClone, key, src[key]); | ||
} | ||
function mix(dst, src, igonres, mode, igonreNull) { | ||
function mix(dst, src, ignores, mode, ignoreNull) { | ||
if (mode) { | ||
switch (mode) { | ||
case 1: | ||
return mix(dst.prototype, src.prototype, igonres, 0); | ||
return mix(dst.prototype, src.prototype, ignores, 0); | ||
case 2: | ||
mix(dst.prototype, src.prototype, igonres, 0); | ||
mix(dst.prototype, src.prototype, ignores, 0); | ||
break; | ||
case 3: | ||
return mix(dst, src.prototype, igonres, 0); | ||
return mix(dst, src.prototype, ignores, 0); | ||
case 4: | ||
return mix(dst.prototype, src, igonres, 0); | ||
return mix(dst.prototype, src, ignores, 0); | ||
} | ||
@@ -249,5 +249,5 @@ } | ||
Object.keys(src).forEach(function (key) { | ||
if (igonres.includes(key)) | ||
if (ignores.includes(key)) | ||
return; | ||
if (igonreNull && isNull(src[key])) | ||
if (ignoreNull && isNull(src[key])) | ||
return; | ||
@@ -258,3 +258,3 @@ if (isObject(src[key]) && | ||
src[key].constructor === null)) { | ||
dst[key] = mix(dst[key], src[key], igonres, 0, igonreNull); | ||
dst[key] = mix(dst[key], src[key], ignores, 0, ignoreNull); | ||
} | ||
@@ -444,7 +444,7 @@ else { | ||
} | ||
function htmlPrefilter(html) { | ||
function filterHTML(html) { | ||
if (!html) | ||
return ""; | ||
var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi; | ||
return html.replace(rxhtmlTag, "<$1></$2>"); | ||
var tagRegExp = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi; | ||
return html.replace(tagRegExp, "<$1></$2>"); | ||
} | ||
@@ -454,3 +454,3 @@ function parseHTML(str) { | ||
var parent = document.createElement("div"); | ||
parent.innerHTML = htmlPrefilter(str); | ||
parent.innerHTML = filterHTML(str); | ||
var childNodes = toArray(parent.childNodes); | ||
@@ -467,2 +467,3 @@ childNodes.forEach(function (childNode) { return parent.removeChild(childNode); }); | ||
exports.escapeRegExp = escapeRegExp; | ||
exports.filterHTML = filterHTML; | ||
exports.final = final; | ||
@@ -475,3 +476,2 @@ exports.firstUpper = firstUpper; | ||
exports.getType = getType; | ||
exports.htmlPrefilter = htmlPrefilter; | ||
exports.isArray = isArray; | ||
@@ -478,0 +478,0 @@ exports.isAsyncFunction = isAsyncFunction; |
154
dist/umd.js
@@ -15,86 +15,86 @@ (function (global, factory) { | ||
function noop() { } | ||
function toString(obj) { | ||
return Object.prototype.toString.call(obj); | ||
function toString(value) { | ||
return Object.prototype.toString.call(value); | ||
} | ||
function getType(obj) { | ||
var str = toString(obj); | ||
function getType(value) { | ||
var str = toString(value); | ||
return /^\[object (.+)\]$/i.exec(str)[1]; | ||
} | ||
function isNull(obj) { | ||
return obj === undefined || obj === null; | ||
function isNull(value) { | ||
return value === undefined || value === null; | ||
} | ||
function isFunction(obj) { | ||
if (isNull(obj)) | ||
function isFunction(value) { | ||
if (isNull(value)) | ||
return false; | ||
return typeof obj === "function"; | ||
return typeof value === "function"; | ||
} | ||
function isAsyncFunction(obj) { | ||
if (isNull(obj)) | ||
function isAsyncFunction(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "AsyncFunction"; | ||
return getType(value) === "AsyncFunction"; | ||
} | ||
function isGeneratorFunction(obj) { | ||
if (isNull(obj)) | ||
function isGeneratorFunction(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "GeneratorFunction"; | ||
return getType(value) === "GeneratorFunction"; | ||
} | ||
function isString(obj) { | ||
if (isNull(obj)) | ||
function isString(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "String"; | ||
return getType(value) === "String"; | ||
} | ||
function isNumber(obj) { | ||
if (isNull(obj)) | ||
function isNumber(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "Number"; | ||
return getType(value) === "Number"; | ||
} | ||
function isBoolean(obj) { | ||
if (isNull(obj)) | ||
function isBoolean(value) { | ||
if (isNull(value)) | ||
return false; | ||
return getType(obj) === "Boolean"; | ||
return getType(value) === "Boolean"; | ||
} | ||
function isElement(obj) { | ||
if (isNull(obj)) | ||
function isElement(value) { | ||
if (isNull(value)) | ||
return false; | ||
if (typeof Element !== "undefined") { | ||
return obj instanceof Element; | ||
return value instanceof Element; | ||
} | ||
else { | ||
return (obj.tagName && | ||
obj.nodeType && | ||
obj.nodeName && | ||
obj.attributes && | ||
obj.ownerDocument); | ||
return (value.tagName && | ||
value.nodeType && | ||
value.nodeName && | ||
value.attributes && | ||
value.ownerDocument); | ||
} | ||
} | ||
function isText(obj) { | ||
if (isNull(obj)) | ||
function isText(value) { | ||
if (isNull(value)) | ||
return false; | ||
return obj instanceof Text; | ||
return value instanceof Text; | ||
} | ||
function isObject(obj) { | ||
if (isNull(obj)) | ||
function isObject(value) { | ||
if (isNull(value)) | ||
return false; | ||
var type = getType(obj); | ||
var type = getType(value); | ||
return type === "Object" || type === "Array"; | ||
} | ||
function isArray(obj) { | ||
if (isNull(obj)) | ||
function isArray(value) { | ||
if (isNull(value)) | ||
return false; | ||
var v1 = getType(obj) === "Array"; | ||
var v2 = obj instanceof Array; | ||
var v3 = !isString(obj) && isNumber(obj.length) && isFunction(obj.splice); | ||
var v4 = !isString(obj) && isNumber(obj.length) && obj[0]; | ||
var v1 = getType(value) === "Array"; | ||
var v2 = value instanceof Array; | ||
var v3 = !isString(value) && isNumber(value.length) && isFunction(value.splice); | ||
var v4 = !isString(value) && isNumber(value.length) && value[0]; | ||
return v1 || v2 || v3 || v4; | ||
} | ||
function isTypedArray(obj) { | ||
return ArrayBuffer.isView(obj) && !(obj instanceof DataView); | ||
function isTypedArray(value) { | ||
return ArrayBuffer.isView(value) && !(value instanceof DataView); | ||
} | ||
function isDate(val) { | ||
if (isNull(val)) | ||
function isDate(value) { | ||
if (isNull(value)) | ||
return false; | ||
return val instanceof Date; | ||
return value instanceof Date; | ||
} | ||
function isRegExp(val) { | ||
return val instanceof RegExp; | ||
function isRegExp(value) { | ||
return value instanceof RegExp; | ||
} | ||
@@ -106,11 +106,11 @@ function toArray(array) { | ||
} | ||
function toDate(val) { | ||
if (isNumber(val)) { | ||
return new Date(val); | ||
function toDate(value) { | ||
if (isNumber(value)) { | ||
return new Date(value); | ||
} | ||
else if (isDate(val)) { | ||
return val; | ||
else if (isDate(value)) { | ||
return value; | ||
} | ||
else if (isString(val)) { | ||
return new Date(replace(replace(val, "-", "/"), "T", " ")); | ||
else if (isString(value)) { | ||
return new Date(replace(replace(value, "-", "/"), "T", " ")); | ||
} | ||
@@ -174,6 +174,6 @@ else { | ||
} | ||
function copy(src, dst, igonres) { | ||
function copy(src, dst, ignores) { | ||
dst = dst || (isArray(src) ? [] : {}); | ||
Object.keys(src).forEach(function (key) { | ||
if (igonres && igonres.indexOf(key) > -1) | ||
if (ignores && ignores.indexOf(key) > -1) | ||
return; | ||
@@ -195,3 +195,3 @@ delete dst[key]; | ||
} | ||
function clone(src, igonres) { | ||
function clone(src, ignores) { | ||
if (isNull(src) || | ||
@@ -216,5 +216,5 @@ isString(src) || | ||
var value = src[key]; | ||
if (objClone[key] !== value && !igonres.includes(key)) { | ||
if (objClone[key] !== value && !ignores.includes(key)) { | ||
if (isObject(value)) { | ||
objClone[key] = clone(value, igonres); | ||
objClone[key] = clone(value, ignores); | ||
} | ||
@@ -227,3 +227,3 @@ else { | ||
["toString", "valueOf"].forEach(function (key) { | ||
if (igonres.includes(key)) | ||
if (ignores.includes(key)) | ||
return; | ||
@@ -234,14 +234,14 @@ final(objClone, key, src[key]); | ||
} | ||
function mix(dst, src, igonres, mode, igonreNull) { | ||
function mix(dst, src, ignores, mode, ignoreNull) { | ||
if (mode) { | ||
switch (mode) { | ||
case 1: | ||
return mix(dst.prototype, src.prototype, igonres, 0); | ||
return mix(dst.prototype, src.prototype, ignores, 0); | ||
case 2: | ||
mix(dst.prototype, src.prototype, igonres, 0); | ||
mix(dst.prototype, src.prototype, ignores, 0); | ||
break; | ||
case 3: | ||
return mix(dst, src.prototype, igonres, 0); | ||
return mix(dst, src.prototype, ignores, 0); | ||
case 4: | ||
return mix(dst.prototype, src, igonres, 0); | ||
return mix(dst.prototype, src, ignores, 0); | ||
} | ||
@@ -252,5 +252,5 @@ } | ||
Object.keys(src).forEach(function (key) { | ||
if (igonres.includes(key)) | ||
if (ignores.includes(key)) | ||
return; | ||
if (igonreNull && isNull(src[key])) | ||
if (ignoreNull && isNull(src[key])) | ||
return; | ||
@@ -261,3 +261,3 @@ if (isObject(src[key]) && | ||
src[key].constructor === null)) { | ||
dst[key] = mix(dst[key], src[key], igonres, 0, igonreNull); | ||
dst[key] = mix(dst[key], src[key], ignores, 0, ignoreNull); | ||
} | ||
@@ -447,7 +447,7 @@ else { | ||
} | ||
function htmlPrefilter(html) { | ||
function filterHTML(html) { | ||
if (!html) | ||
return ""; | ||
var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi; | ||
return html.replace(rxhtmlTag, "<$1></$2>"); | ||
var tagRegExp = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi; | ||
return html.replace(tagRegExp, "<$1></$2>"); | ||
} | ||
@@ -457,3 +457,3 @@ function parseHTML(str) { | ||
var parent = document.createElement("div"); | ||
parent.innerHTML = htmlPrefilter(str); | ||
parent.innerHTML = filterHTML(str); | ||
var childNodes = toArray(parent.childNodes); | ||
@@ -470,2 +470,3 @@ childNodes.forEach(function (childNode) { return parent.removeChild(childNode); }); | ||
exports.escapeRegExp = escapeRegExp; | ||
exports.filterHTML = filterHTML; | ||
exports.final = final; | ||
@@ -478,3 +479,2 @@ exports.firstUpper = firstUpper; | ||
exports.getType = getType; | ||
exports.htmlPrefilter = htmlPrefilter; | ||
exports.isArray = isArray; | ||
@@ -481,0 +481,0 @@ exports.isAsyncFunction = isAsyncFunction; |
{ | ||
"name": "ntils", | ||
"version": "5.1.2", | ||
"version": "5.2.0", | ||
"description": "一个 Node & Browser 工具函数集", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs.js", |
export declare function noop(): void; | ||
export declare function toString(obj: any): any; | ||
export declare function getType(obj: any): string; | ||
export declare function isNull(obj: any): boolean; | ||
export declare function isFunction(obj: any): boolean; | ||
export declare function isAsyncFunction(obj: any): boolean; | ||
export declare function isGeneratorFunction(obj: any): boolean; | ||
export declare function isString(obj: any): boolean; | ||
export declare function isNumber(obj: any): boolean; | ||
export declare function isBoolean(obj: any): boolean; | ||
export declare function isElement(obj: any): any; | ||
export declare function isText(obj: any): boolean; | ||
export declare function isObject(obj: any): boolean; | ||
export declare function isArray(obj: any): boolean; | ||
export declare function isTypedArray(obj: any): boolean; | ||
export declare function isDate(val: any): boolean; | ||
export declare function isRegExp(val: any): boolean; | ||
export declare function toString(value: any): any; | ||
export declare function getType(value: any): string; | ||
export declare function isNull(value: any): value is null; | ||
export declare function isFunction(value: any): value is Function; | ||
export declare function isAsyncFunction(value: any): value is Function; | ||
export declare function isGeneratorFunction(value: any): value is GeneratorFunction; | ||
export declare function isString(value: any): value is string; | ||
export declare function isNumber(value: any): value is number; | ||
export declare function isBoolean(value: any): value is boolean; | ||
export declare function isElement(value: any): value is Element; | ||
export declare function isText(value: any): value is Text; | ||
export declare function isObject(value: any): value is object; | ||
export declare function isArray(value: any): value is any[]; | ||
export declare function isTypedArray(value: any): boolean; | ||
export declare function isDate(value: any): value is Date; | ||
export declare function isRegExp(value: any): value is RegExp; | ||
export declare function toArray<T = any>(array: any): T[]; | ||
export declare function toDate(val: any): Date; | ||
export declare function toDate(value: any): Date; | ||
export declare function replace(str: string, from: string, to: string): string; | ||
export declare function formatDate(value: Date | number | string, format: string, dict?: any): string; | ||
export declare function each(list: any, handler: (key: string | number, value: any) => any, scope: any): any; | ||
export declare function copy(src: any, dst?: any, igonres?: string[]): any; | ||
export declare function clone(src: any, igonres?: string[]): any; | ||
export declare function mix(dst: any, src: any, igonres?: string[], mode?: 0 | 1 | 2 | 3 | 4, igonreNull?: boolean): any; | ||
export declare function copy(src: any, dst?: any, ignores?: string[]): any; | ||
export declare function clone(src: any, ignores?: string[]): any; | ||
export declare function mix(dst: any, src: any, ignores?: string[], mode?: 0 | 1 | 2 | 3 | 4, ignoreNull?: boolean): any; | ||
export declare function final(obj: any, name: string, value: any): void; | ||
@@ -31,3 +31,3 @@ export declare function deepEqual(a: any, b: any): boolean; | ||
export declare function setByPath(obj: any, path: string | string[], value: any): void; | ||
export declare function getByPath(obj: any, path: string | string[], filter?: (valeu?: any, key?: string, obj?: any) => boolean): any; | ||
export declare function getByPath(obj: any, path: string | string[], filter?: (value?: any, key?: string, obj?: any) => boolean): any; | ||
export declare function getFunctionArgumentNames(fn: Function): string[]; | ||
@@ -42,3 +42,3 @@ export declare const FUNC_REGEXP: RegExp; | ||
export declare function toSplitCase(str: string): string; | ||
export declare function htmlPrefilter(html: string): string; | ||
export declare function filterHTML(html: string): string; | ||
export declare function parseHTML(str: string): ChildNode[]; |
62214