diff --git a/CHANGELOG.md b/CHANGELOG.md index 6729b6722..8e2ac4eaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.8.1 (14 Oct 2019) + +* fix(network): style [#121](https://github.com/liriliri/eruda/issues/121) + ## v1.8.0 (13 Oct 2019) * feat(network): display optimization diff --git a/package.json b/package.json index 9d0b00d75..750d41fb7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eruda", - "version": "1.8.0", + "version": "1.8.1", "description": "Console for Mobile Browsers", "main": "eruda.js", "scripts": { diff --git a/src/lib/util.js b/src/lib/util.js index 4028d15be..64a137420 100644 --- a/src/lib/util.js +++ b/src/lib/util.js @@ -1,11 +1,11 @@ // Built by eustia. -/* eslint-disable */ +/* eslint-disable */ -var _ = {}; +var _ = {}; -/* ------------------------------ last ------------------------------ */ +/* ------------------------------ last ------------------------------ */ -export var last = _.last = (function (exports) { +export var last = _.last = (function (exports) { /* Get the last element of array. * * |Name |Type |Desc | @@ -24,14 +24,14 @@ export var last = _.last = (function (exports) { exports = function(arr) { var len = arr ? arr.length : 0; if (len) return arr[len - 1]; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isUndef ------------------------------ */ +/* ------------------------------ isUndef ------------------------------ */ -export var isUndef = _.isUndef = (function (exports) { +export var isUndef = _.isUndef = (function (exports) { /* Check if value is undefined. * * |Name |Type |Desc | @@ -50,14 +50,14 @@ export var isUndef = _.isUndef = (function (exports) { */ exports = function(val) { return val === void 0; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isObj ------------------------------ */ +/* ------------------------------ isObj ------------------------------ */ -export var isObj = _.isObj = (function (exports) { +export var isObj = _.isObj = (function (exports) { /* Check if value is the language type of Object. * * |Name |Type |Desc | @@ -79,14 +79,14 @@ export var isObj = _.isObj = (function (exports) { exports = function(val) { var type = typeof val; return !!val && (type === 'function' || type === 'object'); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ inherits ------------------------------ */ +/* ------------------------------ inherits ------------------------------ */ -export var inherits = _.inherits = (function (exports) { +export var inherits = _.inherits = (function (exports) { /* Inherit the prototype methods from one constructor into another. * * |Name |Type |Desc | @@ -123,14 +123,14 @@ export var inherits = _.inherits = (function (exports) { var objCreate = Object.create; - function noop() {} + function noop() {} - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ has ------------------------------ */ +/* ------------------------------ has ------------------------------ */ -export var has = _.has = (function (exports) { +export var has = _.has = (function (exports) { /* Checks if key is a direct property. * * |Name |Type |Desc | @@ -151,14 +151,14 @@ export var has = _.has = (function (exports) { exports = function(obj, key) { return hasOwnProp.call(obj, key); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ slice ------------------------------ */ +/* ------------------------------ slice ------------------------------ */ -export var slice = _.slice = (function (exports) { +export var slice = _.slice = (function (exports) { /* Create slice of source array or array-like object. * * |Name |Type |Desc | @@ -201,14 +201,14 @@ export var slice = _.slice = (function (exports) { } return ret; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isBrowser ------------------------------ */ +/* ------------------------------ isBrowser ------------------------------ */ -export var isBrowser = _.isBrowser = (function (exports) { +export var isBrowser = _.isBrowser = (function (exports) { /* Check if running in a browser. */ @@ -222,14 +222,14 @@ export var isBrowser = _.isBrowser = (function (exports) { exports = typeof window === 'object' && typeof document === 'object' && - document.nodeType === 9; + document.nodeType === 9; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ noop ------------------------------ */ +/* ------------------------------ noop ------------------------------ */ -export var noop = _.noop = (function (exports) { +export var noop = _.noop = (function (exports) { /* A no-operation function. */ @@ -240,14 +240,14 @@ export var noop = _.noop = (function (exports) { /* typescript * export declare function noop(): void; */ - exports = function() {}; + exports = function() {}; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ before ------------------------------ */ +/* ------------------------------ before ------------------------------ */ -export var before = _.before = (function (exports) { +export var before = _.before = (function (exports) { /* Create a function that invokes less than n times. * * |Name |Type |Desc | @@ -274,14 +274,14 @@ export var before = _.before = (function (exports) { if (n <= 1) fn = null; return memo; }; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ splitCase ------------------------------ */ +/* ------------------------------ splitCase ------------------------------ */ -export var splitCase = _.splitCase = (function (exports) { +export var splitCase = _.splitCase = (function (exports) { /* Split different string case to an array. * * |Name |Type |Desc | @@ -313,14 +313,14 @@ export var splitCase = _.splitCase = (function (exports) { .replace(regSeparator, '-') .replace(regTrim, ''); return str.split('-'); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ camelCase ------------------------------ */ +/* ------------------------------ camelCase ------------------------------ */ -export var camelCase = _.camelCase = (function (exports) { +export var camelCase = _.camelCase = (function (exports) { /* Convert string to "camelCase". * * |Name |Type |Desc | @@ -357,14 +357,14 @@ export var camelCase = _.camelCase = (function (exports) { this[idx] = val.replace(/\w/, function(match) { return match.toUpperCase(); }); - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ kebabCase ------------------------------ */ +/* ------------------------------ kebabCase ------------------------------ */ -export var kebabCase = _.kebabCase = (function (exports) { +export var kebabCase = _.kebabCase = (function (exports) { /* Convert string to "kebabCase". * * |Name |Type |Desc | @@ -390,14 +390,14 @@ export var kebabCase = _.kebabCase = (function (exports) { exports = function(str) { return splitCase(str).join('-'); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ chunk ------------------------------ */ +/* ------------------------------ chunk ------------------------------ */ -export var chunk = _.chunk = (function (exports) { +export var chunk = _.chunk = (function (exports) { /* Split array into groups the length of given size. * * |Name |Type |Desc | @@ -427,14 +427,14 @@ export var chunk = _.chunk = (function (exports) { } return ret; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ clamp ------------------------------ */ +/* ------------------------------ clamp ------------------------------ */ -export var clamp = _.clamp = (function (exports) { +export var clamp = _.clamp = (function (exports) { /* Clamp number within the inclusive lower and upper bounds. * * |Name |Type |Desc | @@ -471,14 +471,14 @@ export var clamp = _.clamp = (function (exports) { if (!isUndef(lower) && n < lower) return lower; if (n > upper) return upper; return n; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ idxOf ------------------------------ */ +/* ------------------------------ idxOf ------------------------------ */ -export var idxOf = _.idxOf = (function (exports) { +export var idxOf = _.idxOf = (function (exports) { /* Get the index at which the first occurrence of value. * * |Name |Type |Desc | @@ -498,14 +498,14 @@ export var idxOf = _.idxOf = (function (exports) { */ exports = function(arr, val, fromIdx) { return Array.prototype.indexOf.call(arr, val, fromIdx); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ toStr ------------------------------ */ +/* ------------------------------ toStr ------------------------------ */ -export var toStr = _.toStr = (function (exports) { +export var toStr = _.toStr = (function (exports) { /* Convert value to a string. * * |Name |Type |Desc | @@ -526,14 +526,14 @@ export var toStr = _.toStr = (function (exports) { */ exports = function(val) { return val == null ? '' : val.toString(); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ debounce ------------------------------ */ +/* ------------------------------ debounce ------------------------------ */ -export var debounce = _.debounce = (function (exports) { +export var debounce = _.debounce = (function (exports) { /* Return a new debounced version of the passed function. * * |Name |Type |Desc | @@ -565,279 +565,279 @@ export var debounce = _.debounce = (function (exports) { if (!immediate) clearTimeout(timeout); if (!immediate || !timeout) timeout = setTimeout(throttler, wait); }; - }; - - return exports; -})({}); - -/* ------------------------------ ucs2 ------------------------------ */ - -export var ucs2 = _.ucs2 = (function (exports) { - /* UCS-2 encoding and decoding. - * - * ### encode - * - * Create a string using an array of code point values. - * - * |Name |Type |Desc | - * |------|------|--------------------| - * |arr |array |Array of code points| - * |return|string|Encoded string | - * - * ### decode - * - * Create an array of code point values using a string. - * - * |Name |Type |Desc | - * |------|------|--------------------| - * |str |string|Input string | - * |return|array |Array of code points| - */ - - /* example - * ucs2.encode([0x61, 0x62, 0x63]); // -> 'abc' - * ucs2.decode('abc'); // -> [0x61, 0x62, 0x63] - * '𝌆'.length; // -> 2 - * ucs2.decode('𝌆').length; // -> 1 - */ - - /* typescript - * export declare const ucs2: { - * encode(arr: number[]): string; - * decode(str: string): number[]; - * }; - */ - // https://mathiasbynens.be/notes/javascript-encoding - exports = { - encode: function(arr) { - return String.fromCodePoint.apply(String, arr); - }, - decode: function(str) { - var ret = []; - var i = 0; - var len = str.length; - - while (i < len) { - var c = str.charCodeAt(i++); // A high surrogate - - if (c >= 0xd800 && c <= 0xdbff && i < len) { - var tail = str.charCodeAt(i++); // nextC >= 0xDC00 && nextC <= 0xDFFF - - if ((tail & 0xfc00) === 0xdc00) { - // C = (H - 0xD800) * 0x400 + L - 0xDC00 + 0x10000 - ret.push(((c & 0x3ff) << 10) + (tail & 0x3ff) + 0x10000); - } else { - ret.push(c); - i--; - } - } else { - ret.push(c); - } - } - - return ret; - } - }; - - return exports; -})({}); - -/* ------------------------------ utf8 ------------------------------ */ - -export var utf8 = _.utf8 = (function (exports) { - /* UTF-8 encoding and decoding. - * - * ### encode - * - * Turn any UTF-8 decoded string into UTF-8 encoded string. - * - * |Name |Type |Desc | - * |------|------|----------------| - * |str |string|String to encode| - * |return|string|Encoded string | - * - * ### decode - * - * Turn any UTF-8 encoded string into UTF-8 decoded string. - * - * |Name |Type |Desc | - * |----------|-------|----------------------| - * |str |string |String to decode | - * |safe=false|boolean|Suppress error if true| - * |return |string |Decoded string | - */ - - /* example - * utf8.encode('\uD800\uDC00'); // -> '\xF0\x90\x80\x80' - * utf8.decode('\xF0\x90\x80\x80'); // -> '\uD800\uDC00' - */ - - /* typescript - * export declare const utf8: { - * encode(str: string): string; - * decode(str: string, safe?: boolean): string; - * }; + }; + + return exports; +})({}); + +/* ------------------------------ ucs2 ------------------------------ */ + +export var ucs2 = _.ucs2 = (function (exports) { + /* UCS-2 encoding and decoding. + * + * ### encode + * + * Create a string using an array of code point values. + * + * |Name |Type |Desc | + * |------|------|--------------------| + * |arr |array |Array of code points| + * |return|string|Encoded string | + * + * ### decode + * + * Create an array of code point values using a string. + * + * |Name |Type |Desc | + * |------|------|--------------------| + * |str |string|Input string | + * |return|array |Array of code points| + */ + + /* example + * ucs2.encode([0x61, 0x62, 0x63]); // -> 'abc' + * ucs2.decode('abc'); // -> [0x61, 0x62, 0x63] + * '𝌆'.length; // -> 2 + * ucs2.decode('𝌆').length; // -> 1 + */ + + /* typescript + * export declare const ucs2: { + * encode(arr: number[]): string; + * decode(str: string): number[]; + * }; + */ + // https://mathiasbynens.be/notes/javascript-encoding + exports = { + encode: function(arr) { + return String.fromCodePoint.apply(String, arr); + }, + decode: function(str) { + var ret = []; + var i = 0; + var len = str.length; + + while (i < len) { + var c = str.charCodeAt(i++); // A high surrogate + + if (c >= 0xd800 && c <= 0xdbff && i < len) { + var tail = str.charCodeAt(i++); // nextC >= 0xDC00 && nextC <= 0xDFFF + + if ((tail & 0xfc00) === 0xdc00) { + // C = (H - 0xD800) * 0x400 + L - 0xDC00 + 0x10000 + ret.push(((c & 0x3ff) << 10) + (tail & 0x3ff) + 0x10000); + } else { + ret.push(c); + i--; + } + } else { + ret.push(c); + } + } + + return ret; + } + }; + + return exports; +})({}); + +/* ------------------------------ utf8 ------------------------------ */ + +export var utf8 = _.utf8 = (function (exports) { + /* UTF-8 encoding and decoding. + * + * ### encode + * + * Turn any UTF-8 decoded string into UTF-8 encoded string. + * + * |Name |Type |Desc | + * |------|------|----------------| + * |str |string|String to encode| + * |return|string|Encoded string | + * + * ### decode + * + * Turn any UTF-8 encoded string into UTF-8 decoded string. + * + * |Name |Type |Desc | + * |----------|-------|----------------------| + * |str |string |String to decode | + * |safe=false|boolean|Suppress error if true| + * |return |string |Decoded string | + */ + + /* example + * utf8.encode('\uD800\uDC00'); // -> '\xF0\x90\x80\x80' + * utf8.decode('\xF0\x90\x80\x80'); // -> '\uD800\uDC00' + */ + + /* typescript + * export declare const utf8: { + * encode(str: string): string; + * decode(str: string, safe?: boolean): string; + * }; */ /* dependencies * ucs2 - */ // https://encoding.spec.whatwg.org/#utf-8 - - exports = { - encode: function(str) { - var codePoints = ucs2.decode(str); - var byteArr = ''; - - for (var i = 0, len = codePoints.length; i < len; i++) { - byteArr += encodeCodePoint(codePoints[i]); - } - - return byteArr; - }, - decode: function decode(str, safe) { - byteArr = ucs2.decode(str); - byteIdx = 0; - byteCount = byteArr.length; - codePoint = 0; - bytesSeen = 0; - bytesNeeded = 0; - lowerBoundary = 0x80; - upperBoundary = 0xbf; - var codePoints = []; - var tmp; - - while ((tmp = decodeCodePoint(safe)) !== false) { - codePoints.push(tmp); - } - - return ucs2.encode(codePoints); - } - }; - var fromCharCode = String.fromCharCode; - - function encodeCodePoint(codePoint) { - // U+0000 to U+0080, ASCII code point - if ((codePoint & 0xffffff80) === 0) { - return fromCharCode(codePoint); - } - - var ret = '', - count, - offset; // U+0080 to U+07FF, inclusive - - if ((codePoint & 0xfffff800) === 0) { - count = 1; - offset = 0xc0; - } else if ((codePoint & 0xffff0000) === 0) { - // U+0800 to U+FFFF, inclusive - count = 2; - offset = 0xe0; - } else if ((codePoint & 0xffe00000) == 0) { - // U+10000 to U+10FFFF, inclusive - count = 3; - offset = 0xf0; - } - - ret += fromCharCode((codePoint >> (6 * count)) + offset); - - while (count > 0) { - var tmp = codePoint >> (6 * (count - 1)); - ret += fromCharCode(0x80 | (tmp & 0x3f)); - count--; - } - - return ret; - } - - var byteArr, - byteIdx, - byteCount, - codePoint, - bytesSeen, - bytesNeeded, - lowerBoundary, - upperBoundary; - - function decodeCodePoint(safe) { - /* eslint-disable no-constant-condition */ - while (true) { - if (byteIdx >= byteCount && bytesNeeded) { - if (safe) return goBack(); - throw new Error('Invalid byte index'); - } - - if (byteIdx === byteCount) return false; - var byte = byteArr[byteIdx]; - byteIdx++; - - if (!bytesNeeded) { - // 0x00 to 0x7F - if ((byte & 0x80) === 0) { - return byte; - } // 0xC2 to 0xDF - - if ((byte & 0xe0) === 0xc0) { - bytesNeeded = 1; - codePoint = byte & 0x1f; - } else if ((byte & 0xf0) === 0xe0) { - // 0xE0 to 0xEF - if (byte === 0xe0) lowerBoundary = 0xa0; - if (byte === 0xed) upperBoundary = 0x9f; - bytesNeeded = 2; - codePoint = byte & 0xf; - } else if ((byte & 0xf8) === 0xf0) { - // 0xF0 to 0xF4 - if (byte === 0xf0) lowerBoundary = 0x90; - if (byte === 0xf4) upperBoundary = 0x8f; - bytesNeeded = 3; - codePoint = byte & 0x7; - } else { - if (safe) return goBack(); - throw new Error('Invalid UTF-8 detected'); - } - - continue; - } - - if (byte < lowerBoundary || byte > upperBoundary) { - if (safe) { - byteIdx--; - return goBack(); - } - - throw new Error('Invalid continuation byte'); - } - - lowerBoundary = 0x80; - upperBoundary = 0xbf; - codePoint = (codePoint << 6) | (byte & 0x3f); - bytesSeen++; - if (bytesSeen !== bytesNeeded) continue; - var tmp = codePoint; - codePoint = 0; - bytesNeeded = 0; - bytesSeen = 0; - return tmp; - } - } - - function goBack() { - var start = byteIdx - bytesSeen - 1; - byteIdx = start + 1; - codePoint = 0; - bytesNeeded = 0; - bytesSeen = 0; - lowerBoundary = 0x80; - upperBoundary = 0xbf; - return byteArr[start]; - } - - return exports; -})({}); - -/* ------------------------------ root ------------------------------ */ - -export var root = _.root = (function (exports) { + */ // https://encoding.spec.whatwg.org/#utf-8 + + exports = { + encode: function(str) { + var codePoints = ucs2.decode(str); + var byteArr = ''; + + for (var i = 0, len = codePoints.length; i < len; i++) { + byteArr += encodeCodePoint(codePoints[i]); + } + + return byteArr; + }, + decode: function decode(str, safe) { + byteArr = ucs2.decode(str); + byteIdx = 0; + byteCount = byteArr.length; + codePoint = 0; + bytesSeen = 0; + bytesNeeded = 0; + lowerBoundary = 0x80; + upperBoundary = 0xbf; + var codePoints = []; + var tmp; + + while ((tmp = decodeCodePoint(safe)) !== false) { + codePoints.push(tmp); + } + + return ucs2.encode(codePoints); + } + }; + var fromCharCode = String.fromCharCode; + + function encodeCodePoint(codePoint) { + // U+0000 to U+0080, ASCII code point + if ((codePoint & 0xffffff80) === 0) { + return fromCharCode(codePoint); + } + + var ret = '', + count, + offset; // U+0080 to U+07FF, inclusive + + if ((codePoint & 0xfffff800) === 0) { + count = 1; + offset = 0xc0; + } else if ((codePoint & 0xffff0000) === 0) { + // U+0800 to U+FFFF, inclusive + count = 2; + offset = 0xe0; + } else if ((codePoint & 0xffe00000) == 0) { + // U+10000 to U+10FFFF, inclusive + count = 3; + offset = 0xf0; + } + + ret += fromCharCode((codePoint >> (6 * count)) + offset); + + while (count > 0) { + var tmp = codePoint >> (6 * (count - 1)); + ret += fromCharCode(0x80 | (tmp & 0x3f)); + count--; + } + + return ret; + } + + var byteArr, + byteIdx, + byteCount, + codePoint, + bytesSeen, + bytesNeeded, + lowerBoundary, + upperBoundary; + + function decodeCodePoint(safe) { + /* eslint-disable no-constant-condition */ + while (true) { + if (byteIdx >= byteCount && bytesNeeded) { + if (safe) return goBack(); + throw new Error('Invalid byte index'); + } + + if (byteIdx === byteCount) return false; + var byte = byteArr[byteIdx]; + byteIdx++; + + if (!bytesNeeded) { + // 0x00 to 0x7F + if ((byte & 0x80) === 0) { + return byte; + } // 0xC2 to 0xDF + + if ((byte & 0xe0) === 0xc0) { + bytesNeeded = 1; + codePoint = byte & 0x1f; + } else if ((byte & 0xf0) === 0xe0) { + // 0xE0 to 0xEF + if (byte === 0xe0) lowerBoundary = 0xa0; + if (byte === 0xed) upperBoundary = 0x9f; + bytesNeeded = 2; + codePoint = byte & 0xf; + } else if ((byte & 0xf8) === 0xf0) { + // 0xF0 to 0xF4 + if (byte === 0xf0) lowerBoundary = 0x90; + if (byte === 0xf4) upperBoundary = 0x8f; + bytesNeeded = 3; + codePoint = byte & 0x7; + } else { + if (safe) return goBack(); + throw new Error('Invalid UTF-8 detected'); + } + + continue; + } + + if (byte < lowerBoundary || byte > upperBoundary) { + if (safe) { + byteIdx--; + return goBack(); + } + + throw new Error('Invalid continuation byte'); + } + + lowerBoundary = 0x80; + upperBoundary = 0xbf; + codePoint = (codePoint << 6) | (byte & 0x3f); + bytesSeen++; + if (bytesSeen !== bytesNeeded) continue; + var tmp = codePoint; + codePoint = 0; + bytesNeeded = 0; + bytesSeen = 0; + return tmp; + } + } + + function goBack() { + var start = byteIdx - bytesSeen - 1; + byteIdx = start + 1; + codePoint = 0; + bytesNeeded = 0; + bytesSeen = 0; + lowerBoundary = 0x80; + upperBoundary = 0xbf; + return byteArr[start]; + } + + return exports; +})({}); + +/* ------------------------------ root ------------------------------ */ + +export var root = _.root = (function (exports) { /* Root object reference, `global` in nodeJs, `window` in browser. */ /* typescript @@ -848,46 +848,46 @@ export var root = _.root = (function (exports) { * isBrowser */ - exports = isBrowser ? window : global; + exports = isBrowser ? window : global; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ detectMocha ------------------------------ */ +/* ------------------------------ detectMocha ------------------------------ */ -export var detectMocha = _.detectMocha = (function (exports) { - /* Detect if mocha is running. - */ +export var detectMocha = _.detectMocha = (function (exports) { + /* Detect if mocha is running. + */ - /* example - * detectMocha(); // -> True if mocha is running. - */ + /* example + * detectMocha(); // -> True if mocha is running. + */ - /* typescript - * export declare function detectMocha(): boolean; + /* typescript + * export declare function detectMocha(): boolean; */ /* dependencies * root - */ + */ - exports = function() { - for (var i = 0, len = methods.length; i < len; i++) { - var method = methods[i]; - if (typeof root[method] !== 'function') return false; - } + exports = function() { + for (var i = 0, len = methods.length; i < len; i++) { + var method = methods[i]; + if (typeof root[method] !== 'function') return false; + } - return true; - }; + return true; + }; - var methods = ['afterEach', 'after', 'beforeEach', 'before', 'describe', 'it']; + var methods = ['afterEach', 'after', 'beforeEach', 'before', 'describe', 'it']; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ keys ------------------------------ */ +/* ------------------------------ keys ------------------------------ */ -export var keys = _.keys = (function (exports) { +export var keys = _.keys = (function (exports) { /* Create an array of the own enumerable property names of object. * * |Name |Type |Desc | @@ -920,14 +920,14 @@ export var keys = _.keys = (function (exports) { return ret; }; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ freeze ------------------------------ */ +/* ------------------------------ freeze ------------------------------ */ -export var freeze = _.freeze = (function (exports) { +export var freeze = _.freeze = (function (exports) { /* Shortcut for Object.freeze. * * Use Object.defineProperties if Object.freeze is not supported. @@ -963,14 +963,14 @@ export var freeze = _.freeze = (function (exports) { }); }); return obj; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ detectOs ------------------------------ */ +/* ------------------------------ detectOs ------------------------------ */ -export var detectOs = _.detectOs = (function (exports) { +export var detectOs = _.detectOs = (function (exports) { /* Detect operating system using ua. * * |Name |Type |Desc | @@ -1010,14 +1010,14 @@ export var detectOs = _.detectOs = (function (exports) { } return 'unknown'; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ restArgs ------------------------------ */ +/* ------------------------------ restArgs ------------------------------ */ -export var restArgs = _.restArgs = (function (exports) { +export var restArgs = _.restArgs = (function (exports) { /* This accumulates the arguments passed into an array, after a given index. * * |Name |Type |Desc | @@ -1066,14 +1066,14 @@ export var restArgs = _.restArgs = (function (exports) { args[startIdx] = rest; return fn.apply(this, args); }; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ optimizeCb ------------------------------ */ +/* ------------------------------ optimizeCb ------------------------------ */ -export var optimizeCb = _.optimizeCb = (function (exports) { +export var optimizeCb = _.optimizeCb = (function (exports) { /* Used for function context binding. */ @@ -1108,50 +1108,50 @@ export var optimizeCb = _.optimizeCb = (function (exports) { return function() { return fn.apply(ctx, arguments); }; - }; - - return exports; -})({}); - -/* ------------------------------ types ------------------------------ */ - -export var types = _.types = (function (exports) { - /* Used for typescript definitions only. - */ - - /* typescript - * export declare namespace types { - * interface Collection {} - * interface List extends Collection { - * [index: number]: T; - * length: number; - * } - * interface ListIterator { - * (value: T, index: number, list: List): TResult; - * } - * interface Dictionary extends Collection { - * [index: string]: T; - * } - * interface ObjectIterator { - * (element: T, key: string, list: Dictionary): TResult; - * } - * interface MemoIterator { - * (prev: TResult, curr: T, index: number, list: List): TResult; - * } - * interface MemoObjectIterator { - * (prev: TResult, curr: T, key: string, list: Dictionary): TResult; - * } - * } - * export declare const types: {} - */ - exports = {}; - - return exports; -})({}); - -/* ------------------------------ endWith ------------------------------ */ - -export var endWith = _.endWith = (function (exports) { + }; + + return exports; +})({}); + +/* ------------------------------ types ------------------------------ */ + +export var types = _.types = (function (exports) { + /* Used for typescript definitions only. + */ + + /* typescript + * export declare namespace types { + * interface Collection {} + * interface List extends Collection { + * [index: number]: T; + * length: number; + * } + * interface ListIterator { + * (value: T, index: number, list: List): TResult; + * } + * interface Dictionary extends Collection { + * [index: string]: T; + * } + * interface ObjectIterator { + * (element: T, key: string, list: Dictionary): TResult; + * } + * interface MemoIterator { + * (prev: TResult, curr: T, index: number, list: List): TResult; + * } + * interface MemoObjectIterator { + * (prev: TResult, curr: T, key: string, list: Dictionary): TResult; + * } + * } + * export declare const types: {} + */ + exports = {}; + + return exports; +})({}); + +/* ------------------------------ endWith ------------------------------ */ + +export var endWith = _.endWith = (function (exports) { /* Check if string ends with the given target string. * * |Name |Type |Desc | @@ -1171,14 +1171,14 @@ export var endWith = _.endWith = (function (exports) { exports = function(str, suffix) { var idx = str.length - suffix.length; return idx >= 0 && str.indexOf(suffix, idx) === idx; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ escape ------------------------------ */ +/* ------------------------------ escape ------------------------------ */ -export var escape = _.escape = (function (exports) { +export var escape = _.escape = (function (exports) { /* Escapes a string for insertion into HTML, replacing &, <, >, ", `, and ' characters. * * |Name |Type |Desc | @@ -1217,14 +1217,14 @@ export var escape = _.escape = (function (exports) { function replaceFn(match) { return map[match]; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ escapeJsStr ------------------------------ */ +/* ------------------------------ escapeJsStr ------------------------------ */ -export var escapeJsStr = _.escapeJsStr = (function (exports) { +export var escapeJsStr = _.escapeJsStr = (function (exports) { /* Escape string to be a valid JavaScript string literal between quotes. * * http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4 @@ -1272,14 +1272,14 @@ export var escapeJsStr = _.escapeJsStr = (function (exports) { }); }; - var regEscapeChars = /["'\\\n\r\u2028\u2029]/g; + var regEscapeChars = /["'\\\n\r\u2028\u2029]/g; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ escapeJsonStr ------------------------------ */ +/* ------------------------------ escapeJsonStr ------------------------------ */ -export var escapeJsonStr = _.escapeJsonStr = (function (exports) { +export var escapeJsonStr = _.escapeJsonStr = (function (exports) { /* Escape json string. */ @@ -1291,14 +1291,14 @@ export var escapeJsonStr = _.escapeJsonStr = (function (exports) { return escapeJsStr(str) .replace(/\\'/g, "'") .replace(/\t/g, '\\t') - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ escapeRegExp ------------------------------ */ +/* ------------------------------ escapeRegExp ------------------------------ */ -export var escapeRegExp = _.escapeRegExp = (function (exports) { +export var escapeRegExp = _.escapeRegExp = (function (exports) { /* Escape special chars to be used as literals in RegExp constructors. * * |Name |Type |Desc | @@ -1316,14 +1316,14 @@ export var escapeRegExp = _.escapeRegExp = (function (exports) { */ exports = function(str) { return str.replace(/\W/g, '\\$&'); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ fileSize ------------------------------ */ +/* ------------------------------ fileSize ------------------------------ */ -export var fileSize = _.fileSize = (function (exports) { +export var fileSize = _.fileSize = (function (exports) { /* Turn bytes into human readable file size. * * |Name |Type |Desc | @@ -1350,14 +1350,14 @@ export var fileSize = _.fileSize = (function (exports) { return +val.toFixed(2) + suffixList[suffixIdx]; }; - var suffixList = ['', 'K', 'M', 'G', 'T']; + var suffixList = ['', 'K', 'M', 'G', 'T']; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ fullUrl ------------------------------ */ +/* ------------------------------ fullUrl ------------------------------ */ -export var fullUrl = _.fullUrl = (function (exports) { +export var fullUrl = _.fullUrl = (function (exports) { /* Add origin to url if needed. */ @@ -1369,14 +1369,14 @@ export var fullUrl = _.fullUrl = (function (exports) { return ( link.protocol + '//' + link.host + link.pathname + link.search + link.hash ) - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ upperFirst ------------------------------ */ +/* ------------------------------ upperFirst ------------------------------ */ -export var upperFirst = _.upperFirst = (function (exports) { +export var upperFirst = _.upperFirst = (function (exports) { /* Convert the first character of string to upper case. * * |Name |Type |Desc | @@ -1395,14 +1395,14 @@ export var upperFirst = _.upperFirst = (function (exports) { exports = function(str) { if (str.length < 1) return str; return str[0].toUpperCase() + str.slice(1); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ getObjType ------------------------------ */ +/* ------------------------------ getObjType ------------------------------ */ -export var getObjType = _.getObjType = (function (exports) { +export var getObjType = _.getObjType = (function (exports) { /* Get object type. */ @@ -1414,14 +1414,14 @@ export var getObjType = _.getObjType = (function (exports) { if (obj.constructor && obj.constructor.name) return obj.constructor.name return upperFirst({}.toString.call(obj).replace(/(\[object )|]/g, '')) - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ identity ------------------------------ */ +/* ------------------------------ identity ------------------------------ */ -export var identity = _.identity = (function (exports) { +export var identity = _.identity = (function (exports) { /* Return the first argument given. * * |Name |Type|Desc | @@ -1439,14 +1439,14 @@ export var identity = _.identity = (function (exports) { */ exports = function(val) { return val; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ objToStr ------------------------------ */ +/* ------------------------------ objToStr ------------------------------ */ -export var objToStr = _.objToStr = (function (exports) { +export var objToStr = _.objToStr = (function (exports) { /* Alias of Object.prototype.toString. * * |Name |Type |Desc | @@ -1466,14 +1466,14 @@ export var objToStr = _.objToStr = (function (exports) { exports = function(val) { return ObjToStr.call(val); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isArgs ------------------------------ */ +/* ------------------------------ isArgs ------------------------------ */ -export var isArgs = _.isArgs = (function (exports) { +export var isArgs = _.isArgs = (function (exports) { /* Check if value is classified as an arguments object. * * |Name |Type |Desc | @@ -1498,14 +1498,14 @@ export var isArgs = _.isArgs = (function (exports) { exports = function(val) { return objToStr(val) === '[object Arguments]'; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isArr ------------------------------ */ +/* ------------------------------ isArr ------------------------------ */ -export var isArr = _.isArr = (function (exports) { +export var isArr = _.isArr = (function (exports) { /* Check if value is an `Array` object. * * |Name |Type |Desc | @@ -1531,14 +1531,14 @@ export var isArr = _.isArr = (function (exports) { Array.isArray || function(val) { return objToStr(val) === '[object Array]'; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ castPath ------------------------------ */ +/* ------------------------------ castPath ------------------------------ */ -export var castPath = _.castPath = (function (exports) { +export var castPath = _.castPath = (function (exports) { /* Cast value into a property path array. * * |Name |Type |Desc | @@ -1574,14 +1574,14 @@ export var castPath = _.castPath = (function (exports) { }; // Lodash _stringToPath var regPropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; - var regEscapeChar = /\\(\\)?/g; + var regEscapeChar = /\\(\\)?/g; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ safeGet ------------------------------ */ +/* ------------------------------ safeGet ------------------------------ */ -export var safeGet = _.safeGet = (function (exports) { +export var safeGet = _.safeGet = (function (exports) { /* Get object property, don't throw undefined error. * * |Name |Type |Desc | @@ -1618,14 +1618,14 @@ export var safeGet = _.safeGet = (function (exports) { } return obj; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ flatten ------------------------------ */ +/* ------------------------------ flatten ------------------------------ */ -export var flatten = _.flatten = (function (exports) { +export var flatten = _.flatten = (function (exports) { /* Recursively flatten an array. * * |Name |Type |Desc | @@ -1661,14 +1661,14 @@ export var flatten = _.flatten = (function (exports) { } return res; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isDate ------------------------------ */ +/* ------------------------------ isDate ------------------------------ */ -export var isDate = _.isDate = (function (exports) { +export var isDate = _.isDate = (function (exports) { /* Check if value is classified as a Date object. * * |Name |Type |Desc | @@ -1691,14 +1691,14 @@ export var isDate = _.isDate = (function (exports) { exports = function(val) { return objToStr(val) === '[object Date]'; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isFn ------------------------------ */ +/* ------------------------------ isFn ------------------------------ */ -export var isFn = _.isFn = (function (exports) { +export var isFn = _.isFn = (function (exports) { /* Check if value is a function. * * |Name |Type |Desc | @@ -1730,54 +1730,54 @@ export var isFn = _.isFn = (function (exports) { objStr === '[object GeneratorFunction]' || objStr === '[object AsyncFunction]' ); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ getProto ------------------------------ */ +/* ------------------------------ getProto ------------------------------ */ -export var getProto = _.getProto = (function (exports) { - /* Get prototype of an object. - * - * |Name |Type|Desc | - * |------|----|---------------------------------------------| - * |obj |* |Target object | - * |return|* |Prototype of given object, null if not exists| - */ +export var getProto = _.getProto = (function (exports) { + /* Get prototype of an object. + * + * |Name |Type|Desc | + * |------|----|---------------------------------------------| + * |obj |* |Target object | + * |return|* |Prototype of given object, null if not exists| + */ - /* example - * const a = {}; - * getProto(Object.create(a)); // -> a - */ + /* example + * const a = {}; + * getProto(Object.create(a)); // -> a + */ - /* typescript - * export declare function getProto(obj: any): any; + /* typescript + * export declare function getProto(obj: any): any; */ /* dependencies * isObj isFn - */ + */ - var getPrototypeOf = Object.getPrototypeOf; - var ObjectCtr = {}.constructor; + var getPrototypeOf = Object.getPrototypeOf; + var ObjectCtr = {}.constructor; - exports = function(obj) { - if (!isObj(obj)) return null; - if (getPrototypeOf) return getPrototypeOf(obj); - var proto = obj.__proto__; - if (proto || proto === null) return proto; - if (isFn(obj.constructor)) return obj.constructor.prototype; - if (obj instanceof ObjectCtr) return ObjectCtr.prototype; - return null; - }; + exports = function(obj) { + if (!isObj(obj)) return null; + if (getPrototypeOf) return getPrototypeOf(obj); + var proto = obj.__proto__; + if (proto || proto === null) return proto; + if (isFn(obj.constructor)) return obj.constructor.prototype; + if (obj instanceof ObjectCtr) return ObjectCtr.prototype; + return null; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isMiniProgram ------------------------------ */ +/* ------------------------------ isMiniProgram ------------------------------ */ -export var isMiniProgram = _.isMiniProgram = (function (exports) { +export var isMiniProgram = _.isMiniProgram = (function (exports) { /* Check if running in wechat mini program. */ @@ -1794,14 +1794,14 @@ export var isMiniProgram = _.isMiniProgram = (function (exports) { */ /* eslint-disable no-undef */ - exports = typeof wx !== 'undefined' && isFn(wx.openLocation); + exports = typeof wx !== 'undefined' && isFn(wx.openLocation); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isNum ------------------------------ */ +/* ------------------------------ isNum ------------------------------ */ -export var isNum = _.isNum = (function (exports) { +export var isNum = _.isNum = (function (exports) { /* Check if value is classified as a Number primitive or object. * * |Name |Type |Desc | @@ -1826,14 +1826,14 @@ export var isNum = _.isNum = (function (exports) { exports = function(val) { return objToStr(val) === '[object Number]'; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isArrLike ------------------------------ */ +/* ------------------------------ isArrLike ------------------------------ */ -export var isArrLike = _.isArrLike = (function (exports) { +export var isArrLike = _.isArrLike = (function (exports) { /* Check if value is array-like. * * |Name |Type |Desc | @@ -1864,14 +1864,14 @@ export var isArrLike = _.isArrLike = (function (exports) { if (!val) return false; var len = val.length; return isNum(len) && len >= 0 && len <= MAX_ARR_IDX && !isFn(val); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ each ------------------------------ */ +/* ------------------------------ each ------------------------------ */ -export var each = _.each = (function (exports) { +export var each = _.each = (function (exports) { /* Iterate over elements of collection and invokes iterator for each element. * * |Name |Type |Desc | @@ -1921,14 +1921,14 @@ export var each = _.each = (function (exports) { } return obj; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ createAssigner ------------------------------ */ +/* ------------------------------ createAssigner ------------------------------ */ -export var createAssigner = _.createAssigner = (function (exports) { +export var createAssigner = _.createAssigner = (function (exports) { /* Used to create extend, extendOwn and defaults. * * |Name |Type |Desc | @@ -1957,14 +1957,14 @@ export var createAssigner = _.createAssigner = (function (exports) { }); return obj; }; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ extendOwn ------------------------------ */ +/* ------------------------------ extendOwn ------------------------------ */ -export var extendOwn = _.extendOwn = (function (exports) { +export var extendOwn = _.extendOwn = (function (exports) { /* Like extend, but only copies own properties over to the destination object. * * |Name |Type |Desc | @@ -1986,14 +1986,14 @@ export var extendOwn = _.extendOwn = (function (exports) { * keys createAssigner */ - exports = createAssigner(keys); + exports = createAssigner(keys); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ values ------------------------------ */ +/* ------------------------------ values ------------------------------ */ -export var values = _.values = (function (exports) { +export var values = _.values = (function (exports) { /* Create an array of the own enumerable property values of object. * * |Name |Type |Desc | @@ -2020,14 +2020,14 @@ export var values = _.values = (function (exports) { ret.push(val); }); return ret; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isStr ------------------------------ */ +/* ------------------------------ isStr ------------------------------ */ -export var isStr = _.isStr = (function (exports) { +export var isStr = _.isStr = (function (exports) { /* Check if value is a string primitive. * * |Name |Type |Desc | @@ -2050,14 +2050,14 @@ export var isStr = _.isStr = (function (exports) { exports = function(val) { return objToStr(val) === '[object String]'; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ contain ------------------------------ */ +/* ------------------------------ contain ------------------------------ */ -export var contain = _.contain = (function (exports) { +export var contain = _.contain = (function (exports) { /* Check if the value is present in the list. * * |Name |Type |Desc | @@ -2088,14 +2088,14 @@ export var contain = _.contain = (function (exports) { if (isStr(arr)) return arr.indexOf(val) > -1; if (!isArrLike(arr)) arr = values(arr); return idxOf(arr, val) >= 0; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isEmpty ------------------------------ */ +/* ------------------------------ isEmpty ------------------------------ */ -export var isEmpty = _.isEmpty = (function (exports) { +export var isEmpty = _.isEmpty = (function (exports) { /* Check if value is an empty object or array. * * |Name |Type |Desc | @@ -2126,14 +2126,14 @@ export var isEmpty = _.isEmpty = (function (exports) { } return keys(val).length === 0; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isBool ------------------------------ */ +/* ------------------------------ isBool ------------------------------ */ -export var isBool = _.isBool = (function (exports) { +export var isBool = _.isBool = (function (exports) { /* Check if value is a boolean primitive. * * |Name |Type |Desc | @@ -2153,14 +2153,14 @@ export var isBool = _.isBool = (function (exports) { */ exports = function(val) { return val === true || val === false; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ startWith ------------------------------ */ +/* ------------------------------ startWith ------------------------------ */ -export var startWith = _.startWith = (function (exports) { +export var startWith = _.startWith = (function (exports) { /* Check if string starts with the given target string. * * |Name |Type |Desc | @@ -2179,14 +2179,14 @@ export var startWith = _.startWith = (function (exports) { */ exports = function(str, prefix) { return str.indexOf(prefix) === 0; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isCrossOrig ------------------------------ */ +/* ------------------------------ isCrossOrig ------------------------------ */ -export var isCrossOrig = _.isCrossOrig = (function (exports) { +export var isCrossOrig = _.isCrossOrig = (function (exports) { /* Check if a url is cross origin. */ @@ -2198,14 +2198,14 @@ export var isCrossOrig = _.isCrossOrig = (function (exports) { exports = function (url) { return !startWith(url, origin) - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isEl ------------------------------ */ +/* ------------------------------ isEl ------------------------------ */ -export var isEl = _.isEl = (function (exports) { +export var isEl = _.isEl = (function (exports) { /* Check if value is a DOM element. * * |Name |Type |Desc | @@ -2223,14 +2223,14 @@ export var isEl = _.isEl = (function (exports) { */ exports = function(val) { return !!(val && val.nodeType === 1); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isErr ------------------------------ */ +/* ------------------------------ isErr ------------------------------ */ -export var isErr = _.isErr = (function (exports) { +export var isErr = _.isErr = (function (exports) { /* Check if value is an error. * * |Name |Type |Desc | @@ -2253,14 +2253,14 @@ export var isErr = _.isErr = (function (exports) { exports = function(val) { return objToStr(val) === '[object Error]'; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isErudaEl ------------------------------ */ +/* ------------------------------ isErudaEl ------------------------------ */ -export var isErudaEl = _.isErudaEl = (function (exports) { +export var isErudaEl = _.isErudaEl = (function (exports) { /* See if an element is within eruda. */ @@ -2275,14 +2275,14 @@ export var isErudaEl = _.isErudaEl = (function (exports) { } return false - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isMatch ------------------------------ */ +/* ------------------------------ isMatch ------------------------------ */ -export var isMatch = _.isMatch = (function (exports) { +export var isMatch = _.isMatch = (function (exports) { /* Check if keys and values in src are contained in obj. * * |Name |Type |Desc | @@ -2317,14 +2317,14 @@ export var isMatch = _.isMatch = (function (exports) { } return true; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ memoize ------------------------------ */ +/* ------------------------------ memoize ------------------------------ */ -export var memoize = _.memoize = (function (exports) { +export var memoize = _.memoize = (function (exports) { /* Memoize a given function by caching the computed result. * * |Name |Type |Desc | @@ -2358,14 +2358,14 @@ export var memoize = _.memoize = (function (exports) { memoize.cache = {}; return memoize; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isMobile ------------------------------ */ +/* ------------------------------ isMobile ------------------------------ */ -export var isMobile = _.isMobile = (function (exports) { +export var isMobile = _.isMobile = (function (exports) { /* Check whether client is using a mobile browser using ua. * * |Name |Type |Desc | @@ -2391,14 +2391,14 @@ export var isMobile = _.isMobile = (function (exports) { exports = memoize(function(ua) { ua = ua || (isBrowser ? navigator.userAgent : ''); return regMobileAll.test(ua) || regMobileFour.test(ua.substr(0, 4)); - }); + }); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ prefix ------------------------------ */ +/* ------------------------------ prefix ------------------------------ */ -export var prefix = _.prefix = (function (exports) { +export var prefix = _.prefix = (function (exports) { /* Add vendor prefixes to a CSS attribute. * * |Name |Type |Desc | @@ -2450,14 +2450,14 @@ export var prefix = _.prefix = (function (exports) { }); var prefixes = ['O', 'ms', 'Moz', 'Webkit']; var regPrefixes = /^(O)|(ms)|(Moz)|(Webkit)|(-o-)|(-ms-)|(-moz-)|(-webkit-)/g; - var style = document.createElement('p').style; + var style = document.createElement('p').style; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isNaN ------------------------------ */ +/* ------------------------------ isNaN ------------------------------ */ -export var isNaN = _.isNaN = (function (exports) { +export var isNaN = _.isNaN = (function (exports) { /* Check if value is an NaN. * * |Name |Type |Desc | @@ -2483,14 +2483,14 @@ export var isNaN = _.isNaN = (function (exports) { exports = function(val) { return isNum(val) && val !== +val; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isNil ------------------------------ */ +/* ------------------------------ isNil ------------------------------ */ -export var isNil = _.isNil = (function (exports) { +export var isNil = _.isNil = (function (exports) { /* Check if value is null or undefined, the same as value == null. * * |Name |Type |Desc | @@ -2513,14 +2513,14 @@ export var isNil = _.isNil = (function (exports) { */ exports = function(val) { return val == null; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ toSrc ------------------------------ */ +/* ------------------------------ toSrc ------------------------------ */ -export var toSrc = _.toSrc = (function (exports) { +export var toSrc = _.toSrc = (function (exports) { /* Convert function to its source code. * * |Name |Type |Desc | @@ -2558,14 +2558,14 @@ export var toSrc = _.toSrc = (function (exports) { return ''; }; - var fnToStr = Function.prototype.toString; + var fnToStr = Function.prototype.toString; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isNative ------------------------------ */ +/* ------------------------------ isNative ------------------------------ */ -export var isNative = _.isNative = (function (exports) { +export var isNative = _.isNative = (function (exports) { /* Check if value is a native function. * * |Name |Type |Desc | @@ -2605,14 +2605,14 @@ export var isNative = _.isNative = (function (exports) { ) + '$' ); - var regIsHostCtor = /^\[object .+?Constructor\]$/; + var regIsHostCtor = /^\[object .+?Constructor\]$/; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isNull ------------------------------ */ +/* ------------------------------ isNull ------------------------------ */ -export var isNull = _.isNull = (function (exports) { +export var isNull = _.isNull = (function (exports) { /* Check if value is an Null. * * |Name |Type |Desc | @@ -2630,14 +2630,14 @@ export var isNull = _.isNull = (function (exports) { */ exports = function(val) { return val === null; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isPrimitive ------------------------------ */ +/* ------------------------------ isPrimitive ------------------------------ */ -export var isPrimitive = _.isPrimitive = (function (exports) { +export var isPrimitive = _.isPrimitive = (function (exports) { /* Check if value is string, number, boolean or null. * * |Name |Type |Desc | @@ -2658,45 +2658,45 @@ export var isPrimitive = _.isPrimitive = (function (exports) { exports = function(val) { var type = typeof val; return val == null || (type !== 'function' && type !== 'object'); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isPromise ------------------------------ */ +/* ------------------------------ isPromise ------------------------------ */ -export var isPromise = _.isPromise = (function (exports) { - /* Check if value looks like a promise. - * - * |Name |Type |Desc | - * |------|-------|----------------------------------| - * |val |* |Value to check | - * |return|boolean|True if value looks like a promise| - */ +export var isPromise = _.isPromise = (function (exports) { + /* Check if value looks like a promise. + * + * |Name |Type |Desc | + * |------|-------|----------------------------------| + * |val |* |Value to check | + * |return|boolean|True if value looks like a promise| + */ - /* example - * isPromise(new Promise(function () {})); // -> true - * isPromise({}); // -> false - */ + /* example + * isPromise(new Promise(function () {})); // -> true + * isPromise({}); // -> false + */ - /* typescript - * export declare function isPromise(val: any): boolean; + /* typescript + * export declare function isPromise(val: any): boolean; */ /* dependencies * isObj isFn - */ + */ - exports = function(val) { - return isObj(val) && isFn(val.then); - }; + exports = function(val) { + return isObj(val) && isFn(val.then); + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isRegExp ------------------------------ */ +/* ------------------------------ isRegExp ------------------------------ */ -export var isRegExp = _.isRegExp = (function (exports) { +export var isRegExp = _.isRegExp = (function (exports) { /* Check if value is a regular expression. * * |Name |Type |Desc | @@ -2719,14 +2719,14 @@ export var isRegExp = _.isRegExp = (function (exports) { exports = function(val) { return objToStr(val) === '[object RegExp]'; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ loadJs ------------------------------ */ +/* ------------------------------ loadJs ------------------------------ */ -export var loadJs = _.loadJs = (function (exports) { +export var loadJs = _.loadJs = (function (exports) { /* Inject script tag into page with given src value. * * |Name|Type |Desc | @@ -2757,14 +2757,14 @@ export var loadJs = _.loadJs = (function (exports) { }; document.body.appendChild(script); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ lowerCase ------------------------------ */ +/* ------------------------------ lowerCase ------------------------------ */ -export var lowerCase = _.lowerCase = (function (exports) { +export var lowerCase = _.lowerCase = (function (exports) { /* Convert string to lower case. * * |Name |Type |Desc | @@ -2787,14 +2787,14 @@ export var lowerCase = _.lowerCase = (function (exports) { exports = function(str) { return toStr(str).toLocaleLowerCase(); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ repeat ------------------------------ */ +/* ------------------------------ repeat ------------------------------ */ -export var repeat = _.repeat = (function (exports) { +export var repeat = _.repeat = (function (exports) { /* Repeat string n-times. * * |Name |Type |Desc | @@ -2824,14 +2824,14 @@ export var repeat = _.repeat = (function (exports) { } return ret; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ lpad ------------------------------ */ +/* ------------------------------ lpad ------------------------------ */ -export var lpad = _.lpad = (function (exports) { +export var lpad = _.lpad = (function (exports) { /* Pad string on the left side if it's shorter than length. * * |Name |Type |Desc | @@ -2863,14 +2863,14 @@ export var lpad = _.lpad = (function (exports) { chars = chars || ' '; if (strLen < len) str = (repeat(chars, len - strLen) + str).slice(-len); return str; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ dateFormat ------------------------------ */ +/* ------------------------------ dateFormat ------------------------------ */ -export var dateFormat = _.dateFormat = (function (exports) { +export var dateFormat = _.dateFormat = (function (exports) { /* Simple but extremely useful date format function. * * |Name |Type |Desc | @@ -3073,14 +3073,14 @@ export var dateFormat = _.dateFormat = (function (exports) { 'November', 'December' ] - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ ltrim ------------------------------ */ +/* ------------------------------ ltrim ------------------------------ */ -export var ltrim = _.ltrim = (function (exports) { +export var ltrim = _.ltrim = (function (exports) { /* Remove chars or white-spaces from beginning of string. * * |Name |Type |Desc | @@ -3125,14 +3125,14 @@ export var ltrim = _.ltrim = (function (exports) { } return start >= len ? '' : str.substr(start, len); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ matcher ------------------------------ */ +/* ------------------------------ matcher ------------------------------ */ -export var matcher = _.matcher = (function (exports) { +export var matcher = _.matcher = (function (exports) { /* Return a predicate function that checks if attrs are contained in an object. * * |Name |Type |Desc | @@ -3164,14 +3164,14 @@ export var matcher = _.matcher = (function (exports) { return function(obj) { return isMatch(obj, attrs); }; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ safeCb ------------------------------ */ +/* ------------------------------ safeCb ------------------------------ */ -export var safeCb = _.safeCb = (function (exports) { +export var safeCb = _.safeCb = (function (exports) { /* Create callback based on input value. */ @@ -3192,14 +3192,14 @@ export var safeCb = _.safeCb = (function (exports) { return obj == null ? undefined : obj[key]; }; }; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ filter ------------------------------ */ +/* ------------------------------ filter ------------------------------ */ -export var filter = _.filter = (function (exports) { +export var filter = _.filter = (function (exports) { /* Iterates over elements of collection, returning an array of all the values that pass a truth test. * * |Name |Type |Desc | @@ -3242,14 +3242,14 @@ export var filter = _.filter = (function (exports) { if (predicate(val, idx, list)) ret.push(val); }); return ret; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ difference ------------------------------ */ +/* ------------------------------ difference ------------------------------ */ -export var difference = _.difference = (function (exports) { +export var difference = _.difference = (function (exports) { /* Create an array of unique array values not included in the other given array. * * |Name |Type |Desc | @@ -3276,14 +3276,14 @@ export var difference = _.difference = (function (exports) { return filter(arr, function(val) { return !contain(rest, val); }); - }); + }); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ evalCss ------------------------------ */ +/* ------------------------------ evalCss ------------------------------ */ -export var evalCss = _.evalCss = (function (exports) { +export var evalCss = _.evalCss = (function (exports) { /* Eval css. */ @@ -3332,14 +3332,14 @@ export var evalCss = _.evalCss = (function (exports) { function resetStyle({ css, el }) { el.innerText = css.replace(/(\d+)px/g, ($0, $1) => +$1 * scale + 'px') - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ unique ------------------------------ */ +/* ------------------------------ unique ------------------------------ */ -export var unique = _.unique = (function (exports) { +export var unique = _.unique = (function (exports) { /* Create duplicate-free version of an array. * * |Name |Type |Desc | @@ -3379,14 +3379,14 @@ export var unique = _.unique = (function (exports) { function isEqual(a, b) { return a === b; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ allKeys ------------------------------ */ +/* ------------------------------ allKeys ------------------------------ */ -export var allKeys = _.allKeys = (function (exports) { +export var allKeys = _.allKeys = (function (exports) { /* Retrieve all the names of object's own and inherited properties. * * |Name |Type |Desc | @@ -3478,14 +3478,14 @@ export var allKeys = _.allKeys = (function (exports) { } return ret; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ defaults ------------------------------ */ +/* ------------------------------ defaults ------------------------------ */ -export var defaults = _.defaults = (function (exports) { +export var defaults = _.defaults = (function (exports) { /* Fill in undefined properties in object with the first value present in the following list of defaults objects. * * |Name |Type |Desc | @@ -3507,14 +3507,14 @@ export var defaults = _.defaults = (function (exports) { * createAssigner allKeys */ - exports = createAssigner(allKeys, true); + exports = createAssigner(allKeys, true); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ highlight ------------------------------ */ +/* ------------------------------ highlight ------------------------------ */ -export var highlight = _.highlight = (function (exports) { +export var highlight = _.highlight = (function (exports) { /* Highlight code. * * |Name |Type |Desc | @@ -3682,14 +3682,14 @@ export var highlight = _.highlight = (function (exports) { re: /(@\w+|:?:\w+|[a-z-]+:)/g, style: 'keyword' } - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ extend ------------------------------ */ +/* ------------------------------ extend ------------------------------ */ -export var extend = _.extend = (function (exports) { +export var extend = _.extend = (function (exports) { /* Copy all of the properties in the source objects over to the destination object. * * |Name |Type |Desc | @@ -3711,14 +3711,14 @@ export var extend = _.extend = (function (exports) { * createAssigner allKeys */ - exports = createAssigner(allKeys); + exports = createAssigner(allKeys); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ clone ------------------------------ */ +/* ------------------------------ clone ------------------------------ */ -export var clone = _.clone = (function (exports) { +export var clone = _.clone = (function (exports) { /* Create a shallow-copied clone of the provided plain object. * * Any nested objects or arrays will be copied by reference, not duplicated. @@ -3744,14 +3744,14 @@ export var clone = _.clone = (function (exports) { exports = function(obj) { if (!isObj(obj)) return obj; return isArr(obj) ? obj.slice() : extend({}, obj); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ copy ------------------------------ */ +/* ------------------------------ copy ------------------------------ */ -export var copy = _.copy = (function (exports) { +export var copy = _.copy = (function (exports) { /* Copy text to clipboard using document.execCommand. * * |Name|Type |Desc | @@ -3801,14 +3801,14 @@ export var copy = _.copy = (function (exports) { } finally { body.removeChild(el); } - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ map ------------------------------ */ +/* ------------------------------ map ------------------------------ */ -export var map = _.map = (function (exports) { +export var map = _.map = (function (exports) { /* Create an array of values by running each element in collection through iteratee. * * |Name |Type |Desc | @@ -3856,14 +3856,14 @@ export var map = _.map = (function (exports) { } return results; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ decodeUriComponent ------------------------------ */ +/* ------------------------------ decodeUriComponent ------------------------------ */ -export var decodeUriComponent = _.decodeUriComponent = (function (exports) { +export var decodeUriComponent = _.decodeUriComponent = (function (exports) { /* Better decodeURIComponent that does not throw if input is invalid. * * |Name |Type |Desc | @@ -3914,14 +3914,14 @@ export var decodeUriComponent = _.decodeUriComponent = (function (exports) { return +('0x' + numStr); } - var regMatcher = /(%[a-f0-9]{2})+/gi; + var regMatcher = /(%[a-f0-9]{2})+/gi; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ cookie ------------------------------ */ +/* ------------------------------ cookie ------------------------------ */ -export var cookie = _.cookie = (function (exports) { +export var cookie = _.cookie = (function (exports) { /* Simple api for handling browser cookies. * * ### get @@ -4042,14 +4042,14 @@ export var cookie = _.cookie = (function (exports) { options.expires = -1; return setCookie(key, '', options); } - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ toArr ------------------------------ */ +/* ------------------------------ toArr ------------------------------ */ -export var toArr = _.toArr = (function (exports) { +export var toArr = _.toArr = (function (exports) { /* Convert value to an array. * * |Name |Type |Desc | @@ -4078,14 +4078,14 @@ export var toArr = _.toArr = (function (exports) { if (isArr(val)) return val; if (isArrLike(val) && !isStr(val)) return map(val); return [val]; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ Class ------------------------------ */ +/* ------------------------------ Class ------------------------------ */ -export var Class = _.Class = (function (exports) { +export var Class = _.Class = (function (exports) { /* Create JavaScript class. * * |Name |Type |Desc | @@ -4212,14 +4212,14 @@ export var Class = _.Class = (function (exports) { toString: function() { return this.constructor.name; } - })); + })); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ Enum ------------------------------ */ +/* ------------------------------ Enum ------------------------------ */ -export var Enum = _.Enum = (function (exports) { +export var Enum = _.Enum = (function (exports) { /* Enum type implementation. * * ### constructor @@ -4279,14 +4279,14 @@ export var Enum = _.Enum = (function (exports) { freeze(this); } - }); + }); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ MutationObserver ------------------------------ */ +/* ------------------------------ MutationObserver ------------------------------ */ -export var MutationObserver = _.MutationObserver = (function (exports) { +export var MutationObserver = _.MutationObserver = (function (exports) { /* Safe MutationObserver, does nothing if MutationObserver is not supported. */ @@ -4317,14 +4317,14 @@ export var MutationObserver = _.MutationObserver = (function (exports) { disconnect: function() {}, takeRecords: function() {} }); - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ Select ------------------------------ */ +/* ------------------------------ Select ------------------------------ */ -export var Select = _.Select = (function (exports) { +export var Select = _.Select = (function (exports) { /* Simple wrapper of querySelectorAll to make dom selection easier. * * ### constructor @@ -4407,14 +4407,14 @@ export var Select = _.Select = (function (exports) { first.length = i; return first; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $safeEls ------------------------------ */ +/* ------------------------------ $safeEls ------------------------------ */ -export var $safeEls = _.$safeEls = (function (exports) { +export var $safeEls = _.$safeEls = (function (exports) { /* Convert value into an array, if it's a string, do querySelector. * * |Name |Type |Desc | @@ -4442,14 +4442,14 @@ export var $safeEls = _.$safeEls = (function (exports) { exports = function(val) { return toArr(isStr(val) ? new Select(val) : val); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $attr ------------------------------ */ +/* ------------------------------ $attr ------------------------------ */ -export var $attr = _.$attr = (function (exports) { +export var $attr = _.$attr = (function (exports) { /* Element attribute manipulation. * * Get the value of an attribute for the first element in the set of matched elements. @@ -4543,14 +4543,14 @@ export var $attr = _.$attr = (function (exports) { el.setAttribute(name, val); }); }); - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $css ------------------------------ */ +/* ------------------------------ $css ------------------------------ */ -export var $css = _.$css = (function (exports) { +export var $css = _.$css = (function (exports) { /* Element css manipulation. * * Get the computed style properties for the first element in the set of matched elements. @@ -4642,14 +4642,14 @@ export var $css = _.$css = (function (exports) { function addPx(key, val) { var needPx = isNum(val) && !contain(cssNumProps, kebabCase(key)); return needPx ? val + 'px' : val; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $data ------------------------------ */ +/* ------------------------------ $data ------------------------------ */ -export var $data = _.$data = (function (exports) { +export var $data = _.$data = (function (exports) { /* Wrapper of $attr, adds data- prefix to keys. */ @@ -4686,14 +4686,14 @@ export var $data = _.$data = (function (exports) { } return $attr(nodes, dataName, val); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $insert ------------------------------ */ +/* ------------------------------ $insert ------------------------------ */ -export var $insert = _.$insert = (function (exports) { +export var $insert = _.$insert = (function (exports) { /* Insert html on different position. * * ### before @@ -4762,14 +4762,14 @@ export var $insert = _.$insert = (function (exports) { node.insertAdjacentHTML(type, val); }); }; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $offset ------------------------------ */ +/* ------------------------------ $offset ------------------------------ */ -export var $offset = _.$offset = (function (exports) { +export var $offset = _.$offset = (function (exports) { /* Get the position of the element in document. * * |Name |Type |Desc | @@ -4807,14 +4807,14 @@ export var $offset = _.$offset = (function (exports) { width: Math.round(clientRect.width), height: Math.round(clientRect.height) }; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $property ------------------------------ */ +/* ------------------------------ $property ------------------------------ */ -export var $property = _.$property = (function (exports) { +export var $property = _.$property = (function (exports) { /* Element property html, text, val getter and setter. * * ### html @@ -4871,14 +4871,14 @@ export var $property = _.$property = (function (exports) { node[name] = val; }); }; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $remove ------------------------------ */ +/* ------------------------------ $remove ------------------------------ */ -export var $remove = _.$remove = (function (exports) { +export var $remove = _.$remove = (function (exports) { /* Remove the set of matched elements from the DOM. * * |Name |Type |Desc | @@ -4904,14 +4904,14 @@ export var $remove = _.$remove = (function (exports) { var parent = el.parentNode; if (parent) parent.removeChild(el); }); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $show ------------------------------ */ +/* ------------------------------ $show ------------------------------ */ -export var $show = _.$show = (function (exports) { +export var $show = _.$show = (function (exports) { /* Show elements. * * |Name |Type |Desc | @@ -4959,14 +4959,14 @@ export var $show = _.$show = (function (exports) { } return elDisplay[elName]; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ Stack ------------------------------ */ +/* ------------------------------ Stack ------------------------------ */ -export var Stack = _.Stack = (function (exports) { +export var Stack = _.Stack = (function (exports) { /* Stack data structure. * * ### clear @@ -5060,14 +5060,14 @@ export var Stack = _.Stack = (function (exports) { toArr: function() { return this._items.slice(0).reverse(); } - }); + }); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ delegate ------------------------------ */ +/* ------------------------------ delegate ------------------------------ */ -export var delegate = _.delegate = (function (exports) { +export var delegate = _.delegate = (function (exports) { /* Event delegation. * * ### add @@ -5259,14 +5259,14 @@ export var delegate = _.delegate = (function (exports) { this.stopPropagation(); } }) - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $event ------------------------------ */ +/* ------------------------------ $event ------------------------------ */ -export var $event = _.$event = (function (exports) { +export var $event = _.$event = (function (exports) { /* bind events to certain dom elements. */ @@ -5319,14 +5319,14 @@ export var $event = _.$event = (function (exports) { delegate[type](node, event, selector, handler); }); }; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ concat ------------------------------ */ +/* ------------------------------ concat ------------------------------ */ -export var concat = _.concat = (function (exports) { +export var concat = _.concat = (function (exports) { /* Concat multiple arrays into a single array. * * |Name |Type |Desc | @@ -5356,14 +5356,14 @@ export var concat = _.concat = (function (exports) { } return ret; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ mapObj ------------------------------ */ +/* ------------------------------ mapObj ------------------------------ */ -export var mapObj = _.mapObj = (function (exports) { +export var mapObj = _.mapObj = (function (exports) { /* Map for objects. * * |Name |Type |Desc | @@ -5406,14 +5406,14 @@ export var mapObj = _.mapObj = (function (exports) { } return ret; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ cloneDeep ------------------------------ */ +/* ------------------------------ cloneDeep ------------------------------ */ -export var cloneDeep = _.cloneDeep = (function (exports) { +export var cloneDeep = _.cloneDeep = (function (exports) { /* Recursively clone value. * * |Name |Type|Desc | @@ -5450,14 +5450,14 @@ export var cloneDeep = _.cloneDeep = (function (exports) { } return obj; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ some ------------------------------ */ +/* ------------------------------ some ------------------------------ */ -export var some = _.some = (function (exports) { +export var some = _.some = (function (exports) { /* Check if predicate return truthy for any element. * * |Name |Type |Desc | @@ -5506,14 +5506,14 @@ export var some = _.some = (function (exports) { } return false; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $class ------------------------------ */ +/* ------------------------------ $class ------------------------------ */ -export var $class = _.$class = (function (exports) { +export var $class = _.$class = (function (exports) { /* Element class manipulations. * * ### add @@ -5619,14 +5619,14 @@ export var $class = _.$class = (function (exports) { function safeName(name) { return isStr(name) ? name.split(/\s+/) : toArr(name); - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $ ------------------------------ */ +/* ------------------------------ $ ------------------------------ */ -export var $ = _.$ = (function (exports) { +export var $ = _.$ = (function (exports) { /* jQuery like style dom manipulator. * * ### Available methods @@ -5808,14 +5808,14 @@ export var $ = _.$ = (function (exports) { function isGetter(name, val) { return isUndef(val) && isStr(name); - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ memStorage ------------------------------ */ +/* ------------------------------ memStorage ------------------------------ */ -export var memStorage = _.memStorage = (function (exports) { +export var memStorage = _.memStorage = (function (exports) { /* Memory-backed implementation of the Web Storage API. * * A replacement for environments where localStorage or sessionStorage is not available. @@ -5893,14 +5893,14 @@ export var memStorage = _.memStorage = (function (exports) { function cloakedKeys() { return keys(cloak); - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ safeStorage ------------------------------ */ +/* ------------------------------ safeStorage ------------------------------ */ -export var safeStorage = _.safeStorage = (function (exports) { +export var safeStorage = _.safeStorage = (function (exports) { /* Safe localStorage and sessionStorage. */ @@ -5935,14 +5935,14 @@ export var safeStorage = _.safeStorage = (function (exports) { } return ret - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ meta ------------------------------ */ +/* ------------------------------ meta ------------------------------ */ -export var meta = _.meta = (function (exports) { +export var meta = _.meta = (function (exports) { /* Document meta manipulation, turn name and content into key value pairs. * * Get meta content with given name. If name is omitted, all pairs will be return. @@ -6070,14 +6070,14 @@ export var meta = _.meta = (function (exports) { function selectMeta(name) { return doc.querySelector('meta[name="' + name + '"]'); - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ toNum ------------------------------ */ +/* ------------------------------ toNum ------------------------------ */ -export var toNum = _.toNum = (function (exports) { +export var toNum = _.toNum = (function (exports) { /* Convert value to a number. * * |Name |Type |Desc | @@ -6108,14 +6108,14 @@ export var toNum = _.toNum = (function (exports) { if (!isStr(val)) return val === 0 ? val : +val; return +val; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ ms ------------------------------ */ +/* ------------------------------ ms ------------------------------ */ -export var ms = _.ms = (function (exports) { +export var ms = _.ms = (function (exports) { /* Convert time string formats to milliseconds. * * Turn time string into milliseconds. @@ -6182,14 +6182,14 @@ export var ms = _.ms = (function (exports) { factor.d = factor.h * 24; factor.y = factor.d * 365.25; var suffixList = ['y', 'd', 'h', 'm', 's']; - var regStrTime = /^((?:\d+)?\.?\d+) *(s|m|h|d|y)?$/; + var regStrTime = /^((?:\d+)?\.?\d+) *(s|m|h|d|y)?$/; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ toInt ------------------------------ */ +/* ------------------------------ toInt ------------------------------ */ -export var toInt = _.toInt = (function (exports) { +export var toInt = _.toInt = (function (exports) { /* Convert value to an integer. * * |Name |Type |Desc | @@ -6215,14 +6215,14 @@ export var toInt = _.toInt = (function (exports) { if (!val) return val === 0 ? val : 0; val = toNum(val); return val - (val % 1); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ detectBrowser ------------------------------ */ +/* ------------------------------ detectBrowser ------------------------------ */ -export var detectBrowser = _.detectBrowser = (function (exports) { +export var detectBrowser = _.detectBrowser = (function (exports) { /* Detect browser info using ua. * * |Name |Type |Desc | @@ -6303,14 +6303,14 @@ export var detectBrowser = _.detectBrowser = (function (exports) { var idx = ua.indexOf(mark); if (idx > -1) return toInt(ua.substring(idx + mark.length, ua.indexOf('.', idx))); - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ nextTick ------------------------------ */ +/* ------------------------------ nextTick ------------------------------ */ -export var nextTick = _.nextTick = (function (exports) { +export var nextTick = _.nextTick = (function (exports) { /* Next tick for both node and browser. * * |Name|Type |Desc | @@ -6347,14 +6347,14 @@ export var nextTick = _.nextTick = (function (exports) { if (typeof fn !== 'function') throw new TypeError(fn + ' is not a function'); return fn; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ now ------------------------------ */ +/* ------------------------------ now ------------------------------ */ -export var now = _.now = (function (exports) { +export var now = _.now = (function (exports) { /* Gets the number of milliseconds that have elapsed since the Unix epoch. */ @@ -6369,14 +6369,14 @@ export var now = _.now = (function (exports) { Date.now || function() { return new Date().getTime(); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ partial ------------------------------ */ +/* ------------------------------ partial ------------------------------ */ -export var partial = _.partial = (function (exports) { +export var partial = _.partial = (function (exports) { /* Partially apply a function by filling in given arguments. * * |Name |Type |Desc | @@ -6406,14 +6406,14 @@ export var partial = _.partial = (function (exports) { args = args.concat(toArr(arguments)); return fn.apply(this, args); }; - }); + }); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ once ------------------------------ */ +/* ------------------------------ once ------------------------------ */ -export var once = _.once = (function (exports) { +export var once = _.once = (function (exports) { /* Create a function that invokes once. * * |Name |Type |Desc | @@ -6437,14 +6437,14 @@ export var once = _.once = (function (exports) { * partial before */ - exports = partial(before, 2); + exports = partial(before, 2); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ Emitter ------------------------------ */ +/* ------------------------------ Emitter ------------------------------ */ -export var Emitter = _.Emitter = (function (exports) { +export var Emitter = _.Emitter = (function (exports) { /* Event emitter class which provides observer pattern. * * ### on @@ -6552,14 +6552,14 @@ export var Emitter = _.Emitter = (function (exports) { obj._events = obj._events || {}; } } - ); + ); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ Logger ------------------------------ */ +/* ------------------------------ Logger ------------------------------ */ -export var Logger = _.Logger = (function (exports) { +export var Logger = _.Logger = (function (exports) { /* Simple logger with level filter. * * ### constructor @@ -6691,14 +6691,14 @@ export var Logger = _.Logger = (function (exports) { SILENT: 5 }) } - ); + ); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ Store ------------------------------ */ +/* ------------------------------ Store ------------------------------ */ -export var Store = _.Store = (function (exports) { +export var Store = _.Store = (function (exports) { /* Memory storage. * * Extend from Emitter. @@ -6846,14 +6846,14 @@ export var Store = _.Store = (function (exports) { save: function(data) { this._data = data; } - }); + }); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ orientation ------------------------------ */ +/* ------------------------------ orientation ------------------------------ */ -export var orientation = _.orientation = (function (exports) { +export var orientation = _.orientation = (function (exports) { /* Screen orientation helper. * * ### on @@ -6911,14 +6911,14 @@ export var orientation = _.orientation = (function (exports) { }, 200); }, false - ); + ); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ perfNow ------------------------------ */ +/* ------------------------------ perfNow ------------------------------ */ -export var perfNow = _.perfNow = (function (exports) { +export var perfNow = _.perfNow = (function (exports) { /* High resolution time up to microsecond precision. */ @@ -6963,14 +6963,14 @@ export var perfNow = _.perfNow = (function (exports) { exports = function() { return now() - loadTime; }; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ pxToNum ------------------------------ */ +/* ------------------------------ pxToNum ------------------------------ */ -export var pxToNum = _.pxToNum = (function (exports) { +export var pxToNum = _.pxToNum = (function (exports) { /* Turn string like '0px' to number. */ @@ -6980,14 +6980,14 @@ export var pxToNum = _.pxToNum = (function (exports) { exports = function (str) { return toNum(str.replace('px', '')) - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ rmCookie ------------------------------ */ +/* ------------------------------ rmCookie ------------------------------ */ -export var rmCookie = _.rmCookie = (function (exports) { +export var rmCookie = _.rmCookie = (function (exports) { /* Loop through all possible path and domain to remove cookie. * * |Name|Type |Desc | @@ -7067,14 +7067,14 @@ export var rmCookie = _.rmCookie = (function (exports) { cookie.remove(key, options); return !cookie.get(key); } - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ rtrim ------------------------------ */ +/* ------------------------------ rtrim ------------------------------ */ -export var rtrim = _.rtrim = (function (exports) { +export var rtrim = _.rtrim = (function (exports) { /* Remove chars or white-spaces from end of string. * * |Name |Type |Desc | @@ -7118,14 +7118,14 @@ export var rtrim = _.rtrim = (function (exports) { } return end >= 0 ? str.substring(0, end + 1) : ''; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ trim ------------------------------ */ +/* ------------------------------ trim ------------------------------ */ -export var trim = _.trim = (function (exports) { +export var trim = _.trim = (function (exports) { /* Remove chars or white-spaces from beginning end of string. * * |Name |Type |Desc | @@ -7154,14 +7154,14 @@ export var trim = _.trim = (function (exports) { exports = function(str, chars) { if (chars == null) return str.replace(regSpace, ''); return ltrim(rtrim(str, chars), chars); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ query ------------------------------ */ +/* ------------------------------ query ------------------------------ */ -export var query = _.query = (function (exports) { +export var query = _.query = (function (exports) { /* Parse and stringify url query strings. * * ### parse @@ -7240,14 +7240,14 @@ export var query = _.query = (function (exports) { ).join('&'); } }; - var regIllegalChars = /^(\?|#|&)/g; + var regIllegalChars = /^(\?|#|&)/g; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ Url ------------------------------ */ +/* ------------------------------ Url ------------------------------ */ -export var Url = _.Url = (function (exports) { +export var Url = _.Url = (function (exports) { /* Simple url manipulator. * * ### constructor @@ -7484,14 +7484,14 @@ export var Url = _.Url = (function (exports) { ); var regProto = /^([a-z0-9.+-]+:)/i; var regPort = /:[0-9]*$/; - var hostEndingChars = ['/', '?', '#']; + var hostEndingChars = ['/', '?', '#']; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ getFileName ------------------------------ */ +/* ------------------------------ getFileName ------------------------------ */ -export var getFileName = _.getFileName = (function (exports) { +export var getFileName = _.getFileName = (function (exports) { /* Extract file name from url. */ @@ -7510,14 +7510,14 @@ export var getFileName = _.getFileName = (function (exports) { } return ret - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ ajax ------------------------------ */ +/* ------------------------------ ajax ------------------------------ */ -export var ajax = _.ajax = (function (exports) { +export var ajax = _.ajax = (function (exports) { /* Perform an asynchronous HTTP request. * * |Name |Type |Desc | @@ -7690,14 +7690,14 @@ export var ajax = _.ajax = (function (exports) { success: success, dataType: dataType }; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ type ------------------------------ */ +/* ------------------------------ type ------------------------------ */ -export var type = _.type = (function (exports) { +export var type = _.type = (function (exports) { /* Determine the internal JavaScript [[Class]] of an object. * * |Name |Type |Desc | @@ -7737,14 +7737,14 @@ export var type = _.type = (function (exports) { return lowerCase ? ret[1].toLowerCase() : ret[1]; }; - var regObj = /^\[object\s+(.*?)]$/; + var regObj = /^\[object\s+(.*?)]$/; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ stringify ------------------------------ */ +/* ------------------------------ stringify ------------------------------ */ -export var stringify = _.stringify = (function (exports) { +export var stringify = _.stringify = (function (exports) { /* JSON stringify with support for circular object, function etc. * * Undefined is treated as null value. @@ -7812,14 +7812,14 @@ export var stringify = _.stringify = (function (exports) { return val; }; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ LocalStore ------------------------------ */ +/* ------------------------------ LocalStore ------------------------------ */ -export var LocalStore = _.LocalStore = (function (exports) { +export var LocalStore = _.LocalStore = (function (exports) { /* LocalStorage wrapper. * * Extend from Store. @@ -7868,324 +7868,324 @@ export var LocalStore = _.LocalStore = (function (exports) { if (isEmpty(data)) return localStorage.removeItem(this._name); localStorage.setItem(this._name, stringify(data)); } - }); - - return exports; -})({}); - -/* ------------------------------ stringifyAll ------------------------------ */ - -export var stringifyAll = _.stringifyAll = (function (exports) { - /* Stringify object into json with types. - * - * |Name |Type |Desc | - * |---------|------|-------------------| - * |obj |* |Object to stringify| - * |[options]|object|Stringify options | - * |return |string|Stringified object | - * - * Available options: - * - * |Name |Type |Desc | - * |------------------|-------|-------------------------| - * |unenumerable=false|boolean|Include unenumerable keys| - * |symbol=false |boolean|Include symbol keys | - * |accessGetter=false|boolean|Access getter value | - * |timeout=0 |number |Timeout of stringify | - * |depth=0 |number |Max depth of recursion | - * |[ignore] |array |Values to ignore | - * - * When time is out, all remaining values will all be "Timeout". - */ - - /* example - * stringifyAll(function test() {}); // -> '{"value":"function test() {}","type":"Function",...}' - */ - - /* typescript - * export declare namespace stringifyAll { - * interface IOptions { - * unenumerable?: boolean; - * symbol?: boolean; - * accessGetter?: boolean; - * timeout?: number; - * depth?: number; - * ignore?: any[]; - * } - * } - * export declare function stringifyAll( - * obj: any, - * options?: stringifyAll.IOptions - * ): string; + }); + + return exports; +})({}); + +/* ------------------------------ stringifyAll ------------------------------ */ + +export var stringifyAll = _.stringifyAll = (function (exports) { + /* Stringify object into json with types. + * + * |Name |Type |Desc | + * |---------|------|-------------------| + * |obj |* |Object to stringify| + * |[options]|object|Stringify options | + * |return |string|Stringified object | + * + * Available options: + * + * |Name |Type |Desc | + * |------------------|-------|-------------------------| + * |unenumerable=false|boolean|Include unenumerable keys| + * |symbol=false |boolean|Include symbol keys | + * |accessGetter=false|boolean|Access getter value | + * |timeout=0 |number |Timeout of stringify | + * |depth=0 |number |Max depth of recursion | + * |[ignore] |array |Values to ignore | + * + * When time is out, all remaining values will all be "Timeout". + */ + + /* example + * stringifyAll(function test() {}); // -> '{"value":"function test() {}","type":"Function",...}' + */ + + /* typescript + * export declare namespace stringifyAll { + * interface IOptions { + * unenumerable?: boolean; + * symbol?: boolean; + * accessGetter?: boolean; + * timeout?: number; + * depth?: number; + * ignore?: any[]; + * } + * } + * export declare function stringifyAll( + * obj: any, + * options?: stringifyAll.IOptions + * ): string; */ /* dependencies * escapeJsStr type toStr endWith toSrc keys each Class getProto difference extend isPromise filter now allKeys contain - */ - - exports = function(obj) { - var _ref = - arguments.length > 1 && arguments[1] !== undefined - ? arguments[1] - : {}, - self = _ref.self, - _ref$startTime = _ref.startTime, - startTime = _ref$startTime === void 0 ? now() : _ref$startTime, - _ref$timeout = _ref.timeout, - timeout = _ref$timeout === void 0 ? 0 : _ref$timeout, - _ref$depth = _ref.depth, - depth = _ref$depth === void 0 ? 0 : _ref$depth, - _ref$curDepth = _ref.curDepth, - curDepth = _ref$curDepth === void 0 ? 1 : _ref$curDepth, - _ref$visitor = _ref.visitor, - visitor = _ref$visitor === void 0 ? new Visitor() : _ref$visitor, - _ref$unenumerable = _ref.unenumerable, - unenumerable = _ref$unenumerable === void 0 ? false : _ref$unenumerable, - _ref$symbol = _ref.symbol, - symbol = _ref$symbol === void 0 ? false : _ref$symbol, - _ref$accessGetter = _ref.accessGetter, - accessGetter = _ref$accessGetter === void 0 ? false : _ref$accessGetter, - _ref$ignore = _ref.ignore, - ignore = _ref$ignore === void 0 ? [] : _ref$ignore; - - var json = ''; - var options = { - visitor: visitor, - unenumerable: unenumerable, - symbol: symbol, - accessGetter: accessGetter, - depth: depth, - curDepth: curDepth + 1, - timeout: timeout, - startTime: startTime, - ignore: ignore - }; - var t = type(obj, false); - - if (t === 'String') { - json = wrapStr(obj); - } else if (t === 'Number') { - json = toStr(obj); - - if (endWith(json, 'Infinity')) { - json = '{"value":"'.concat(json, '","type":"Number"}'); - } - } else if (t === 'NaN') { - json = '{"value":"NaN","type":"Number"}'; - } else if (t === 'Boolean') { - json = obj ? 'true' : 'false'; - } else if (t === 'Null') { - json = 'null'; - } else if (t === 'Undefined') { - json = '{"type":"Undefined"}'; - } else if (t === 'Symbol') { - var val = 'Symbol'; - - try { - val = toStr(obj); - /* eslint-disable no-empty */ - } catch (e) {} - - json = '{"value":'.concat(wrapStr(val), ',"type":"Symbol"}'); - } else { - if (timeout && now() - startTime > timeout) { - return wrapStr('Timeout'); - } - - if (depth && curDepth > depth) { - return wrapStr('{...}'); - } - - json = '{'; - var parts = []; - var visitedObj = visitor.get(obj); - var id; - - if (visitedObj) { - id = visitedObj.id; - parts.push('"reference":'.concat(id)); - } else { - id = visitor.set(obj); - parts.push('"id":'.concat(id)); - } - - parts.push('"type":"'.concat(t, '"')); - - if (endWith(t, 'Function')) { - parts.push('"value":'.concat(wrapStr(toSrc(obj)))); - } else if (t === 'RegExp') { - parts.push('"value":'.concat(wrapStr(obj))); - } - - if (!visitedObj) { - var enumerableKeys = keys(obj); - - if (enumerableKeys.length) { - parts.push( - iterateObj( - 'enumerable', - enumerableKeys, - self || obj, - options - ) - ); - } - - if (unenumerable) { - var unenumerableKeys = difference( - allKeys(obj, { - prototype: false, - unenumerable: true - }), - enumerableKeys - ); - - if (unenumerableKeys.length) { - parts.push( - iterateObj( - 'unenumerable', - unenumerableKeys, - self || obj, - options - ) - ); - } - } - - if (symbol) { - var symbolKeys = filter( - allKeys(obj, { - prototype: false, - symbol: true - }), - function(key) { - return typeof key === 'symbol'; - } - ); - - if (symbolKeys.length) { - parts.push( - iterateObj('symbol', symbolKeys, self || obj, options) - ); - } - } - - var prototype = getProto(obj); - - if (prototype && !contain(ignore, prototype)) { - var proto = '"proto":'.concat( - exports( - prototype, - extend(options, { - self: self || obj - }) - ) - ); - parts.push(proto); - } - } - - json += parts.join(',') + '}'; - } - - return json; - }; - - function iterateObj(name, keys, obj, options) { - var parts = []; - each(keys, function(key) { - var val; - var descriptor = Object.getOwnPropertyDescriptor(obj, key); - var hasGetter = descriptor && descriptor.get; - var hasSetter = descriptor && descriptor.set; - - if (!options.accessGetter && hasGetter) { - val = '(...)'; - } else { - try { - val = obj[key]; - - if (contain(options.ignore, val)) { - return; - } - - if (isPromise(val)) { - val.catch(function() {}); - } - } catch (e) { - val = e.message; - } - } - - parts.push(''.concat(wrapKey(key), ':').concat(exports(val, options))); - - if (hasGetter) { - parts.push( - '' - .concat(wrapKey('get ' + toStr(key)), ':') - .concat(exports(descriptor.get, options)) - ); - } - - if (hasSetter) { - parts.push( - '' - .concat(wrapKey('set ' + toStr(key)), ':') - .concat(exports(descriptor.set, options)) - ); - } - }); - return '"'.concat(name, '":{') + parts.join(',') + '}'; - } - - function wrapKey(key) { - return '"'.concat(escapeJsonStr(key), '"'); - } - - function wrapStr(str) { - return '"'.concat(escapeJsonStr(toStr(str)), '"'); - } - - function escapeJsonStr(str) { - return escapeJsStr(str) - .replace(/\\'/g, "'") - .replace(/\t/g, '\\t'); - } - - var Visitor = Class({ - initialize: function() { - this.id = 0; - this.visited = []; - }, - set: function(val) { - var visited = this.visited, - id = this.id; - var obj = { - id: id, - val: val - }; - visited.push(obj); - this.id++; - return id; - }, - get: function(val) { - var visited = this.visited; - - for (var i = 0, len = visited.length; i < len; i++) { - var obj = visited[i]; - if (val === obj.val) return obj; - } - - return false; - } - }); - - return exports; -})({}); - -/* ------------------------------ stripHtmlTag ------------------------------ */ - -export var stripHtmlTag = _.stripHtmlTag = (function (exports) { + */ + + exports = function(obj) { + var _ref = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : {}, + self = _ref.self, + _ref$startTime = _ref.startTime, + startTime = _ref$startTime === void 0 ? now() : _ref$startTime, + _ref$timeout = _ref.timeout, + timeout = _ref$timeout === void 0 ? 0 : _ref$timeout, + _ref$depth = _ref.depth, + depth = _ref$depth === void 0 ? 0 : _ref$depth, + _ref$curDepth = _ref.curDepth, + curDepth = _ref$curDepth === void 0 ? 1 : _ref$curDepth, + _ref$visitor = _ref.visitor, + visitor = _ref$visitor === void 0 ? new Visitor() : _ref$visitor, + _ref$unenumerable = _ref.unenumerable, + unenumerable = _ref$unenumerable === void 0 ? false : _ref$unenumerable, + _ref$symbol = _ref.symbol, + symbol = _ref$symbol === void 0 ? false : _ref$symbol, + _ref$accessGetter = _ref.accessGetter, + accessGetter = _ref$accessGetter === void 0 ? false : _ref$accessGetter, + _ref$ignore = _ref.ignore, + ignore = _ref$ignore === void 0 ? [] : _ref$ignore; + + var json = ''; + var options = { + visitor: visitor, + unenumerable: unenumerable, + symbol: symbol, + accessGetter: accessGetter, + depth: depth, + curDepth: curDepth + 1, + timeout: timeout, + startTime: startTime, + ignore: ignore + }; + var t = type(obj, false); + + if (t === 'String') { + json = wrapStr(obj); + } else if (t === 'Number') { + json = toStr(obj); + + if (endWith(json, 'Infinity')) { + json = '{"value":"'.concat(json, '","type":"Number"}'); + } + } else if (t === 'NaN') { + json = '{"value":"NaN","type":"Number"}'; + } else if (t === 'Boolean') { + json = obj ? 'true' : 'false'; + } else if (t === 'Null') { + json = 'null'; + } else if (t === 'Undefined') { + json = '{"type":"Undefined"}'; + } else if (t === 'Symbol') { + var val = 'Symbol'; + + try { + val = toStr(obj); + /* eslint-disable no-empty */ + } catch (e) {} + + json = '{"value":'.concat(wrapStr(val), ',"type":"Symbol"}'); + } else { + if (timeout && now() - startTime > timeout) { + return wrapStr('Timeout'); + } + + if (depth && curDepth > depth) { + return wrapStr('{...}'); + } + + json = '{'; + var parts = []; + var visitedObj = visitor.get(obj); + var id; + + if (visitedObj) { + id = visitedObj.id; + parts.push('"reference":'.concat(id)); + } else { + id = visitor.set(obj); + parts.push('"id":'.concat(id)); + } + + parts.push('"type":"'.concat(t, '"')); + + if (endWith(t, 'Function')) { + parts.push('"value":'.concat(wrapStr(toSrc(obj)))); + } else if (t === 'RegExp') { + parts.push('"value":'.concat(wrapStr(obj))); + } + + if (!visitedObj) { + var enumerableKeys = keys(obj); + + if (enumerableKeys.length) { + parts.push( + iterateObj( + 'enumerable', + enumerableKeys, + self || obj, + options + ) + ); + } + + if (unenumerable) { + var unenumerableKeys = difference( + allKeys(obj, { + prototype: false, + unenumerable: true + }), + enumerableKeys + ); + + if (unenumerableKeys.length) { + parts.push( + iterateObj( + 'unenumerable', + unenumerableKeys, + self || obj, + options + ) + ); + } + } + + if (symbol) { + var symbolKeys = filter( + allKeys(obj, { + prototype: false, + symbol: true + }), + function(key) { + return typeof key === 'symbol'; + } + ); + + if (symbolKeys.length) { + parts.push( + iterateObj('symbol', symbolKeys, self || obj, options) + ); + } + } + + var prototype = getProto(obj); + + if (prototype && !contain(ignore, prototype)) { + var proto = '"proto":'.concat( + exports( + prototype, + extend(options, { + self: self || obj + }) + ) + ); + parts.push(proto); + } + } + + json += parts.join(',') + '}'; + } + + return json; + }; + + function iterateObj(name, keys, obj, options) { + var parts = []; + each(keys, function(key) { + var val; + var descriptor = Object.getOwnPropertyDescriptor(obj, key); + var hasGetter = descriptor && descriptor.get; + var hasSetter = descriptor && descriptor.set; + + if (!options.accessGetter && hasGetter) { + val = '(...)'; + } else { + try { + val = obj[key]; + + if (contain(options.ignore, val)) { + return; + } + + if (isPromise(val)) { + val.catch(function() {}); + } + } catch (e) { + val = e.message; + } + } + + parts.push(''.concat(wrapKey(key), ':').concat(exports(val, options))); + + if (hasGetter) { + parts.push( + '' + .concat(wrapKey('get ' + toStr(key)), ':') + .concat(exports(descriptor.get, options)) + ); + } + + if (hasSetter) { + parts.push( + '' + .concat(wrapKey('set ' + toStr(key)), ':') + .concat(exports(descriptor.set, options)) + ); + } + }); + return '"'.concat(name, '":{') + parts.join(',') + '}'; + } + + function wrapKey(key) { + return '"'.concat(escapeJsonStr(key), '"'); + } + + function wrapStr(str) { + return '"'.concat(escapeJsonStr(toStr(str)), '"'); + } + + function escapeJsonStr(str) { + return escapeJsStr(str) + .replace(/\\'/g, "'") + .replace(/\t/g, '\\t'); + } + + var Visitor = Class({ + initialize: function() { + this.id = 0; + this.visited = []; + }, + set: function(val) { + var visited = this.visited, + id = this.id; + var obj = { + id: id, + val: val + }; + visited.push(obj); + this.id++; + return id; + }, + get: function(val) { + var visited = this.visited; + + for (var i = 0, len = visited.length; i < len; i++) { + var obj = visited[i]; + if (val === obj.val) return obj; + } + + return false; + } + }); + + return exports; +})({}); + +/* ------------------------------ stripHtmlTag ------------------------------ */ + +export var stripHtmlTag = _.stripHtmlTag = (function (exports) { /* Strip html tags from a string. * * |Name |Type |Desc | @@ -8205,14 +8205,14 @@ export var stripHtmlTag = _.stripHtmlTag = (function (exports) { exports = function(str) { return str.replace(regHtmlTag, ''); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ throttle ------------------------------ */ +/* ------------------------------ throttle ------------------------------ */ -export var throttle = _.throttle = (function (exports) { +export var throttle = _.throttle = (function (exports) { /* Return a new throttled version of the passed function. * * |Name |Type |Desc | @@ -8237,14 +8237,14 @@ export var throttle = _.throttle = (function (exports) { exports = function(fn, wait) { return debounce(fn, wait, true); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ tryIt ------------------------------ */ +/* ------------------------------ tryIt ------------------------------ */ -export var tryIt = _.tryIt = (function (exports) { +export var tryIt = _.tryIt = (function (exports) { /* Run function in a try catch. * * |Name|Type |Desc | @@ -8278,112 +8278,112 @@ export var tryIt = _.tryIt = (function (exports) { cb(e); return; } - }; - - return exports; -})({}); - -/* ------------------------------ uncaught ------------------------------ */ - -export var uncaught = _.uncaught = (function (exports) { - /* Handle global uncaught errors and promise rejections. - * - * ### start - * - * Start handling of errors. - * - * ### stop - * - * Stop handling. - * - * ### addListener - * - * Add listener for handling errors. - * - * |Name|Type |Desc | - * |----|--------|--------------| - * |fn |function|Error listener| - * - * ### rmListener - * - * Remove listener. - * - * ### rmAllListeners - * - * Remove all listeners. - */ - - /* example - * uncaught.start(); - * uncaught.addListener(err => { - * // Do something. - * }); - */ - - /* typescript - * export declare const uncaught: { - * start(): void; - * stop(): void; - * addListener(fn: (err: Error) => void): void; - * rmListener(fn: (err: Error) => void): void; - * rmAllListeners(): void; - * }; + }; + + return exports; +})({}); + +/* ------------------------------ uncaught ------------------------------ */ + +export var uncaught = _.uncaught = (function (exports) { + /* Handle global uncaught errors and promise rejections. + * + * ### start + * + * Start handling of errors. + * + * ### stop + * + * Stop handling. + * + * ### addListener + * + * Add listener for handling errors. + * + * |Name|Type |Desc | + * |----|--------|--------------| + * |fn |function|Error listener| + * + * ### rmListener + * + * Remove listener. + * + * ### rmAllListeners + * + * Remove all listeners. + */ + + /* example + * uncaught.start(); + * uncaught.addListener(err => { + * // Do something. + * }); + */ + + /* typescript + * export declare const uncaught: { + * start(): void; + * stop(): void; + * addListener(fn: (err: Error) => void): void; + * rmListener(fn: (err: Error) => void): void; + * rmAllListeners(): void; + * }; */ /* dependencies * isBrowser - */ - - var listeners = []; - var isOn = false; - exports = { - start: function() { - isOn = true; - }, - stop: function() { - isOn = false; - }, - addListener: function(fn) { - listeners.push(fn); - }, - rmListener: function(fn) { - var idx = listeners.indexOf(fn); - - if (idx > -1) { - listeners.splice(idx, 1); - } - }, - rmAllListeners: function() { - listeners = []; - } - }; - - if (isBrowser) { - window.addEventListener('error', function(event) { - callListeners(event.error); - }); - window.addEventListener('unhandledrejection', function(e) { - callListeners(e.reason); - }); - } else { - process.on('uncaughtException', callListeners); - process.on('unhandledRejection', callListeners); - } - - function callListeners(err) { - if (!isOn) return; - - for (var i = 0, len = listeners.length; i < len; i++) { - listeners[i](err); - } - } - - return exports; -})({}); - -/* ------------------------------ uniqId ------------------------------ */ - -export var uniqId = _.uniqId = (function (exports) { + */ + + var listeners = []; + var isOn = false; + exports = { + start: function() { + isOn = true; + }, + stop: function() { + isOn = false; + }, + addListener: function(fn) { + listeners.push(fn); + }, + rmListener: function(fn) { + var idx = listeners.indexOf(fn); + + if (idx > -1) { + listeners.splice(idx, 1); + } + }, + rmAllListeners: function() { + listeners = []; + } + }; + + if (isBrowser) { + window.addEventListener('error', function(event) { + callListeners(event.error); + }); + window.addEventListener('unhandledrejection', function(e) { + callListeners(e.reason); + }); + } else { + process.on('uncaughtException', callListeners); + process.on('unhandledRejection', callListeners); + } + + function callListeners(err) { + if (!isOn) return; + + for (var i = 0, len = listeners.length; i < len; i++) { + listeners[i](err); + } + } + + return exports; +})({}); + +/* ------------------------------ uniqId ------------------------------ */ + +export var uniqId = _.uniqId = (function (exports) { /* Generate a globally-unique id. * * |Name |Type |Desc | @@ -8404,14 +8404,14 @@ export var uniqId = _.uniqId = (function (exports) { exports = function(prefix) { var id = ++idCounter + ''; return prefix ? prefix + id : id; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ viewportScale ------------------------------ */ +/* ------------------------------ viewportScale ------------------------------ */ -export var viewportScale = _.viewportScale = (function (exports) { +export var viewportScale = _.viewportScale = (function (exports) { /* Get viewport scale. */ @@ -8448,14 +8448,14 @@ export var viewportScale = _.viewportScale = (function (exports) { if (isNaN(ret)) return 1; return ret; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ wrap ------------------------------ */ +/* ------------------------------ wrap ------------------------------ */ -export var wrap = _.wrap = (function (exports) { +export var wrap = _.wrap = (function (exports) { /* Wrap the function inside a wrapper function, passing it as the first argument. * * |Name |Type |Desc | @@ -8482,9 +8482,9 @@ export var wrap = _.wrap = (function (exports) { exports = function(fn, wrapper) { return partial(wrapper, fn); - }; + }; - return exports; -})({}); + return exports; +})({}); export default _; \ No newline at end of file diff --git a/test/util.js b/test/util.js index c7f9293b1..cb0e3fc5d 100644 --- a/test/util.js +++ b/test/util.js @@ -191,70 +191,70 @@ /* ------------------------------ ucs2 ------------------------------ */ var ucs2 = _.ucs2 = (function (exports) { - /* UCS-2 encoding and decoding. - * - * ### encode - * - * Create a string using an array of code point values. - * - * |Name |Type |Desc | - * |------|------|--------------------| - * |arr |array |Array of code points| - * |return|string|Encoded string | - * - * ### decode - * - * Create an array of code point values using a string. - * - * |Name |Type |Desc | - * |------|------|--------------------| - * |str |string|Input string | - * |return|array |Array of code points| - */ - - /* example - * ucs2.encode([0x61, 0x62, 0x63]); // -> 'abc' - * ucs2.decode('abc'); // -> [0x61, 0x62, 0x63] - * '𝌆'.length; // -> 2 - * ucs2.decode('𝌆').length; // -> 1 - */ - - /* typescript - * export declare const ucs2: { - * encode(arr: number[]): string; - * decode(str: string): number[]; - * }; - */ - // https://mathiasbynens.be/notes/javascript-encoding - exports = { - encode: function(arr) { - return String.fromCodePoint.apply(String, arr); - }, - decode: function(str) { - var ret = []; - var i = 0; - var len = str.length; - - while (i < len) { - var c = str.charCodeAt(i++); // A high surrogate - - if (c >= 0xd800 && c <= 0xdbff && i < len) { - var tail = str.charCodeAt(i++); // nextC >= 0xDC00 && nextC <= 0xDFFF - - if ((tail & 0xfc00) === 0xdc00) { - // C = (H - 0xD800) * 0x400 + L - 0xDC00 + 0x10000 - ret.push(((c & 0x3ff) << 10) + (tail & 0x3ff) + 0x10000); - } else { - ret.push(c); - i--; - } - } else { - ret.push(c); - } - } - - return ret; - } + /* UCS-2 encoding and decoding. + * + * ### encode + * + * Create a string using an array of code point values. + * + * |Name |Type |Desc | + * |------|------|--------------------| + * |arr |array |Array of code points| + * |return|string|Encoded string | + * + * ### decode + * + * Create an array of code point values using a string. + * + * |Name |Type |Desc | + * |------|------|--------------------| + * |str |string|Input string | + * |return|array |Array of code points| + */ + + /* example + * ucs2.encode([0x61, 0x62, 0x63]); // -> 'abc' + * ucs2.decode('abc'); // -> [0x61, 0x62, 0x63] + * '𝌆'.length; // -> 2 + * ucs2.decode('𝌆').length; // -> 1 + */ + + /* typescript + * export declare const ucs2: { + * encode(arr: number[]): string; + * decode(str: string): number[]; + * }; + */ + // https://mathiasbynens.be/notes/javascript-encoding + exports = { + encode: function(arr) { + return String.fromCodePoint.apply(String, arr); + }, + decode: function(str) { + var ret = []; + var i = 0; + var len = str.length; + + while (i < len) { + var c = str.charCodeAt(i++); // A high surrogate + + if (c >= 0xd800 && c <= 0xdbff && i < len) { + var tail = str.charCodeAt(i++); // nextC >= 0xDC00 && nextC <= 0xDFFF + + if ((tail & 0xfc00) === 0xdc00) { + // C = (H - 0xD800) * 0x400 + L - 0xDC00 + 0x10000 + ret.push(((c & 0x3ff) << 10) + (tail & 0x3ff) + 0x10000); + } else { + ret.push(c); + i--; + } + } else { + ret.push(c); + } + } + + return ret; + } }; return exports; @@ -263,191 +263,191 @@ /* ------------------------------ utf8 ------------------------------ */ var utf8 = _.utf8 = (function (exports) { - /* UTF-8 encoding and decoding. - * - * ### encode - * - * Turn any UTF-8 decoded string into UTF-8 encoded string. - * - * |Name |Type |Desc | - * |------|------|----------------| - * |str |string|String to encode| - * |return|string|Encoded string | - * - * ### decode - * - * Turn any UTF-8 encoded string into UTF-8 decoded string. - * - * |Name |Type |Desc | - * |----------|-------|----------------------| - * |str |string |String to decode | - * |safe=false|boolean|Suppress error if true| - * |return |string |Decoded string | - */ - - /* example - * utf8.encode('\uD800\uDC00'); // -> '\xF0\x90\x80\x80' - * utf8.decode('\xF0\x90\x80\x80'); // -> '\uD800\uDC00' - */ - - /* typescript - * export declare const utf8: { - * encode(str: string): string; - * decode(str: string, safe?: boolean): string; - * }; + /* UTF-8 encoding and decoding. + * + * ### encode + * + * Turn any UTF-8 decoded string into UTF-8 encoded string. + * + * |Name |Type |Desc | + * |------|------|----------------| + * |str |string|String to encode| + * |return|string|Encoded string | + * + * ### decode + * + * Turn any UTF-8 encoded string into UTF-8 decoded string. + * + * |Name |Type |Desc | + * |----------|-------|----------------------| + * |str |string |String to decode | + * |safe=false|boolean|Suppress error if true| + * |return |string |Decoded string | + */ + + /* example + * utf8.encode('\uD800\uDC00'); // -> '\xF0\x90\x80\x80' + * utf8.decode('\xF0\x90\x80\x80'); // -> '\uD800\uDC00' + */ + + /* typescript + * export declare const utf8: { + * encode(str: string): string; + * decode(str: string, safe?: boolean): string; + * }; */ /* dependencies * ucs2 - */ // https://encoding.spec.whatwg.org/#utf-8 - - exports = { - encode: function(str) { - var codePoints = ucs2.decode(str); - var byteArr = ''; - - for (var i = 0, len = codePoints.length; i < len; i++) { - byteArr += encodeCodePoint(codePoints[i]); - } - - return byteArr; - }, - decode: function decode(str, safe) { - byteArr = ucs2.decode(str); - byteIdx = 0; - byteCount = byteArr.length; - codePoint = 0; - bytesSeen = 0; - bytesNeeded = 0; - lowerBoundary = 0x80; - upperBoundary = 0xbf; - var codePoints = []; - var tmp; - - while ((tmp = decodeCodePoint(safe)) !== false) { - codePoints.push(tmp); - } - - return ucs2.encode(codePoints); - } - }; - var fromCharCode = String.fromCharCode; - - function encodeCodePoint(codePoint) { - // U+0000 to U+0080, ASCII code point - if ((codePoint & 0xffffff80) === 0) { - return fromCharCode(codePoint); - } - - var ret = '', - count, - offset; // U+0080 to U+07FF, inclusive - - if ((codePoint & 0xfffff800) === 0) { - count = 1; - offset = 0xc0; - } else if ((codePoint & 0xffff0000) === 0) { - // U+0800 to U+FFFF, inclusive - count = 2; - offset = 0xe0; - } else if ((codePoint & 0xffe00000) == 0) { - // U+10000 to U+10FFFF, inclusive - count = 3; - offset = 0xf0; - } - - ret += fromCharCode((codePoint >> (6 * count)) + offset); - - while (count > 0) { - var tmp = codePoint >> (6 * (count - 1)); - ret += fromCharCode(0x80 | (tmp & 0x3f)); - count--; - } - - return ret; - } - - var byteArr, - byteIdx, - byteCount, - codePoint, - bytesSeen, - bytesNeeded, - lowerBoundary, - upperBoundary; - - function decodeCodePoint(safe) { - /* eslint-disable no-constant-condition */ - while (true) { - if (byteIdx >= byteCount && bytesNeeded) { - if (safe) return goBack(); - throw new Error('Invalid byte index'); - } - - if (byteIdx === byteCount) return false; - var byte = byteArr[byteIdx]; - byteIdx++; - - if (!bytesNeeded) { - // 0x00 to 0x7F - if ((byte & 0x80) === 0) { - return byte; - } // 0xC2 to 0xDF - - if ((byte & 0xe0) === 0xc0) { - bytesNeeded = 1; - codePoint = byte & 0x1f; - } else if ((byte & 0xf0) === 0xe0) { - // 0xE0 to 0xEF - if (byte === 0xe0) lowerBoundary = 0xa0; - if (byte === 0xed) upperBoundary = 0x9f; - bytesNeeded = 2; - codePoint = byte & 0xf; - } else if ((byte & 0xf8) === 0xf0) { - // 0xF0 to 0xF4 - if (byte === 0xf0) lowerBoundary = 0x90; - if (byte === 0xf4) upperBoundary = 0x8f; - bytesNeeded = 3; - codePoint = byte & 0x7; - } else { - if (safe) return goBack(); - throw new Error('Invalid UTF-8 detected'); - } - - continue; - } - - if (byte < lowerBoundary || byte > upperBoundary) { - if (safe) { - byteIdx--; - return goBack(); - } - - throw new Error('Invalid continuation byte'); - } - - lowerBoundary = 0x80; - upperBoundary = 0xbf; - codePoint = (codePoint << 6) | (byte & 0x3f); - bytesSeen++; - if (bytesSeen !== bytesNeeded) continue; - var tmp = codePoint; - codePoint = 0; - bytesNeeded = 0; - bytesSeen = 0; - return tmp; - } - } - - function goBack() { - var start = byteIdx - bytesSeen - 1; - byteIdx = start + 1; - codePoint = 0; - bytesNeeded = 0; - bytesSeen = 0; - lowerBoundary = 0x80; - upperBoundary = 0xbf; - return byteArr[start]; + */ // https://encoding.spec.whatwg.org/#utf-8 + + exports = { + encode: function(str) { + var codePoints = ucs2.decode(str); + var byteArr = ''; + + for (var i = 0, len = codePoints.length; i < len; i++) { + byteArr += encodeCodePoint(codePoints[i]); + } + + return byteArr; + }, + decode: function decode(str, safe) { + byteArr = ucs2.decode(str); + byteIdx = 0; + byteCount = byteArr.length; + codePoint = 0; + bytesSeen = 0; + bytesNeeded = 0; + lowerBoundary = 0x80; + upperBoundary = 0xbf; + var codePoints = []; + var tmp; + + while ((tmp = decodeCodePoint(safe)) !== false) { + codePoints.push(tmp); + } + + return ucs2.encode(codePoints); + } + }; + var fromCharCode = String.fromCharCode; + + function encodeCodePoint(codePoint) { + // U+0000 to U+0080, ASCII code point + if ((codePoint & 0xffffff80) === 0) { + return fromCharCode(codePoint); + } + + var ret = '', + count, + offset; // U+0080 to U+07FF, inclusive + + if ((codePoint & 0xfffff800) === 0) { + count = 1; + offset = 0xc0; + } else if ((codePoint & 0xffff0000) === 0) { + // U+0800 to U+FFFF, inclusive + count = 2; + offset = 0xe0; + } else if ((codePoint & 0xffe00000) == 0) { + // U+10000 to U+10FFFF, inclusive + count = 3; + offset = 0xf0; + } + + ret += fromCharCode((codePoint >> (6 * count)) + offset); + + while (count > 0) { + var tmp = codePoint >> (6 * (count - 1)); + ret += fromCharCode(0x80 | (tmp & 0x3f)); + count--; + } + + return ret; + } + + var byteArr, + byteIdx, + byteCount, + codePoint, + bytesSeen, + bytesNeeded, + lowerBoundary, + upperBoundary; + + function decodeCodePoint(safe) { + /* eslint-disable no-constant-condition */ + while (true) { + if (byteIdx >= byteCount && bytesNeeded) { + if (safe) return goBack(); + throw new Error('Invalid byte index'); + } + + if (byteIdx === byteCount) return false; + var byte = byteArr[byteIdx]; + byteIdx++; + + if (!bytesNeeded) { + // 0x00 to 0x7F + if ((byte & 0x80) === 0) { + return byte; + } // 0xC2 to 0xDF + + if ((byte & 0xe0) === 0xc0) { + bytesNeeded = 1; + codePoint = byte & 0x1f; + } else if ((byte & 0xf0) === 0xe0) { + // 0xE0 to 0xEF + if (byte === 0xe0) lowerBoundary = 0xa0; + if (byte === 0xed) upperBoundary = 0x9f; + bytesNeeded = 2; + codePoint = byte & 0xf; + } else if ((byte & 0xf8) === 0xf0) { + // 0xF0 to 0xF4 + if (byte === 0xf0) lowerBoundary = 0x90; + if (byte === 0xf4) upperBoundary = 0x8f; + bytesNeeded = 3; + codePoint = byte & 0x7; + } else { + if (safe) return goBack(); + throw new Error('Invalid UTF-8 detected'); + } + + continue; + } + + if (byte < lowerBoundary || byte > upperBoundary) { + if (safe) { + byteIdx--; + return goBack(); + } + + throw new Error('Invalid continuation byte'); + } + + lowerBoundary = 0x80; + upperBoundary = 0xbf; + codePoint = (codePoint << 6) | (byte & 0x3f); + bytesSeen++; + if (bytesSeen !== bytesNeeded) continue; + var tmp = codePoint; + codePoint = 0; + bytesNeeded = 0; + bytesSeen = 0; + return tmp; + } + } + + function goBack() { + var start = byteIdx - bytesSeen - 1; + byteIdx = start + 1; + codePoint = 0; + bytesNeeded = 0; + bytesSeen = 0; + lowerBoundary = 0x80; + upperBoundary = 0xbf; + return byteArr[start]; } return exports; @@ -554,34 +554,34 @@ /* ------------------------------ types ------------------------------ */ var types = _.types = (function (exports) { - /* Used for typescript definitions only. - */ - - /* typescript - * export declare namespace types { - * interface Collection {} - * interface List extends Collection { - * [index: number]: T; - * length: number; - * } - * interface ListIterator { - * (value: T, index: number, list: List): TResult; - * } - * interface Dictionary extends Collection { - * [index: string]: T; - * } - * interface ObjectIterator { - * (element: T, key: string, list: Dictionary): TResult; - * } - * interface MemoIterator { - * (prev: TResult, curr: T, index: number, list: List): TResult; - * } - * interface MemoObjectIterator { - * (prev: TResult, curr: T, key: string, list: Dictionary): TResult; - * } - * } - * export declare const types: {} - */ + /* Used for typescript definitions only. + */ + + /* typescript + * export declare namespace types { + * interface Collection {} + * interface List extends Collection { + * [index: number]: T; + * length: number; + * } + * interface ListIterator { + * (value: T, index: number, list: List): TResult; + * } + * interface Dictionary extends Collection { + * [index: string]: T; + * } + * interface ObjectIterator { + * (element: T, key: string, list: Dictionary): TResult; + * } + * interface MemoIterator { + * (prev: TResult, curr: T, index: number, list: List): TResult; + * } + * interface MemoObjectIterator { + * (prev: TResult, curr: T, key: string, list: Dictionary): TResult; + * } + * } + * export declare const types: {} + */ exports = {}; return exports; @@ -986,38 +986,38 @@ /* ------------------------------ getProto ------------------------------ */ var getProto = _.getProto = (function (exports) { - /* Get prototype of an object. - * - * |Name |Type|Desc | - * |------|----|---------------------------------------------| - * |obj |* |Target object | - * |return|* |Prototype of given object, null if not exists| - */ + /* Get prototype of an object. + * + * |Name |Type|Desc | + * |------|----|---------------------------------------------| + * |obj |* |Target object | + * |return|* |Prototype of given object, null if not exists| + */ - /* example - * const a = {}; - * getProto(Object.create(a)); // -> a - */ + /* example + * const a = {}; + * getProto(Object.create(a)); // -> a + */ - /* typescript - * export declare function getProto(obj: any): any; + /* typescript + * export declare function getProto(obj: any): any; */ /* dependencies * isObj isFn - */ - - var getPrototypeOf = Object.getPrototypeOf; - var ObjectCtr = {}.constructor; - - exports = function(obj) { - if (!isObj(obj)) return null; - if (getPrototypeOf) return getPrototypeOf(obj); - var proto = obj.__proto__; - if (proto || proto === null) return proto; - if (isFn(obj.constructor)) return obj.constructor.prototype; - if (obj instanceof ObjectCtr) return ObjectCtr.prototype; - return null; + */ + + var getPrototypeOf = Object.getPrototypeOf; + var ObjectCtr = {}.constructor; + + exports = function(obj) { + if (!isObj(obj)) return null; + if (getPrototypeOf) return getPrototypeOf(obj); + var proto = obj.__proto__; + if (proto || proto === null) return proto; + if (isFn(obj.constructor)) return obj.constructor.prototype; + if (obj instanceof ObjectCtr) return ObjectCtr.prototype; + return null; }; return exports; @@ -1189,29 +1189,29 @@ /* ------------------------------ detectMocha ------------------------------ */ var detectMocha = _.detectMocha = (function (exports) { - /* Detect if mocha is running. - */ + /* Detect if mocha is running. + */ - /* example - * detectMocha(); // -> True if mocha is running. - */ + /* example + * detectMocha(); // -> True if mocha is running. + */ - /* typescript - * export declare function detectMocha(): boolean; + /* typescript + * export declare function detectMocha(): boolean; */ /* dependencies * root - */ + */ - exports = function() { - for (var i = 0, len = methods.length; i < len; i++) { - var method = methods[i]; - if (typeof root[method] !== 'function') return false; - } + exports = function() { + for (var i = 0, len = methods.length; i < len; i++) { + var method = methods[i]; + if (typeof root[method] !== 'function') return false; + } - return true; - }; + return true; + }; var methods = ['afterEach', 'after', 'beforeEach', 'before', 'describe', 'it']; @@ -1598,29 +1598,29 @@ /* ------------------------------ isPromise ------------------------------ */ var isPromise = _.isPromise = (function (exports) { - /* Check if value looks like a promise. - * - * |Name |Type |Desc | - * |------|-------|----------------------------------| - * |val |* |Value to check | - * |return|boolean|True if value looks like a promise| - */ + /* Check if value looks like a promise. + * + * |Name |Type |Desc | + * |------|-------|----------------------------------| + * |val |* |Value to check | + * |return|boolean|True if value looks like a promise| + */ - /* example - * isPromise(new Promise(function () {})); // -> true - * isPromise({}); // -> false - */ + /* example + * isPromise(new Promise(function () {})); // -> true + * isPromise({}); // -> false + */ - /* typescript - * export declare function isPromise(val: any): boolean; + /* typescript + * export declare function isPromise(val: any): boolean; */ /* dependencies * isObj isFn - */ + */ - exports = function(val) { - return isObj(val) && isFn(val.then); + exports = function(val) { + return isObj(val) && isFn(val.then); }; return exports; @@ -2966,308 +2966,308 @@ /* ------------------------------ stringifyAll ------------------------------ */ _.stringifyAll = (function (exports) { - /* Stringify object into json with types. - * - * |Name |Type |Desc | - * |---------|------|-------------------| - * |obj |* |Object to stringify| - * |[options]|object|Stringify options | - * |return |string|Stringified object | - * - * Available options: - * - * |Name |Type |Desc | - * |------------------|-------|-------------------------| - * |unenumerable=false|boolean|Include unenumerable keys| - * |symbol=false |boolean|Include symbol keys | - * |accessGetter=false|boolean|Access getter value | - * |timeout=0 |number |Timeout of stringify | - * |depth=0 |number |Max depth of recursion | - * |[ignore] |array |Values to ignore | - * - * When time is out, all remaining values will all be "Timeout". - */ - - /* example - * stringifyAll(function test() {}); // -> '{"value":"function test() {}","type":"Function",...}' - */ - - /* typescript - * export declare namespace stringifyAll { - * interface IOptions { - * unenumerable?: boolean; - * symbol?: boolean; - * accessGetter?: boolean; - * timeout?: number; - * depth?: number; - * ignore?: any[]; - * } - * } - * export declare function stringifyAll( - * obj: any, - * options?: stringifyAll.IOptions - * ): string; + /* Stringify object into json with types. + * + * |Name |Type |Desc | + * |---------|------|-------------------| + * |obj |* |Object to stringify| + * |[options]|object|Stringify options | + * |return |string|Stringified object | + * + * Available options: + * + * |Name |Type |Desc | + * |------------------|-------|-------------------------| + * |unenumerable=false|boolean|Include unenumerable keys| + * |symbol=false |boolean|Include symbol keys | + * |accessGetter=false|boolean|Access getter value | + * |timeout=0 |number |Timeout of stringify | + * |depth=0 |number |Max depth of recursion | + * |[ignore] |array |Values to ignore | + * + * When time is out, all remaining values will all be "Timeout". + */ + + /* example + * stringifyAll(function test() {}); // -> '{"value":"function test() {}","type":"Function",...}' + */ + + /* typescript + * export declare namespace stringifyAll { + * interface IOptions { + * unenumerable?: boolean; + * symbol?: boolean; + * accessGetter?: boolean; + * timeout?: number; + * depth?: number; + * ignore?: any[]; + * } + * } + * export declare function stringifyAll( + * obj: any, + * options?: stringifyAll.IOptions + * ): string; */ /* dependencies * escapeJsStr type toStr endWith toSrc keys each Class getProto difference extend isPromise filter now allKeys contain - */ - - exports = function(obj) { - var _ref = - arguments.length > 1 && arguments[1] !== undefined - ? arguments[1] - : {}, - self = _ref.self, - _ref$startTime = _ref.startTime, - startTime = _ref$startTime === void 0 ? now() : _ref$startTime, - _ref$timeout = _ref.timeout, - timeout = _ref$timeout === void 0 ? 0 : _ref$timeout, - _ref$depth = _ref.depth, - depth = _ref$depth === void 0 ? 0 : _ref$depth, - _ref$curDepth = _ref.curDepth, - curDepth = _ref$curDepth === void 0 ? 1 : _ref$curDepth, - _ref$visitor = _ref.visitor, - visitor = _ref$visitor === void 0 ? new Visitor() : _ref$visitor, - _ref$unenumerable = _ref.unenumerable, - unenumerable = _ref$unenumerable === void 0 ? false : _ref$unenumerable, - _ref$symbol = _ref.symbol, - symbol = _ref$symbol === void 0 ? false : _ref$symbol, - _ref$accessGetter = _ref.accessGetter, - accessGetter = _ref$accessGetter === void 0 ? false : _ref$accessGetter, - _ref$ignore = _ref.ignore, - ignore = _ref$ignore === void 0 ? [] : _ref$ignore; - - var json = ''; - var options = { - visitor: visitor, - unenumerable: unenumerable, - symbol: symbol, - accessGetter: accessGetter, - depth: depth, - curDepth: curDepth + 1, - timeout: timeout, - startTime: startTime, - ignore: ignore - }; - var t = type(obj, false); - - if (t === 'String') { - json = wrapStr(obj); - } else if (t === 'Number') { - json = toStr(obj); - - if (endWith(json, 'Infinity')) { - json = '{"value":"'.concat(json, '","type":"Number"}'); - } - } else if (t === 'NaN') { - json = '{"value":"NaN","type":"Number"}'; - } else if (t === 'Boolean') { - json = obj ? 'true' : 'false'; - } else if (t === 'Null') { - json = 'null'; - } else if (t === 'Undefined') { - json = '{"type":"Undefined"}'; - } else if (t === 'Symbol') { - var val = 'Symbol'; - - try { - val = toStr(obj); - /* eslint-disable no-empty */ - } catch (e) {} - - json = '{"value":'.concat(wrapStr(val), ',"type":"Symbol"}'); - } else { - if (timeout && now() - startTime > timeout) { - return wrapStr('Timeout'); - } - - if (depth && curDepth > depth) { - return wrapStr('{...}'); - } - - json = '{'; - var parts = []; - var visitedObj = visitor.get(obj); - var id; - - if (visitedObj) { - id = visitedObj.id; - parts.push('"reference":'.concat(id)); - } else { - id = visitor.set(obj); - parts.push('"id":'.concat(id)); - } - - parts.push('"type":"'.concat(t, '"')); - - if (endWith(t, 'Function')) { - parts.push('"value":'.concat(wrapStr(toSrc(obj)))); - } else if (t === 'RegExp') { - parts.push('"value":'.concat(wrapStr(obj))); - } - - if (!visitedObj) { - var enumerableKeys = keys(obj); - - if (enumerableKeys.length) { - parts.push( - iterateObj( - 'enumerable', - enumerableKeys, - self || obj, - options - ) - ); - } - - if (unenumerable) { - var unenumerableKeys = difference( - allKeys(obj, { - prototype: false, - unenumerable: true - }), - enumerableKeys - ); - - if (unenumerableKeys.length) { - parts.push( - iterateObj( - 'unenumerable', - unenumerableKeys, - self || obj, - options - ) - ); - } - } - - if (symbol) { - var symbolKeys = filter( - allKeys(obj, { - prototype: false, - symbol: true - }), - function(key) { - return typeof key === 'symbol'; - } - ); - - if (symbolKeys.length) { - parts.push( - iterateObj('symbol', symbolKeys, self || obj, options) - ); - } - } - - var prototype = getProto(obj); - - if (prototype && !contain(ignore, prototype)) { - var proto = '"proto":'.concat( - exports( - prototype, - extend(options, { - self: self || obj - }) - ) - ); - parts.push(proto); - } - } - - json += parts.join(',') + '}'; - } - - return json; - }; - - function iterateObj(name, keys, obj, options) { - var parts = []; - each(keys, function(key) { - var val; - var descriptor = Object.getOwnPropertyDescriptor(obj, key); - var hasGetter = descriptor && descriptor.get; - var hasSetter = descriptor && descriptor.set; - - if (!options.accessGetter && hasGetter) { - val = '(...)'; - } else { - try { - val = obj[key]; - - if (contain(options.ignore, val)) { - return; - } - - if (isPromise(val)) { - val.catch(function() {}); - } - } catch (e) { - val = e.message; - } - } - - parts.push(''.concat(wrapKey(key), ':').concat(exports(val, options))); - - if (hasGetter) { - parts.push( - '' - .concat(wrapKey('get ' + toStr(key)), ':') - .concat(exports(descriptor.get, options)) - ); - } - - if (hasSetter) { - parts.push( - '' - .concat(wrapKey('set ' + toStr(key)), ':') - .concat(exports(descriptor.set, options)) - ); - } - }); - return '"'.concat(name, '":{') + parts.join(',') + '}'; - } - - function wrapKey(key) { - return '"'.concat(escapeJsonStr(key), '"'); - } - - function wrapStr(str) { - return '"'.concat(escapeJsonStr(toStr(str)), '"'); - } - - function escapeJsonStr(str) { - return escapeJsStr(str) - .replace(/\\'/g, "'") - .replace(/\t/g, '\\t'); - } - - var Visitor = Class({ - initialize: function() { - this.id = 0; - this.visited = []; - }, - set: function(val) { - var visited = this.visited, - id = this.id; - var obj = { - id: id, - val: val - }; - visited.push(obj); - this.id++; - return id; - }, - get: function(val) { - var visited = this.visited; - - for (var i = 0, len = visited.length; i < len; i++) { - var obj = visited[i]; - if (val === obj.val) return obj; - } - - return false; - } + */ + + exports = function(obj) { + var _ref = + arguments.length > 1 && arguments[1] !== undefined + ? arguments[1] + : {}, + self = _ref.self, + _ref$startTime = _ref.startTime, + startTime = _ref$startTime === void 0 ? now() : _ref$startTime, + _ref$timeout = _ref.timeout, + timeout = _ref$timeout === void 0 ? 0 : _ref$timeout, + _ref$depth = _ref.depth, + depth = _ref$depth === void 0 ? 0 : _ref$depth, + _ref$curDepth = _ref.curDepth, + curDepth = _ref$curDepth === void 0 ? 1 : _ref$curDepth, + _ref$visitor = _ref.visitor, + visitor = _ref$visitor === void 0 ? new Visitor() : _ref$visitor, + _ref$unenumerable = _ref.unenumerable, + unenumerable = _ref$unenumerable === void 0 ? false : _ref$unenumerable, + _ref$symbol = _ref.symbol, + symbol = _ref$symbol === void 0 ? false : _ref$symbol, + _ref$accessGetter = _ref.accessGetter, + accessGetter = _ref$accessGetter === void 0 ? false : _ref$accessGetter, + _ref$ignore = _ref.ignore, + ignore = _ref$ignore === void 0 ? [] : _ref$ignore; + + var json = ''; + var options = { + visitor: visitor, + unenumerable: unenumerable, + symbol: symbol, + accessGetter: accessGetter, + depth: depth, + curDepth: curDepth + 1, + timeout: timeout, + startTime: startTime, + ignore: ignore + }; + var t = type(obj, false); + + if (t === 'String') { + json = wrapStr(obj); + } else if (t === 'Number') { + json = toStr(obj); + + if (endWith(json, 'Infinity')) { + json = '{"value":"'.concat(json, '","type":"Number"}'); + } + } else if (t === 'NaN') { + json = '{"value":"NaN","type":"Number"}'; + } else if (t === 'Boolean') { + json = obj ? 'true' : 'false'; + } else if (t === 'Null') { + json = 'null'; + } else if (t === 'Undefined') { + json = '{"type":"Undefined"}'; + } else if (t === 'Symbol') { + var val = 'Symbol'; + + try { + val = toStr(obj); + /* eslint-disable no-empty */ + } catch (e) {} + + json = '{"value":'.concat(wrapStr(val), ',"type":"Symbol"}'); + } else { + if (timeout && now() - startTime > timeout) { + return wrapStr('Timeout'); + } + + if (depth && curDepth > depth) { + return wrapStr('{...}'); + } + + json = '{'; + var parts = []; + var visitedObj = visitor.get(obj); + var id; + + if (visitedObj) { + id = visitedObj.id; + parts.push('"reference":'.concat(id)); + } else { + id = visitor.set(obj); + parts.push('"id":'.concat(id)); + } + + parts.push('"type":"'.concat(t, '"')); + + if (endWith(t, 'Function')) { + parts.push('"value":'.concat(wrapStr(toSrc(obj)))); + } else if (t === 'RegExp') { + parts.push('"value":'.concat(wrapStr(obj))); + } + + if (!visitedObj) { + var enumerableKeys = keys(obj); + + if (enumerableKeys.length) { + parts.push( + iterateObj( + 'enumerable', + enumerableKeys, + self || obj, + options + ) + ); + } + + if (unenumerable) { + var unenumerableKeys = difference( + allKeys(obj, { + prototype: false, + unenumerable: true + }), + enumerableKeys + ); + + if (unenumerableKeys.length) { + parts.push( + iterateObj( + 'unenumerable', + unenumerableKeys, + self || obj, + options + ) + ); + } + } + + if (symbol) { + var symbolKeys = filter( + allKeys(obj, { + prototype: false, + symbol: true + }), + function(key) { + return typeof key === 'symbol'; + } + ); + + if (symbolKeys.length) { + parts.push( + iterateObj('symbol', symbolKeys, self || obj, options) + ); + } + } + + var prototype = getProto(obj); + + if (prototype && !contain(ignore, prototype)) { + var proto = '"proto":'.concat( + exports( + prototype, + extend(options, { + self: self || obj + }) + ) + ); + parts.push(proto); + } + } + + json += parts.join(',') + '}'; + } + + return json; + }; + + function iterateObj(name, keys, obj, options) { + var parts = []; + each(keys, function(key) { + var val; + var descriptor = Object.getOwnPropertyDescriptor(obj, key); + var hasGetter = descriptor && descriptor.get; + var hasSetter = descriptor && descriptor.set; + + if (!options.accessGetter && hasGetter) { + val = '(...)'; + } else { + try { + val = obj[key]; + + if (contain(options.ignore, val)) { + return; + } + + if (isPromise(val)) { + val.catch(function() {}); + } + } catch (e) { + val = e.message; + } + } + + parts.push(''.concat(wrapKey(key), ':').concat(exports(val, options))); + + if (hasGetter) { + parts.push( + '' + .concat(wrapKey('get ' + toStr(key)), ':') + .concat(exports(descriptor.get, options)) + ); + } + + if (hasSetter) { + parts.push( + '' + .concat(wrapKey('set ' + toStr(key)), ':') + .concat(exports(descriptor.set, options)) + ); + } + }); + return '"'.concat(name, '":{') + parts.join(',') + '}'; + } + + function wrapKey(key) { + return '"'.concat(escapeJsonStr(key), '"'); + } + + function wrapStr(str) { + return '"'.concat(escapeJsonStr(toStr(str)), '"'); + } + + function escapeJsonStr(str) { + return escapeJsStr(str) + .replace(/\\'/g, "'") + .replace(/\t/g, '\\t'); + } + + var Visitor = Class({ + initialize: function() { + this.id = 0; + this.visited = []; + }, + set: function(val) { + var visited = this.visited, + id = this.id; + var obj = { + id: id, + val: val + }; + visited.push(obj); + this.id++; + return id; + }, + get: function(val) { + var visited = this.visited; + + for (var i = 0, len = visited.length; i < len; i++) { + var obj = visited[i]; + if (val === obj.val) return obj; + } + + return false; + } }); return exports;