Comparing version 5.6.2 to 5.7.0
export const DASH_ALPHA_REGEX = /[-_. ]+([a-z])/g; | ||
export const PROP_NAME_REGEX = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; | ||
export const ESCAPE_CHAR_REGEX = /\\(\\)?/g; | ||
export const IS_DEEP_PROP_REGEX = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -91,2 +91,3 @@ * Released under the MIT License. | ||
var ESCAPE_CHAR_REGEX = /\\(\\)?/g; | ||
var IS_DEEP_PROP_REGEX = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; | ||
@@ -211,7 +212,7 @@ function isString (value) { | ||
function isUndefined (value) { | ||
return typeof value === 'undefined'; | ||
} | ||
function get (object, path) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
return object[path]; | ||
} | ||
function get (object, path, defaultValue) { | ||
var part; | ||
@@ -226,5 +227,10 @@ while (!isNil(object) && (part = PROP_NAME_REGEX.exec(path))) { | ||
} | ||
return isUndefined(object) ? defaultValue : object; | ||
return object; | ||
} | ||
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); | ||
@@ -289,2 +295,6 @@ var uidCounter = 0; | ||
function isUndefined (value) { | ||
return typeof value === 'undefined'; | ||
} | ||
function isWindow (elem) { | ||
@@ -386,3 +396,3 @@ return elem && elem === elem.window; | ||
forOwn: forOwn$1, | ||
get: get, | ||
get: get$1, | ||
map: map$3 | ||
@@ -392,3 +402,7 @@ }; | ||
function decode(input) { | ||
return decodeURIComponent(input.replace(/\+/g, ' ')); | ||
try { | ||
return decodeURIComponent(input.replace(/\+/g, ' ')); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
@@ -405,12 +419,13 @@ | ||
var key = part[1]; | ||
// 匹配到querystring | ||
if (part[0] !== key) { | ||
var value = part[2]; | ||
var value = decode(part[2]); | ||
var last = result[key]; | ||
// 没有相同的key值 | ||
if (isUndefined(last)) { | ||
result[key] = decode(value); | ||
result[key] = value; | ||
} else if (isArray$1(last)) { // 继续追加 | ||
append(last, decode(value)); | ||
append(last, value); | ||
} else { // 已存在key | ||
result[key] = [last, decode(value)]; | ||
result[key] = [last, value]; | ||
} | ||
@@ -427,2 +442,10 @@ } | ||
function encode(input) { | ||
try { | ||
return encodeURIComponent(input); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
function stringify(obj, sep, eq) { | ||
@@ -434,6 +457,12 @@ if ( sep === void 0 ) sep = '&'; | ||
forOwn$1(obj, function (value, key) { | ||
if (!value && (isNil(value) || isNaN(value))) { | ||
if (isNil(value) || isNaN(value)) { | ||
value = ''; | ||
} | ||
append(arr, encodeURIComponent(key) + eq + encodeURIComponent(value)); | ||
key = encode(key); | ||
value = encode(value); | ||
if (key && value) { | ||
append(arr, key + eq + value); | ||
} | ||
}); | ||
@@ -449,2 +478,45 @@ return arr.length ? arr.join(sep) : ''; | ||
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; | ||
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) { | ||
@@ -506,3 +578,3 @@ return new Promise(function (resolve) { | ||
forOwn: forOwn$1, | ||
get: get, | ||
get: get$1, | ||
getUid: getUid, | ||
@@ -531,2 +603,3 @@ hasOwn: hasOwn, | ||
qs: qs, | ||
set: set, | ||
sleep: sleep, | ||
@@ -533,0 +606,0 @@ type: type, |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -89,2 +89,3 @@ * Released under the MIT License. | ||
var ESCAPE_CHAR_REGEX = /\\(\\)?/g; | ||
var IS_DEEP_PROP_REGEX = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; | ||
@@ -209,7 +210,7 @@ function isString (value) { | ||
function isUndefined (value) { | ||
return typeof value === 'undefined'; | ||
} | ||
function get (object, path) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
return object[path]; | ||
} | ||
function get (object, path, defaultValue) { | ||
var part; | ||
@@ -224,5 +225,10 @@ while (!isNil(object) && (part = PROP_NAME_REGEX.exec(path))) { | ||
} | ||
return isUndefined(object) ? defaultValue : object; | ||
return object; | ||
} | ||
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); | ||
@@ -287,2 +293,6 @@ var uidCounter = 0; | ||
function isUndefined (value) { | ||
return typeof value === 'undefined'; | ||
} | ||
function isWindow (elem) { | ||
@@ -384,3 +394,3 @@ return elem && elem === elem.window; | ||
forOwn: forOwn$1, | ||
get: get, | ||
get: get$1, | ||
map: map$3 | ||
@@ -390,3 +400,7 @@ }; | ||
function decode(input) { | ||
return decodeURIComponent(input.replace(/\+/g, ' ')); | ||
try { | ||
return decodeURIComponent(input.replace(/\+/g, ' ')); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
@@ -403,12 +417,13 @@ | ||
var key = part[1]; | ||
// 匹配到querystring | ||
if (part[0] !== key) { | ||
var value = part[2]; | ||
var value = decode(part[2]); | ||
var last = result[key]; | ||
// 没有相同的key值 | ||
if (isUndefined(last)) { | ||
result[key] = decode(value); | ||
result[key] = value; | ||
} else if (isArray$1(last)) { // 继续追加 | ||
append(last, decode(value)); | ||
append(last, value); | ||
} else { // 已存在key | ||
result[key] = [last, decode(value)]; | ||
result[key] = [last, value]; | ||
} | ||
@@ -425,2 +440,10 @@ } | ||
function encode(input) { | ||
try { | ||
return encodeURIComponent(input); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
function stringify(obj, sep, eq) { | ||
@@ -432,6 +455,12 @@ if ( sep === void 0 ) sep = '&'; | ||
forOwn$1(obj, function (value, key) { | ||
if (!value && (isNil(value) || isNaN(value))) { | ||
if (isNil(value) || isNaN(value)) { | ||
value = ''; | ||
} | ||
append(arr, encodeURIComponent(key) + eq + encodeURIComponent(value)); | ||
key = encode(key); | ||
value = encode(value); | ||
if (key && value) { | ||
append(arr, key + eq + value); | ||
} | ||
}); | ||
@@ -447,2 +476,45 @@ return arr.length ? arr.join(sep) : ''; | ||
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; | ||
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) { | ||
@@ -504,3 +576,3 @@ return new Promise(function (resolve) { | ||
forOwn: forOwn$1, | ||
get: get, | ||
get: get$1, | ||
getUid: getUid, | ||
@@ -529,2 +601,3 @@ hasOwn: hasOwn, | ||
qs: qs, | ||
set: set, | ||
sleep: sleep, | ||
@@ -531,0 +604,0 @@ type: type, |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -95,2 +95,3 @@ * Released under the MIT License. | ||
var ESCAPE_CHAR_REGEX = /\\(\\)?/g; | ||
var IS_DEEP_PROP_REGEX = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; | ||
@@ -215,7 +216,7 @@ function isString (value) { | ||
function isUndefined (value) { | ||
return typeof value === 'undefined'; | ||
} | ||
function get (object, path) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
return object[path]; | ||
} | ||
function get (object, path, defaultValue) { | ||
var part; | ||
@@ -230,5 +231,10 @@ while (!isNil(object) && (part = PROP_NAME_REGEX.exec(path))) { | ||
} | ||
return isUndefined(object) ? defaultValue : object; | ||
return object; | ||
} | ||
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); | ||
@@ -293,2 +299,6 @@ var uidCounter = 0; | ||
function isUndefined (value) { | ||
return typeof value === 'undefined'; | ||
} | ||
function isWindow (elem) { | ||
@@ -390,3 +400,3 @@ return elem && elem === elem.window; | ||
forOwn: forOwn$1, | ||
get: get, | ||
get: get$1, | ||
map: map$3 | ||
@@ -396,3 +406,7 @@ }; | ||
function decode(input) { | ||
return decodeURIComponent(input.replace(/\+/g, ' ')); | ||
try { | ||
return decodeURIComponent(input.replace(/\+/g, ' ')); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
@@ -409,12 +423,13 @@ | ||
var key = part[1]; | ||
// 匹配到querystring | ||
if (part[0] !== key) { | ||
var value = part[2]; | ||
var value = decode(part[2]); | ||
var last = result[key]; | ||
// 没有相同的key值 | ||
if (isUndefined(last)) { | ||
result[key] = decode(value); | ||
result[key] = value; | ||
} else if (isArray$1(last)) { // 继续追加 | ||
append(last, decode(value)); | ||
append(last, value); | ||
} else { // 已存在key | ||
result[key] = [last, decode(value)]; | ||
result[key] = [last, value]; | ||
} | ||
@@ -431,2 +446,10 @@ } | ||
function encode(input) { | ||
try { | ||
return encodeURIComponent(input); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
function stringify(obj, sep, eq) { | ||
@@ -438,6 +461,12 @@ if ( sep === void 0 ) sep = '&'; | ||
forOwn$1(obj, function (value, key) { | ||
if (!value && (isNil(value) || isNaN(value))) { | ||
if (isNil(value) || isNaN(value)) { | ||
value = ''; | ||
} | ||
append(arr, encodeURIComponent(key) + eq + encodeURIComponent(value)); | ||
key = encode(key); | ||
value = encode(value); | ||
if (key && value) { | ||
append(arr, key + eq + value); | ||
} | ||
}); | ||
@@ -453,2 +482,45 @@ return arr.length ? arr.join(sep) : ''; | ||
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; | ||
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) { | ||
@@ -510,3 +582,3 @@ return new Promise(function (resolve) { | ||
forOwn: forOwn$1, | ||
get: get, | ||
get: get$1, | ||
getUid: getUid, | ||
@@ -535,2 +607,3 @@ hasOwn: hasOwn, | ||
qs: qs, | ||
set: set, | ||
sleep: sleep, | ||
@@ -537,0 +610,0 @@ type: type, |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
* Released under the MIT License. | ||
*/ | ||
var n,t;n=this,t=function(){"use strict";var n={after:function(n,t,e){var r=n[t];n[t]=function(){r.apply(this,arguments),e.call(this)}},around:function(n,t,e){var r=n[t];n[t]=function(){for(var n=[],t=arguments.length;t--;)n[t]=arguments[t];return e.call(this,r,n)}},before:function(n,t,e){var r=n[t];n[t]=function(){e.call(this),r.apply(this,arguments)}}},t={objectobject:7,objectundefined:6};var e={msie:function(){return document.documentMode||t[typeof document.all+typeof XMLHttpRequest]},os:function(n){n=n||"";var t={};t.webkit=n.match(/WebKit\/([\d.]+)/),t.android=n.match(/(Android)\s+([\d.]+)/)||n.match(/Silk-Accelerated/),t.androidICS=t.android&&n.match(/(Android)\s4/),t.ipad=n.match(/(iPad).*OS\s([\d_]+)/),t.iphone=!t.ipad&&n.match(/(iPhone\sOS)\s([\d_]+)/),t.ios7=(t.ipad||t.iphone)&&(n.match(/7_/)||n.match(/8_/)),t.webos=n.match(/(webOS|hpwOS)[\s/]([\d.]+)/),t.touchpad=t.webos&&n.match(/TouchPad/),t.ios=t.ipad||t.iphone,t.playbook=n.match(/PlayBook/),t.blackberry10=n.match(/BB10/),t.blackberry=t.playbook||t.blackberry10||n.match(/BlackBerry/),t.chrome=n.match(/Chrome/),t.opera=n.match(/Opera/),t.safari=n.match(/Safari\/([\d.]+)/),t.fennec=n.match(/fennec/i)||n.match(/Firefox/);var e=n.match(/MSIE\s([\d.]+)/)||n.match(/(?:trident)(?:.*rv:([\w.]+))?/i);return e&&(t.ie=parseFloat(e[1])),t.ieTouch=t.ie&&n.toLowerCase().match(/touch/i),t.tizen=n.match(/Tizen/i),t.kindle=n.match(/Silk-Accelerated/),t.wechat=n.match(/MicroMessenger/i),t}},r=/[-_. ]+([a-z])/g,a=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,f=/\\(\\)?/g;function c(n){return"string"==typeof n}function s(n){return null==n}function o(n){return"function"==typeof n}function i(n){return"number"==typeof n}function u(n){return!s(n)&&i(n.length)&&!o(n)}function l(n,t){return t?n.bind(t):n}function d(n,t,e,r,o){for(var i=l(r,o),c=t,u=void 0;!1!==u&&c<e;c++)u=i(n[c],c,n)}function h(n,t,e){d(n,0,n.length,t,e)}function p(n,t,e,r){var o=l(e,r);for(var i in t)if(!1===n(o,t[i],i))break}function m(r,n,t){p(function(n,t,e){if(r.hasOwnProperty(e))return n(t,e,r)},r,n,t)}function b(n,t,e){for(var r=l(t,e),o=0,i=void 0;!1!==i&&o<n;o++)i=r(o,o,o)}function v(n,t,e){n&&(u(n)?h(n,t,e):i(n)?b(n,t,e):m(n,t,e))}function y(n,t,e){return n&&b(n,t,e)}function g(n){return null!==n&&"object"==typeof n}function j(n,t,e){return g(n)&&m(n,t,e)}function w(n){return void 0===n}function O(n,t,e){for(var r;!s(n)&&(r=a.exec(t));){var o=r[0],i=r[1],c=r[2],u=r[3];n=n[c?u.replace(f,"$1"):i||o]}return w(n)?e:n}var k="celia_uid_"+(1e9*Math.random()>>>0),S=0;var A=Object.prototype.hasOwnProperty;var C=Object.prototype.toString;function x(n){return C.call(n)}function E(n){return n instanceof Date}var P=Number.isInteger||function(n){return i(n)&&isFinite(n)&&n>>0===n};function F(n){return n instanceof RegExp}var I=Array.isArray;function N(n,t){return n[n.length]=t,n}function B(n,t,e,r){var o=[],i=l(e,r);return n(t,function(n,t){s(n=i(n,t))||N(o,n)}),o}var R={forNumber:y,map:function(n,t,e){return B(y,n,t,e)}};var T={assign:Object.assign||function(n){if(s(n))throw new TypeError("Cannot convert undefined or null to object");var e=Object(n);return d(arguments,1,arguments.length,function(n){m(n,function(n,t){e[t]=n})}),e},forIn:function(n,t,e){return g(n)&&function(r,n,t){p(function(n,t,e){return n(t,e,r)},r,n,t)}(n,t,e)},forOwn:j,get:O,map:function(n,t,e){return B(j,n,t,e)}};function _(n){return decodeURIComponent(n.replace(/\+/g," "))}var M=/([^=?&]+)=?([^&]*)/g,U=Array.isArray;var z={parse:function(n){var t={};if(c(n))for(var e;e=M.exec(n);){var r=e[1];if(e[0]!==r){var o=e[2],i=t[r];w(i)?t[r]=_(o):U(i)?N(i,_(o)):t[r]=[i,_(o)]}}return t},prefix:function(n,t){return n?(t||"?")+n:n},stringify:function(n,t,e){void 0===t&&(t="&"),void 0===e&&(e="=");var r=[];return j(n,function(n,t){n||!s(n)&&!isNaN(n)||(n=""),N(r,encodeURIComponent(t)+e+encodeURIComponent(n))}),r.length?r.join(t):""}};var L={};"Boolean,Number,String,Function,AsyncFunction,Array,Date,RegExp,Object,Error,Symbol".split(",").forEach(function(n){L["[object "+n+"]"]=n.toLowerCase()});var q={isAbsolute:function(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)},join:function(n){var t=arguments.length;s(n)?1<t&&(n=""):n=n.replace(/\/+$/,"");var e="";return d(arguments,1,t,function(n){n&&(e+="/",e+=n)}),e&&(n+=e.replace(/\/+/g,"/")),n}};return{aop:n,browser:e,camelCase:function(n){return c(n)?n.replace(r,function(n,t){return t.toUpperCase()}):n},debounce:function(n,t){var e=null;function r(){null!==e&&(clearTimeout(e),e=null)}function o(){r(),e=setTimeout(n,t)}return o.cancel=r,o},each:v,forEach:function(n,t,e){return n&&h(n,t,e)},forNumber:y,forOwn:j,get:O,getUid:function(n){return n[k]||(n[k]=++S)},hasOwn:function(n,t){return A.call(n,t)},isArrayLike:u,isAsyncFunction:function(n){return"[object AsyncFunction]"===x(n)},isBoolean:function(n){return"boolean"==typeof n},isDate:E,isFunction:o,isInteger:P,isNil:s,isNumber:i,isObject:g,isPlainObject:function(n){return!s(n)&&"[object Object]"===x(n)},isPromiseLike:function(n){return!!n&&o(n.then)&&o(n.catch)},isRegExp:F,isString:c,isUndefined:w,isWindow:function(n){return n&&n===n.window},looseEqual:function e(t,r){if(g(t)&&g(r)){if(I(t)&&I(r))return t.length===r.length&&t.every(function(n,t){return e(n,r[t])});if(E(t)&&E(r))return+t==+r;if(F(t)&&F(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 t===r},map:function(n,t,e){return B(v,n,t,e)},noop:function(){},number:R,object:T,qs:z,sleep:function(t){return new Promise(function(n){setTimeout(n,t)})},type:function(n){return s(n)?n+"":g(n)||o(n)?L[x(n)]||"object":typeof n},url:q}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n=n||self).celia=t(); | ||
var n,t;n=this,t=function(){"use strict";var n={after:function(n,t,e){var r=n[t];n[t]=function(){r.apply(this,arguments),e.call(this)}},around:function(n,t,e){var r=n[t];n[t]=function(){for(var n=[],t=arguments.length;t--;)n[t]=arguments[t];return e.call(this,r,n)}},before:function(n,t,e){var r=n[t];n[t]=function(){e.call(this),r.apply(this,arguments)}}},t={objectobject:7,objectundefined:6};var e={msie:function(){return document.documentMode||t[typeof document.all+typeof XMLHttpRequest]},os:function(n){n=n||"";var t={};t.webkit=n.match(/WebKit\/([\d.]+)/),t.android=n.match(/(Android)\s+([\d.]+)/)||n.match(/Silk-Accelerated/),t.androidICS=t.android&&n.match(/(Android)\s4/),t.ipad=n.match(/(iPad).*OS\s([\d_]+)/),t.iphone=!t.ipad&&n.match(/(iPhone\sOS)\s([\d_]+)/),t.ios7=(t.ipad||t.iphone)&&(n.match(/7_/)||n.match(/8_/)),t.webos=n.match(/(webOS|hpwOS)[\s/]([\d.]+)/),t.touchpad=t.webos&&n.match(/TouchPad/),t.ios=t.ipad||t.iphone,t.playbook=n.match(/PlayBook/),t.blackberry10=n.match(/BB10/),t.blackberry=t.playbook||t.blackberry10||n.match(/BlackBerry/),t.chrome=n.match(/Chrome/),t.opera=n.match(/Opera/),t.safari=n.match(/Safari\/([\d.]+)/),t.fennec=n.match(/fennec/i)||n.match(/Firefox/);var e=n.match(/MSIE\s([\d.]+)/)||n.match(/(?:trident)(?:.*rv:([\w.]+))?/i);return e&&(t.ie=parseFloat(e[1])),t.ieTouch=t.ie&&n.toLowerCase().match(/touch/i),t.tizen=n.match(/Tizen/i),t.kindle=n.match(/Silk-Accelerated/),t.wechat=n.match(/MicroMessenger/i),t}},r=/[-_. ]+([a-z])/g,d=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,h=/\\(\\)?/g,p=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;function m(n){return"string"==typeof n}function v(n){return null==n}function o(n){return"function"==typeof n}function i(n){return"number"==typeof n}function c(n){return!v(n)&&i(n.length)&&!o(n)}function a(n,t){return t?n.bind(t):n}function u(n,t,e,r,o){for(var i=a(r,o),c=t,u=void 0;!1!==u&&c<e;c++)u=i(n[c],c,n)}function f(n,t,e){u(n,0,n.length,t,e)}function s(n,t,e,r){var o=a(e,r);for(var i in t)if(!1===n(o,t[i],i))break}function l(r,n,t){s(function(n,t,e){if(r.hasOwnProperty(e))return n(t,e,r)},r,n,t)}function b(n,t,e){for(var r=a(t,e),o=0,i=void 0;!1!==i&&o<n;o++)i=r(o,o,o)}function y(n,t,e){n&&(c(n)?f(n,t,e):i(n)?b(n,t,e):l(n,t,e))}function g(n,t,e){return n&&b(n,t,e)}function j(n){return null!==n&&"object"==typeof n}function w(n,t,e){return j(n)&&l(n,t,e)}function O(n,t,e){var r=v(n)?void 0:function(n,t){if(!m(t)||!p.test(t))return n[t];for(var e;!v(n)&&(e=d.exec(t));){var r=e[0],o=e[1],i=e[2],c=e[3];n=n[i?c.replace(h,"$1"):o||r]}return n}(n,t);return void 0===r?e:r}var k="celia_uid_"+(1e9*Math.random()>>>0),S=0;var A=Object.prototype.hasOwnProperty;var x=Object.prototype.toString;function C(n){return x.call(n)}function E(n){return n instanceof Date}var P=Number.isInteger||function(n){return i(n)&&isFinite(n)&&n>>0===n};function F(n){return n instanceof RegExp}function N(n){return void 0===n}var B=Array.isArray;function I(n,t){return n[n.length]=t,n}function T(n,t,e,r){var o=[],i=a(e,r);return n(t,function(n,t){v(n=i(n,t))||I(o,n)}),o}var _={forNumber:g,map:function(n,t,e){return T(g,n,t,e)}};var M={assign:Object.assign||function(n){if(v(n))throw new TypeError("Cannot convert undefined or null to object");var e=Object(n);return u(arguments,1,arguments.length,function(n){l(n,function(n,t){e[t]=n})}),e},forIn:function(n,t,e){return j(n)&&function(r,n,t){s(function(n,t,e){return n(t,e,r)},r,n,t)}(n,t,e)},forOwn:w,get:O,map:function(n,t,e){return T(w,n,t,e)}};function R(n){try{return decodeURIComponent(n.replace(/\+/g," "))}catch(n){return null}}var z=/([^=?&]+)=?([^&]*)/g,L=Array.isArray;function U(n){try{return encodeURIComponent(n)}catch(n){return null}}var $={parse:function(n){var t={};if(m(n))for(var e;e=z.exec(n);){var r=e[1];if(e[0]!==r){var o=R(e[2]),i=t[r];N(i)?t[r]=o:L(i)?I(i,o):t[r]=[i,o]}}return t},prefix:function(n,t){return n?(t||"?")+n:n},stringify:function(n,t,e){void 0===t&&(t="&"),void 0===e&&(e="=");var r=[];return w(n,function(n,t){(v(n)||isNaN(n))&&(n=""),t=U(t),n=U(n),t&&n&&I(r,t+e+n)}),r.length?r.join(t):""}};var q={};"Boolean,Number,String,Function,AsyncFunction,Array,Date,RegExp,Object,Error,Symbol".split(",").forEach(function(n){q["[object "+n+"]"]=n.toLowerCase()});var D={isAbsolute:function(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)},join:function(n){var t=arguments.length;v(n)?1<t&&(n=""):n=n.replace(/\/+$/,"");var e="";return u(arguments,1,t,function(n){n&&(e+="/",e+=n)}),e&&(n+=e.replace(/\/+/g,"/")),n}};return{aop:n,browser:e,camelCase:function(n){return m(n)?n.replace(r,function(n,t){return t.toUpperCase()}):n},debounce:function(n,t){var e=null;function r(){null!==e&&(clearTimeout(e),e=null)}function o(){r(),e=setTimeout(n,t)}return o.cancel=r,o},each:y,forEach:function(n,t,e){return n&&f(n,t,e)},forNumber:g,forOwn:w,get:O,getUid:function(n){return n[k]||(n[k]=++S)},hasOwn:function(n,t){return A.call(n,t)},isArrayLike:c,isAsyncFunction:function(n){return"[object AsyncFunction]"===C(n)},isBoolean:function(n){return"boolean"==typeof n},isDate:E,isFunction:o,isInteger:P,isNil:v,isNumber:i,isObject:j,isPlainObject:function(n){return!v(n)&&"[object Object]"===C(n)},isPromiseLike:function(n){return!!n&&o(n.then)&&o(n.catch)},isRegExp:F,isString:m,isUndefined:N,isWindow:function(n){return n&&n===n.window},looseEqual:function e(t,r){if(j(t)&&j(r)){if(B(t)&&B(r))return t.length===r.length&&t.every(function(n,t){return e(n,r[t])});if(E(t)&&E(r))return+t==+r;if(F(t)&&F(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 t===r},map:function(n,t,e){return T(y,n,t,e)},noop:function(){},number:_,object:M,qs:$,set:function(n,t,e){if(!v(n)){if(!m(t)||!p.test(t))return void(n[t]=e);for(var r,o,i=[],c=0;r=d.exec(t);){var u=r[0],a=r[1],f=r[2],s=r[3],l=void 0;f?v(l=n[o=s.replace(h,"$1")])&&(l=n[o]={}):a?v(l=n[o=a])&&(l=n[a]=[]):v(l=n[o=u])&&(l=n[u]={}),n=l,i[c++]=l}(n=i[c-2])[o]=e}},sleep:function(t){return new Promise(function(n){setTimeout(n,t)})},type:function(n){return v(n)?n+"":j(n)||o(n)?q[C(n)]||"object":typeof n},url:D}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n=n||self).celia=t(); |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
* Released under the MIT License. | ||
*/ | ||
var n,e;n=this,e=function(){"use strict";function f(n,e){return e?n.bind(e):n}function u(n,e,t){return n&&function(n,e,t){for(var u=f(e,t),o=0,r=void 0;!1!==r&&o<n;o++)r=u(o,o,o)}(n,e,t)}return{forNumber:u,map:function(n,e,t){return function(n,e,t,u){var o=[],r=f(t,u);return n(e,function(n,e){(function(n){return null==n})(n=r(n,e))||function(n,e){n[n.length]=e}(o,n)}),o}(u,n,e,t)}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n=n||self).celia=e(); | ||
var n,e;n=this,e=function(){"use strict";function f(n,e){return e?n.bind(e):n}function u(n,e,t){return n&&function(n,e,t){for(var u=f(e,t),o=0,r=void 0;!1!==r&&o<n;o++)r=u(o,o,o)}(n,e,t)}return{forNumber:u,map:function(n,e,t){return function(n,e,t,u){var o=[],r=f(t,u);return n(e,function(n,e){!function(n){return null==n}(n=r(n,e))&&function(n,e){n[n.length]=e}(o,n)}),o}(u,n,e,t)}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n=n||self).celia=e(); |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -81,4 +81,4 @@ * Released under the MIT License. | ||
function isUndefined (value) { | ||
return typeof value === 'undefined'; | ||
function isString (value) { | ||
return typeof value === 'string'; | ||
} | ||
@@ -88,4 +88,9 @@ | ||
var ESCAPE_CHAR_REGEX = /\\(\\)?/g; | ||
var IS_DEEP_PROP_REGEX = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; | ||
function get (object, path, defaultValue) { | ||
function get (object, path) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
return object[path]; | ||
} | ||
var part; | ||
@@ -100,5 +105,10 @@ while (!isNil(object) && (part = PROP_NAME_REGEX.exec(path))) { | ||
} | ||
return isUndefined(object) ? defaultValue : object; | ||
return object; | ||
} | ||
function get$1 (object, path, defaultValue) { | ||
var result = isNil(object) ? undefined : get(object, path); | ||
return result === undefined ? defaultValue : result; | ||
} | ||
function append (arr, obj) { | ||
@@ -129,3 +139,3 @@ arr[arr.length] = obj; | ||
forOwn: forOwn$1, | ||
get: get, | ||
get: get$1, | ||
map: map$1 | ||
@@ -132,0 +142,0 @@ }; |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -85,4 +85,4 @@ * Released under the MIT License. | ||
function isUndefined (value) { | ||
return typeof value === 'undefined'; | ||
function isString (value) { | ||
return typeof value === 'string'; | ||
} | ||
@@ -92,4 +92,9 @@ | ||
var ESCAPE_CHAR_REGEX = /\\(\\)?/g; | ||
var IS_DEEP_PROP_REGEX = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/; | ||
function get (object, path, defaultValue) { | ||
function get (object, path) { | ||
if (!isString(path) || !IS_DEEP_PROP_REGEX.test(path)) { | ||
return object[path]; | ||
} | ||
var part; | ||
@@ -104,5 +109,10 @@ while (!isNil(object) && (part = PROP_NAME_REGEX.exec(path))) { | ||
} | ||
return isUndefined(object) ? defaultValue : object; | ||
return object; | ||
} | ||
function get$1 (object, path, defaultValue) { | ||
var result = isNil(object) ? undefined : get(object, path); | ||
return result === undefined ? defaultValue : result; | ||
} | ||
function append (arr, obj) { | ||
@@ -133,3 +143,3 @@ arr[arr.length] = obj; | ||
forOwn: forOwn$1, | ||
get: get, | ||
get: get$1, | ||
map: map$1 | ||
@@ -136,0 +146,0 @@ }; |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
* Released under the MIT License. | ||
*/ | ||
var n,t;n=this,t=function(){"use strict";function c(n){return null==n}function a(n,t){return t?n.bind(t):n}function o(n,t,r,e){var o=a(r,e);for(var u in t)if(!1===n(o,t[u],u))break}function e(e,n,t){o(function(n,t,r){if(e.hasOwnProperty(r))return n(t,r,e)},e,n,t)}var n=Object.assign||function(n){if(c(n))throw new TypeError("Cannot convert undefined or null to object");var r=Object(n);return function(n,t,r,e,o){for(var u=a(e,o),f=t,i=void 0;!1!==i&&f<r;f++)i=u(n[f],f,n)}(arguments,1,arguments.length,function(n){e(n,function(n,t){r[t]=n})}),r};function u(n){return null!==n&&"object"==typeof n}function f(n,t,r){return u(n)&&e(n,t,r)}var d=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,l=/\\(\\)?/g;return{assign:n,forIn:function(n,t,r){return u(n)&&function(e,n,t){o(function(n,t,r){return n(t,r,e)},e,n,t)}(n,t,r)},forOwn:f,get:function(n,t,r){for(var e;!c(n)&&(e=d.exec(t));){var o=e[0],u=e[1],f=e[2],i=e[3];n=n[f?i.replace(l,"$1"):u||o]}return function(n){return void 0===n}(n)?r:n},map:function(n,t,r){return function(n,t,r,e){var o=[],u=a(r,e);return n(t,function(n,t){c(n=u(n,t))||function(n,t){n[n.length]=t}(o,n)}),o}(f,n,t,r)}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n=n||self).celia=t(); | ||
var n,t;n=this,t=function(){"use strict";function i(n){return null==n}function c(n,t){return t?n.bind(t):n}function o(n,t,r,e){var o=c(r,e);for(var u in t)if(!1===n(o,t[u],u))break}function e(e,n,t){o(function(n,t,r){if(e.hasOwnProperty(r))return n(t,r,e)},e,n,t)}var n=Object.assign||function(n){if(i(n))throw new TypeError("Cannot convert undefined or null to object");var r=Object(n);return function(n,t,r,e,o){for(var u=c(e,o),f=t,i=void 0;!1!==i&&f<r;f++)i=u(n[f],f,n)}(arguments,1,arguments.length,function(n){e(n,function(n,t){r[t]=n})}),r};function u(n){return null!==n&&"object"==typeof n}function f(n,t,r){return u(n)&&e(n,t,r)}var a=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,d=/\\(\\)?/g,v=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/;return{assign:n,forIn:function(n,t,r){return u(n)&&function(e,n,t){o(function(n,t,r){return n(t,r,e)},e,n,t)}(n,t,r)},forOwn:f,get:function(n,t,r){var e=i(n)?void 0:function(n,t){if(!function(n){return"string"==typeof n}(t)||!v.test(t))return n[t];for(var r;!i(n)&&(r=a.exec(t));){var e=r[0],o=r[1],u=r[2],f=r[3];n=n[u?f.replace(d,"$1"):o||e]}return n}(n,t);return void 0===e?r:e},map:function(n,t,r){return function(n,t,r,e){var o=[],u=c(r,e);return n(t,function(n,t){i(n=u(n,t))||function(n,t){n[n.length]=t}(o,n)}),o}(f,n,t,r)}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n=n||self).celia=t(); |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -22,3 +22,7 @@ * Released under the MIT License. | ||
function decode(input) { | ||
return decodeURIComponent(input.replace(/\+/g, ' ')); | ||
try { | ||
return decodeURIComponent(input.replace(/\+/g, ' ')); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
@@ -35,12 +39,13 @@ | ||
var key = part[1]; | ||
// 匹配到querystring | ||
if (part[0] !== key) { | ||
var value = part[2]; | ||
var value = decode(part[2]); | ||
var last = result[key]; | ||
// 没有相同的key值 | ||
if (isUndefined(last)) { | ||
result[key] = decode(value); | ||
result[key] = value; | ||
} else if (isArray(last)) { // 继续追加 | ||
append(last, decode(value)); | ||
append(last, value); | ||
} else { // 已存在key | ||
result[key] = [last, decode(value)]; | ||
result[key] = [last, value]; | ||
} | ||
@@ -93,2 +98,10 @@ } | ||
function encode(input) { | ||
try { | ||
return encodeURIComponent(input); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
function stringify(obj, sep, eq) { | ||
@@ -100,6 +113,12 @@ if ( sep === void 0 ) sep = '&'; | ||
forOwn$1(obj, function (value, key) { | ||
if (!value && (isNil(value) || isNaN(value))) { | ||
if (isNil(value) || isNaN(value)) { | ||
value = ''; | ||
} | ||
append(arr, encodeURIComponent(key) + eq + encodeURIComponent(value)); | ||
key = encode(key); | ||
value = encode(value); | ||
if (key && value) { | ||
append(arr, key + eq + value); | ||
} | ||
}); | ||
@@ -106,0 +125,0 @@ return arr.length ? arr.join(sep) : ''; |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -26,3 +26,7 @@ * Released under the MIT License. | ||
function decode(input) { | ||
return decodeURIComponent(input.replace(/\+/g, ' ')); | ||
try { | ||
return decodeURIComponent(input.replace(/\+/g, ' ')); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
@@ -39,12 +43,13 @@ | ||
var key = part[1]; | ||
// 匹配到querystring | ||
if (part[0] !== key) { | ||
var value = part[2]; | ||
var value = decode(part[2]); | ||
var last = result[key]; | ||
// 没有相同的key值 | ||
if (isUndefined(last)) { | ||
result[key] = decode(value); | ||
result[key] = value; | ||
} else if (isArray(last)) { // 继续追加 | ||
append(last, decode(value)); | ||
append(last, value); | ||
} else { // 已存在key | ||
result[key] = [last, decode(value)]; | ||
result[key] = [last, value]; | ||
} | ||
@@ -97,2 +102,10 @@ } | ||
function encode(input) { | ||
try { | ||
return encodeURIComponent(input); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
function stringify(obj, sep, eq) { | ||
@@ -104,6 +117,12 @@ if ( sep === void 0 ) sep = '&'; | ||
forOwn$1(obj, function (value, key) { | ||
if (!value && (isNil(value) || isNaN(value))) { | ||
if (isNil(value) || isNaN(value)) { | ||
value = ''; | ||
} | ||
append(arr, encodeURIComponent(key) + eq + encodeURIComponent(value)); | ||
key = encode(key); | ||
value = encode(value); | ||
if (key && value) { | ||
append(arr, key + eq + value); | ||
} | ||
}); | ||
@@ -110,0 +129,0 @@ return arr.length ? arr.join(sep) : ''; |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
* Released under the MIT License. | ||
*/ | ||
var n,e;n=this,e=function(){"use strict";function f(n,e){return n[n.length]=e,n}function u(n){return decodeURIComponent(n.replace(/\+/g," "))}var c=/([^=?&]+)=?([^&]*)/g,a=Array.isArray;return{parse:function(n){var e={};if(function(n){return"string"==typeof n}(n))for(var r;r=c.exec(n);){var t=r[1];if(r[0]!==t){var o=r[2],i=e[t];void 0===i?e[t]=u(o):a(i)?f(i,u(o)):e[t]=[i,u(o)]}}return e},prefix:function(n,e){return n?(e||"?")+n:n},stringify:function(n,e,r){void 0===e&&(e="&"),void 0===r&&(r="=");var t=[];return function(n,e,r){(function(n){return null!==n&&"object"==typeof n})(n)&&function(t,n,e){!function(n,e,r,t){var o=function(n,e){return e?n.bind(e):n}(r,t);for(var i in e)if(!1===n(o,e[i],i))break}(function(n,e,r){if(t.hasOwnProperty(r))return n(e,r,t)},t,n,e)}(n,e,r)}(n,function(n,e){n||!function(n){return null==n}(n)&&!isNaN(n)||(n=""),f(t,encodeURIComponent(e)+r+encodeURIComponent(n))}),t.length?t.join(e):""}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n=n||self).celia=e(); | ||
var n,r;n=this,r=function(){"use strict";function u(n,r){return n[n.length]=r,n}function f(n){try{return decodeURIComponent(n.replace(/\+/g," "))}catch(n){return null}}var c=/([^=?&]+)=?([^&]*)/g,a=Array.isArray;function o(n){try{return encodeURIComponent(n)}catch(n){return null}}return{parse:function(n){var r={};if(function(n){return"string"==typeof n}(n))for(var t;t=c.exec(n);){var e=t[1];if(t[0]!==e){var o=f(t[2]),i=r[e];void 0===i?r[e]=o:a(i)?u(i,o):r[e]=[i,o]}}return r},prefix:function(n,r){return n?(r||"?")+n:n},stringify:function(n,r,t){void 0===r&&(r="&"),void 0===t&&(t="=");var e=[];return function(n,r,t){!function(n){return null!==n&&"object"==typeof n}(n)||function(e,n,r){!function(n,r,t,e){var o=function(n,r){return r?n.bind(r):n}(t,e);for(var i in r)if(!1===n(o,r[i],i))break}(function(n,r,t){if(e.hasOwnProperty(t))return n(r,t,e)},e,n,r)}(n,r,t)}(n,function(n,r){(function(n){return null==n}(n)||isNaN(n))&&(n=""),r=o(r),n=o(n),r&&n&&u(e,r+t+n)}),e.length?e.join(r):""}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(n=n||self).celia=r(); |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v5.6.2 | ||
* celia.js v5.7.0 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
12
get.js
import isNil from './isNil'; | ||
import isUndefined from './isUndefined'; | ||
import { PROP_NAME_REGEX, ESCAPE_CHAR_REGEX } from './_internal/_regex'; | ||
import get from './_internal/_get'; | ||
export default function (object, path, defaultValue) { | ||
let part; | ||
while (!isNil(object) && (part = PROP_NAME_REGEX.exec(path))) { | ||
const [match, number, quote, subString] = part; | ||
const prop = quote ? subString.replace(ESCAPE_CHAR_REGEX, '$1') : (number || match); | ||
object = object[prop]; | ||
} | ||
return isUndefined(object) ? defaultValue : object; | ||
const result = isNil(object) ? undefined : get(object, path); | ||
return result === undefined ? defaultValue : result; | ||
} |
@@ -33,2 +33,3 @@ import aop from './aop.js'; | ||
import qs from './qs.js'; | ||
import set from './set.js'; | ||
import sleep from './sleep.js'; | ||
@@ -70,2 +71,3 @@ import type from './type.js'; | ||
qs, | ||
set, | ||
sleep, | ||
@@ -72,0 +74,0 @@ type, |
{ | ||
"name": "celia", | ||
"version": "5.6.2", | ||
"version": "5.7.0", | ||
"description": "A modern JavaScript utility library delivering modularity, performance, & extras.", | ||
@@ -47,3 +47,3 @@ "main": "./dist/celia.c.js", | ||
"jest": "^24.0.0", | ||
"kyla": "^1.0.0-beta.2", | ||
"kyla": "^1.0.0", | ||
"moment": "^2.24.0", | ||
@@ -50,0 +50,0 @@ "rimraf": "^2.6.3", |
@@ -6,3 +6,7 @@ import append from '../_internal/_array/_append'; | ||
function decode(input) { | ||
return decodeURIComponent(input.replace(/\+/g, ' ')); | ||
try { | ||
return decodeURIComponent(input.replace(/\+/g, ' ')); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
@@ -19,12 +23,13 @@ | ||
const key = part[1]; | ||
// 匹配到querystring | ||
if (part[0] !== key) { | ||
const value = part[2]; | ||
const value = decode(part[2]); | ||
const last = result[key]; | ||
// 没有相同的key值 | ||
if (isUndefined(last)) { | ||
result[key] = decode(value); | ||
result[key] = value; | ||
} else if (isArray(last)) { // 继续追加 | ||
append(last, decode(value)); | ||
append(last, value); | ||
} else { // 已存在key | ||
result[key] = [last, decode(value)]; | ||
result[key] = [last, value]; | ||
} | ||
@@ -31,0 +36,0 @@ } |
@@ -5,11 +5,25 @@ import forOwn from '../forOwn'; | ||
function encode(input) { | ||
try { | ||
return encodeURIComponent(input); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
export default function stringify(obj, sep = '&', eq = '=') { | ||
let arr = []; | ||
forOwn(obj, (value, key) => { | ||
if (!value && (isNil(value) || isNaN(value))) { | ||
if (isNil(value) || isNaN(value)) { | ||
value = ''; | ||
} | ||
append(arr, encodeURIComponent(key) + eq + encodeURIComponent(value)); | ||
key = encode(key); | ||
value = encode(value); | ||
if (key && value) { | ||
append(arr, key + eq + value); | ||
} | ||
}); | ||
return arr.length ? arr.join(sep) : ''; | ||
} |
@@ -99,2 +99,3 @@ # celia | ||
- noop | ||
- set | ||
- sleep | ||
@@ -101,0 +102,0 @@ - type |
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
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
101215
99
3041
121