Comparing version 6.0.3 to 6.1.0-beta.1
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -11,3 +11,2 @@ * Released under the MIT License. | ||
require('./_bindContext.js'); | ||
require('./hasOwn.js'); | ||
var _forOwn = require('./_forOwn.js'); | ||
@@ -14,0 +13,0 @@ |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -10,3 +10,3 @@ * Released under the MIT License. | ||
function _forIn (value, iterator, context) { | ||
function forIn (value, iterator, context) { | ||
iterator = _bindContext(iterator, context); | ||
@@ -19,2 +19,2 @@ for (var key in value) { | ||
module.exports = _forIn; | ||
module.exports = forIn; |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -13,3 +13,3 @@ * Released under the MIT License. | ||
for (var i = 0; i < value; i++) { | ||
i = iterator(i, i, value) === false ? value : i; | ||
iterator(i, i, value) === false && (i = value); | ||
} | ||
@@ -16,0 +16,0 @@ } |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -9,19 +9,20 @@ * Released under the MIT License. | ||
var _bindContext = require('./_bindContext.js'); | ||
var hasOwn = require('./hasOwn.js'); | ||
// import hasOwn from './hasOwn'; | ||
function forOwn (value, iterator, context) { | ||
iterator = _bindContext(iterator, context); | ||
// const keys = Object.keys(value); | ||
// const len = keys.length; | ||
// for (let i = 0, key; i < len; i++) { | ||
// key = keys[i]; | ||
// i = iterator(value[key], key, value) === false ? len : i; | ||
var keys = Object.keys(value); | ||
var len = keys.length; | ||
for (var i = 0, key = (void 0); i < len; i++) { | ||
key = keys[i]; | ||
iterator(value[key], key, value) === false && (i = len); | ||
} | ||
// for (let key in value) { | ||
// if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
// break; | ||
// } | ||
// } | ||
for (var key in value) { | ||
if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
break; | ||
} | ||
} | ||
} | ||
module.exports = forOwn; |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -13,3 +13,3 @@ * Released under the MIT License. | ||
for (var i = start; i < end; i++) { | ||
i = iterator(value[i], i, value) === false ? end : i; | ||
iterator(value[i], i, value) === false && (i = end); | ||
} | ||
@@ -16,0 +16,0 @@ } |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
287
amd.js
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -28,20 +28,17 @@ * Released under the MIT License. | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function hasOwn (obj, key) { | ||
return hasOwnProperty.call(obj, key); | ||
} | ||
// import hasOwn from './hasOwn'; | ||
function forOwn (value, iterator, context) { | ||
iterator = bindContext(iterator, context); | ||
// const keys = Object.keys(value); | ||
// const len = keys.length; | ||
// for (let i = 0, key; i < len; i++) { | ||
// key = keys[i]; | ||
// i = iterator(value[key], key, value) === false ? len : i; | ||
var keys = Object.keys(value); | ||
var len = keys.length; | ||
for (var i = 0, key = (void 0); i < len; i++) { | ||
key = keys[i]; | ||
iterator(value[key], key, value) === false && (i = len); | ||
} | ||
// for (let key in value) { | ||
// if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
// break; | ||
// } | ||
// } | ||
for (var key in value) { | ||
if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
break; | ||
} | ||
} | ||
} | ||
@@ -65,3 +62,3 @@ | ||
for (var i = start; i < end; i++) { | ||
i = iterator(value[i], i, value) === false ? end : i; | ||
iterator(value[i], i, value) === false && (i = end); | ||
} | ||
@@ -74,3 +71,3 @@ } | ||
function _forIn (value, iterator, context) { | ||
function forIn (value, iterator, context) { | ||
iterator = bindContext(iterator, context); | ||
@@ -86,6 +83,32 @@ for (var key in value) { | ||
for (var i = 0; i < value; i++) { | ||
i = iterator(i, i, value) === false ? value : i; | ||
iterator(i, i, value) === false && (i = value); | ||
} | ||
} | ||
function isString (value) { | ||
return typeof value === 'string'; | ||
} | ||
var PROP_NAME_REGEX = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; | ||
var ESCAPE_CHAR_REGEX = /\\(\\)?/g; | ||
var IS_DEEP_PROP_REGEX = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; | ||
function get (object, path) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
return object[path]; | ||
} | ||
var part; | ||
PROP_NAME_REGEX.lastIndex = 0; | ||
while (!isNil(object) && (part = PROP_NAME_REGEX.exec(path))) { | ||
var match = part[0]; | ||
var number = part[1]; | ||
var quote = part[2]; | ||
var subString = part[3]; | ||
var prop = quote ? subString.replace(ESCAPE_CHAR_REGEX, '$1') : (number || match); | ||
object = object[prop]; | ||
} | ||
return object; | ||
} | ||
function isNumber (value) { | ||
@@ -119,4 +142,132 @@ return typeof value === 'number'; | ||
function isObject (value) { | ||
return value !== null && typeof value === 'object'; | ||
} | ||
function afterCall (obj, methodName, after) { | ||
if (isObject(obj)) { | ||
var old = obj[methodName]; | ||
obj[methodName] = function () { | ||
old.apply(this, arguments); | ||
return after.apply(this, arguments); | ||
}; | ||
} | ||
} | ||
function each (value, iterator, context) { | ||
!isNil(value) && forOwn(value, iterator, context); | ||
} | ||
var isArray = Array.isArray; | ||
function alias (proto, mappings) { | ||
if (isObject(proto)) { | ||
each(mappings, function (mapping, key) { | ||
key = proto[key]; | ||
isArray(mapping) | ||
? mapping.forEach(function (m) { return (proto[m] = key); }) | ||
: (proto[mapping] = key); | ||
}); | ||
} | ||
} | ||
function aroundCall (obj, method, around) { | ||
if (isObject(obj)) { | ||
var old = obj[method]; | ||
obj[method] = function () { | ||
var args = [], len = arguments.length; | ||
while ( len-- ) args[ len ] = arguments[ len ]; | ||
return around.call(this, old, args); | ||
}; | ||
} | ||
} | ||
function assert (condition, msg) { | ||
if (!condition) { | ||
throw new Error(msg); | ||
} | ||
} | ||
var assign = Object.assign || _assign; | ||
function assign$1(target, nextSource) { | ||
var copy; | ||
!isNil(nextSource) && forOwn(nextSource, function (nextVal, nextKey) { | ||
copy = target[nextKey]; | ||
isObject(copy) && isObject(nextVal) | ||
? assign$1(copy, nextVal) | ||
: (target[nextKey] = nextVal); | ||
}); | ||
} | ||
function assignDeep (target) { | ||
if (isNil(target)) { | ||
throw new TypeError('Cannot convert undefined or null to object'); | ||
} | ||
var to = Object(target); | ||
loop(arguments, 1, arguments.length, function (nextSource) { | ||
assign$1(to, nextSource); | ||
}); | ||
return to; | ||
} | ||
function beforeCall (obj, methodName, before) { | ||
if (isObject(obj)) { | ||
var old = obj[methodName]; | ||
obj[methodName] = function () { | ||
before.apply(this, arguments); | ||
return old.apply(this, arguments); | ||
}; | ||
} | ||
} | ||
function copy(value) { | ||
return isObject(value) | ||
? assign({}, value) | ||
: value; | ||
} | ||
var isArray$1 = Array.isArray; | ||
function copyDeep(value) { | ||
var target = value; | ||
if (isArray$1(value)) { | ||
target = []; | ||
value.forEach(function (val, i) { | ||
target[i] = copyDeep(val); | ||
}); | ||
} else if (isObject(value)) { | ||
target = {}; | ||
forOwn(value, function (val, key) { | ||
target[key] = copyDeep(val); | ||
}); | ||
} | ||
return target; | ||
} | ||
function copy$1 (value, deep) { | ||
return deep ? copyDeep(value) : copy(value); | ||
} | ||
function debounce (fn, wait) { | ||
var timeout = null; | ||
function cancel() { | ||
if (timeout !== null) { | ||
clearTimeout(timeout); | ||
timeout = null; | ||
} | ||
} | ||
function debounce() { | ||
cancel(); | ||
timeout = setTimeout(fn, wait); | ||
} | ||
debounce.cancel = cancel; | ||
return debounce; | ||
} | ||
function isFunction (value) { | ||
@@ -130,3 +281,3 @@ return typeof value === 'function'; | ||
function each (value, cb, context) { | ||
function each$1 (value, cb, context) { | ||
if (isArrayLike(value)) { | ||
@@ -141,6 +292,11 @@ forEach(value, cb, context); | ||
function isObject (value) { | ||
return value !== null && typeof value === 'object'; | ||
function forIn$1 (value, iterator, context) { | ||
!isNil(value) && forIn(value, iterator, context); | ||
} | ||
function get$1 (object, path, defaultValue) { | ||
var result = isNil(object) ? undefined : get(object, path); | ||
return result === undefined ? defaultValue : result; | ||
} | ||
var UID_PROPERTY = 'celia_uid_' + ((Math.random() * 1e9) >>> 0); | ||
@@ -151,2 +307,3 @@ var uidCounter = 0; | ||
return obj[UID_PROPERTY] || (++uidCounter, Object.defineProperty(obj, UID_PROPERTY, { | ||
configurable: true, | ||
value: uidCounter | ||
@@ -162,2 +319,7 @@ }), uidCounter); | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function hasOwn (obj, key) { | ||
return hasOwnProperty.call(obj, key); | ||
} | ||
var PROTOCOL = /^([a-z][a-z\d+\-.]*:)?\/\//i; | ||
@@ -221,6 +383,2 @@ | ||
function isString (value) { | ||
return typeof value === 'string'; | ||
} | ||
function isUndefined (value) { | ||
@@ -234,3 +392,3 @@ return typeof value === 'undefined'; | ||
var isArray = Array.isArray; | ||
var isArray$2 = Array.isArray; | ||
function looseEqual(a, b) { | ||
@@ -241,3 +399,3 @@ if (a === b) { | ||
if (isObject(a) && isObject(b)) { | ||
if (isArray(a) && isArray(b)) { // 判断是否是数组 | ||
if (isArray$2(a) && isArray$2(b)) { // 判断是否是数组 | ||
return a.length === b.length && a.every(function (e, i) { | ||
@@ -262,7 +420,62 @@ return looseEqual(e, b[i]); | ||
function map$1 (elems, callback, context) { | ||
return map(each, elems, callback, context); | ||
return map(each$1, elems, callback, context); | ||
} | ||
function mapObject (elems, callback, context) { | ||
var ret = {}; | ||
var cb = bindContext(callback, context); | ||
each(elems, function (elem, key) { | ||
elem = cb(elem, key); | ||
!isNil(elem) && (ret[key] = elem); | ||
}); | ||
return ret; | ||
} | ||
function noop() { } | ||
function set (object, path, value) { | ||
if (!isNil(object)) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
object[path] = value; | ||
return; | ||
} | ||
var part; | ||
var queue = []; | ||
var i = 0; | ||
var key; | ||
PROP_NAME_REGEX.lastIndex = 0; | ||
while ((part = PROP_NAME_REGEX.exec(path))) { | ||
var match = part[0]; | ||
var number = part[1]; | ||
var quote = part[2]; | ||
var subString = part[3]; | ||
var obj = (void 0); | ||
if (quote) { | ||
key = subString.replace(ESCAPE_CHAR_REGEX, '$1'); | ||
obj = object[key]; | ||
if (isNil(obj)) { | ||
obj = object[key] = {}; | ||
} | ||
} else if (number) { | ||
obj = object[key = number]; | ||
if (isNil(obj)) { | ||
obj = object[number] = []; | ||
} | ||
} else { | ||
obj = object[key = match]; | ||
if (isNil(obj)) { | ||
obj = object[match] = {}; | ||
} | ||
} | ||
object = obj; | ||
queue[i++] = obj; | ||
} | ||
object = queue[i - 2]; | ||
object[key] = value; | ||
} | ||
} | ||
function sleep (ms) { | ||
@@ -290,6 +503,7 @@ return new Promise(function (resolve) { | ||
exports._forEach = forEach; | ||
exports._forIn = _forIn; | ||
exports._forIn = forIn; | ||
exports._forNumber = forNumber; | ||
exports._forOwn = forOwn; | ||
exports._forSlice = forSlice; | ||
exports._get = get; | ||
exports._isInteger = _isInteger; | ||
@@ -299,4 +513,15 @@ exports._loop = loop; | ||
exports._repeat = _repeat; | ||
exports.afterCall = afterCall; | ||
exports.alias = alias; | ||
exports.aroundCall = aroundCall; | ||
exports.assert = assert; | ||
exports.assign = assign; | ||
exports.each = each; | ||
exports.assignDeep = assignDeep; | ||
exports.beforeCall = beforeCall; | ||
exports.copy = copy$1; | ||
exports.debounce = debounce; | ||
exports.each = each$1; | ||
exports.forIn = forIn$1; | ||
exports.forOwn = each; | ||
exports.get = get$1; | ||
exports.getEasyHash = getEasyHash; | ||
@@ -324,3 +549,5 @@ exports.getUid = getUid; | ||
exports.map = map$1; | ||
exports.mapObject = mapObject; | ||
exports.noop = noop; | ||
exports.set = set; | ||
exports.sleep = sleep; | ||
@@ -327,0 +554,0 @@ exports.toString = toString$1; |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
* Released under the MIT License. | ||
*/ | ||
define(["exports"],function(n){"use strict";function u(n,t){return n[n.length]=t,n}function c(n){return null==n}function t(n,t,r,e){for(;t<r;t++)e(n[t],t,n)}function f(n,t){return t?n.bind(t):n}var r=Object.prototype.hasOwnProperty;function o(n,t){return r.call(n,t)}function e(n,t,r){for(var e in t=f(t,r),n)if(o(n,e)&&!1===t(n[e],e,n))break}function i(n){if(c(n))throw new TypeError("Cannot convert undefined or null to object");var r=Object(n);return t(arguments,1,arguments.length,function(n){c(n)||e(n,function(n,t){r[t]=n})}),r}function a(n,t,r,e,o){e=f(e,o);for(var i=t;i<r;i++)i=!1===e(n[i],i,n)?r:i}function s(n,t,r){a(n,0,n.length,t,r)}function l(n,t,r){t=f(t,r);for(var e=0;e<n;e++)e=!1===t(e,e,n)?n:e}function b(n){return"number"==typeof n}function p(n){return b(n)&&isFinite(n)&&n>>0===n}function y(n,t,r,e){var o=[],i=f(r,e);return n(t,function(n,t){c(n=i(n,t))||u(o,n)}),o}var g=Object.assign||i;function v(n){return"function"==typeof n}function d(n){return!c(n)&&b(n.length)&&!v(n)}function h(n,t,r){d(n)?s(n,t,r):b(n)?l(n,t,r):c(n)||e(n,t,r)}function j(n){return null!==n&&"object"==typeof n}var O="celia_uid_"+(1e9*Math.random()>>>0),_=0;function m(n){return n[O]||(++_,Object.defineProperty(n,O,{value:_}),_)}var w=/^([a-z][a-z\d+\-.]*:)?\/\//i;var E=Object.prototype.toString;function A(n){return E.call(n)}function S(n){return n instanceof Date}var F={false:!0,null:!0,undefined:!0,0:!0,NaN:!0,"":!0};var N=Number.isInteger||p;function k(n){return n instanceof RegExp}var x=Array.isArray;var P={};"Boolean,Number,String,Function,AsyncFunction,Array,Date,RegExp,Object,Error,Symbol".split(",").forEach(function(n){P["[object "+n+"]"]=n.toLowerCase()}),n._append=u,n._assign=i,n._bindContext=f,n._forEach=s,n._forIn=function(n,t,r){for(var e in t=f(t,r),n)if(!1===t(n[e],e))break},n._forNumber=l,n._forOwn=e,n._forSlice=a,n._isInteger=p,n._loop=t,n._map=y,n._repeat=function(n,t,r){for(;n<t;n++)r(n,t)},n.assign=g,n.each=h,n.getEasyHash=function(n){return j(n)?"o"+m(n):(typeof n)[0]+n},n.getUid=m,n.hasOwn=o,n.isAbsoluteURL=function(n){return w.test(n)},n.isArrayLike=d,n.isAsyncFunction=function(n){return"[object AsyncFunction]"===A(n)},n.isBoolean=function(n){return"boolean"==typeof n},n.isDate=S,n.isFalsy=function(n){return!!F[n]},n.isFunction=v,n.isInteger=N,n.isNil=c,n.isNumber=b,n.isObject=j,n.isPlainObject=function(n){return!c(n)&&"[object Object]"===A(n)},n.isPromiseLike=function(n){return!!n&&v(n.then)&&v(n.catch)},n.isRegExp=k,n.isString=function(n){return"string"==typeof n},n.isUndefined=function(n){return void 0===n},n.isWindow=function(n){return n&&n===n.window},n.looseEqual=function r(t,e){if(t===e)return!0;if(j(t)&&j(e)){if(x(t)&&x(e))return t.length===e.length&&t.every(function(n,t){return r(n,e[t])});if(S(t)&&S(e))return+t==+e;if(k(t)&&k(e))return t.toString()===e.toString();var n=Object.keys(t),o=Object.keys(e);return n.length===o.length&&n.every(function(n){return r(t[n],e[n])})}return!1},n.map=function(n,t,r){return y(h,n,t,r)},n.noop=function(){},n.sleep=function(t){return new Promise(function(n){setTimeout(n,t)})},n.toString=A,n.type=function(n){return c(n)?n+"":j(n)||v(n)?P[A(n)]||"object":typeof n}}); | ||
define(["exports"],function(n){"use strict";function u(n,t){return n[n.length]=t,n}function v(n){return null==n}function e(n,t,r,e){for(;t<r;t++)e(n[t],t,n)}function c(n,t){return t?n.bind(t):n}function i(n,t,r){t=c(t,r);for(var e=Object.keys(n),o=e.length,i=0,u=void 0;i<o;i++)!1===t(n[u=e[i]],u,n)&&(i=o)}function t(n){if(v(n))throw new TypeError("Cannot convert undefined or null to object");var r=Object(n);return e(arguments,1,arguments.length,function(n){v(n)||i(n,function(n,t){r[t]=n})}),r}function o(n,t,r,e,o){e=c(e,o);for(var i=t;i<r;i++)!1===e(n[i],i,n)&&(i=r)}function f(n,t,r){o(n,0,n.length,t,r)}function a(n,t,r){for(var e in t=c(t,r),n)if(!1===t(n[e],e))break}function s(n,t,r){t=c(t,r);for(var e=0;e<n;e++)!1===t(e,e,n)&&(e=n)}function p(n){return"string"==typeof n}var y=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,b=/\\(\\)?/g,g=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;function l(n,t){if(!p(t)||!g.test(t))return n[t];var r;for(y.lastIndex=0;!v(n)&&(r=y.exec(t));){var e=r[0],o=r[1],i=r[2],u=r[3];n=n[i?u.replace(b,"$1"):o||e]}return n}function d(n){return"number"==typeof n}function r(n){return d(n)&&isFinite(n)&&n>>0===n}function h(n,t,r,e){var o=[],i=c(r,e);return n(t,function(n,t){v(n=i(n,t))||u(o,n)}),o}function j(n){return null!==n&&"object"==typeof n}function O(n,t,r){v(n)||i(n,t,r)}var m=Array.isArray;var w=Object.assign||t;var _=Array.isArray;function E(n){return"function"==typeof n}function A(n){return!v(n)&&d(n.length)&&!E(n)}function x(n,t,r){A(n)?f(n,t,r):d(n)?s(n,t,r):v(n)||i(n,t,r)}var S="celia_uid_"+(1e9*Math.random()>>>0),C=0;function F(n){return n[S]||(++C,Object.defineProperty(n,S,{configurable:!0,value:C}),C)}var I=Object.prototype.hasOwnProperty;var N=/^([a-z][a-z\d+\-.]*:)?\/\//i;var k=Object.prototype.toString;function P(n){return k.call(n)}function T(n){return n instanceof Date}var D={false:!0,null:!0,undefined:!0,0:!0,NaN:!0,"":!0};var L=Number.isInteger||r;function R(n){return n instanceof RegExp}var U=Array.isArray;var $={};"Boolean,Number,String,Function,AsyncFunction,Array,Date,RegExp,Object,Error,Symbol".split(",").forEach(function(n){$["[object "+n+"]"]=n.toLowerCase()}),n._append=u,n._assign=t,n._bindContext=c,n._forEach=f,n._forIn=a,n._forNumber=s,n._forOwn=i,n._forSlice=o,n._get=l,n._isInteger=r,n._loop=e,n._map=h,n._repeat=function(n,t,r){for(;n<t;n++)r(n,t)},n.afterCall=function(n,t,r){if(j(n)){var e=n[t];n[t]=function(){return e.apply(this,arguments),r.apply(this,arguments)}}},n.alias=function(r,n){j(r)&&O(n,function(n,t){t=r[t],m(n)?n.forEach(function(n){return r[n]=t}):r[n]=t})},n.aroundCall=function(n,t,r){if(j(n)){var e=n[t];n[t]=function(){for(var n=[],t=arguments.length;t--;)n[t]=arguments[t];return r.call(this,e,n)}}},n.assert=function(n,t){if(!n)throw new Error(t)},n.assign=w,n.assignDeep=function(n){if(v(n))throw new TypeError("Cannot convert undefined or null to object");var t=Object(n);return e(arguments,1,arguments.length,function(n){!function r(e,n){var o;v(n)||i(n,function(n,t){j(o=e[t])&&j(n)?r(o,n):e[t]=n})}(t,n)}),t},n.beforeCall=function(n,t,r){if(j(n)){var e=n[t];n[t]=function(){return r.apply(this,arguments),e.apply(this,arguments)}}},n.copy=function(n,t){return t?function r(n){var e=n;return _(n)?(e=[],n.forEach(function(n,t){e[t]=r(n)})):j(n)&&(e={},i(n,function(n,t){e[t]=r(n)})),e}(n):function(n){return j(n)?w({},n):n}(n)},n.debounce=function(n,t){var r=null;function e(){null!==r&&(clearTimeout(r),r=null)}function o(){e(),r=setTimeout(n,t)}return o.cancel=e,o},n.each=x,n.forIn=function(n,t,r){v(n)||a(n,t,r)},n.forOwn=O,n.get=function(n,t,r){var e=v(n)?void 0:l(n,t);return void 0===e?r:e},n.getEasyHash=function(n){return j(n)?"o"+F(n):(typeof n)[0]+n},n.getUid=F,n.hasOwn=function(n,t){return I.call(n,t)},n.isAbsoluteURL=function(n){return N.test(n)},n.isArrayLike=A,n.isAsyncFunction=function(n){return"[object AsyncFunction]"===P(n)},n.isBoolean=function(n){return"boolean"==typeof n},n.isDate=T,n.isFalsy=function(n){return!!D[n]},n.isFunction=E,n.isInteger=L,n.isNil=v,n.isNumber=d,n.isObject=j,n.isPlainObject=function(n){return!v(n)&&"[object Object]"===P(n)},n.isPromiseLike=function(n){return!!n&&E(n.then)&&E(n.catch)},n.isRegExp=R,n.isString=p,n.isUndefined=function(n){return void 0===n},n.isWindow=function(n){return n&&n===n.window},n.looseEqual=function r(t,e){if(t===e)return!0;if(j(t)&&j(e)){if(U(t)&&U(e))return t.length===e.length&&t.every(function(n,t){return r(n,e[t])});if(T(t)&&T(e))return+t==+e;if(R(t)&&R(e))return t.toString()===e.toString();var n=Object.keys(t),o=Object.keys(e);return n.length===o.length&&n.every(function(n){return r(t[n],e[n])})}return!1},n.map=function(n,t,r){return h(x,n,t,r)},n.mapObject=function(n,t,r){var e={},o=c(t,r);return O(n,function(n,t){v(n=o(n,t))||(e[t]=n)}),e},n.noop=function(){},n.set=function(n,t,r){if(!v(n)){if(!p(t)||!g.test(t))return void(n[t]=r);var e,o,i=[],u=0;for(y.lastIndex=0;e=y.exec(t);){var c=e[0],f=e[1],a=e[2],s=e[3],l=void 0;a?v(l=n[o=s.replace(b,"$1")])&&(l=n[o]={}):f?v(l=n[o=f])&&(l=n[f]=[]):v(l=n[o=c])&&(l=n[c]={}),n=l,i[u++]=l}(n=i[u-2])[o]=r}},n.sleep=function(t){return new Promise(function(n){setTimeout(n,t)})},n.toString=P,n.type=function(n){return v(n)?n+"":j(n)||E(n)?$[P(n)]||"object":typeof n}}); |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -11,3 +11,2 @@ * Released under the MIT License. | ||
require('./_bindContext.js'); | ||
require('./hasOwn.js'); | ||
require('./_forOwn.js'); | ||
@@ -14,0 +13,0 @@ var _assign = require('./_assign.js'); |
287
cjs.js
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -28,20 +28,17 @@ * Released under the MIT License. | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function hasOwn (obj, key) { | ||
return hasOwnProperty.call(obj, key); | ||
} | ||
// import hasOwn from './hasOwn'; | ||
function forOwn (value, iterator, context) { | ||
iterator = bindContext(iterator, context); | ||
// const keys = Object.keys(value); | ||
// const len = keys.length; | ||
// for (let i = 0, key; i < len; i++) { | ||
// key = keys[i]; | ||
// i = iterator(value[key], key, value) === false ? len : i; | ||
var keys = Object.keys(value); | ||
var len = keys.length; | ||
for (var i = 0, key = (void 0); i < len; i++) { | ||
key = keys[i]; | ||
iterator(value[key], key, value) === false && (i = len); | ||
} | ||
// for (let key in value) { | ||
// if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
// break; | ||
// } | ||
// } | ||
for (var key in value) { | ||
if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
break; | ||
} | ||
} | ||
} | ||
@@ -65,3 +62,3 @@ | ||
for (var i = start; i < end; i++) { | ||
i = iterator(value[i], i, value) === false ? end : i; | ||
iterator(value[i], i, value) === false && (i = end); | ||
} | ||
@@ -74,3 +71,3 @@ } | ||
function _forIn (value, iterator, context) { | ||
function forIn (value, iterator, context) { | ||
iterator = bindContext(iterator, context); | ||
@@ -86,6 +83,32 @@ for (var key in value) { | ||
for (var i = 0; i < value; i++) { | ||
i = iterator(i, i, value) === false ? value : i; | ||
iterator(i, i, value) === false && (i = value); | ||
} | ||
} | ||
function isString (value) { | ||
return typeof value === 'string'; | ||
} | ||
var PROP_NAME_REGEX = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; | ||
var ESCAPE_CHAR_REGEX = /\\(\\)?/g; | ||
var IS_DEEP_PROP_REGEX = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; | ||
function get (object, path) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
return object[path]; | ||
} | ||
var part; | ||
PROP_NAME_REGEX.lastIndex = 0; | ||
while (!isNil(object) && (part = PROP_NAME_REGEX.exec(path))) { | ||
var match = part[0]; | ||
var number = part[1]; | ||
var quote = part[2]; | ||
var subString = part[3]; | ||
var prop = quote ? subString.replace(ESCAPE_CHAR_REGEX, '$1') : (number || match); | ||
object = object[prop]; | ||
} | ||
return object; | ||
} | ||
function isNumber (value) { | ||
@@ -119,4 +142,132 @@ return typeof value === 'number'; | ||
function isObject (value) { | ||
return value !== null && typeof value === 'object'; | ||
} | ||
function afterCall (obj, methodName, after) { | ||
if (isObject(obj)) { | ||
var old = obj[methodName]; | ||
obj[methodName] = function () { | ||
old.apply(this, arguments); | ||
return after.apply(this, arguments); | ||
}; | ||
} | ||
} | ||
function each (value, iterator, context) { | ||
!isNil(value) && forOwn(value, iterator, context); | ||
} | ||
var isArray = Array.isArray; | ||
function alias (proto, mappings) { | ||
if (isObject(proto)) { | ||
each(mappings, function (mapping, key) { | ||
key = proto[key]; | ||
isArray(mapping) | ||
? mapping.forEach(function (m) { return (proto[m] = key); }) | ||
: (proto[mapping] = key); | ||
}); | ||
} | ||
} | ||
function aroundCall (obj, method, around) { | ||
if (isObject(obj)) { | ||
var old = obj[method]; | ||
obj[method] = function () { | ||
var args = [], len = arguments.length; | ||
while ( len-- ) args[ len ] = arguments[ len ]; | ||
return around.call(this, old, args); | ||
}; | ||
} | ||
} | ||
function assert (condition, msg) { | ||
if (!condition) { | ||
throw new Error(msg); | ||
} | ||
} | ||
var assign = Object.assign || _assign; | ||
function assign$1(target, nextSource) { | ||
var copy; | ||
!isNil(nextSource) && forOwn(nextSource, function (nextVal, nextKey) { | ||
copy = target[nextKey]; | ||
isObject(copy) && isObject(nextVal) | ||
? assign$1(copy, nextVal) | ||
: (target[nextKey] = nextVal); | ||
}); | ||
} | ||
function assignDeep (target) { | ||
if (isNil(target)) { | ||
throw new TypeError('Cannot convert undefined or null to object'); | ||
} | ||
var to = Object(target); | ||
loop(arguments, 1, arguments.length, function (nextSource) { | ||
assign$1(to, nextSource); | ||
}); | ||
return to; | ||
} | ||
function beforeCall (obj, methodName, before) { | ||
if (isObject(obj)) { | ||
var old = obj[methodName]; | ||
obj[methodName] = function () { | ||
before.apply(this, arguments); | ||
return old.apply(this, arguments); | ||
}; | ||
} | ||
} | ||
function copy(value) { | ||
return isObject(value) | ||
? assign({}, value) | ||
: value; | ||
} | ||
var isArray$1 = Array.isArray; | ||
function copyDeep(value) { | ||
var target = value; | ||
if (isArray$1(value)) { | ||
target = []; | ||
value.forEach(function (val, i) { | ||
target[i] = copyDeep(val); | ||
}); | ||
} else if (isObject(value)) { | ||
target = {}; | ||
forOwn(value, function (val, key) { | ||
target[key] = copyDeep(val); | ||
}); | ||
} | ||
return target; | ||
} | ||
function copy$1 (value, deep) { | ||
return deep ? copyDeep(value) : copy(value); | ||
} | ||
function debounce (fn, wait) { | ||
var timeout = null; | ||
function cancel() { | ||
if (timeout !== null) { | ||
clearTimeout(timeout); | ||
timeout = null; | ||
} | ||
} | ||
function debounce() { | ||
cancel(); | ||
timeout = setTimeout(fn, wait); | ||
} | ||
debounce.cancel = cancel; | ||
return debounce; | ||
} | ||
function isFunction (value) { | ||
@@ -130,3 +281,3 @@ return typeof value === 'function'; | ||
function each (value, cb, context) { | ||
function each$1 (value, cb, context) { | ||
if (isArrayLike(value)) { | ||
@@ -141,6 +292,11 @@ forEach(value, cb, context); | ||
function isObject (value) { | ||
return value !== null && typeof value === 'object'; | ||
function forIn$1 (value, iterator, context) { | ||
!isNil(value) && forIn(value, iterator, context); | ||
} | ||
function get$1 (object, path, defaultValue) { | ||
var result = isNil(object) ? undefined : get(object, path); | ||
return result === undefined ? defaultValue : result; | ||
} | ||
var UID_PROPERTY = 'celia_uid_' + ((Math.random() * 1e9) >>> 0); | ||
@@ -151,2 +307,3 @@ var uidCounter = 0; | ||
return obj[UID_PROPERTY] || (++uidCounter, Object.defineProperty(obj, UID_PROPERTY, { | ||
configurable: true, | ||
value: uidCounter | ||
@@ -162,2 +319,7 @@ }), uidCounter); | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function hasOwn (obj, key) { | ||
return hasOwnProperty.call(obj, key); | ||
} | ||
var PROTOCOL = /^([a-z][a-z\d+\-.]*:)?\/\//i; | ||
@@ -221,6 +383,2 @@ | ||
function isString (value) { | ||
return typeof value === 'string'; | ||
} | ||
function isUndefined (value) { | ||
@@ -234,3 +392,3 @@ return typeof value === 'undefined'; | ||
var isArray = Array.isArray; | ||
var isArray$2 = Array.isArray; | ||
function looseEqual(a, b) { | ||
@@ -241,3 +399,3 @@ if (a === b) { | ||
if (isObject(a) && isObject(b)) { | ||
if (isArray(a) && isArray(b)) { // 判断是否是数组 | ||
if (isArray$2(a) && isArray$2(b)) { // 判断是否是数组 | ||
return a.length === b.length && a.every(function (e, i) { | ||
@@ -262,7 +420,62 @@ return looseEqual(e, b[i]); | ||
function map$1 (elems, callback, context) { | ||
return map(each, elems, callback, context); | ||
return map(each$1, elems, callback, context); | ||
} | ||
function mapObject (elems, callback, context) { | ||
var ret = {}; | ||
var cb = bindContext(callback, context); | ||
each(elems, function (elem, key) { | ||
elem = cb(elem, key); | ||
!isNil(elem) && (ret[key] = elem); | ||
}); | ||
return ret; | ||
} | ||
function noop() { } | ||
function set (object, path, value) { | ||
if (!isNil(object)) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
object[path] = value; | ||
return; | ||
} | ||
var part; | ||
var queue = []; | ||
var i = 0; | ||
var key; | ||
PROP_NAME_REGEX.lastIndex = 0; | ||
while ((part = PROP_NAME_REGEX.exec(path))) { | ||
var match = part[0]; | ||
var number = part[1]; | ||
var quote = part[2]; | ||
var subString = part[3]; | ||
var obj = (void 0); | ||
if (quote) { | ||
key = subString.replace(ESCAPE_CHAR_REGEX, '$1'); | ||
obj = object[key]; | ||
if (isNil(obj)) { | ||
obj = object[key] = {}; | ||
} | ||
} else if (number) { | ||
obj = object[key = number]; | ||
if (isNil(obj)) { | ||
obj = object[number] = []; | ||
} | ||
} else { | ||
obj = object[key = match]; | ||
if (isNil(obj)) { | ||
obj = object[match] = {}; | ||
} | ||
} | ||
object = obj; | ||
queue[i++] = obj; | ||
} | ||
object = queue[i - 2]; | ||
object[key] = value; | ||
} | ||
} | ||
function sleep (ms) { | ||
@@ -290,6 +503,7 @@ return new Promise(function (resolve) { | ||
exports._forEach = forEach; | ||
exports._forIn = _forIn; | ||
exports._forIn = forIn; | ||
exports._forNumber = forNumber; | ||
exports._forOwn = forOwn; | ||
exports._forSlice = forSlice; | ||
exports._get = get; | ||
exports._isInteger = _isInteger; | ||
@@ -299,4 +513,15 @@ exports._loop = loop; | ||
exports._repeat = _repeat; | ||
exports.afterCall = afterCall; | ||
exports.alias = alias; | ||
exports.aroundCall = aroundCall; | ||
exports.assert = assert; | ||
exports.assign = assign; | ||
exports.each = each; | ||
exports.assignDeep = assignDeep; | ||
exports.beforeCall = beforeCall; | ||
exports.copy = copy$1; | ||
exports.debounce = debounce; | ||
exports.each = each$1; | ||
exports.forIn = forIn$1; | ||
exports.forOwn = each; | ||
exports.get = get$1; | ||
exports.getEasyHash = getEasyHash; | ||
@@ -324,5 +549,7 @@ exports.getUid = getUid; | ||
exports.map = map$1; | ||
exports.mapObject = mapObject; | ||
exports.noop = noop; | ||
exports.set = set; | ||
exports.sleep = sleep; | ||
exports.toString = toString$1; | ||
exports.type = type; |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -10,3 +10,2 @@ * Released under the MIT License. | ||
require('./_bindContext.js'); | ||
require('./hasOwn.js'); | ||
var _forOwn = require('./_forOwn.js'); | ||
@@ -13,0 +12,0 @@ require('./_forSlice.js'); |
271
es.js
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -26,20 +26,17 @@ * Released under the MIT License. | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function hasOwn (obj, key) { | ||
return hasOwnProperty.call(obj, key); | ||
} | ||
// import hasOwn from './hasOwn'; | ||
function forOwn (value, iterator, context) { | ||
iterator = bindContext(iterator, context); | ||
// const keys = Object.keys(value); | ||
// const len = keys.length; | ||
// for (let i = 0, key; i < len; i++) { | ||
// key = keys[i]; | ||
// i = iterator(value[key], key, value) === false ? len : i; | ||
var keys = Object.keys(value); | ||
var len = keys.length; | ||
for (var i = 0, key = (void 0); i < len; i++) { | ||
key = keys[i]; | ||
iterator(value[key], key, value) === false && (i = len); | ||
} | ||
// for (let key in value) { | ||
// if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
// break; | ||
// } | ||
// } | ||
for (var key in value) { | ||
if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
break; | ||
} | ||
} | ||
} | ||
@@ -63,3 +60,3 @@ | ||
for (var i = start; i < end; i++) { | ||
i = iterator(value[i], i, value) === false ? end : i; | ||
iterator(value[i], i, value) === false && (i = end); | ||
} | ||
@@ -72,3 +69,3 @@ } | ||
function _forIn (value, iterator, context) { | ||
function forIn (value, iterator, context) { | ||
iterator = bindContext(iterator, context); | ||
@@ -84,6 +81,32 @@ for (var key in value) { | ||
for (var i = 0; i < value; i++) { | ||
i = iterator(i, i, value) === false ? value : i; | ||
iterator(i, i, value) === false && (i = value); | ||
} | ||
} | ||
function isString (value) { | ||
return typeof value === 'string'; | ||
} | ||
var PROP_NAME_REGEX = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; | ||
var ESCAPE_CHAR_REGEX = /\\(\\)?/g; | ||
var IS_DEEP_PROP_REGEX = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; | ||
function get (object, path) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
return object[path]; | ||
} | ||
var part; | ||
PROP_NAME_REGEX.lastIndex = 0; | ||
while (!isNil(object) && (part = PROP_NAME_REGEX.exec(path))) { | ||
var match = part[0]; | ||
var number = part[1]; | ||
var quote = part[2]; | ||
var subString = part[3]; | ||
var prop = quote ? subString.replace(ESCAPE_CHAR_REGEX, '$1') : (number || match); | ||
object = object[prop]; | ||
} | ||
return object; | ||
} | ||
function isNumber (value) { | ||
@@ -117,4 +140,132 @@ return typeof value === 'number'; | ||
function isObject (value) { | ||
return value !== null && typeof value === 'object'; | ||
} | ||
function afterCall (obj, methodName, after) { | ||
if (isObject(obj)) { | ||
var old = obj[methodName]; | ||
obj[methodName] = function () { | ||
old.apply(this, arguments); | ||
return after.apply(this, arguments); | ||
}; | ||
} | ||
} | ||
function each (value, iterator, context) { | ||
!isNil(value) && forOwn(value, iterator, context); | ||
} | ||
var isArray = Array.isArray; | ||
function alias (proto, mappings) { | ||
if (isObject(proto)) { | ||
each(mappings, function (mapping, key) { | ||
key = proto[key]; | ||
isArray(mapping) | ||
? mapping.forEach(function (m) { return (proto[m] = key); }) | ||
: (proto[mapping] = key); | ||
}); | ||
} | ||
} | ||
function aroundCall (obj, method, around) { | ||
if (isObject(obj)) { | ||
var old = obj[method]; | ||
obj[method] = function () { | ||
var args = [], len = arguments.length; | ||
while ( len-- ) args[ len ] = arguments[ len ]; | ||
return around.call(this, old, args); | ||
}; | ||
} | ||
} | ||
function assert (condition, msg) { | ||
if (!condition) { | ||
throw new Error(msg); | ||
} | ||
} | ||
var assign = Object.assign || _assign; | ||
function assign$1(target, nextSource) { | ||
var copy; | ||
!isNil(nextSource) && forOwn(nextSource, function (nextVal, nextKey) { | ||
copy = target[nextKey]; | ||
isObject(copy) && isObject(nextVal) | ||
? assign$1(copy, nextVal) | ||
: (target[nextKey] = nextVal); | ||
}); | ||
} | ||
function assignDeep (target) { | ||
if (isNil(target)) { | ||
throw new TypeError('Cannot convert undefined or null to object'); | ||
} | ||
var to = Object(target); | ||
loop(arguments, 1, arguments.length, function (nextSource) { | ||
assign$1(to, nextSource); | ||
}); | ||
return to; | ||
} | ||
function beforeCall (obj, methodName, before) { | ||
if (isObject(obj)) { | ||
var old = obj[methodName]; | ||
obj[methodName] = function () { | ||
before.apply(this, arguments); | ||
return old.apply(this, arguments); | ||
}; | ||
} | ||
} | ||
function copy(value) { | ||
return isObject(value) | ||
? assign({}, value) | ||
: value; | ||
} | ||
var isArray$1 = Array.isArray; | ||
function copyDeep(value) { | ||
var target = value; | ||
if (isArray$1(value)) { | ||
target = []; | ||
value.forEach(function (val, i) { | ||
target[i] = copyDeep(val); | ||
}); | ||
} else if (isObject(value)) { | ||
target = {}; | ||
forOwn(value, function (val, key) { | ||
target[key] = copyDeep(val); | ||
}); | ||
} | ||
return target; | ||
} | ||
function copy$1 (value, deep) { | ||
return deep ? copyDeep(value) : copy(value); | ||
} | ||
function debounce (fn, wait) { | ||
var timeout = null; | ||
function cancel() { | ||
if (timeout !== null) { | ||
clearTimeout(timeout); | ||
timeout = null; | ||
} | ||
} | ||
function debounce() { | ||
cancel(); | ||
timeout = setTimeout(fn, wait); | ||
} | ||
debounce.cancel = cancel; | ||
return debounce; | ||
} | ||
function isFunction (value) { | ||
@@ -128,3 +279,3 @@ return typeof value === 'function'; | ||
function each (value, cb, context) { | ||
function each$1 (value, cb, context) { | ||
if (isArrayLike(value)) { | ||
@@ -139,6 +290,11 @@ forEach(value, cb, context); | ||
function isObject (value) { | ||
return value !== null && typeof value === 'object'; | ||
function forIn$1 (value, iterator, context) { | ||
!isNil(value) && forIn(value, iterator, context); | ||
} | ||
function get$1 (object, path, defaultValue) { | ||
var result = isNil(object) ? undefined : get(object, path); | ||
return result === undefined ? defaultValue : result; | ||
} | ||
var UID_PROPERTY = 'celia_uid_' + ((Math.random() * 1e9) >>> 0); | ||
@@ -149,2 +305,3 @@ var uidCounter = 0; | ||
return obj[UID_PROPERTY] || (++uidCounter, Object.defineProperty(obj, UID_PROPERTY, { | ||
configurable: true, | ||
value: uidCounter | ||
@@ -160,2 +317,7 @@ }), uidCounter); | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function hasOwn (obj, key) { | ||
return hasOwnProperty.call(obj, key); | ||
} | ||
var PROTOCOL = /^([a-z][a-z\d+\-.]*:)?\/\//i; | ||
@@ -219,6 +381,2 @@ | ||
function isString (value) { | ||
return typeof value === 'string'; | ||
} | ||
function isUndefined (value) { | ||
@@ -232,3 +390,3 @@ return typeof value === 'undefined'; | ||
var isArray = Array.isArray; | ||
var isArray$2 = Array.isArray; | ||
function looseEqual(a, b) { | ||
@@ -239,3 +397,3 @@ if (a === b) { | ||
if (isObject(a) && isObject(b)) { | ||
if (isArray(a) && isArray(b)) { // 判断是否是数组 | ||
if (isArray$2(a) && isArray$2(b)) { // 判断是否是数组 | ||
return a.length === b.length && a.every(function (e, i) { | ||
@@ -260,7 +418,62 @@ return looseEqual(e, b[i]); | ||
function map$1 (elems, callback, context) { | ||
return map(each, elems, callback, context); | ||
return map(each$1, elems, callback, context); | ||
} | ||
function mapObject (elems, callback, context) { | ||
var ret = {}; | ||
var cb = bindContext(callback, context); | ||
each(elems, function (elem, key) { | ||
elem = cb(elem, key); | ||
!isNil(elem) && (ret[key] = elem); | ||
}); | ||
return ret; | ||
} | ||
function noop() { } | ||
function set (object, path, value) { | ||
if (!isNil(object)) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
object[path] = value; | ||
return; | ||
} | ||
var part; | ||
var queue = []; | ||
var i = 0; | ||
var key; | ||
PROP_NAME_REGEX.lastIndex = 0; | ||
while ((part = PROP_NAME_REGEX.exec(path))) { | ||
var match = part[0]; | ||
var number = part[1]; | ||
var quote = part[2]; | ||
var subString = part[3]; | ||
var obj = (void 0); | ||
if (quote) { | ||
key = subString.replace(ESCAPE_CHAR_REGEX, '$1'); | ||
obj = object[key]; | ||
if (isNil(obj)) { | ||
obj = object[key] = {}; | ||
} | ||
} else if (number) { | ||
obj = object[key = number]; | ||
if (isNil(obj)) { | ||
obj = object[number] = []; | ||
} | ||
} else { | ||
obj = object[key = match]; | ||
if (isNil(obj)) { | ||
obj = object[match] = {}; | ||
} | ||
} | ||
object = obj; | ||
queue[i++] = obj; | ||
} | ||
object = queue[i - 2]; | ||
object[key] = value; | ||
} | ||
} | ||
function sleep (ms) { | ||
@@ -284,2 +497,2 @@ return new Promise(function (resolve) { | ||
export { append as _append, _assign, bindContext as _bindContext, forEach as _forEach, _forIn, forNumber as _forNumber, forOwn as _forOwn, forSlice as _forSlice, _isInteger, loop as _loop, map as _map, _repeat, assign, each, getEasyHash, getUid, hasOwn, isAbsoluteURL, isArrayLike, isAsyncFunction, isBoolean, isDate, isFalsy, isFunction, isInteger, isNil, isNumber, isObject, isPlainObject, isPromiseLike, isRegExp, isString, isUndefined, isWindow, looseEqual, map$1 as map, noop, sleep, toString$1 as toString, type }; | ||
export { append as _append, _assign, bindContext as _bindContext, forEach as _forEach, forIn as _forIn, forNumber as _forNumber, forOwn as _forOwn, forSlice as _forSlice, get as _get, _isInteger, loop as _loop, map as _map, _repeat, afterCall, alias, aroundCall, assert, assign, assignDeep, beforeCall, copy$1 as copy, debounce, each$1 as each, forIn$1 as forIn, each as forOwn, get$1 as get, getEasyHash, getUid, hasOwn, isAbsoluteURL, isArrayLike, isAsyncFunction, isBoolean, isDate, isFalsy, isFunction, isInteger, isNil, isNumber, isObject, isPlainObject, isPromiseLike, isRegExp, isString, isUndefined, isWindow, looseEqual, map$1 as map, mapObject, noop, set, sleep, toString$1 as toString, type }; |
@@ -6,4 +6,4 @@ import bindContext from './_bindContext'; | ||
for (let i = 0; i < value; i++) { | ||
i = iterator(i, i, value) === false ? value : i; | ||
iterator(i, i, value) === false && (i = value); | ||
} | ||
}; |
import bindContext from './_bindContext'; | ||
import hasOwn from './hasOwn'; | ||
// import hasOwn from './hasOwn'; | ||
export default function (value, iterator, context) { | ||
iterator = bindContext(iterator, context); | ||
// const keys = Object.keys(value); | ||
// const len = keys.length; | ||
// for (let i = 0, key; i < len; i++) { | ||
// key = keys[i]; | ||
// i = iterator(value[key], key, value) === false ? len : i; | ||
const keys = Object.keys(value); | ||
const len = keys.length; | ||
for (let i = 0, key; i < len; i++) { | ||
key = keys[i]; | ||
iterator(value[key], key, value) === false && (i = len); | ||
} | ||
// for (let key in value) { | ||
// if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
// break; | ||
// } | ||
// } | ||
for (let key in value) { | ||
if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
break; | ||
} | ||
} | ||
}; |
@@ -6,4 +6,4 @@ import bindContext from './_bindContext'; | ||
for (let i = start; i < end; i++) { | ||
i = iterator(value[i], i, value) === false ? end : i; | ||
iterator(value[i], i, value) === false && (i = end); | ||
} | ||
}; |
@@ -6,4 +6,5 @@ const UID_PROPERTY = 'celia_uid_' + ((Math.random() * 1e9) >>> 0); | ||
return obj[UID_PROPERTY] || (++uidCounter, Object.defineProperty(obj, UID_PROPERTY, { | ||
configurable: true, | ||
value: uidCounter | ||
}), uidCounter); | ||
}; |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -13,2 +13,3 @@ * Released under the MIT License. | ||
return obj[UID_PROPERTY] || (++uidCounter, Object.defineProperty(obj, UID_PROPERTY, { | ||
configurable: true, | ||
value: uidCounter | ||
@@ -15,0 +16,0 @@ }), uidCounter); |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
287
iife.js
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -29,20 +29,17 @@ * Released under the MIT License. | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function hasOwn (obj, key) { | ||
return hasOwnProperty.call(obj, key); | ||
} | ||
// import hasOwn from './hasOwn'; | ||
function forOwn (value, iterator, context) { | ||
iterator = bindContext(iterator, context); | ||
// const keys = Object.keys(value); | ||
// const len = keys.length; | ||
// for (let i = 0, key; i < len; i++) { | ||
// key = keys[i]; | ||
// i = iterator(value[key], key, value) === false ? len : i; | ||
var keys = Object.keys(value); | ||
var len = keys.length; | ||
for (var i = 0, key = (void 0); i < len; i++) { | ||
key = keys[i]; | ||
iterator(value[key], key, value) === false && (i = len); | ||
} | ||
// for (let key in value) { | ||
// if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
// break; | ||
// } | ||
// } | ||
for (var key in value) { | ||
if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
break; | ||
} | ||
} | ||
} | ||
@@ -66,3 +63,3 @@ | ||
for (var i = start; i < end; i++) { | ||
i = iterator(value[i], i, value) === false ? end : i; | ||
iterator(value[i], i, value) === false && (i = end); | ||
} | ||
@@ -75,3 +72,3 @@ } | ||
function _forIn (value, iterator, context) { | ||
function forIn (value, iterator, context) { | ||
iterator = bindContext(iterator, context); | ||
@@ -87,6 +84,32 @@ for (var key in value) { | ||
for (var i = 0; i < value; i++) { | ||
i = iterator(i, i, value) === false ? value : i; | ||
iterator(i, i, value) === false && (i = value); | ||
} | ||
} | ||
function isString (value) { | ||
return typeof value === 'string'; | ||
} | ||
var PROP_NAME_REGEX = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; | ||
var ESCAPE_CHAR_REGEX = /\\(\\)?/g; | ||
var IS_DEEP_PROP_REGEX = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; | ||
function get (object, path) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
return object[path]; | ||
} | ||
var part; | ||
PROP_NAME_REGEX.lastIndex = 0; | ||
while (!isNil(object) && (part = PROP_NAME_REGEX.exec(path))) { | ||
var match = part[0]; | ||
var number = part[1]; | ||
var quote = part[2]; | ||
var subString = part[3]; | ||
var prop = quote ? subString.replace(ESCAPE_CHAR_REGEX, '$1') : (number || match); | ||
object = object[prop]; | ||
} | ||
return object; | ||
} | ||
function isNumber (value) { | ||
@@ -120,4 +143,132 @@ return typeof value === 'number'; | ||
function isObject (value) { | ||
return value !== null && typeof value === 'object'; | ||
} | ||
function afterCall (obj, methodName, after) { | ||
if (isObject(obj)) { | ||
var old = obj[methodName]; | ||
obj[methodName] = function () { | ||
old.apply(this, arguments); | ||
return after.apply(this, arguments); | ||
}; | ||
} | ||
} | ||
function each (value, iterator, context) { | ||
!isNil(value) && forOwn(value, iterator, context); | ||
} | ||
var isArray = Array.isArray; | ||
function alias (proto, mappings) { | ||
if (isObject(proto)) { | ||
each(mappings, function (mapping, key) { | ||
key = proto[key]; | ||
isArray(mapping) | ||
? mapping.forEach(function (m) { return (proto[m] = key); }) | ||
: (proto[mapping] = key); | ||
}); | ||
} | ||
} | ||
function aroundCall (obj, method, around) { | ||
if (isObject(obj)) { | ||
var old = obj[method]; | ||
obj[method] = function () { | ||
var args = [], len = arguments.length; | ||
while ( len-- ) args[ len ] = arguments[ len ]; | ||
return around.call(this, old, args); | ||
}; | ||
} | ||
} | ||
function assert (condition, msg) { | ||
if (!condition) { | ||
throw new Error(msg); | ||
} | ||
} | ||
var assign = Object.assign || _assign; | ||
function assign$1(target, nextSource) { | ||
var copy; | ||
!isNil(nextSource) && forOwn(nextSource, function (nextVal, nextKey) { | ||
copy = target[nextKey]; | ||
isObject(copy) && isObject(nextVal) | ||
? assign$1(copy, nextVal) | ||
: (target[nextKey] = nextVal); | ||
}); | ||
} | ||
function assignDeep (target) { | ||
if (isNil(target)) { | ||
throw new TypeError('Cannot convert undefined or null to object'); | ||
} | ||
var to = Object(target); | ||
loop(arguments, 1, arguments.length, function (nextSource) { | ||
assign$1(to, nextSource); | ||
}); | ||
return to; | ||
} | ||
function beforeCall (obj, methodName, before) { | ||
if (isObject(obj)) { | ||
var old = obj[methodName]; | ||
obj[methodName] = function () { | ||
before.apply(this, arguments); | ||
return old.apply(this, arguments); | ||
}; | ||
} | ||
} | ||
function copy(value) { | ||
return isObject(value) | ||
? assign({}, value) | ||
: value; | ||
} | ||
var isArray$1 = Array.isArray; | ||
function copyDeep(value) { | ||
var target = value; | ||
if (isArray$1(value)) { | ||
target = []; | ||
value.forEach(function (val, i) { | ||
target[i] = copyDeep(val); | ||
}); | ||
} else if (isObject(value)) { | ||
target = {}; | ||
forOwn(value, function (val, key) { | ||
target[key] = copyDeep(val); | ||
}); | ||
} | ||
return target; | ||
} | ||
function copy$1 (value, deep) { | ||
return deep ? copyDeep(value) : copy(value); | ||
} | ||
function debounce (fn, wait) { | ||
var timeout = null; | ||
function cancel() { | ||
if (timeout !== null) { | ||
clearTimeout(timeout); | ||
timeout = null; | ||
} | ||
} | ||
function debounce() { | ||
cancel(); | ||
timeout = setTimeout(fn, wait); | ||
} | ||
debounce.cancel = cancel; | ||
return debounce; | ||
} | ||
function isFunction (value) { | ||
@@ -131,3 +282,3 @@ return typeof value === 'function'; | ||
function each (value, cb, context) { | ||
function each$1 (value, cb, context) { | ||
if (isArrayLike(value)) { | ||
@@ -142,6 +293,11 @@ forEach(value, cb, context); | ||
function isObject (value) { | ||
return value !== null && typeof value === 'object'; | ||
function forIn$1 (value, iterator, context) { | ||
!isNil(value) && forIn(value, iterator, context); | ||
} | ||
function get$1 (object, path, defaultValue) { | ||
var result = isNil(object) ? undefined : get(object, path); | ||
return result === undefined ? defaultValue : result; | ||
} | ||
var UID_PROPERTY = 'celia_uid_' + ((Math.random() * 1e9) >>> 0); | ||
@@ -152,2 +308,3 @@ var uidCounter = 0; | ||
return obj[UID_PROPERTY] || (++uidCounter, Object.defineProperty(obj, UID_PROPERTY, { | ||
configurable: true, | ||
value: uidCounter | ||
@@ -163,2 +320,7 @@ }), uidCounter); | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function hasOwn (obj, key) { | ||
return hasOwnProperty.call(obj, key); | ||
} | ||
var PROTOCOL = /^([a-z][a-z\d+\-.]*:)?\/\//i; | ||
@@ -222,6 +384,2 @@ | ||
function isString (value) { | ||
return typeof value === 'string'; | ||
} | ||
function isUndefined (value) { | ||
@@ -235,3 +393,3 @@ return typeof value === 'undefined'; | ||
var isArray = Array.isArray; | ||
var isArray$2 = Array.isArray; | ||
function looseEqual(a, b) { | ||
@@ -242,3 +400,3 @@ if (a === b) { | ||
if (isObject(a) && isObject(b)) { | ||
if (isArray(a) && isArray(b)) { // 判断是否是数组 | ||
if (isArray$2(a) && isArray$2(b)) { // 判断是否是数组 | ||
return a.length === b.length && a.every(function (e, i) { | ||
@@ -263,7 +421,62 @@ return looseEqual(e, b[i]); | ||
function map$1 (elems, callback, context) { | ||
return map(each, elems, callback, context); | ||
return map(each$1, elems, callback, context); | ||
} | ||
function mapObject (elems, callback, context) { | ||
var ret = {}; | ||
var cb = bindContext(callback, context); | ||
each(elems, function (elem, key) { | ||
elem = cb(elem, key); | ||
!isNil(elem) && (ret[key] = elem); | ||
}); | ||
return ret; | ||
} | ||
function noop() { } | ||
function set (object, path, value) { | ||
if (!isNil(object)) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
object[path] = value; | ||
return; | ||
} | ||
var part; | ||
var queue = []; | ||
var i = 0; | ||
var key; | ||
PROP_NAME_REGEX.lastIndex = 0; | ||
while ((part = PROP_NAME_REGEX.exec(path))) { | ||
var match = part[0]; | ||
var number = part[1]; | ||
var quote = part[2]; | ||
var subString = part[3]; | ||
var obj = (void 0); | ||
if (quote) { | ||
key = subString.replace(ESCAPE_CHAR_REGEX, '$1'); | ||
obj = object[key]; | ||
if (isNil(obj)) { | ||
obj = object[key] = {}; | ||
} | ||
} else if (number) { | ||
obj = object[key = number]; | ||
if (isNil(obj)) { | ||
obj = object[number] = []; | ||
} | ||
} else { | ||
obj = object[key = match]; | ||
if (isNil(obj)) { | ||
obj = object[match] = {}; | ||
} | ||
} | ||
object = obj; | ||
queue[i++] = obj; | ||
} | ||
object = queue[i - 2]; | ||
object[key] = value; | ||
} | ||
} | ||
function sleep (ms) { | ||
@@ -291,6 +504,7 @@ return new Promise(function (resolve) { | ||
exports._forEach = forEach; | ||
exports._forIn = _forIn; | ||
exports._forIn = forIn; | ||
exports._forNumber = forNumber; | ||
exports._forOwn = forOwn; | ||
exports._forSlice = forSlice; | ||
exports._get = get; | ||
exports._isInteger = _isInteger; | ||
@@ -300,4 +514,15 @@ exports._loop = loop; | ||
exports._repeat = _repeat; | ||
exports.afterCall = afterCall; | ||
exports.alias = alias; | ||
exports.aroundCall = aroundCall; | ||
exports.assert = assert; | ||
exports.assign = assign; | ||
exports.each = each; | ||
exports.assignDeep = assignDeep; | ||
exports.beforeCall = beforeCall; | ||
exports.copy = copy$1; | ||
exports.debounce = debounce; | ||
exports.each = each$1; | ||
exports.forIn = forIn$1; | ||
exports.forOwn = each; | ||
exports.get = get$1; | ||
exports.getEasyHash = getEasyHash; | ||
@@ -325,3 +550,5 @@ exports.getUid = getUid; | ||
exports.map = map$1; | ||
exports.mapObject = mapObject; | ||
exports.noop = noop; | ||
exports.set = set; | ||
exports.sleep = sleep; | ||
@@ -328,0 +555,0 @@ exports.toString = toString$1; |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
* Released under the MIT License. | ||
*/ | ||
!function(n){"use strict";function u(n,t){return n[n.length]=t,n}function c(n){return null==n}function t(n,t,r,e){for(;t<r;t++)e(n[t],t,n)}function f(n,t){return t?n.bind(t):n}var r=Object.prototype.hasOwnProperty;function o(n,t){return r.call(n,t)}function e(n,t,r){for(var e in t=f(t,r),n)if(o(n,e)&&!1===t(n[e],e,n))break}function i(n){if(c(n))throw new TypeError("Cannot convert undefined or null to object");var r=Object(n);return t(arguments,1,arguments.length,function(n){c(n)||e(n,function(n,t){r[t]=n})}),r}function a(n,t,r,e,o){e=f(e,o);for(var i=t;i<r;i++)i=!1===e(n[i],i,n)?r:i}function s(n,t,r){a(n,0,n.length,t,r)}function l(n,t,r){t=f(t,r);for(var e=0;e<n;e++)e=!1===t(e,e,n)?n:e}function b(n){return"number"==typeof n}function p(n){return b(n)&&isFinite(n)&&n>>0===n}function y(n,t,r,e){var o=[],i=f(r,e);return n(t,function(n,t){c(n=i(n,t))||u(o,n)}),o}var g=Object.assign||i;function v(n){return"function"==typeof n}function h(n){return!c(n)&&b(n.length)&&!v(n)}function d(n,t,r){h(n)?s(n,t,r):b(n)?l(n,t,r):c(n)||e(n,t,r)}function j(n){return null!==n&&"object"==typeof n}var O="celia_uid_"+(1e9*Math.random()>>>0),_=0;function m(n){return n[O]||(++_,Object.defineProperty(n,O,{value:_}),_)}var w=/^([a-z][a-z\d+\-.]*:)?\/\//i;var E=Object.prototype.toString;function A(n){return E.call(n)}function S(n){return n instanceof Date}var F={false:!0,null:!0,undefined:!0,0:!0,NaN:!0,"":!0};var N=Number.isInteger||p;function k(n){return n instanceof RegExp}var P=Array.isArray;var x={};"Boolean,Number,String,Function,AsyncFunction,Array,Date,RegExp,Object,Error,Symbol".split(",").forEach(function(n){x["[object "+n+"]"]=n.toLowerCase()}),n._append=u,n._assign=i,n._bindContext=f,n._forEach=s,n._forIn=function(n,t,r){for(var e in t=f(t,r),n)if(!1===t(n[e],e))break},n._forNumber=l,n._forOwn=e,n._forSlice=a,n._isInteger=p,n._loop=t,n._map=y,n._repeat=function(n,t,r){for(;n<t;n++)r(n,t)},n.assign=g,n.each=d,n.getEasyHash=function(n){return j(n)?"o"+m(n):(typeof n)[0]+n},n.getUid=m,n.hasOwn=o,n.isAbsoluteURL=function(n){return w.test(n)},n.isArrayLike=h,n.isAsyncFunction=function(n){return"[object AsyncFunction]"===A(n)},n.isBoolean=function(n){return"boolean"==typeof n},n.isDate=S,n.isFalsy=function(n){return!!F[n]},n.isFunction=v,n.isInteger=N,n.isNil=c,n.isNumber=b,n.isObject=j,n.isPlainObject=function(n){return!c(n)&&"[object Object]"===A(n)},n.isPromiseLike=function(n){return!!n&&v(n.then)&&v(n.catch)},n.isRegExp=k,n.isString=function(n){return"string"==typeof n},n.isUndefined=function(n){return void 0===n},n.isWindow=function(n){return n&&n===n.window},n.looseEqual=function r(t,e){if(t===e)return!0;if(j(t)&&j(e)){if(P(t)&&P(e))return t.length===e.length&&t.every(function(n,t){return r(n,e[t])});if(S(t)&&S(e))return+t==+e;if(k(t)&&k(e))return t.toString()===e.toString();var n=Object.keys(t),o=Object.keys(e);return n.length===o.length&&n.every(function(n){return r(t[n],e[n])})}return!1},n.map=function(n,t,r){return y(d,n,t,r)},n.noop=function(){},n.sleep=function(t){return new Promise(function(n){setTimeout(n,t)})},n.toString=A,n.type=function(n){return c(n)?n+"":j(n)||v(n)?x[A(n)]||"object":typeof n}}({}); | ||
!function(n){"use strict";function u(n,t){return n[n.length]=t,n}function v(n){return null==n}function e(n,t,r,e){for(;t<r;t++)e(n[t],t,n)}function c(n,t){return t?n.bind(t):n}function i(n,t,r){t=c(t,r);for(var e=Object.keys(n),o=e.length,i=0,u=void 0;i<o;i++)!1===t(n[u=e[i]],u,n)&&(i=o)}function t(n){if(v(n))throw new TypeError("Cannot convert undefined or null to object");var r=Object(n);return e(arguments,1,arguments.length,function(n){v(n)||i(n,function(n,t){r[t]=n})}),r}function o(n,t,r,e,o){e=c(e,o);for(var i=t;i<r;i++)!1===e(n[i],i,n)&&(i=r)}function f(n,t,r){o(n,0,n.length,t,r)}function a(n,t,r){for(var e in t=c(t,r),n)if(!1===t(n[e],e))break}function s(n,t,r){t=c(t,r);for(var e=0;e<n;e++)!1===t(e,e,n)&&(e=n)}function p(n){return"string"==typeof n}var y=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,b=/\\(\\)?/g,g=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;function l(n,t){if(!p(t)||!g.test(t))return n[t];var r;for(y.lastIndex=0;!v(n)&&(r=y.exec(t));){var e=r[0],o=r[1],i=r[2],u=r[3];n=n[i?u.replace(b,"$1"):o||e]}return n}function d(n){return"number"==typeof n}function r(n){return d(n)&&isFinite(n)&&n>>0===n}function h(n,t,r,e){var o=[],i=c(r,e);return n(t,function(n,t){v(n=i(n,t))||u(o,n)}),o}function j(n){return null!==n&&"object"==typeof n}function O(n,t,r){v(n)||i(n,t,r)}var m=Array.isArray;var w=Object.assign||t;var _=Array.isArray;function E(n){return"function"==typeof n}function A(n){return!v(n)&&d(n.length)&&!E(n)}function x(n,t,r){A(n)?f(n,t,r):d(n)?s(n,t,r):v(n)||i(n,t,r)}var S="celia_uid_"+(1e9*Math.random()>>>0),C=0;function F(n){return n[S]||(++C,Object.defineProperty(n,S,{configurable:!0,value:C}),C)}var I=Object.prototype.hasOwnProperty;var N=/^([a-z][a-z\d+\-.]*:)?\/\//i;var k=Object.prototype.toString;function P(n){return k.call(n)}function T(n){return n instanceof Date}var D={false:!0,null:!0,undefined:!0,0:!0,NaN:!0,"":!0};var L=Number.isInteger||r;function R(n){return n instanceof RegExp}var U=Array.isArray;var $={};"Boolean,Number,String,Function,AsyncFunction,Array,Date,RegExp,Object,Error,Symbol".split(",").forEach(function(n){$["[object "+n+"]"]=n.toLowerCase()}),n._append=u,n._assign=t,n._bindContext=c,n._forEach=f,n._forIn=a,n._forNumber=s,n._forOwn=i,n._forSlice=o,n._get=l,n._isInteger=r,n._loop=e,n._map=h,n._repeat=function(n,t,r){for(;n<t;n++)r(n,t)},n.afterCall=function(n,t,r){if(j(n)){var e=n[t];n[t]=function(){return e.apply(this,arguments),r.apply(this,arguments)}}},n.alias=function(r,n){j(r)&&O(n,function(n,t){t=r[t],m(n)?n.forEach(function(n){return r[n]=t}):r[n]=t})},n.aroundCall=function(n,t,r){if(j(n)){var e=n[t];n[t]=function(){for(var n=[],t=arguments.length;t--;)n[t]=arguments[t];return r.call(this,e,n)}}},n.assert=function(n,t){if(!n)throw new Error(t)},n.assign=w,n.assignDeep=function(n){if(v(n))throw new TypeError("Cannot convert undefined or null to object");var t=Object(n);return e(arguments,1,arguments.length,function(n){!function r(e,n){var o;v(n)||i(n,function(n,t){j(o=e[t])&&j(n)?r(o,n):e[t]=n})}(t,n)}),t},n.beforeCall=function(n,t,r){if(j(n)){var e=n[t];n[t]=function(){return r.apply(this,arguments),e.apply(this,arguments)}}},n.copy=function(n,t){return t?function r(n){var e=n;return _(n)?(e=[],n.forEach(function(n,t){e[t]=r(n)})):j(n)&&(e={},i(n,function(n,t){e[t]=r(n)})),e}(n):function(n){return j(n)?w({},n):n}(n)},n.debounce=function(n,t){var r=null;function e(){null!==r&&(clearTimeout(r),r=null)}function o(){e(),r=setTimeout(n,t)}return o.cancel=e,o},n.each=x,n.forIn=function(n,t,r){v(n)||a(n,t,r)},n.forOwn=O,n.get=function(n,t,r){var e=v(n)?void 0:l(n,t);return void 0===e?r:e},n.getEasyHash=function(n){return j(n)?"o"+F(n):(typeof n)[0]+n},n.getUid=F,n.hasOwn=function(n,t){return I.call(n,t)},n.isAbsoluteURL=function(n){return N.test(n)},n.isArrayLike=A,n.isAsyncFunction=function(n){return"[object AsyncFunction]"===P(n)},n.isBoolean=function(n){return"boolean"==typeof n},n.isDate=T,n.isFalsy=function(n){return!!D[n]},n.isFunction=E,n.isInteger=L,n.isNil=v,n.isNumber=d,n.isObject=j,n.isPlainObject=function(n){return!v(n)&&"[object Object]"===P(n)},n.isPromiseLike=function(n){return!!n&&E(n.then)&&E(n.catch)},n.isRegExp=R,n.isString=p,n.isUndefined=function(n){return void 0===n},n.isWindow=function(n){return n&&n===n.window},n.looseEqual=function r(t,e){if(t===e)return!0;if(j(t)&&j(e)){if(U(t)&&U(e))return t.length===e.length&&t.every(function(n,t){return r(n,e[t])});if(T(t)&&T(e))return+t==+e;if(R(t)&&R(e))return t.toString()===e.toString();var n=Object.keys(t),o=Object.keys(e);return n.length===o.length&&n.every(function(n){return r(t[n],e[n])})}return!1},n.map=function(n,t,r){return h(x,n,t,r)},n.mapObject=function(n,t,r){var e={},o=c(t,r);return O(n,function(n,t){v(n=o(n,t))||(e[t]=n)}),e},n.noop=function(){},n.set=function(n,t,r){if(!v(n)){if(!p(t)||!g.test(t))return void(n[t]=r);var e,o,i=[],u=0;for(y.lastIndex=0;e=y.exec(t);){var c=e[0],f=e[1],a=e[2],s=e[3],l=void 0;a?v(l=n[o=s.replace(b,"$1")])&&(l=n[o]={}):f?v(l=n[o=f])&&(l=n[f]=[]):v(l=n[o=c])&&(l=n[c]={}),n=l,i[u++]=l}(n=i[u-2])[o]=r}},n.sleep=function(t){return new Promise(function(n){setTimeout(n,t)})},n.toString=P,n.type=function(n){return v(n)?n+"":j(n)||E(n)?$[P(n)]||"object":typeof n}}({}); |
43
index.js
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -12,3 +12,2 @@ * Released under the MIT License. | ||
var _bindContext = require('./_bindContext.js'); | ||
var hasOwn = require('./hasOwn.js'); | ||
var _forOwn = require('./_forOwn.js'); | ||
@@ -20,2 +19,5 @@ var _assign = require('./_assign.js'); | ||
var _forNumber = require('./_forNumber.js'); | ||
var isString = require('./isString.js'); | ||
require('./chunk-7d075939.js'); | ||
var _get = require('./_get.js'); | ||
var isNumber = require('./isNumber.js'); | ||
@@ -25,9 +27,21 @@ var _isInteger = require('./_isInteger.js'); | ||
var _repeat = require('./_repeat.js'); | ||
var isObject = require('./isObject.js'); | ||
var afterCall = require('./afterCall.js'); | ||
var forOwn = require('./forOwn.js'); | ||
var alias = require('./alias.js'); | ||
var aroundCall = require('./aroundCall.js'); | ||
var assert = require('./assert.js'); | ||
var assign = require('./assign.js'); | ||
var assignDeep = require('./assignDeep.js'); | ||
var beforeCall = require('./beforeCall.js'); | ||
var copy = require('./copy.js'); | ||
var debounce = require('./debounce.js'); | ||
var isFunction = require('./isFunction.js'); | ||
var isArrayLike = require('./isArrayLike.js'); | ||
var each = require('./each.js'); | ||
var isObject = require('./isObject.js'); | ||
var forIn = require('./forIn.js'); | ||
var get = require('./get.js'); | ||
var getUid = require('./getUid.js'); | ||
var getEasyHash = require('./getEasyHash.js'); | ||
var hasOwn = require('./hasOwn.js'); | ||
var isAbsoluteURL = require('./isAbsoluteURL.js'); | ||
@@ -43,3 +57,2 @@ var toString = require('./toString.js'); | ||
var isRegExp = require('./isRegExp.js'); | ||
var isString = require('./isString.js'); | ||
var isUndefined = require('./isUndefined.js'); | ||
@@ -49,3 +62,5 @@ var isWindow = require('./isWindow.js'); | ||
var map = require('./map.js'); | ||
var mapObject = require('./mapObject.js'); | ||
var noop = require('./noop.js'); | ||
var set = require('./set.js'); | ||
var sleep = require('./sleep.js'); | ||
@@ -60,3 +75,2 @@ var type = require('./type.js'); | ||
exports._bindContext = _bindContext; | ||
exports.hasOwn = hasOwn; | ||
exports._forOwn = _forOwn; | ||
@@ -68,2 +82,4 @@ exports._assign = _assign; | ||
exports._forNumber = _forNumber; | ||
exports.isString = isString; | ||
exports._get = _get; | ||
exports.isNumber = isNumber; | ||
@@ -73,9 +89,21 @@ exports._isInteger = _isInteger; | ||
exports._repeat = _repeat; | ||
exports.isObject = isObject; | ||
exports.afterCall = afterCall; | ||
exports.forOwn = forOwn; | ||
exports.alias = alias; | ||
exports.aroundCall = aroundCall; | ||
exports.assert = assert; | ||
exports.assign = assign; | ||
exports.assignDeep = assignDeep; | ||
exports.beforeCall = beforeCall; | ||
exports.copy = copy; | ||
exports.debounce = debounce; | ||
exports.isFunction = isFunction; | ||
exports.isArrayLike = isArrayLike; | ||
exports.each = each; | ||
exports.isObject = isObject; | ||
exports.forIn = forIn; | ||
exports.get = get; | ||
exports.getUid = getUid; | ||
exports.getEasyHash = getEasyHash; | ||
exports.hasOwn = hasOwn; | ||
exports.isAbsoluteURL = isAbsoluteURL; | ||
@@ -91,3 +119,2 @@ exports.toString = toString; | ||
exports.isRegExp = isRegExp; | ||
exports.isString = isString; | ||
exports.isUndefined = isUndefined; | ||
@@ -97,4 +124,6 @@ exports.isWindow = isWindow; | ||
exports.map = map; | ||
exports.mapObject = mapObject; | ||
exports.noop = noop; | ||
exports.set = set; | ||
exports.sleep = sleep; | ||
exports.type = type; |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -11,3 +11,2 @@ * Released under the MIT License. | ||
require('./_bindContext.js'); | ||
require('./hasOwn.js'); | ||
require('./_forOwn.js'); | ||
@@ -14,0 +13,0 @@ require('./_forSlice.js'); |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
{ | ||
"name": "celia", | ||
"version": "6.0.3", | ||
"version": "6.1.0-beta.1", | ||
"description": "A modern JavaScript utility library delivering modularity, performance, and extras.", | ||
"main": "./index.js", | ||
"module": "./es.js", | ||
"unpkg": "./iife.js", | ||
"jsdelivr": "./iife.js", | ||
"unpkg": "./umd.js", | ||
"jsdelivr": "./umd.js", | ||
"scripts": { | ||
@@ -10,0 +10,0 @@ "build": "node ./scripts/build.js", |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -9,4 +9,4 @@ * Released under the MIT License. | ||
var isNil = require('./isNil.js'); | ||
var isObject = require('./isObject.js'); | ||
var isFunction = require('./isFunction.js'); | ||
var isObject = require('./isObject.js'); | ||
var toString = require('./toString.js'); | ||
@@ -13,0 +13,0 @@ |
287
umd.js
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -32,20 +32,17 @@ * Released under the MIT License. | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function hasOwn (obj, key) { | ||
return hasOwnProperty.call(obj, key); | ||
} | ||
// import hasOwn from './hasOwn'; | ||
function forOwn (value, iterator, context) { | ||
iterator = bindContext(iterator, context); | ||
// const keys = Object.keys(value); | ||
// const len = keys.length; | ||
// for (let i = 0, key; i < len; i++) { | ||
// key = keys[i]; | ||
// i = iterator(value[key], key, value) === false ? len : i; | ||
var keys = Object.keys(value); | ||
var len = keys.length; | ||
for (var i = 0, key = (void 0); i < len; i++) { | ||
key = keys[i]; | ||
iterator(value[key], key, value) === false && (i = len); | ||
} | ||
// for (let key in value) { | ||
// if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
// break; | ||
// } | ||
// } | ||
for (var key in value) { | ||
if (hasOwn(value, key) && iterator(value[key], key, value) === false) { | ||
break; | ||
} | ||
} | ||
} | ||
@@ -69,3 +66,3 @@ | ||
for (var i = start; i < end; i++) { | ||
i = iterator(value[i], i, value) === false ? end : i; | ||
iterator(value[i], i, value) === false && (i = end); | ||
} | ||
@@ -78,3 +75,3 @@ } | ||
function _forIn (value, iterator, context) { | ||
function forIn (value, iterator, context) { | ||
iterator = bindContext(iterator, context); | ||
@@ -90,6 +87,32 @@ for (var key in value) { | ||
for (var i = 0; i < value; i++) { | ||
i = iterator(i, i, value) === false ? value : i; | ||
iterator(i, i, value) === false && (i = value); | ||
} | ||
} | ||
function isString (value) { | ||
return typeof value === 'string'; | ||
} | ||
var PROP_NAME_REGEX = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; | ||
var ESCAPE_CHAR_REGEX = /\\(\\)?/g; | ||
var IS_DEEP_PROP_REGEX = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; | ||
function get (object, path) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
return object[path]; | ||
} | ||
var part; | ||
PROP_NAME_REGEX.lastIndex = 0; | ||
while (!isNil(object) && (part = PROP_NAME_REGEX.exec(path))) { | ||
var match = part[0]; | ||
var number = part[1]; | ||
var quote = part[2]; | ||
var subString = part[3]; | ||
var prop = quote ? subString.replace(ESCAPE_CHAR_REGEX, '$1') : (number || match); | ||
object = object[prop]; | ||
} | ||
return object; | ||
} | ||
function isNumber (value) { | ||
@@ -123,4 +146,132 @@ return typeof value === 'number'; | ||
function isObject (value) { | ||
return value !== null && typeof value === 'object'; | ||
} | ||
function afterCall (obj, methodName, after) { | ||
if (isObject(obj)) { | ||
var old = obj[methodName]; | ||
obj[methodName] = function () { | ||
old.apply(this, arguments); | ||
return after.apply(this, arguments); | ||
}; | ||
} | ||
} | ||
function each (value, iterator, context) { | ||
!isNil(value) && forOwn(value, iterator, context); | ||
} | ||
var isArray = Array.isArray; | ||
function alias (proto, mappings) { | ||
if (isObject(proto)) { | ||
each(mappings, function (mapping, key) { | ||
key = proto[key]; | ||
isArray(mapping) | ||
? mapping.forEach(function (m) { return (proto[m] = key); }) | ||
: (proto[mapping] = key); | ||
}); | ||
} | ||
} | ||
function aroundCall (obj, method, around) { | ||
if (isObject(obj)) { | ||
var old = obj[method]; | ||
obj[method] = function () { | ||
var args = [], len = arguments.length; | ||
while ( len-- ) args[ len ] = arguments[ len ]; | ||
return around.call(this, old, args); | ||
}; | ||
} | ||
} | ||
function assert (condition, msg) { | ||
if (!condition) { | ||
throw new Error(msg); | ||
} | ||
} | ||
var assign = Object.assign || _assign; | ||
function assign$1(target, nextSource) { | ||
var copy; | ||
!isNil(nextSource) && forOwn(nextSource, function (nextVal, nextKey) { | ||
copy = target[nextKey]; | ||
isObject(copy) && isObject(nextVal) | ||
? assign$1(copy, nextVal) | ||
: (target[nextKey] = nextVal); | ||
}); | ||
} | ||
function assignDeep (target) { | ||
if (isNil(target)) { | ||
throw new TypeError('Cannot convert undefined or null to object'); | ||
} | ||
var to = Object(target); | ||
loop(arguments, 1, arguments.length, function (nextSource) { | ||
assign$1(to, nextSource); | ||
}); | ||
return to; | ||
} | ||
function beforeCall (obj, methodName, before) { | ||
if (isObject(obj)) { | ||
var old = obj[methodName]; | ||
obj[methodName] = function () { | ||
before.apply(this, arguments); | ||
return old.apply(this, arguments); | ||
}; | ||
} | ||
} | ||
function copy(value) { | ||
return isObject(value) | ||
? assign({}, value) | ||
: value; | ||
} | ||
var isArray$1 = Array.isArray; | ||
function copyDeep(value) { | ||
var target = value; | ||
if (isArray$1(value)) { | ||
target = []; | ||
value.forEach(function (val, i) { | ||
target[i] = copyDeep(val); | ||
}); | ||
} else if (isObject(value)) { | ||
target = {}; | ||
forOwn(value, function (val, key) { | ||
target[key] = copyDeep(val); | ||
}); | ||
} | ||
return target; | ||
} | ||
function copy$1 (value, deep) { | ||
return deep ? copyDeep(value) : copy(value); | ||
} | ||
function debounce (fn, wait) { | ||
var timeout = null; | ||
function cancel() { | ||
if (timeout !== null) { | ||
clearTimeout(timeout); | ||
timeout = null; | ||
} | ||
} | ||
function debounce() { | ||
cancel(); | ||
timeout = setTimeout(fn, wait); | ||
} | ||
debounce.cancel = cancel; | ||
return debounce; | ||
} | ||
function isFunction (value) { | ||
@@ -134,3 +285,3 @@ return typeof value === 'function'; | ||
function each (value, cb, context) { | ||
function each$1 (value, cb, context) { | ||
if (isArrayLike(value)) { | ||
@@ -145,6 +296,11 @@ forEach(value, cb, context); | ||
function isObject (value) { | ||
return value !== null && typeof value === 'object'; | ||
function forIn$1 (value, iterator, context) { | ||
!isNil(value) && forIn(value, iterator, context); | ||
} | ||
function get$1 (object, path, defaultValue) { | ||
var result = isNil(object) ? undefined : get(object, path); | ||
return result === undefined ? defaultValue : result; | ||
} | ||
var UID_PROPERTY = 'celia_uid_' + ((Math.random() * 1e9) >>> 0); | ||
@@ -155,2 +311,3 @@ var uidCounter = 0; | ||
return obj[UID_PROPERTY] || (++uidCounter, Object.defineProperty(obj, UID_PROPERTY, { | ||
configurable: true, | ||
value: uidCounter | ||
@@ -166,2 +323,7 @@ }), uidCounter); | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function hasOwn (obj, key) { | ||
return hasOwnProperty.call(obj, key); | ||
} | ||
var PROTOCOL = /^([a-z][a-z\d+\-.]*:)?\/\//i; | ||
@@ -225,6 +387,2 @@ | ||
function isString (value) { | ||
return typeof value === 'string'; | ||
} | ||
function isUndefined (value) { | ||
@@ -238,3 +396,3 @@ return typeof value === 'undefined'; | ||
var isArray = Array.isArray; | ||
var isArray$2 = Array.isArray; | ||
function looseEqual(a, b) { | ||
@@ -245,3 +403,3 @@ if (a === b) { | ||
if (isObject(a) && isObject(b)) { | ||
if (isArray(a) && isArray(b)) { // 判断是否是数组 | ||
if (isArray$2(a) && isArray$2(b)) { // 判断是否是数组 | ||
return a.length === b.length && a.every(function (e, i) { | ||
@@ -266,7 +424,62 @@ return looseEqual(e, b[i]); | ||
function map$1 (elems, callback, context) { | ||
return map(each, elems, callback, context); | ||
return map(each$1, elems, callback, context); | ||
} | ||
function mapObject (elems, callback, context) { | ||
var ret = {}; | ||
var cb = bindContext(callback, context); | ||
each(elems, function (elem, key) { | ||
elem = cb(elem, key); | ||
!isNil(elem) && (ret[key] = elem); | ||
}); | ||
return ret; | ||
} | ||
function noop() { } | ||
function set (object, path, value) { | ||
if (!isNil(object)) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
object[path] = value; | ||
return; | ||
} | ||
var part; | ||
var queue = []; | ||
var i = 0; | ||
var key; | ||
PROP_NAME_REGEX.lastIndex = 0; | ||
while ((part = PROP_NAME_REGEX.exec(path))) { | ||
var match = part[0]; | ||
var number = part[1]; | ||
var quote = part[2]; | ||
var subString = part[3]; | ||
var obj = (void 0); | ||
if (quote) { | ||
key = subString.replace(ESCAPE_CHAR_REGEX, '$1'); | ||
obj = object[key]; | ||
if (isNil(obj)) { | ||
obj = object[key] = {}; | ||
} | ||
} else if (number) { | ||
obj = object[key = number]; | ||
if (isNil(obj)) { | ||
obj = object[number] = []; | ||
} | ||
} else { | ||
obj = object[key = match]; | ||
if (isNil(obj)) { | ||
obj = object[match] = {}; | ||
} | ||
} | ||
object = obj; | ||
queue[i++] = obj; | ||
} | ||
object = queue[i - 2]; | ||
object[key] = value; | ||
} | ||
} | ||
function sleep (ms) { | ||
@@ -294,6 +507,7 @@ return new Promise(function (resolve) { | ||
exports._forEach = forEach; | ||
exports._forIn = _forIn; | ||
exports._forIn = forIn; | ||
exports._forNumber = forNumber; | ||
exports._forOwn = forOwn; | ||
exports._forSlice = forSlice; | ||
exports._get = get; | ||
exports._isInteger = _isInteger; | ||
@@ -303,4 +517,15 @@ exports._loop = loop; | ||
exports._repeat = _repeat; | ||
exports.afterCall = afterCall; | ||
exports.alias = alias; | ||
exports.aroundCall = aroundCall; | ||
exports.assert = assert; | ||
exports.assign = assign; | ||
exports.each = each; | ||
exports.assignDeep = assignDeep; | ||
exports.beforeCall = beforeCall; | ||
exports.copy = copy$1; | ||
exports.debounce = debounce; | ||
exports.each = each$1; | ||
exports.forIn = forIn$1; | ||
exports.forOwn = each; | ||
exports.get = get$1; | ||
exports.getEasyHash = getEasyHash; | ||
@@ -328,3 +553,5 @@ exports.getUid = getUid; | ||
exports.map = map$1; | ||
exports.mapObject = mapObject; | ||
exports.noop = noop; | ||
exports.set = set; | ||
exports.sleep = sleep; | ||
@@ -331,0 +558,0 @@ exports.toString = toString$1; |
/* | ||
* celia.js v6.0.3 | ||
* celia.js v6.1.0-beta.1 | ||
* (c) 2018-2019 Jesse Feng | ||
* Released under the MIT License. | ||
*/ | ||
var n,t;n=this,t=function(n){"use strict";function u(n,t){return n[n.length]=t,n}function f(n){return null==n}function t(n,t,e,r){for(;t<e;t++)r(n[t],t,n)}function c(n,t){return t?n.bind(t):n}var e=Object.prototype.hasOwnProperty;function o(n,t){return e.call(n,t)}function r(n,t,e){for(var r in t=c(t,e),n)if(o(n,r)&&!1===t(n[r],r,n))break}function i(n){if(f(n))throw new TypeError("Cannot convert undefined or null to object");var e=Object(n);return t(arguments,1,arguments.length,function(n){f(n)||r(n,function(n,t){e[t]=n})}),e}function a(n,t,e,r,o){r=c(r,o);for(var i=t;i<e;i++)i=!1===r(n[i],i,n)?e:i}function s(n,t,e){a(n,0,n.length,t,e)}function l(n,t,e){t=c(t,e);for(var r=0;r<n;r++)r=!1===t(r,r,n)?n:r}function p(n){return"number"==typeof n}function b(n){return p(n)&&isFinite(n)&&n>>0===n}function y(n,t,e,r){var o=[],i=c(e,r);return n(t,function(n,t){f(n=i(n,t))||u(o,n)}),o}var g=Object.assign||i;function d(n){return"function"==typeof n}function v(n){return!f(n)&&p(n.length)&&!d(n)}function h(n,t,e){v(n)?s(n,t,e):p(n)?l(n,t,e):f(n)||r(n,t,e)}function j(n){return null!==n&&"object"==typeof n}var m="celia_uid_"+(1e9*Math.random()>>>0),O=0;function _(n){return n[m]||(++O,Object.defineProperty(n,m,{value:O}),O)}var w=/^([a-z][a-z\d+\-.]*:)?\/\//i;var E=Object.prototype.toString;function A(n){return E.call(n)}function S(n){return n instanceof Date}var x={false:!0,null:!0,undefined:!0,0:!0,NaN:!0,"":!0};var F=Number.isInteger||b;function N(n){return n instanceof RegExp}var k=Array.isArray;var P={};"Boolean,Number,String,Function,AsyncFunction,Array,Date,RegExp,Object,Error,Symbol".split(",").forEach(function(n){P["[object "+n+"]"]=n.toLowerCase()}),n._append=u,n._assign=i,n._bindContext=c,n._forEach=s,n._forIn=function(n,t,e){for(var r in t=c(t,e),n)if(!1===t(n[r],r))break},n._forNumber=l,n._forOwn=r,n._forSlice=a,n._isInteger=b,n._loop=t,n._map=y,n._repeat=function(n,t,e){for(;n<t;n++)e(n,t)},n.assign=g,n.each=h,n.getEasyHash=function(n){return j(n)?"o"+_(n):(typeof n)[0]+n},n.getUid=_,n.hasOwn=o,n.isAbsoluteURL=function(n){return w.test(n)},n.isArrayLike=v,n.isAsyncFunction=function(n){return"[object AsyncFunction]"===A(n)},n.isBoolean=function(n){return"boolean"==typeof n},n.isDate=S,n.isFalsy=function(n){return!!x[n]},n.isFunction=d,n.isInteger=F,n.isNil=f,n.isNumber=p,n.isObject=j,n.isPlainObject=function(n){return!f(n)&&"[object Object]"===A(n)},n.isPromiseLike=function(n){return!!n&&d(n.then)&&d(n.catch)},n.isRegExp=N,n.isString=function(n){return"string"==typeof n},n.isUndefined=function(n){return void 0===n},n.isWindow=function(n){return n&&n===n.window},n.looseEqual=function e(t,r){if(t===r)return!0;if(j(t)&&j(r)){if(k(t)&&k(r))return t.length===r.length&&t.every(function(n,t){return e(n,r[t])});if(S(t)&&S(r))return+t==+r;if(N(t)&&N(r))return t.toString()===r.toString();var n=Object.keys(t),o=Object.keys(r);return n.length===o.length&&n.every(function(n){return e(t[n],r[n])})}return!1},n.map=function(n,t,e){return y(h,n,t,e)},n.noop=function(){},n.sleep=function(t){return new Promise(function(n){setTimeout(n,t)})},n.toString=A,n.type=function(n){return f(n)?n+"":j(n)||d(n)?P[A(n)]||"object":typeof n}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).celia={}); | ||
var n,t;n=this,t=function(n){"use strict";function u(n,t){return n[n.length]=t,n}function p(n){return null==n}function e(n,t,r,e){for(;t<r;t++)e(n[t],t,n)}function f(n,t){return t?n.bind(t):n}function i(n,t,r){t=f(t,r);for(var e=Object.keys(n),o=e.length,i=0,u=void 0;i<o;i++)!1===t(n[u=e[i]],u,n)&&(i=o)}function t(n){if(p(n))throw new TypeError("Cannot convert undefined or null to object");var r=Object(n);return e(arguments,1,arguments.length,function(n){p(n)||i(n,function(n,t){r[t]=n})}),r}function o(n,t,r,e,o){e=f(e,o);for(var i=t;i<r;i++)!1===e(n[i],i,n)&&(i=r)}function c(n,t,r){o(n,0,n.length,t,r)}function a(n,t,r){for(var e in t=f(t,r),n)if(!1===t(n[e],e))break}function s(n,t,r){t=f(t,r);for(var e=0;e<n;e++)!1===t(e,e,n)&&(e=n)}function v(n){return"string"==typeof n}var y=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,d=/\\(\\)?/g,b=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;function l(n,t){if(!v(t)||!b.test(t))return n[t];var r;for(y.lastIndex=0;!p(n)&&(r=y.exec(t));){var e=r[0],o=r[1],i=r[2],u=r[3];n=n[i?u.replace(d,"$1"):o||e]}return n}function g(n){return"number"==typeof n}function r(n){return g(n)&&isFinite(n)&&n>>0===n}function h(n,t,r,e){var o=[],i=f(r,e);return n(t,function(n,t){p(n=i(n,t))||u(o,n)}),o}function j(n){return null!==n&&"object"==typeof n}function O(n,t,r){p(n)||i(n,t,r)}var m=Array.isArray;var w=Object.assign||t;var _=Array.isArray;function E(n){return"function"==typeof n}function A(n){return!p(n)&&g(n.length)&&!E(n)}function x(n,t,r){A(n)?c(n,t,r):g(n)?s(n,t,r):p(n)||i(n,t,r)}var S="celia_uid_"+(1e9*Math.random()>>>0),C=0;function F(n){return n[S]||(++C,Object.defineProperty(n,S,{configurable:!0,value:C}),C)}var I=Object.prototype.hasOwnProperty;var N=/^([a-z][a-z\d+\-.]*:)?\/\//i;var k=Object.prototype.toString;function P(n){return k.call(n)}function T(n){return n instanceof Date}var D={false:!0,null:!0,undefined:!0,0:!0,NaN:!0,"":!0};var L=Number.isInteger||r;function R(n){return n instanceof RegExp}var U=Array.isArray;var $={};"Boolean,Number,String,Function,AsyncFunction,Array,Date,RegExp,Object,Error,Symbol".split(",").forEach(function(n){$["[object "+n+"]"]=n.toLowerCase()}),n._append=u,n._assign=t,n._bindContext=f,n._forEach=c,n._forIn=a,n._forNumber=s,n._forOwn=i,n._forSlice=o,n._get=l,n._isInteger=r,n._loop=e,n._map=h,n._repeat=function(n,t,r){for(;n<t;n++)r(n,t)},n.afterCall=function(n,t,r){if(j(n)){var e=n[t];n[t]=function(){return e.apply(this,arguments),r.apply(this,arguments)}}},n.alias=function(r,n){j(r)&&O(n,function(n,t){t=r[t],m(n)?n.forEach(function(n){return r[n]=t}):r[n]=t})},n.aroundCall=function(n,t,r){if(j(n)){var e=n[t];n[t]=function(){for(var n=[],t=arguments.length;t--;)n[t]=arguments[t];return r.call(this,e,n)}}},n.assert=function(n,t){if(!n)throw new Error(t)},n.assign=w,n.assignDeep=function(n){if(p(n))throw new TypeError("Cannot convert undefined or null to object");var t=Object(n);return e(arguments,1,arguments.length,function(n){!function r(e,n){var o;p(n)||i(n,function(n,t){j(o=e[t])&&j(n)?r(o,n):e[t]=n})}(t,n)}),t},n.beforeCall=function(n,t,r){if(j(n)){var e=n[t];n[t]=function(){return r.apply(this,arguments),e.apply(this,arguments)}}},n.copy=function(n,t){return t?function r(n){var e=n;return _(n)?(e=[],n.forEach(function(n,t){e[t]=r(n)})):j(n)&&(e={},i(n,function(n,t){e[t]=r(n)})),e}(n):function(n){return j(n)?w({},n):n}(n)},n.debounce=function(n,t){var r=null;function e(){null!==r&&(clearTimeout(r),r=null)}function o(){e(),r=setTimeout(n,t)}return o.cancel=e,o},n.each=x,n.forIn=function(n,t,r){p(n)||a(n,t,r)},n.forOwn=O,n.get=function(n,t,r){var e=p(n)?void 0:l(n,t);return void 0===e?r:e},n.getEasyHash=function(n){return j(n)?"o"+F(n):(typeof n)[0]+n},n.getUid=F,n.hasOwn=function(n,t){return I.call(n,t)},n.isAbsoluteURL=function(n){return N.test(n)},n.isArrayLike=A,n.isAsyncFunction=function(n){return"[object AsyncFunction]"===P(n)},n.isBoolean=function(n){return"boolean"==typeof n},n.isDate=T,n.isFalsy=function(n){return!!D[n]},n.isFunction=E,n.isInteger=L,n.isNil=p,n.isNumber=g,n.isObject=j,n.isPlainObject=function(n){return!p(n)&&"[object Object]"===P(n)},n.isPromiseLike=function(n){return!!n&&E(n.then)&&E(n.catch)},n.isRegExp=R,n.isString=v,n.isUndefined=function(n){return void 0===n},n.isWindow=function(n){return n&&n===n.window},n.looseEqual=function r(t,e){if(t===e)return!0;if(j(t)&&j(e)){if(U(t)&&U(e))return t.length===e.length&&t.every(function(n,t){return r(n,e[t])});if(T(t)&&T(e))return+t==+e;if(R(t)&&R(e))return t.toString()===e.toString();var n=Object.keys(t),o=Object.keys(e);return n.length===o.length&&n.every(function(n){return r(t[n],e[n])})}return!1},n.map=function(n,t,r){return h(x,n,t,r)},n.mapObject=function(n,t,r){var e={},o=f(t,r);return O(n,function(n,t){p(n=o(n,t))||(e[t]=n)}),e},n.noop=function(){},n.set=function(n,t,r){if(!p(n)){if(!v(t)||!b.test(t))return void(n[t]=r);var e,o,i=[],u=0;for(y.lastIndex=0;e=y.exec(t);){var f=e[0],c=e[1],a=e[2],s=e[3],l=void 0;a?p(l=n[o=s.replace(d,"$1")])&&(l=n[o]={}):c?p(l=n[o=c])&&(l=n[c]=[]):p(l=n[o=f])&&(l=n[f]={}),n=l,i[u++]=l}(n=i[u-2])[o]=r}},n.sleep=function(t){return new Promise(function(n){setTimeout(n,t)})},n.toString=P,n.type=function(n){return p(n)?n+"":j(n)||E(n)?$[P(n)]||"object":typeof n}},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).celia={}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
125474
122
3744
1