diff --git a/doc/TOOL_API.md b/doc/TOOL_API.md index 4d282f9..447c5e1 100644 --- a/doc/TOOL_API.md +++ b/doc/TOOL_API.md @@ -159,6 +159,21 @@ info.add('title', 'content'); info.add('location', () => location.href); ``` +### get + +Get info or infos. + +|Name |Type |Desc | +|------|---------------|------------| +|name |string |Info name | +|return|string function|Info content| + +```javascript +info.add('title', 'content') +info.get(); // -> [{name: 'title', val: 'content'}] +info.get('title') // -> 'content' +``` + ### remove Remove specified info. diff --git a/doc/UTIL_API.md b/doc/UTIL_API.md index 88368d9..4bf4a90 100644 --- a/doc/UTIL_API.md +++ b/doc/UTIL_API.md @@ -1,7 +1,7 @@ -# Eruda Util Documentation - -## $ - +# Eruda Util Documentation + +## $ + jQuery like style dom manipulator. ### Available methods @@ -19,10 +19,10 @@ $btn.on('click', function () { // Do something... }); -``` - -## $attr - +``` + +## $attr + Element attribute manipulation. Get the value of an attribute for the first element in the set of matched elements. @@ -63,10 +63,10 @@ $attr('#test', { 'attr1': 'test', 'attr2': 'test' }); -``` - -## $class - +``` + +## $class + Element class manipulations. ### add @@ -114,10 +114,10 @@ $class.remove('#test', 'class1'); $class.has('#test', 'class1'); // -> false $class.toggle('#test', 'class1'); $class.has('#test', 'class1'); // -> true -``` - -## $css - +``` + +## $css + Element css manipulation. Get the computed style properties for the first element in the set of matched elements. @@ -148,18 +148,18 @@ $css('#test', { }); $css('#test', 'display', 'block'); $css('#test', 'color'); // -> #fff -``` - -## $data - +``` + +## $data + Wrapper of $attr, adds data- prefix to keys. ```javascript $data('#test', 'attr1', 'eustia'); -``` - -## $event - +``` + +## $event + bind events to certain dom elements. ```javascript @@ -169,10 +169,10 @@ function clickHandler() } $event.on('#test', 'click', clickHandler); $event.off('#test', 'click', clickHandler); -``` - -## $insert - +``` + +## $insert + Insert html on different position. ### before @@ -206,10 +206,10 @@ $insert.prepend('#test', '
Hello
'); // -> 'Hello' -``` - -## toArr - +``` + +## toArr + Convert value to an array. |Name |Type |Desc | @@ -2213,10 +2243,10 @@ toArr({a: 1, b: 2}); // -> [{a: 1, b: 2}] toArr('abc'); // -> ['abc'] toArr(1); // -> [1] toArr(null); // -> [] -``` - -## toInt - +``` + +## toInt + Convert value to an integer. |Name |Type |Desc | @@ -2227,10 +2257,10 @@ Convert value to an integer. ```javascript toInt(1.1); // -> 1 toInt(undefined); // -> 0 -``` - -## toNum - +``` + +## toNum + Convert value to a number. |Name |Type |Desc | @@ -2240,10 +2270,10 @@ Convert value to a number. ```javascript toNum('5'); // -> 5 -``` - -## toSrc - +``` + +## toSrc + Convert function to its source code. |Name |Type |Desc | @@ -2254,10 +2284,10 @@ Convert function to its source code. ```javascript toSrc(Math.min); // -> 'function min() { [native code] }' toSrc(function () {}) // -> 'function () { }' -``` - -## toStr - +``` + +## toStr + Convert value to a string. |Name |Type |Desc | @@ -2270,10 +2300,10 @@ toStr(null); // -> '' toStr(1); // -> '1' toStr(false); // -> 'false' toStr([1, 2, 3]); // -> '1,2,3' -``` - -## trim - +``` + +## trim + Remove chars or white-spaces from beginning end of string. |Name |Type |Desc | @@ -2286,10 +2316,10 @@ Remove chars or white-spaces from beginning end of string. trim(' abc '); // -> 'abc' trim('_abc_', '_'); // -> 'abc' trim('_abc_', ['a', 'c', '_']); // -> 'b' -``` - -## tryIt - +``` + +## tryIt + Run function in a try catch. |Name|Type |Desc | @@ -2305,10 +2335,10 @@ tryIt(function () { if (err) console.log(err); }); -``` - -## type - +``` + +## type + Determine the internal JavaScript [[Class]] of an object. |Name |Type |Desc | @@ -2321,10 +2351,10 @@ type(5); // -> 'number' type({}); // -> 'object' type(function () {}); // -> 'function' type([]); // -> 'array' -``` - -## ucs2 - +``` + +## ucs2 + UCS-2 encoding and decoding. ### encode @@ -2350,10 +2380,10 @@ ucs2.encode([0x61, 0x62, 0x63]); // -> 'abc' ucs2.decode('abc'); // -> [0x61, 0x62, 0x63] '𝌆'.length; // -> 2 ucs2.decode('𝌆').length; // -> 1 -``` - -## uniqId - +``` + +## uniqId + Generate a globally-unique id. |Name |Type |Desc | @@ -2363,10 +2393,10 @@ Generate a globally-unique id. ```javascript uniqId('eusita_'); // -> 'eustia_xxx' -``` - -## unique - +``` + +## unique + Create duplicate-free version of an array. |Name |Type |Desc | @@ -2377,10 +2407,10 @@ Create duplicate-free version of an array. ```javascript unique([1, 2, 3, 1]); // -> [1, 2, 3] -``` - -## upperFirst - +``` + +## upperFirst + Convert the first character of string to upper case. |Name |Type |Desc | @@ -2390,10 +2420,10 @@ Convert the first character of string to upper case. ```javascript upperFirst('red'); // -> Red -``` - -## utf8 - +``` + +## utf8 + UTF-8 encoding and decoding. ### encode @@ -2418,10 +2448,10 @@ Turn any UTF-8 encoded string into UTF-8 decoded string. ```javascript utf8.encode('\uD800\uDC00'); // -> '\xF0\x90\x80\x80' utf8.decode('\xF0\x90\x80\x80'); // -> '\uD800\uDC00' -``` - -## values - +``` + +## values + Create an array of the own enumerable property values of object. |Name |Type |Desc | @@ -2431,18 +2461,18 @@ Create an array of the own enumerable property values of object. ```javascript values({one: 1, two: 2}); // -> [1, 2] -``` - -## viewportScale - +``` + +## viewportScale + Get viewport scale. ```javascript viewportScale(); // -> 3 -``` - -## wrap - +``` + +## wrap + Wrap the function inside a wrapper function, passing it as the first argument. |Name |Type |Desc | @@ -2457,4 +2487,4 @@ var p = wrap(escape, function(fn, text) return '' + fn(text) + '
'; }); p('You & Me'); // -> 'You & Me
' -``` +``` diff --git a/src/Info/Info.js b/src/Info/Info.js index 224b6f2..f3f5238 100644 --- a/src/Info/Info.js +++ b/src/Info/Info.js @@ -1,6 +1,6 @@ import Tool from '../DevTools/Tool' import defInfo from './defInfo' -import { evalCss, each, isFn } from '../lib/util' +import { evalCss, each, isFn, isUndef, cloneDeep } from '../lib/util' export default class Info extends Tool { constructor() { @@ -28,8 +28,8 @@ export default class Info extends Tool { evalCss.remove(this._style) } add(name, val) { - let infos = this._infos, - isUpdate = false + let infos = this._infos + let isUpdate = false each(infos, info => { if (name !== info.name) return @@ -44,6 +44,21 @@ export default class Info extends Tool { return this } + get(name) { + let infos = this._infos + + if (isUndef(name)) { + return cloneDeep(infos) + } + + let result + + each(infos, info => { + if (name === info.name) result = info.val + }) + + return result + } remove(name) { let infos = this._infos diff --git a/src/lib/util.js b/src/lib/util.js index fd0c598..d5270e1 100644 --- a/src/lib/util.js +++ b/src/lib/util.js @@ -1,11 +1,11 @@ // Built by eustia. -"use strict"; +"use strict"; -var _ = {}; +var _ = {}; -/* ------------------------------ last ------------------------------ */ +/* ------------------------------ last ------------------------------ */ -export var last = _.last = (function () { +export var last = _.last = (function () { /* Get the last element of array. * * |Name |Type |Desc | @@ -27,14 +27,14 @@ export var last = _.last = (function () { var len = arr ? arr.length : 0; if (len) return arr[len - 1]; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isUndef ------------------------------ */ +/* ------------------------------ isUndef ------------------------------ */ -export var isUndef = _.isUndef = (function () { +export var isUndef = _.isUndef = (function () { /* Check if value is undefined. * * |Name |Type |Desc | @@ -55,14 +55,14 @@ export var isUndef = _.isUndef = (function () { function exports(val) { return val === void 0; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isObj ------------------------------ */ +/* ------------------------------ isObj ------------------------------ */ -export var isObj = _.isObj = (function () { +export var isObj = _.isObj = (function () { /* Check if value is the language type of Object. * * |Name |Type |Desc | @@ -87,42 +87,14 @@ export var isObj = _.isObj = (function () { var type = typeof val; return !!val && (type === 'function' || type === 'object'); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ startWith ------------------------------ */ +/* ------------------------------ inherits ------------------------------ */ -export var startWith = _.startWith = (function () { - /* Check if string starts with the given target string. - * - * |Name |Type |Desc | - * |------|-------|---------------------------------| - * |str |string |String to search | - * |prefix|string |String prefix | - * |return|boolean|True if string starts with prefix| - * - * ```javascript - * startWith('ab', 'a'); // -> true - * ``` - */ - - /* module - * env: all - * test: all - */ - - function exports(str, prefix) { - return str.indexOf(prefix) === 0; - } - - return exports; -})(); - -/* ------------------------------ inherits ------------------------------ */ - -export var inherits = _.inherits = (function () { +export var inherits = _.inherits = (function () { /* Inherit the prototype methods from one constructor into another. * * |Name |Type |Desc | @@ -165,14 +137,14 @@ export var inherits = _.inherits = (function () { var objCreate = Object.create; - function noop() {} + function noop() {} - return exports; -})(); + return exports; +})(); -/* ------------------------------ has ------------------------------ */ +/* ------------------------------ has ------------------------------ */ -export var has = _.has = (function () { +export var has = _.has = (function () { /* Checks if key is a direct property. * * |Name |Type |Desc | @@ -195,14 +167,14 @@ export var has = _.has = (function () { function exports(obj, key) { return hasOwnProp.call(obj, key); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ slice ------------------------------ */ +/* ------------------------------ slice ------------------------------ */ -export var slice = _.slice = (function () { +export var slice = _.slice = (function () { /* Create slice of source array or array-like object. * * |Name |Type |Desc | @@ -244,14 +216,14 @@ export var slice = _.slice = (function () { while (start < end) ret.push(arr[start++]); 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. * * ```javascript @@ -267,14 +239,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 () { +export var noop = _.noop = (function () { /* A no-operation function. * * ```javascript @@ -287,14 +259,14 @@ export var noop = _.noop = (function () { * test: all */ - function exports() {} + function exports() {} - return exports; -})(); + return exports; +})(); -/* ------------------------------ allKeys ------------------------------ */ +/* ------------------------------ allKeys ------------------------------ */ -export var allKeys = _.allKeys = (function () { +export var allKeys = _.allKeys = (function () { /* Retrieve all the names of object's own and inherited properties. * * |Name |Type |Desc | @@ -323,14 +295,14 @@ export var allKeys = _.allKeys = (function () { for (key in obj) ret.push(key); return ret; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ before ------------------------------ */ +/* ------------------------------ before ------------------------------ */ -export var before = _.before = (function () { +export var before = _.before = (function () { /* Create a function that invokes less than n times. * * |Name |Type |Desc | @@ -361,14 +333,14 @@ export var before = _.before = (function () { return memo; }; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ splitCase ------------------------------ */ +/* ------------------------------ splitCase ------------------------------ */ -export var splitCase = _.splitCase = (function () { +export var splitCase = _.splitCase = (function () { /* Split different string case to an array. * * |Name |Type |Desc | @@ -403,14 +375,14 @@ export var splitCase = _.splitCase = (function () { .replace(regTrim, ''); return str.split('-'); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ camelCase ------------------------------ */ +/* ------------------------------ camelCase ------------------------------ */ -export var camelCase = _.camelCase = (function () { +export var camelCase = _.camelCase = (function () { /* Convert string to "camelCase". * * |Name |Type |Desc | @@ -451,14 +423,14 @@ export var camelCase = _.camelCase = (function () { this[idx] = val.replace(/\w/, function(match) { return match.toUpperCase(); }); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ kebabCase ------------------------------ */ +/* ------------------------------ kebabCase ------------------------------ */ -export var kebabCase = _.kebabCase = (function () { +export var kebabCase = _.kebabCase = (function () { /* Convert string to "kebabCase". * * |Name |Type |Desc | @@ -485,14 +457,14 @@ export var kebabCase = _.kebabCase = (function () { function exports(str) { return splitCase(str).join('-'); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ chunk ------------------------------ */ +/* ------------------------------ chunk ------------------------------ */ -export var chunk = _.chunk = (function () { +export var chunk = _.chunk = (function () { /* Split array into groups the length of given size. * * |Name |Type |Desc | @@ -525,14 +497,14 @@ export var chunk = _.chunk = (function () { } return ret; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ clamp ------------------------------ */ +/* ------------------------------ clamp ------------------------------ */ -export var clamp = _.clamp = (function () { +export var clamp = _.clamp = (function () { /* Clamp number within the inclusive lower and upper bounds. * * |Name |Type |Desc | @@ -571,14 +543,14 @@ export var clamp = _.clamp = (function () { if (n > upper) return upper; return n; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ idxOf ------------------------------ */ +/* ------------------------------ idxOf ------------------------------ */ -export var idxOf = _.idxOf = (function () { +export var idxOf = _.idxOf = (function () { /* Get the index at which the first occurrence of value. * * |Name |Type |Desc | @@ -599,14 +571,14 @@ export var idxOf = _.idxOf = (function () { function exports(arr, val, fromIdx) { return Array.prototype.indexOf.call(arr, val, fromIdx); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ toStr ------------------------------ */ +/* ------------------------------ toStr ------------------------------ */ -export var toStr = _.toStr = (function () { +export var toStr = _.toStr = (function () { /* Convert value to a string. * * |Name |Type |Desc | @@ -629,14 +601,14 @@ export var toStr = _.toStr = (function () { function exports(val) { return val == null ? '' : val.toString(); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ ucs2 ------------------------------ */ +/* ------------------------------ ucs2 ------------------------------ */ -export var ucs2 = _.ucs2 = (function (exports) { +export var ucs2 = _.ucs2 = (function (exports) { /* UCS-2 encoding and decoding. * * ### encode @@ -702,14 +674,14 @@ export var ucs2 = _.ucs2 = (function (exports) { return ret; } - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ utf8 ------------------------------ */ +/* ------------------------------ utf8 ------------------------------ */ -export var utf8 = _.utf8 = (function (exports) { +export var utf8 = _.utf8 = (function (exports) { /* UTF-8 encoding and decoding. * * ### encode @@ -906,14 +878,14 @@ export var utf8 = _.utf8 = (function (exports) { upperBoundary = 0xbf; return byteArr[start]; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ root ------------------------------ */ +/* ------------------------------ root ------------------------------ */ -export var root = _.root = (function (exports) { +export var root = _.root = (function (exports) { /* Root object reference, `global` in nodeJs, `window` in browser. */ /* module @@ -925,14 +897,14 @@ 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 () { +export var detectMocha = _.detectMocha = (function () { /* Detect if mocha is running. * * ```javascript @@ -959,14 +931,14 @@ export var detectMocha = _.detectMocha = (function () { 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 | @@ -1001,14 +973,14 @@ export var keys = _.keys = (function (exports) { return ret; }; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ freeze ------------------------------ */ +/* ------------------------------ freeze ------------------------------ */ -export var freeze = _.freeze = (function () { +export var freeze = _.freeze = (function () { /* Shortcut for Object.freeze. * * Use Object.defineProperties if Object.freeze is not supported. @@ -1048,14 +1020,14 @@ export var freeze = _.freeze = (function () { }); return obj; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ detectOs ------------------------------ */ +/* ------------------------------ detectOs ------------------------------ */ -export var detectOs = _.detectOs = (function () { +export var detectOs = _.detectOs = (function () { /* Detect operating system using ua. * * |Name |Type |Desc | @@ -1099,14 +1071,14 @@ export var detectOs = _.detectOs = (function () { } return 'unknown'; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ optimizeCb ------------------------------ */ +/* ------------------------------ optimizeCb ------------------------------ */ -export var optimizeCb = _.optimizeCb = (function () { +export var optimizeCb = _.optimizeCb = (function () { /* Used for function context binding. */ @@ -1140,14 +1112,14 @@ export var optimizeCb = _.optimizeCb = (function () { return function() { return fn.apply(ctx, arguments); }; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ endWith ------------------------------ */ +/* ------------------------------ endWith ------------------------------ */ -export var endWith = _.endWith = (function () { +export var endWith = _.endWith = (function () { /* Check if string ends with the given target string. * * |Name |Type |Desc | @@ -1170,14 +1142,14 @@ export var endWith = _.endWith = (function () { 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 () { +export var escape = _.escape = (function () { /* Escapes a string for insertion into HTML, replacing &, <, >, ", `, and ' characters. * * |Name |Type |Desc | @@ -1218,14 +1190,14 @@ export var escape = _.escape = (function () { function replaceFn(match) { return map[match]; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ escapeJsStr ------------------------------ */ +/* ------------------------------ escapeJsStr ------------------------------ */ -export var escapeJsStr = _.escapeJsStr = (function () { +export var escapeJsStr = _.escapeJsStr = (function () { /* Escape string to be a valid JavaScript string literal between quotes. * * http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4 @@ -1270,14 +1242,14 @@ export var escapeJsStr = _.escapeJsStr = (function () { }); } - 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 () { +export var escapeJsonStr = _.escapeJsonStr = (function () { /* Escape json string. */ @@ -1286,15 +1258,15 @@ export var escapeJsonStr = _.escapeJsonStr = (function () { */ function exports(str) { - return escapeJsStr(str).replace(/\\'/g, "'"); - } + return escapeJsStr(str).replace(/\\'/g, "'") + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ escapeRegExp ------------------------------ */ +/* ------------------------------ escapeRegExp ------------------------------ */ -export var escapeRegExp = _.escapeRegExp = (function () { +export var escapeRegExp = _.escapeRegExp = (function () { /* Escape special chars to be used as literals in RegExp constructors. * * |Name |Type |Desc | @@ -1314,14 +1286,14 @@ export var escapeRegExp = _.escapeRegExp = (function () { function exports(str) { return str.replace(/\W/g, '\\$&'); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ fileSize ------------------------------ */ +/* ------------------------------ fileSize ------------------------------ */ -export var fileSize = _.fileSize = (function () { +export var fileSize = _.fileSize = (function () { /* Turn bytes into human readable file size. * * |Name |Type |Desc | @@ -1352,14 +1324,42 @@ export var fileSize = _.fileSize = (function () { return +val.toFixed(2) + suffixList[suffixIdx]; } - var suffixList = ['', 'K', 'M', 'G', 'T']; + var suffixList = ['', 'K', 'M', 'G', 'T']; - return exports; -})(); + return exports; +})(); -/* ------------------------------ fullUrl ------------------------------ */ +/* ------------------------------ startWith ------------------------------ */ -export var fullUrl = _.fullUrl = (function () { +export var startWith = _.startWith = (function () { + /* Check if string starts with the given target string. + * + * |Name |Type |Desc | + * |------|-------|---------------------------------| + * |str |string |String to search | + * |prefix|string |String prefix | + * |return|boolean|True if string starts with prefix| + * + * ```javascript + * startWith('ab', 'a'); // -> true + * ``` + */ + + /* module + * env: all + * test: all + */ + + function exports(str, prefix) { + return str.indexOf(prefix) === 0; + } + + return exports; +})(); + +/* ------------------------------ fullUrl ------------------------------ */ + +export var fullUrl = _.fullUrl = (function () { /* Add origin to url if needed. */ @@ -1367,22 +1367,22 @@ export var fullUrl = _.fullUrl = (function () { * startWith */ - let origin = window.location.origin; + let origin = window.location.origin function exports(url) { - if (startWith(url, 'http')) return url; + if (startWith(url, 'http')) return url - if (!startWith(url, '/')) url = '/' + url; + if (!startWith(url, '/')) url = '/' + url - return origin + url; - } + return origin + url + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ upperFirst ------------------------------ */ +/* ------------------------------ upperFirst ------------------------------ */ -export var upperFirst = _.upperFirst = (function () { +export var upperFirst = _.upperFirst = (function () { /* Convert the first character of string to upper case. * * |Name |Type |Desc | @@ -1404,14 +1404,14 @@ export var upperFirst = _.upperFirst = (function () { if (str.length < 1) return str; return str[0].toUpperCase() + str.slice(1); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ getObjType ------------------------------ */ +/* ------------------------------ getObjType ------------------------------ */ -export var getObjType = _.getObjType = (function () { +export var getObjType = _.getObjType = (function () { /* Get object type. */ @@ -1420,17 +1420,17 @@ export var getObjType = _.getObjType = (function () { */ function exports(obj) { - if (obj.constructor && obj.constructor.name) return obj.constructor.name; + if (obj.constructor && obj.constructor.name) return obj.constructor.name - return upperFirst({}.toString.call(obj).replace(/(\[object )|]/g, '')); - } + return upperFirst({}.toString.call(obj).replace(/(\[object )|]/g, '')) + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ identity ------------------------------ */ +/* ------------------------------ identity ------------------------------ */ -export var identity = _.identity = (function () { +export var identity = _.identity = (function () { /* Return the first argument given. * * |Name |Type|Desc | @@ -1450,14 +1450,14 @@ export var identity = _.identity = (function () { function exports(val) { return val; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ objToStr ------------------------------ */ +/* ------------------------------ objToStr ------------------------------ */ -export var objToStr = _.objToStr = (function () { +export var objToStr = _.objToStr = (function () { /* Alias of Object.prototype.toString. * * |Name |Type |Desc | @@ -1479,14 +1479,14 @@ export var objToStr = _.objToStr = (function () { function exports(val) { return ObjToStr.call(val); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isArgs ------------------------------ */ +/* ------------------------------ isArgs ------------------------------ */ -export var isArgs = _.isArgs = (function () { +export var isArgs = _.isArgs = (function () { /* Check if value is classified as an arguments object. * * |Name |Type |Desc | @@ -1512,14 +1512,14 @@ export var isArgs = _.isArgs = (function () { function exports(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 | @@ -1546,14 +1546,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 () { +export var castPath = _.castPath = (function () { /* Cast value into a property path array. * * |Name |Type |Desc | @@ -1594,14 +1594,14 @@ export var castPath = _.castPath = (function () { // Lodash _stringToPath var regPropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g, - regEscapeChar = /\\(\\)?/g; + regEscapeChar = /\\(\\)?/g; - return exports; -})(); + return exports; +})(); -/* ------------------------------ safeGet ------------------------------ */ +/* ------------------------------ safeGet ------------------------------ */ -export var safeGet = _.safeGet = (function () { +export var safeGet = _.safeGet = (function () { /* Get object property, don't throw undefined error. * * |Name |Type |Desc | @@ -1640,14 +1640,14 @@ export var safeGet = _.safeGet = (function () { } return obj; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isDate ------------------------------ */ +/* ------------------------------ isDate ------------------------------ */ -export var isDate = _.isDate = (function () { +export var isDate = _.isDate = (function () { /* Check if value is classified as a Date object. * * |Name |Type |Desc | @@ -1671,14 +1671,14 @@ export var isDate = _.isDate = (function () { function exports(val) { return objToStr(val) === '[object Date]'; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isFn ------------------------------ */ +/* ------------------------------ isFn ------------------------------ */ -export var isFn = _.isFn = (function () { +export var isFn = _.isFn = (function () { /* Check if value is a function. * * |Name |Type |Desc | @@ -1710,14 +1710,14 @@ export var isFn = _.isFn = (function () { objStr === '[object Function]' || objStr === '[object GeneratorFunction]' ); - } + } - 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. * * ```javascript @@ -1735,14 +1735,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 () { +export var isNum = _.isNum = (function () { /* Check if value is classified as a Number primitive or object. * * |Name |Type |Desc | @@ -1768,14 +1768,14 @@ export var isNum = _.isNum = (function () { function exports(val) { return objToStr(val) === '[object Number]'; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isArrLike ------------------------------ */ +/* ------------------------------ isArrLike ------------------------------ */ -export var isArrLike = _.isArrLike = (function () { +export var isArrLike = _.isArrLike = (function () { /* Check if value is array-like. * * |Name |Type |Desc | @@ -1809,14 +1809,14 @@ export var isArrLike = _.isArrLike = (function () { 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 () { +export var each = _.each = (function () { /* Iterate over elements of collection and invokes iteratee for each element. * * |Name |Type |Desc | @@ -1854,14 +1854,14 @@ export var each = _.each = (function () { } return obj; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ createAssigner ------------------------------ */ +/* ------------------------------ createAssigner ------------------------------ */ -export var createAssigner = _.createAssigner = (function () { +export var createAssigner = _.createAssigner = (function () { /* Used to create extend, extendOwn and defaults. * * |Name |Type |Desc | @@ -1894,14 +1894,14 @@ export var createAssigner = _.createAssigner = (function () { return obj; }; - } + } - 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 | @@ -1924,14 +1924,14 @@ export var defaults = _.defaults = (function (exports) { * createAssigner allKeys */ - exports = createAssigner(allKeys, true); + exports = createAssigner(allKeys, true); - 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 | @@ -1954,14 +1954,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 () { +export var clone = _.clone = (function () { /* Create a shallow-copied clone of the provided plain object. * * Any nested objects or arrays will be copied by reference, not duplicated. @@ -1989,14 +1989,14 @@ export var clone = _.clone = (function () { if (!isObj(obj)) return obj; return isArr(obj) ? obj.slice() : extend({}, 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 | @@ -2019,14 +2019,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 () { +export var values = _.values = (function () { /* Create an array of the own enumerable property values of object. * * |Name |Type |Desc | @@ -2056,14 +2056,14 @@ export var values = _.values = (function () { }); return ret; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ contain ------------------------------ */ +/* ------------------------------ contain ------------------------------ */ -export var contain = _.contain = (function () { +export var contain = _.contain = (function () { /* Check if the value is present in the list. * * |Name |Type |Desc | @@ -2091,14 +2091,14 @@ export var contain = _.contain = (function () { if (!isArrLike(arr)) arr = values(arr); return idxOf(arr, val) >= 0; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isStr ------------------------------ */ +/* ------------------------------ isStr ------------------------------ */ -export var isStr = _.isStr = (function () { +export var isStr = _.isStr = (function () { /* Check if value is a string primitive. * * |Name |Type |Desc | @@ -2122,14 +2122,14 @@ export var isStr = _.isStr = (function () { function exports(val) { return objToStr(val) === '[object String]'; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isEmpty ------------------------------ */ +/* ------------------------------ isEmpty ------------------------------ */ -export var isEmpty = _.isEmpty = (function () { +export var isEmpty = _.isEmpty = (function () { /* Check if value is an empty object or array. * * |Name |Type |Desc | @@ -2161,14 +2161,14 @@ export var isEmpty = _.isEmpty = (function () { } return keys(val).length === 0; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isBool ------------------------------ */ +/* ------------------------------ isBool ------------------------------ */ -export var isBool = _.isBool = (function () { +export var isBool = _.isBool = (function () { /* Check if value is a boolean primitive. * * |Name |Type |Desc | @@ -2190,14 +2190,14 @@ export var isBool = _.isBool = (function () { function exports(val) { return val === true || val === false; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isCrossOrig ------------------------------ */ +/* ------------------------------ isCrossOrig ------------------------------ */ -export var isCrossOrig = _.isCrossOrig = (function () { +export var isCrossOrig = _.isCrossOrig = (function () { /* Check if a url is cross origin. */ @@ -2205,18 +2205,18 @@ export var isCrossOrig = _.isCrossOrig = (function () { * startWith */ - var origin = window.location.origin; + var origin = window.location.origin function exports(url) { - return !startWith(url, origin); - } + return !startWith(url, origin) + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isEl ------------------------------ */ +/* ------------------------------ isEl ------------------------------ */ -export var isEl = _.isEl = (function () { +export var isEl = _.isEl = (function () { /* Check if value is a DOM element. * * |Name |Type |Desc | @@ -2236,14 +2236,14 @@ export var isEl = _.isEl = (function () { function exports(val) { return !!(val && val.nodeType === 1); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isErr ------------------------------ */ +/* ------------------------------ isErr ------------------------------ */ -export var isErr = _.isErr = (function () { +export var isErr = _.isErr = (function () { /* Check if value is an error. * * |Name |Type |Desc | @@ -2267,36 +2267,36 @@ export var isErr = _.isErr = (function () { function exports(val) { return objToStr(val) === '[object Error]'; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isErudaEl ------------------------------ */ +/* ------------------------------ isErudaEl ------------------------------ */ -export var isErudaEl = _.isErudaEl = (function () { +export var isErudaEl = _.isErudaEl = (function () { /* See if an element is within eruda. */ function exports(el) { - var parentNode = el.parentNode; + var parentNode = el.parentNode - if (!parentNode) return false; + if (!parentNode) return false - while (parentNode) { - parentNode = parentNode.parentNode; - if (parentNode && parentNode.id === 'eruda') return true; - } + while (parentNode) { + parentNode = parentNode.parentNode + if (parentNode && parentNode.id === 'eruda') return true + } - return false; - } + return false + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isMatch ------------------------------ */ +/* ------------------------------ isMatch ------------------------------ */ -export var isMatch = _.isMatch = (function () { +export var isMatch = _.isMatch = (function () { /* Check if keys and values in src are contained in obj. * * |Name |Type |Desc | @@ -2333,14 +2333,14 @@ export var isMatch = _.isMatch = (function () { } return true; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ memoize ------------------------------ */ +/* ------------------------------ memoize ------------------------------ */ -export var memoize = _.memoize = (function () { +export var memoize = _.memoize = (function () { /* Memoize a given function by caching the computed result. * * |Name |Type |Desc | @@ -2379,14 +2379,14 @@ export var memoize = _.memoize = (function () { 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 | @@ -2415,14 +2415,14 @@ export var isMobile = _.isMobile = (function (exports) { 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 | @@ -2476,14 +2476,14 @@ export var prefix = _.prefix = (function (exports) { var prefixes = ['O', 'ms', 'Moz', 'Webkit'], regPrefixes = /^(O)|(ms)|(Moz)|(Webkit)|(-o-)|(-ms-)|(-moz-)|(-webkit-)/g, - style = document.createElement('p').style; + style = document.createElement('p').style; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ isNaN ------------------------------ */ +/* ------------------------------ isNaN ------------------------------ */ -export var isNaN = _.isNaN = (function () { +export var isNaN = _.isNaN = (function () { /* Check if value is an NaN. * * |Name |Type |Desc | @@ -2510,14 +2510,14 @@ export var isNaN = _.isNaN = (function () { function exports(val) { return isNum(val) && val !== +val; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isNil ------------------------------ */ +/* ------------------------------ isNil ------------------------------ */ -export var isNil = _.isNil = (function () { +export var isNil = _.isNil = (function () { /* Check if value is null or undefined, the same as value == null. * * |Name |Type |Desc | @@ -2542,14 +2542,14 @@ export var isNil = _.isNil = (function () { function exports(val) { return val == null; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ toSrc ------------------------------ */ +/* ------------------------------ toSrc ------------------------------ */ -export var toSrc = _.toSrc = (function () { +export var toSrc = _.toSrc = (function () { /* Convert function to its source code. * * |Name |Type |Desc | @@ -2588,14 +2588,14 @@ export var toSrc = _.toSrc = (function () { return ''; } - var fnToStr = Function.prototype.toString; + var fnToStr = Function.prototype.toString; - return exports; -})(); + return exports; +})(); -/* ------------------------------ isNative ------------------------------ */ +/* ------------------------------ isNative ------------------------------ */ -export var isNative = _.isNative = (function () { +export var isNative = _.isNative = (function () { /* Check if value is a native function. * * |Name |Type |Desc | @@ -2615,7 +2615,7 @@ export var isNative = _.isNative = (function () { */ /* dependencies - * isObj isFn has toSrc + * isObj isFn toSrc */ function exports(val) { @@ -2640,14 +2640,14 @@ export var isNative = _.isNative = (function () { '$' ); - var regIsHostCtor = /^\[object .+?Constructor\]$/; + var regIsHostCtor = /^\[object .+?Constructor\]$/; - return exports; -})(); + return exports; +})(); -/* ------------------------------ isNull ------------------------------ */ +/* ------------------------------ isNull ------------------------------ */ -export var isNull = _.isNull = (function () { +export var isNull = _.isNull = (function () { /* Check if value is an Null. * * |Name |Type |Desc | @@ -2667,14 +2667,14 @@ export var isNull = _.isNull = (function () { function exports(val) { return val === null; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ isRegExp ------------------------------ */ +/* ------------------------------ isRegExp ------------------------------ */ -export var isRegExp = _.isRegExp = (function () { +export var isRegExp = _.isRegExp = (function () { /* Check if value is a regular expression. * * |Name |Type |Desc | @@ -2698,14 +2698,14 @@ export var isRegExp = _.isRegExp = (function () { function exports(val) { return objToStr(val) === '[object RegExp]'; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ loadJs ------------------------------ */ +/* ------------------------------ loadJs ------------------------------ */ -export var loadJs = _.loadJs = (function () { +export var loadJs = _.loadJs = (function () { /* Inject script tag into page with given src value. * * |Name|Type |Desc | @@ -2738,14 +2738,14 @@ export var loadJs = _.loadJs = (function () { cb && cb(!isNotLoaded); }; document.body.appendChild(script); - } + } - 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 | @@ -2778,14 +2778,14 @@ export var repeat = _.repeat = (function (exports) { } return ret; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ lpad ------------------------------ */ +/* ------------------------------ lpad ------------------------------ */ -export var lpad = _.lpad = (function () { +export var lpad = _.lpad = (function () { /* Pad string on the left side if it's shorter than length. * * |Name |Type |Desc | @@ -2822,14 +2822,14 @@ export var lpad = _.lpad = (function () { if (strLen < len) str = (repeat(chars, len - strLen) + str).slice(-len); return str; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ dateFormat ------------------------------ */ +/* ------------------------------ dateFormat ------------------------------ */ -export var dateFormat = _.dateFormat = (function () { +export var dateFormat = _.dateFormat = (function () { /* Simple but extremely useful date format function. * * |Name |Type |Desc | @@ -3033,14 +3033,14 @@ export var dateFormat = _.dateFormat = (function () { 'November', 'December' ] - }; + }; - return exports; -})(); + return exports; +})(); -/* ------------------------------ ltrim ------------------------------ */ +/* ------------------------------ ltrim ------------------------------ */ -export var ltrim = _.ltrim = (function () { +export var ltrim = _.ltrim = (function () { /* Remove chars or white-spaces from beginning of string. * * |Name |Type |Desc | @@ -3088,14 +3088,14 @@ export var ltrim = _.ltrim = (function () { } return start >= len ? '' : str.substr(start, len); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ matcher ------------------------------ */ +/* ------------------------------ matcher ------------------------------ */ -export var matcher = _.matcher = (function () { +export var matcher = _.matcher = (function () { /* Return a predicate function that checks if attrs are contained in an object. * * |Name |Type |Desc | @@ -3127,14 +3127,14 @@ export var matcher = _.matcher = (function () { 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. */ @@ -3159,14 +3159,14 @@ export var safeCb = _.safeCb = (function (exports) { return obj == null ? undefined : obj[key]; }; }; - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ filter ------------------------------ */ +/* ------------------------------ filter ------------------------------ */ -export var filter = _.filter = (function () { +export var filter = _.filter = (function () { /* Iterates over elements of collection, returning an array of all the values that pass a truth test. * * |Name |Type |Desc | @@ -3203,14 +3203,14 @@ export var filter = _.filter = (function () { }); return ret; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ evalCss ------------------------------ */ +/* ------------------------------ evalCss ------------------------------ */ -export var evalCss = _.evalCss = (function () { +export var evalCss = _.evalCss = (function () { /* Eval css. */ @@ -3219,54 +3219,54 @@ export var evalCss = _.evalCss = (function () { */ var styleList = [], - scale = 1; + scale = 1 function exports(css, container) { - css = toStr(css); + css = toStr(css) - for (var i = 0, len = styleList.length; i < len; i++) { - if (styleList[i].css === css) return; - } + for (var i = 0, len = styleList.length; i < len; i++) { + if (styleList[i].css === css) return + } - container = container || exports.container || document.head; - const el = document.createElement('style'); + container = container || exports.container || document.head + const el = document.createElement('style') - el.type = 'text/css'; - container.appendChild(el); + el.type = 'text/css' + container.appendChild(el) - let style = { css, el, container }; - resetStyle(style); - styleList.push(style); + let style = { css, el, container } + resetStyle(style) + styleList.push(style) - return style; + return style } exports.setScale = function(s) { - scale = s; - each(styleList, style => resetStyle(style)); - }; - - exports.clear = function() { - each(styleList, ({ container, el }) => container.removeChild(el)); - styleList = []; - }; - - exports.remove = function(style) { - styleList = filter(styleList, s => s !== style); - - style.container.removeChild(style.el); - }; - - function resetStyle({ css, el }) { - el.innerText = css.replace(/(\d+)px/g, ($0, $1) => +$1 * scale + 'px'); + scale = s + each(styleList, style => resetStyle(style)) } - return exports; -})(); + exports.clear = function() { + each(styleList, ({ container, el }) => container.removeChild(el)) + styleList = [] + } -/* ------------------------------ map ------------------------------ */ + exports.remove = function(style) { + styleList = filter(styleList, s => s !== style) -export var map = _.map = (function () { + style.container.removeChild(style.el) + } + + function resetStyle({ css, el }) { + el.innerText = css.replace(/(\d+)px/g, ($0, $1) => +$1 * scale + 'px') + } + + return exports; +})(); + +/* ------------------------------ map ------------------------------ */ + +export var map = _.map = (function () { /* Create an array of values by running each element in collection through iteratee. * * |Name |Type |Desc | @@ -3303,14 +3303,14 @@ export var map = _.map = (function () { } return results; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ decodeUriComponent ------------------------------ */ +/* ------------------------------ decodeUriComponent ------------------------------ */ -export var decodeUriComponent = _.decodeUriComponent = (function () { +export var decodeUriComponent = _.decodeUriComponent = (function () { /* Better decodeURIComponent that does not throw if input is invalid. * * |Name |Type |Desc | @@ -3337,8 +3337,6 @@ export var decodeUriComponent = _.decodeUriComponent = (function () { try { return decodeURIComponent(str); } catch (e) { - var replaceMap = {}; - var matches = str.match(regMatcher); each(matches, function(match) { @@ -3364,14 +3362,14 @@ export var decodeUriComponent = _.decodeUriComponent = (function () { 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 @@ -3482,14 +3480,14 @@ export var cookie = _.cookie = (function (exports) { return setCookie(key, '', options); } - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ toArr ------------------------------ */ +/* ------------------------------ toArr ------------------------------ */ -export var toArr = _.toArr = (function () { +export var toArr = _.toArr = (function () { /* Convert value to an array. * * |Name |Type |Desc | @@ -3522,14 +3520,14 @@ export var toArr = _.toArr = (function () { if (isArrLike(val) && !isStr(val)) return map(val); return [val]; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ Class ------------------------------ */ +/* ------------------------------ Class ------------------------------ */ -export var Class = _.Class = (function () { +export var Class = _.Class = (function () { /* Create JavaScript class. * * |Name |Type |Desc | @@ -3581,7 +3579,7 @@ export var Class = _.Class = (function () { */ /* dependencies - * extend toArr inherits has safeGet isMiniProgram + * extend toArr inherits safeGet isMiniProgram */ function exports(methods, statics) { @@ -3648,14 +3646,14 @@ export var Class = _.Class = (function () { 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 @@ -3713,14 +3711,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. * * ```javascript @@ -3754,14 +3752,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 @@ -3847,14 +3845,14 @@ export var Select = _.Select = (function (exports) { first.length = i; return first; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $safeEls ------------------------------ */ +/* ------------------------------ $safeEls ------------------------------ */ -export var $safeEls = _.$safeEls = (function () { +export var $safeEls = _.$safeEls = (function () { /* Convert value into an array, if it's a string, do querySelector. * * |Name |Type |Desc | @@ -3878,14 +3876,14 @@ export var $safeEls = _.$safeEls = (function () { function exports(val) { return toArr(isStr(val) ? new Select(val) : val); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ $attr ------------------------------ */ +/* ------------------------------ $attr ------------------------------ */ -export var $attr = _.$attr = (function () { +export var $attr = _.$attr = (function () { /* Element attribute manipulation. * * Get the value of an attribute for the first element in the set of matched elements. @@ -3974,14 +3972,14 @@ export var $attr = _.$attr = (function () { el.setAttribute(name, val); }); }); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ $data ------------------------------ */ +/* ------------------------------ $data ------------------------------ */ -export var $data = _.$data = (function () { +export var $data = _.$data = (function () { /* Wrapper of $attr, adds data- prefix to keys. * * ```javascript @@ -4010,14 +4008,14 @@ export var $data = _.$data = (function () { } return $attr(nodes, dataName, val); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ $css ------------------------------ */ +/* ------------------------------ $css ------------------------------ */ -export var $css = _.$css = (function () { +export var $css = _.$css = (function () { /* Element css manipulation. * * Get the computed style properties for the first element in the set of matched elements. @@ -4057,7 +4055,7 @@ export var $css = _.$css = (function () { */ /* dependencies - * isStr isObj kebabCase isUndef contain isNum $safeEls startWith prefix + * isStr isObj kebabCase isUndef contain isNum $safeEls prefix */ function exports(nodes, name, val) { @@ -4107,14 +4105,14 @@ export var $css = _.$css = (function () { var needPx = isNum(val) && !contain(cssNumProps, kebabCase(key)); return needPx ? val + 'px' : 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 @@ -4175,14 +4173,14 @@ export var $insert = _.$insert = (function (exports) { node.insertAdjacentHTML(type, val); }); }; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $offset ------------------------------ */ +/* ------------------------------ $offset ------------------------------ */ -export var $offset = _.$offset = (function () { +export var $offset = _.$offset = (function () { /* Get the position of the element in document. * * |Name |Type |Desc | @@ -4216,14 +4214,14 @@ export var $offset = _.$offset = (function () { 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 @@ -4273,14 +4271,14 @@ export var $property = _.$property = (function (exports) { node[name] = val; }); }; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ $remove ------------------------------ */ +/* ------------------------------ $remove ------------------------------ */ -export var $remove = _.$remove = (function () { +export var $remove = _.$remove = (function () { /* Remove the set of matched elements from the DOM. * * |Name |Type |Desc | @@ -4309,14 +4307,14 @@ export var $remove = _.$remove = (function () { if (parent) parent.removeChild(el); }); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ $show ------------------------------ */ +/* ------------------------------ $show ------------------------------ */ -export var $show = _.$show = (function () { +export var $show = _.$show = (function () { /* Show elements. * * |Name |Type |Desc | @@ -4366,14 +4364,14 @@ export var $show = _.$show = (function () { } return elDisplay[elName]; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ delegate ------------------------------ */ +/* ------------------------------ delegate ------------------------------ */ -export var delegate = _.delegate = (function (exports) { +export var delegate = _.delegate = (function (exports) { /* Event delegation. * * ### add @@ -4499,7 +4497,7 @@ export var delegate = _.delegate = (function (exports) { handlers.delegateCount = 0; el.addEventListener( type, - function(e) { + function() { trigger.apply(el, arguments); }, false @@ -4561,14 +4559,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. * * ```javascript @@ -4608,14 +4606,14 @@ export var $event = _.$event = (function (exports) { delegate[type](node, event, selector, handler); }); }; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ concat ------------------------------ */ +/* ------------------------------ concat ------------------------------ */ -export var concat = _.concat = (function () { +export var concat = _.concat = (function () { /* Concat multiple arrays into a single array. * * |Name |Type |Desc | @@ -4646,14 +4644,103 @@ export var concat = _.concat = (function () { } return ret; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ some ------------------------------ */ +/* ------------------------------ mapObj ------------------------------ */ -export var some = _.some = (function () { +export var mapObj = _.mapObj = (function () { + /* Map for objects. + * + * |Name |Type |Desc | + * |--------|--------|------------------------------| + * |obj |object |Object to iterate over | + * |iteratee|function|Function invoked per iteration| + * |[ctx] |* |Function context | + * |return |object |New mapped object | + * + * ```javascript + * mapObj({a: 1, b: 2}, function (val, key) { return val + 1 }); // -> {a: 2, b: 3} + * ``` + */ + + /* module + * env: all + * test: all + */ + + /* dependencies + * safeCb keys + */ + + function exports(obj, iteratee, ctx) { + iteratee = safeCb(iteratee, ctx); + + var _keys = keys(obj), + len = _keys.length, + ret = {}; + + for (var i = 0; i < len; i++) { + var curKey = _keys[i]; + ret[curKey] = iteratee(obj[curKey], curKey, obj); + } + + return ret; + } + + return exports; +})(); + +/* ------------------------------ cloneDeep ------------------------------ */ + +export var cloneDeep = _.cloneDeep = (function () { + /* Recursively clone value. + * + * |Name |Type|Desc | + * |------|----|-----------------| + * |val |* |Value to clone | + * |return|* |Deep cloned Value| + * + * ```javascript + * var obj = [{a: 1}, {a: 2}]; + * var obj2 = cloneDeep(obj); + * console.log(obj[0] === obj2[1]); // -> false + * ``` + */ + + /* module + * env: all + * test: all + */ + + /* dependencies + * isObj isFn isArr mapObj + */ + + function exports(obj) { + if (isArr(obj)) { + return obj.map(function(val) { + return exports(val); + }); + } + + if (isObj(obj) && !isFn(obj)) { + return mapObj(obj, function(val) { + return exports(val); + }); + } + + return obj; + } + + return exports; +})(); + +/* ------------------------------ some ------------------------------ */ + +export var some = _.some = (function () { /* Check if predicate return truthy for any element. * * |Name |Type |Desc | @@ -4692,14 +4779,14 @@ export var some = _.some = (function () { } return false; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ $class ------------------------------ */ +/* ------------------------------ $class ------------------------------ */ -export var $class = _.$class = (function (exports) { +export var $class = _.$class = (function (exports) { /* Element class manipulations. * * ### add @@ -4807,14 +4894,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 () { +export var $ = _.$ = (function () { /* jQuery like style dom manipulator. * * ### Available methods @@ -4979,14 +5066,14 @@ export var $ = _.$ = (function () { 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. @@ -5065,14 +5152,14 @@ export var memStorage = _.memStorage = (function (exports) { function cloakedKeys() { return keys(cloak); - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ safeStorage ------------------------------ */ +/* ------------------------------ safeStorage ------------------------------ */ -export var safeStorage = _.safeStorage = (function () { +export var safeStorage = _.safeStorage = (function () { /* Safe localStorage and sessionStorage. */ @@ -5081,40 +5168,40 @@ export var safeStorage = _.safeStorage = (function () { */ function exports(type, memReplacement) { - if (isUndef(memReplacement)) memReplacement = true; + if (isUndef(memReplacement)) memReplacement = true - var ret; + var ret - switch (type) { - case 'local': - ret = window.localStorage; - break; - case 'session': - ret = window.sessionStorage; - break; - } + switch (type) { + case 'local': + ret = window.localStorage + break + case 'session': + ret = window.sessionStorage + break + } - try { - // Safari private browsing - var x = 'test-localStorage-' + Date.now(); - ret.setItem(x, x); - var y = ret.getItem(x); - ret.removeItem(x); - if (y !== x) throw new Error(); - } catch (e) { - if (memReplacement) return memStorage; - return; - } + try { + // Safari private browsing + var x = 'test-localStorage-' + Date.now() + ret.setItem(x, x) + var y = ret.getItem(x) + ret.removeItem(x) + if (y !== x) throw new Error() + } catch (e) { + if (memReplacement) return memStorage + return + } - return ret; - } + return ret + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ meta ------------------------------ */ +/* ------------------------------ meta ------------------------------ */ -export var meta = _.meta = (function () { +export var meta = _.meta = (function () { /* 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. @@ -5246,14 +5333,14 @@ export var meta = _.meta = (function () { 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 | @@ -5286,14 +5373,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 () { +export var ms = _.ms = (function () { /* Convert time string formats to milliseconds. * * Turn time string into milliseconds. @@ -5364,14 +5451,14 @@ export var ms = _.ms = (function () { 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 () { +export var toInt = _.toInt = (function () { /* Convert value to an integer. * * |Name |Type |Desc | @@ -5400,14 +5487,14 @@ export var toInt = _.toInt = (function () { val = toNum(val); return val - (val % 1); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ detectBrowser ------------------------------ */ +/* ------------------------------ detectBrowser ------------------------------ */ -export var detectBrowser = _.detectBrowser = (function () { +export var detectBrowser = _.detectBrowser = (function () { /* Detect browser info using ua. * * |Name |Type |Desc | @@ -5493,14 +5580,14 @@ export var detectBrowser = _.detectBrowser = (function () { 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 | @@ -5541,14 +5628,14 @@ export var nextTick = _.nextTick = (function (exports) { 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. * * ```javascript @@ -5565,14 +5652,14 @@ export var now = _.now = (function (exports) { Date.now || function() { return new Date().getTime(); - }; + }; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ restArgs ------------------------------ */ +/* ------------------------------ restArgs ------------------------------ */ -export var restArgs = _.restArgs = (function () { +export var restArgs = _.restArgs = (function () { /* This accumulates the arguments passed into an array, after a given index. * * |Name |Type |Desc | @@ -5620,14 +5707,14 @@ export var restArgs = _.restArgs = (function () { return fn.apply(this, args); }; - } + } - 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 | @@ -5660,14 +5747,14 @@ export var partial = _.partial = (function (exports) { 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 | @@ -5692,14 +5779,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 @@ -5804,14 +5891,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 @@ -5936,14 +6023,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. @@ -6093,14 +6180,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 @@ -6158,14 +6245,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. * * ```javascript @@ -6208,14 +6295,14 @@ export var perfNow = _.perfNow = (function (exports) { exports = function() { return now() - loadTime; }; - } + } - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ pxToNum ------------------------------ */ +/* ------------------------------ pxToNum ------------------------------ */ -export var pxToNum = _.pxToNum = (function () { +export var pxToNum = _.pxToNum = (function () { /* Turn string like '0px' to number. */ @@ -6224,15 +6311,15 @@ export var pxToNum = _.pxToNum = (function () { */ function exports(str) { - return toNum(str.replace('px', '')); - } + return toNum(str.replace('px', '')) + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ rmCookie ------------------------------ */ +/* ------------------------------ rmCookie ------------------------------ */ -export var rmCookie = _.rmCookie = (function () { +export var rmCookie = _.rmCookie = (function () { /* Loop through all possible path and domain to remove cookie. * * |Name|Type |Desc | @@ -6295,14 +6382,14 @@ export var rmCookie = _.rmCookie = (function () { return !cookie.get(key); } - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ rtrim ------------------------------ */ +/* ------------------------------ rtrim ------------------------------ */ -export var rtrim = _.rtrim = (function () { +export var rtrim = _.rtrim = (function () { /* Remove chars or white-spaces from end of string. * * |Name |Type |Desc | @@ -6349,14 +6436,14 @@ export var rtrim = _.rtrim = (function () { } return end >= 0 ? str.substring(0, end + 1) : ''; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ trim ------------------------------ */ +/* ------------------------------ trim ------------------------------ */ -export var trim = _.trim = (function () { +export var trim = _.trim = (function () { /* Remove chars or white-spaces from beginning end of string. * * |Name |Type |Desc | @@ -6387,14 +6474,14 @@ export var trim = _.trim = (function () { if (chars == null) return str.replace(regSpace, ''); return ltrim(rtrim(str, chars), chars); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ getFileName ------------------------------ */ +/* ------------------------------ getFileName ------------------------------ */ -export var getFileName = _.getFileName = (function () { +export var getFileName = _.getFileName = (function () { /* Extract file name from url. */ @@ -6403,19 +6490,19 @@ export var getFileName = _.getFileName = (function () { */ function exports(url) { - var ret = last(url.split('/')); + var ret = last(url.split('/')) - if (ret.indexOf('?') > -1) ret = trim(ret.split('?')[0]); + if (ret.indexOf('?') > -1) ret = trim(ret.split('?')[0]) - return ret === '' ? 'unknown' : ret; - } + return ret === '' ? 'unknown' : ret + } - 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 @@ -6499,14 +6586,14 @@ export var query = _.query = (function (exports) { } }; - 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 @@ -6715,14 +6802,14 @@ export var Url = _.Url = (function (exports) { var regProto = /^([a-z0-9.+-]+:)/i, regPort = /:[0-9]*$/, - hostEndingChars = ['/', '?', '#']; + hostEndingChars = ['/', '?', '#']; - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ ajax ------------------------------ */ +/* ------------------------------ ajax ------------------------------ */ -export var ajax = _.ajax = (function () { +export var ajax = _.ajax = (function () { /* Perform an asynchronous HTTP request. * * |Name |Type |Desc | @@ -6731,7 +6818,7 @@ export var ajax = _.ajax = (function () { * * Available options: * - * |Name |Type |Desc | + * |Name |Type |Desc | * |---------------------------------------------|-------------|---------------------------| * |url |string |Request url | * |data |string object|Request data | @@ -6885,14 +6972,14 @@ export var ajax = _.ajax = (function () { success: success, dataType: dataType }; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ type ------------------------------ */ +/* ------------------------------ type ------------------------------ */ -export var type = _.type = (function () { +export var type = _.type = (function () { /* Determine the internal JavaScript [[Class]] of an object. * * |Name |Type |Desc | @@ -6929,14 +7016,14 @@ export var type = _.type = (function () { return ret[1].toLowerCase(); } - var regObj = /^\[object\s+(.*?)]$/; + var regObj = /^\[object\s+(.*?)]$/; - return exports; -})(); + return exports; +})(); -/* ------------------------------ stringify ------------------------------ */ +/* ------------------------------ stringify ------------------------------ */ -export var stringify = _.stringify = (function () { +export var stringify = _.stringify = (function () { /* JSON stringify with support for circular object, function etc. * * Undefined is treated as null value. @@ -7004,14 +7091,14 @@ export var stringify = _.stringify = (function () { 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. @@ -7058,14 +7145,14 @@ export var LocalStore = _.LocalStore = (function (exports) { if (isEmpty(data)) return localStorage.removeItem(this._name); localStorage.setItem(this._name, stringify(data)); } - }); + }); - return exports; -})({}); + return exports; +})({}); -/* ------------------------------ stripHtmlTag ------------------------------ */ +/* ------------------------------ stripHtmlTag ------------------------------ */ -export var stripHtmlTag = _.stripHtmlTag = (function () { +export var stripHtmlTag = _.stripHtmlTag = (function () { /* Strip html tags from a string. * * |Name |Type |Desc | @@ -7087,14 +7174,14 @@ export var stripHtmlTag = _.stripHtmlTag = (function () { function exports(str) { return str.replace(regHtmlTag, ''); - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ tryIt ------------------------------ */ +/* ------------------------------ tryIt ------------------------------ */ -export var tryIt = _.tryIt = (function () { +export var tryIt = _.tryIt = (function () { /* Run function in a try catch. * * |Name|Type |Desc | @@ -7131,14 +7218,14 @@ export var tryIt = _.tryIt = (function () { cb(e); return; } - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ uniqId ------------------------------ */ +/* ------------------------------ uniqId ------------------------------ */ -export var uniqId = _.uniqId = (function () { +export var uniqId = _.uniqId = (function () { /* Generate a globally-unique id. * * |Name |Type |Desc | @@ -7162,14 +7249,14 @@ export var uniqId = _.uniqId = (function () { var id = ++idCounter + ''; return prefix ? prefix + id : id; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ unique ------------------------------ */ +/* ------------------------------ unique ------------------------------ */ -export var unique = _.unique = (function () { +export var unique = _.unique = (function () { /* Create duplicate-free version of an array. * * |Name |Type |Desc | @@ -7208,14 +7295,14 @@ export var unique = _.unique = (function () { function isEqual(a, b) { return a === b; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ viewportScale ------------------------------ */ +/* ------------------------------ viewportScale ------------------------------ */ -export var viewportScale = _.viewportScale = (function () { +export var viewportScale = _.viewportScale = (function () { /* Get viewport scale. * * ```javascript @@ -7262,14 +7349,14 @@ export var viewportScale = _.viewportScale = (function () { if (isNaN(ret)) return 1; return ret; - } + } - return exports; -})(); + return exports; +})(); -/* ------------------------------ wrap ------------------------------ */ +/* ------------------------------ wrap ------------------------------ */ -export var wrap = _.wrap = (function () { +export var wrap = _.wrap = (function () { /* Wrap the function inside a wrapper function, passing it as the first argument. * * |Name |Type |Desc | @@ -7298,9 +7385,9 @@ export var wrap = _.wrap = (function () { function exports(fn, wrapper) { return partial(wrapper, fn); - } + } - return exports; -})(); + return exports; +})(); export default _; \ No newline at end of file diff --git a/test/info.js b/test/info.js index ddc124c..9a3b02a 100644 --- a/test/info.js +++ b/test/info.js @@ -39,6 +39,12 @@ describe('info', function() { expect($tool.find('.eruda-content')).toContainText('eruda') }) + it('get', function() { + expect(tool.get()).toEqual([{ name: 'test', val: 'eruda' }]) + expect(tool.get('test')).toBe('eruda') + expect(tool.get('test2')).not.toBeDefined() + }) + it('remove', function() { tool.remove('test') expect($tool.find('li')).toHaveLength(0)