From 71a53b11c3df47737fb56eb991f2a99be086ba0a Mon Sep 17 00:00:00 2001 From: surunzi Date: Sun, 18 Aug 2019 01:39:10 +0800 Subject: [PATCH] release: v1.5.9 --- CHANGELOG.md | 6 + DOC.md | 2930 ++++++++++++++++++++++++------------------------ index.json | 9 +- package.json | 2 +- src/c/crc16.js | 1 + src/c/crc32.js | 1 + src/c/crc8.js | 1 + 7 files changed, 1481 insertions(+), 1469 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3104ba5..c379c71b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v1.5.9 (17 Aug 2019) + +* add: crc8 +* add: crc16 +* add: crc32 + ## v1.5.8 (12 Aug 2019) * add: eslint for release package diff --git a/DOC.md b/DOC.md index d2c1ac93..558ef832 100644 --- a/DOC.md +++ b/DOC.md @@ -1,7 +1,7 @@ -# Licia Documentation - -## $ - +# Licia Documentation + +## $ + jQuery like style dom manipulator. ### Available methods @@ -18,10 +18,10 @@ $btn.show(); $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. @@ -62,10 +62,10 @@ $attr('#test', { 'attr1': 'test', 'attr2': 'test' }); -``` - -## $class - +``` + +## $class + Element class manipulations. ### add @@ -113,10 +113,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. @@ -147,18 +147,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 @@ -167,10 +167,10 @@ function clickHandler() { } $event.on('#test', 'click', clickHandler); $event.off('#test', 'click', clickHandler); -``` - -## $insert - +``` + +## $insert + Insert html on different position. ### before @@ -204,10 +204,10 @@ $insert.prepend('#test', '
licia
'); // ->
licia
$insert.append('#test', '
licia
'); // ->
licia
-``` - -## $offset - +``` + +## $offset + Get the position of the element in document. |Name |Type |Desc | @@ -216,10 +216,10 @@ Get the position of the element in document. ```javascript $offset('#test'); // -> {left: 0, top: 0, width: 0, height: 0} -``` - -## $property - +``` + +## $property + Element property html, text, val getter and setter. ### html @@ -241,10 +241,10 @@ set the value of every matched element. ```javascript $property.html('#test', 'licia'); $property.html('#test'); // -> licia -``` - -## $remove - +``` + +## $remove + Remove the set of matched elements from the DOM. |Name |Type |Desc | @@ -253,10 +253,10 @@ Remove the set of matched elements from the DOM. ```javascript $remove('#test'); -``` - -## $safeEls - +``` + +## $safeEls + Convert value into an array, if it's a string, do querySelector. |Name |Type |Desc | @@ -268,10 +268,10 @@ Convert value into an array, if it's a string, do querySelector. $safeEls(document.querySelector('.test')); $safeEls(document.querySelectorAll('.test')); $safeEls('.test'); // -> Array of elements with test class -``` - -## $show - +``` + +## $show + Show elements. |Name |Type |Desc | @@ -280,10 +280,10 @@ Show elements. ```javascript $show('#test'); -``` - -## Blob - +``` + +## Blob + Use Blob when available, otherwise BlobBuilder. ### constructor @@ -295,10 +295,10 @@ Use Blob when available, otherwise BlobBuilder. ```javascript var blob = new Blob([]); -``` - -## Class - +``` + +## Class + Create JavaScript class. |Name |Type |Desc | @@ -336,10 +336,10 @@ var Student = People.extend({ var a = new Student('allen', 17, 'Hogwarts'); a.introduce(); // -> 'I am allen, 17 years old. \n I study at Hogwarts.' Student.is(a); // -> true -``` - -## Color - +``` + +## Color + Color converter. ### constructor @@ -374,10 +374,10 @@ Color.parse('rgb(170, 287, 204, 0.5)'); // -> {val: [170, 187, 204, 0.5], model: var color = new Color('#abc'); color.toRgb(); // -> 'rgb(170, 187, 204)' color.toHsl(); // -> 'hsl(210, 25%, 73%)' -``` - -## Dispatcher - +``` + +## Dispatcher + Flux dispatcher. [Related docs](https://facebook.github.io/flux/docs/dispatcher.html) @@ -394,10 +394,10 @@ dispatcher.register(function (payload) { dispatcher.dispatch({ actionType: 'action' }); -``` - -## Emitter - +``` + +## Emitter + Event emitter class which provides observer pattern. ### on @@ -439,10 +439,10 @@ var event = new Emitter(); event.on('test', function () { console.log('test') }); event.emit('test'); // Logs out 'test'. Emitter.mixin({}); -``` - -## Enum - +``` + +## Enum + Enum type implementation. ### constructor @@ -463,10 +463,10 @@ const val = 1; if (val === importance.CRITICAL) { // Do something. } -``` - -## JsonTransformer - +``` + +## JsonTransformer + Json to json transformer. ### constructor @@ -545,10 +545,10 @@ data.filter('books', function (book) { return book.price > 5 }); data.compute('author', function (author) { return author.firstname + author.lastname }); data.set('count', data.get('books').length); data.get(); // -> {books: [{title: 'Book 2', price: 10}], author: 'RedHoodSu', count: 1} -``` - -## LinkedList - +``` + +## LinkedList + Doubly-linked list implementation. ### size @@ -600,10 +600,10 @@ Convert the list to a JavaScript array. var linkedList = new LinkedList(); linkedList.push(5); linkedList.pop(); // -> 5 -``` - -## LocalStore - +``` + +## LocalStore + LocalStorage wrapper. Extend from Store. @@ -618,10 +618,10 @@ Extend from Store. ```javascript var store = new LocalStore('licia'); store.set('name', 'licia'); -``` - -## Logger - +``` + +## Logger + Simple logger with level filter. ### constructor @@ -669,10 +669,10 @@ logger.on('all', function (type, argList) { logger.on('debug', function (argList) { // Affected by log level. }); -``` - -## Lru - +``` + +## Lru + Simple LRU cache. ### constructor @@ -723,10 +723,10 @@ Clear cache. const cache = new Lru(50); cache.set('test', 'licia'); cache.get('test'); // -> 'licia' -``` - -## MediaQuery - +``` + +## MediaQuery + CSS media query listener. Extend from Emitter. @@ -757,10 +757,10 @@ mediaQuery.isMatch(); // -> false mediaQuery.on('match', () => { // Do something... }); -``` - -## MutationObserver - +``` + +## MutationObserver + Safe MutationObserver, does nothing if MutationObserver is not supported. ```javascript @@ -769,10 +769,10 @@ var observer = new MutationObserver(function (mutations) { }); observer.observe(document.documentElement); observer.disconnect(); -``` - -## Promise - +``` + +## Promise + Lightweight Promise implementation. [Promises spec](https://github.com/promises-aplus/promises-spec) @@ -793,10 +793,10 @@ function get(url) { get('test.json').then(function (result) { // Do something... }); -``` - -## PseudoMap - +``` + +## PseudoMap + Like es6 Map, without iterators. It supports only string keys, and uses Map if exists. @@ -805,10 +805,10 @@ It supports only string keys, and uses Map if exists. var map = new PseudoMap(); map.set('1', 1); map.get('1'); // -> 1 -``` - -## Queue - +``` + +## Queue + Queue data structure. ### clear @@ -855,10 +855,10 @@ queue.dequeue(); // -> 2 console.log(queue.size); // -> 1 queue.peek(); // -> 3 console.log(queue.size); // -> 1 -``` - -## QuickLru - +``` + +## QuickLru + LRU implementation without linked list. Inspired by the [hashlru algorithm](https://github.com/dominictarr/hashlru#algorithm). @@ -869,10 +869,10 @@ The api is the same as Lru module. const cache = new QuickLru(50); cache.set('test', 'licia'); cache.get('test'); // -> 'licia' -``` - -## ReduceStore - +``` + +## ReduceStore + Simplified redux like state container. ### constructor @@ -920,10 +920,10 @@ store.subscribe(function () { store.dispatch({type: 'INCREMENT'}); // 1 store.dispatch({type: 'INCREMENT'}); // 2 store.dispatch({type: 'DECREMENT'}); // 1 -``` - -## Select - +``` + +## Select + Simple wrapper of querySelectorAll to make dom selection easier. ### constructor @@ -953,10 +953,10 @@ var $test = new Select('#test'); $test.find('.test').each(function (idx, element) { // Manipulate dom nodes }); -``` - -## SessionStore - +``` + +## SessionStore + SessionStorage wrapper. Extend from Store. @@ -971,10 +971,10 @@ Extend from Store. ```javascript var store = new SessionStore('licia'); store.set('name', 'licia'); -``` - -## Stack - +``` + +## Stack + Stack data structure. ### clear @@ -1017,10 +1017,10 @@ var stack = new Stack(); stack.push(2); // -> 1 stack.push(3); // -> 2 stack.pop(); // -> 3 -``` - -## State - +``` + +## State + Simple state machine. Extend from Emitter. @@ -1059,10 +1059,10 @@ state.on('error', function (err, event) { // Error handler }); state.play('eustia'); -``` - -## Store - +``` + +## Store + Memory storage. Extend from Emitter. @@ -1137,10 +1137,10 @@ store.each(function (val, key) { store.on('change', function (key, newVal, oldVal) { // It triggers whenever set is called. }); -``` - -## Tween - +``` + +## Tween + Tween engine for JavaScript animations. Extend from Emitter. @@ -1189,10 +1189,10 @@ tween.on('update', function (target) { console.log(target.x, target.y); // -> 100, 100 }); tween.to({x: 100, y: 100}, 1000, 'inElastic').play(); -``` - -## Url - +``` + +## Url + Simple url manipulator. ### constructor @@ -1262,10 +1262,10 @@ console.log(url.port); // -> '8080' url.query.foo = 'bar'; url.rmQuery('eruda'); url.toString(); // -> 'http://example.com:8080/?foo=bar' -``` - -## Validator - +``` + +## Validator + Object values validation. ### constructor @@ -1311,10 +1311,10 @@ var validator = new Validator({ validator.validate({}); // -> 'test is required' validator.validate({test: 1}); // -> 'test should be a string with length 5'; validator.validate({test: 'licia'}); // -> true -``` - -## abbrev - +``` + +## abbrev + Calculate the set of unique abbreviations for a given set of strings. |Name |Type |Desc | @@ -1325,10 +1325,10 @@ Calculate the set of unique abbreviations for a given set of strings. ```javascript abbrev('lina', 'luna'); // -> {li: 'lina', lin: 'lina', lina: 'lina', lu: 'luna', lun: 'luna', luna: 'luna'} -``` - -## after - +``` + +## after + Create a function that invokes once it's called n or more times. |Name |Type |Desc | @@ -1341,10 +1341,10 @@ Create a function that invokes once it's called n or more times. var fn = after(5, function() { // -> Only invoke after fn is called 5 times. }); -``` - -## ajax - +``` + +## ajax + Perform an asynchronous HTTP request. |Name |Type |Desc | @@ -1394,10 +1394,10 @@ ajax({ ajax.get('http://example.com', {}, function (data) { // ... }); -``` - -## allKeys - +``` + +## allKeys + Retrieve all the names of object's own and inherited properties. |Name |Type |Desc | @@ -1420,10 +1420,10 @@ Members of Object's prototype won't be retrieved. var obj = Object.create({zero: 0}); obj.one = 1; allKeys(obj) // -> ['zero', 'one'] -``` - -## ansiColor - +``` + +## ansiColor + Ansi colors. ### Available colors @@ -1438,10 +1438,10 @@ bgBlackBright, bgRedBright, bgGreenBright, bgYellowBright, bgBlueBright, bgMagen ```javascript ansiColor.red('Warning'); -``` - -## arrToMap - +``` + +## arrToMap + Make an object map using array of strings. |Name |Type |Desc | @@ -1458,18 +1458,18 @@ const key = 'column-count'; let val = '5'; if (needPx[key]) val += 'px'; console.log(val); // -> '5px' -``` - -## atob - +``` + +## atob + Use Buffer to emulate atob when running in node. ```javascript atob('SGVsbG8gV29ybGQ='); // -> 'Hello World' -``` - -## average - +``` + +## average + Get average value of given numbers. |Name |Type |Desc | @@ -1479,10 +1479,10 @@ Get average value of given numbers. ```javascript average(5, 3, 1); // -> 3 -``` - -## base64 - +``` + +## base64 + Basic base64 encoding and decoding. ### encode @@ -1506,10 +1506,10 @@ Turn a base64 string into a byte array. ```javascript base64.encode([168, 174, 155, 255]); // -> 'qK6b/w==' base64.decode('qK6b/w=='); // -> [168, 174, 155, 255] -``` - -## before - +``` + +## before + Create a function that invokes less than n times. |Name |Type |Desc | @@ -1523,10 +1523,10 @@ Subsequent calls to the created function return the result of the last fn invoca ```javascript const fn = before(5, function() {}); fn(); // Allow function to be call 4 times at last. -``` - -## binarySearch - +``` + +## binarySearch + Binary search implementation. |Name |Type |Desc | @@ -1554,10 +1554,10 @@ binarySearch( return a.key < b.key ? -1 : 1; } ); // -> 0 -``` - -## bind - +``` + +## bind + Create a function bound to a given object. |Name |Type |Desc | @@ -1572,18 +1572,18 @@ var fn = bind(function (msg) { console.log(this.name + ':' + msg); }, {name: 'eustia'}, 'I am a utility library.'); fn(); // -> 'eustia: I am a utility library.' -``` - -## btoa - +``` + +## btoa + Use Buffer to emulate btoa when running in node. ```javascript btoa('Hello World'); // -> 'SGVsbG8gV29ybGQ=' -``` - -## bubbleSort - +``` + +## bubbleSort + Bubble sort implementation. |Name |Type |Desc | @@ -1594,10 +1594,10 @@ Bubble sort implementation. ```javascript bubbleSort([2, 1]); // -> [1, 2] -``` - -## bytesToStr - +``` + +## bytesToStr + Convert bytes to string. |Name |Type |Desc | @@ -1607,10 +1607,10 @@ Convert bytes to string. ```javascript bytesToStr([108, 105, 99, 105, 97]); // -> 'licia' -``` - -## callbackify - +``` + +## callbackify + Convert a function that returns a Promise to a function following the error-first callback style. |Name |Type |Desc | @@ -1630,10 +1630,10 @@ var cbFn = callbackify(fn); cbFn(function (err, value) { // ... }); -``` - -## camelCase - +``` + +## camelCase + Convert string to "camelCase". |Name |Type |Desc | @@ -1646,10 +1646,10 @@ camelCase('foo-bar'); // -> fooBar camelCase('foo bar'); // -> fooBar camelCase('foo_bar'); // -> fooBar camelCase('foo.bar'); // -> fooBar -``` - -## capitalize - +``` + +## capitalize + Convert the first character to upper case and the remaining to lower case. |Name |Type |Desc | @@ -1659,10 +1659,10 @@ Convert the first character to upper case and the remaining to lower case. ```javascript capitalize('rED'); // -> Red -``` - -## castPath - +``` + +## castPath + Cast value into a property path array. |Name |Type |Desc | @@ -1676,10 +1676,10 @@ castPath('a.b.c'); // -> ['a', 'b', 'c'] castPath(['a']); // -> ['a'] castPath('a[0].b'); // -> ['a', '0', 'b'] castPath('a.b.c', {'a.b.c': true}); // -> ['a.b.c'] -``` - -## centerAlign - +``` + +## centerAlign + Center align text in a string. |Name |Type |Desc | @@ -1692,10 +1692,10 @@ Center align text in a string. centerAlign('test', 8); // -> ' test' centerAlign('test\nlines', 8); // -> ' test\n lines' centerAlign(['test', 'lines'], 8); // -> ' test\n lines' -``` - -## char - +``` + +## char + Return string representing a character whose Unicode code point is the given integer. |Name |Type |Desc | @@ -1706,10 +1706,10 @@ Return string representing a character whose Unicode code point is the given int ```javascript char(65); // -> 'A' char(97); // -> 'a' -``` - -## chunk - +``` + +## chunk + Split array into groups the length of given size. |Name |Type |Desc | @@ -1722,10 +1722,10 @@ Split array into groups the length of given size. chunk([1, 2, 3, 4], 2); // -> [[1, 2], [3, 4]] chunk([1, 2, 3, 4], 3); // -> [[1, 2, 3], [4]] chunk([1, 2, 3, 4]); // -> [[1], [2], [3], [4]] -``` - -## clamp - +``` + +## clamp + Clamp number within the inclusive lower and upper bounds. |Name |Type |Desc | @@ -1741,10 +1741,10 @@ clamp(10, -5, 5); // -> 5 clamp(2, -5, 5); // -> 2 clamp(10, 5); // -> 5 clamp(2, 5); // -> 2 -``` - -## className - +``` + +## className + Utility for conditionally joining class names. |Name |Type |Desc | @@ -1758,10 +1758,10 @@ className('a', false, 'b', 0, 1, 'c'); // -> 'a b 1 c' className('a', ['b', 'c']); // -> 'a b c' className('a', {b: false, c: true}); // -> 'a c' className('a', ['b', 'c', {d: true, e: false}]); // -> 'a b c d'; -``` - -## clone - +``` + +## clone + Create a shallow-copied clone of the provided plain object. Any nested objects or arrays will be copied by reference, not duplicated. @@ -1773,10 +1773,10 @@ Any nested objects or arrays will be copied by reference, not duplicated. ```javascript clone({name: 'eustia'}); // -> {name: 'eustia'} -``` - -## cloneDeep - +``` + +## cloneDeep + Recursively clone value. |Name |Type|Desc | @@ -1788,10 +1788,10 @@ Recursively clone value. var obj = [{a: 1}, {a: 2}]; var obj2 = cloneDeep(obj); console.log(obj[0] === obj2[1]); // -> false -``` - -## cmpVersion - +``` + +## cmpVersion + Compare version strings. |Name |Type |Desc | @@ -1806,10 +1806,10 @@ cmpVersion('1.0.2', '1.0.2'); // -> 0 cmpVersion('2.0', '2.0.0'); // -> 0 cmpVersion('3.0.1', '3.0.0.2'); // -> 1 cmpVersion('1.1.1', '1.2.3'); // -> -1 -``` - -## combine - +``` + +## combine + Create an array by using one array for keys and another for its values. |Name |Type |Desc | @@ -1820,10 +1820,10 @@ Create an array by using one array for keys and another for its values. ```javascript combine(['a', 'b', 'c'], [1, 2, 3]); // -> {a: 1, b: 2, c: 3} -``` - -## compact - +``` + +## compact + Return a copy of the array with all falsy values removed. The values false, null, 0, "", undefined, and NaN are falsey. @@ -1835,10 +1835,10 @@ The values false, null, 0, "", undefined, and NaN are falsey. ```javascript compact([0, 1, false, 2, '', 3]); // -> [1, 2, 3] -``` - -## compose - +``` + +## compose + Compose a list of functions. Each function consumes the return value of the function that follows. @@ -1856,10 +1856,10 @@ var welcome = compose(function (name) { }); welcome('licia'); // -> 'hi: LICIA!' -``` - -## compressImg - +``` + +## compressImg + Compress image using canvas. |Name |Type |Desc | @@ -1890,10 +1890,10 @@ compressImg(file, { }, function (err, file) { // ... }); -``` - -## concat - +``` + +## concat + Concat multiple arrays into a single array. |Name |Type |Desc | @@ -1903,10 +1903,10 @@ Concat multiple arrays into a single array. ```javascript concat([1, 2], [3], [4, 5]); // -> [1, 2, 3, 4, 5] -``` - -## contain - +``` + +## contain + Check if the value is present in the list. |Name |Type |Desc | @@ -1919,10 +1919,10 @@ Check if the value is present in the list. contain([1, 2, 3], 1); // -> true contain({a: 1, b: 2}, 1); // -> true contain('abc', 'a'); // -> true -``` - -## convertBase - +``` + +## convertBase + Convert base of a number. |Name |Type |Desc | @@ -1935,10 +1935,10 @@ Convert base of a number. ```javascript convertBase('10', 2, 10); // -> '2' convertBase('ff', 16, 2); // -> '11111111' -``` - -## convertBin - +``` + +## convertBin + Convert binary data type. |Name |Type |Desc | @@ -1967,10 +1967,10 @@ convertBin('qK6b/w==', 'Uint8Array'); // -> [168, 174, 155, 255] convertBin.blobToArrBuffer(new Blob[]).then(arrBuffer => { // Do something... }); -``` - -## cookie - +``` + +## cookie + Simple api for handling browser cookies. ### get @@ -2007,10 +2007,10 @@ Remove cookie value. cookie.set('a', '1', {path: '/'}); cookie.get('a'); // -> '1' cookie.remove('a'); -``` - -## copy - +``` + +## copy + Copy text to clipboard using document.execCommand. |Name|Type |Desc | @@ -2022,10 +2022,10 @@ Copy text to clipboard using document.execCommand. copy('text', function (err) { // Handle errors. }); -``` - -## crc1 - +``` + +## crc1 + CRC1 implementation. |Name |Type |Desc | @@ -2036,10 +2036,10 @@ CRC1 implementation. ```javascript crc1('1234567890').toString(16); // -> 'd' -``` - -## crc16 - +``` + +## crc16 + CRC16 implementation. |Name |Type |Desc | @@ -2050,10 +2050,10 @@ CRC16 implementation. ```javascript crc16('1234567890').toString(16); // -> 'c57a' -``` - -## crc32 - +``` + +## crc32 + CRC32 implementation. |Name |Type |Desc | @@ -2064,10 +2064,10 @@ CRC32 implementation. ```javascript crc32('1234567890').toString(16); // -> '261daee5' -``` - -## crc8 - +``` + +## crc8 + CRC8 implementation. |Name |Type |Desc | @@ -2078,20 +2078,20 @@ CRC8 implementation. ```javascript crc8('1234567890').toString(16); // -> '52' -``` - -## createAssigner - +``` + +## createAssigner + Used to create extend, extendOwn and defaults. |Name |Type |Desc | |--------|--------|------------------------------| |keysFn |function|Function to get object keys | |defaults|boolean |No override when set to true | -|return |function|Result function, extend... | - -## createUrl - +|return |function|Result function, extend... | + +## createUrl + CreateObjectURL wrapper. |Name |Type |Desc | @@ -2105,10 +2105,10 @@ createUrl('test', {type: 'text/plain'}); // -> Blob url createUrl(['test', 'test']); createUrl(new Blob([])); createUrl(new File(['test'], 'test.txt')); -``` - -## cssSupports - +``` + +## cssSupports + Check if browser supports a given CSS feature. |Name |Type |Desc | @@ -2123,10 +2123,10 @@ cssSupports('display', 'invalid'); // -> false cssSupports('text-decoration-line', 'underline'); // -> true cssSupports('grid'); // -> true cssSupports('invalid'); // -> false -``` - -## curry - +``` + +## curry + Function currying. |Name |Type |Desc | @@ -2138,10 +2138,10 @@ Function currying. var add = curry(function (a, b) { return a + b }); var add1 = add(1); add1(2); // -> 3 -``` - -## dateFormat - +``` + +## dateFormat + Simple but extremely useful date format function. |Name |Type |Desc | @@ -2185,10 +2185,10 @@ Simple but extremely useful date format function. dateFormat('isoDate'); // -> 2016-11-19 dateFormat('yyyy-mm-dd HH:MM:ss'); // -> 2016-11-19 19:00:04 dateFormat(new Date(), 'yyyy-mm-dd'); // -> 2016-11-19 -``` - -## debounce - +``` + +## debounce + Return a new debounced version of the passed function. |Name |Type |Desc | @@ -2200,10 +2200,10 @@ Return a new debounced version of the passed function. ```javascript const calLayout = debounce(function () {}, 300); // $(window).resize(calLayout); -``` - -## debug - +``` + +## debug + A tiny JavaScript debugging utility. |Name |Type |Desc | @@ -2215,10 +2215,10 @@ A tiny JavaScript debugging utility. var d = debug('test'); d('doing lots of uninteresting work'); d.enabled = false; -``` - -## decodeUriComponent - +``` + +## decodeUriComponent + Better decodeURIComponent that does not throw if input is invalid. |Name |Type |Desc | @@ -2229,10 +2229,10 @@ Better decodeURIComponent that does not throw if input is invalid. ```javascript decodeUriComponent('%%25%'); // -> '%%%' decodeUriComponent('%E0%A4%A'); // -> '\xE0\xA4%A' -``` - -## defaults - +``` + +## defaults + Fill in undefined properties in object with the first value present in the following list of defaults objects. |Name |Type |Desc | @@ -2243,10 +2243,10 @@ Fill in undefined properties in object with the first value present in the follo ```javascript defaults({name: 'RedHood'}, {name: 'Unknown', age: 24}); // -> {name: 'RedHood', age: 24} -``` - -## define - +``` + +## define + Define a module, should be used along with use. |Name |Type |Desc | @@ -2264,10 +2264,10 @@ define('A', function () { define('B', ['A'], function (A) { return 'B' + A; }); -``` - -## defineProp - +``` + +## defineProp + Shortcut for Object.defineProperty(defineProperties). |Name |Type |Desc | @@ -2316,10 +2316,10 @@ defineProp(obj2, { // obj2.a is equal to 3 obj2.b = 4; // obj2.a is equal to 2 -``` - -## delRequireCache - +``` + +## delRequireCache + Delete node.js require cache. |Name|Type |Desc | @@ -2331,10 +2331,10 @@ const licia = require('licia'); licia.a = 5; delRequireCache('licia'); require('licia').a; // -> undefined -``` - -## delay - +``` + +## delay + Invoke function after certain milliseconds. |Name |Type |Desc | @@ -2348,10 +2348,10 @@ delay(function (text) { console.log(text); }, 1000, 'later'); // -> Logs 'later' after one second -``` - -## delegate - +``` + +## delegate + Event delegation. ### add @@ -2376,10 +2376,10 @@ function clickHandler() { } delegate.add(container, 'click', '.children', clickHandler); delegate.remove(container, 'click', '.children', clickHandler); -``` - -## deprecate - +``` + +## deprecate + Node.js util.deprecate with browser support. |Name |Type |Desc | @@ -2392,10 +2392,10 @@ Node.js util.deprecate with browser support. const fn = () => {}; const obsoleteFn = deprecate(fn); obsoleteFn(); -``` - -## detectBrowser - +``` + +## detectBrowser + Detect browser info using ua. |Name |Type |Desc | @@ -2410,18 +2410,18 @@ var browser = detectBrowser(); if (browser.name === 'ie' && browser.version < 9) { // Do something about old IE... } -``` - -## detectMocha - +``` + +## detectMocha + Detect if mocha is running. ```javascript detectMocha(); // -> True if mocha is running. -``` - -## detectOs - +``` + +## detectOs + Detect operating system using ua. |Name |Type |Desc | @@ -2435,10 +2435,10 @@ Supported os: windows, os x, linux, ios, android, windows phone if (detectOs() === 'ios') { // Do something about ios... } -``` - -## difference - +``` + +## difference + Create an array of unique array values not included in the other given array. |Name |Type |Desc | @@ -2449,10 +2449,10 @@ Create an array of unique array values not included in the other given array. ```javascript difference([3, 2, 1], [4, 2]); // -> [3, 1] -``` - -## dotCase - +``` + +## dotCase + Convert string to "dotCase". |Name |Type |Desc | @@ -2463,10 +2463,10 @@ Convert string to "dotCase". ```javascript dotCase('fooBar'); // -> foo.bar dotCase('foo bar'); // -> foo.bar -``` - -## download - +``` + +## download + Trigger a file download on client side. |Name |Type |Desc | @@ -2477,10 +2477,10 @@ Trigger a file download on client side. ```javascript download('test', 'test.txt'); -``` - -## each - +``` + +## each + Iterate over elements of collection and invokes iterator for each element. |Name |Type |Desc | @@ -2491,10 +2491,10 @@ Iterate over elements of collection and invokes iterator for each element. ```javascript each({'a': 1, 'b': 2}, function (val, key) {}); -``` - -## easing - +``` + +## easing + Easing functions adapted from http://jqueryui.com/ . |Name |Type |Desc | @@ -2505,10 +2505,10 @@ Easing functions adapted from http://jqueryui.com/ . ```javascript easing.linear(0.5); // -> 0.5 easing.inElastic(0.5, 500); // -> 0.03125 -``` - -## endWith - +``` + +## endWith + Check if string ends with the given target string. |Name |Type |Desc | @@ -2519,10 +2519,10 @@ Check if string ends with the given target string. ```javascript endWith('ab', 'b'); // -> true -``` - -## escape - +``` + +## escape + Escapes a string for insertion into HTML, replacing &, <, >, ", `, and ' characters. |Name |Type |Desc | @@ -2532,10 +2532,10 @@ Escapes a string for insertion into HTML, replacing &, <, >, ", `, and ' charact ```javascript escape('You & Me'); // -> 'You & Me' -``` - -## escapeJsStr - +``` + +## escapeJsStr + Escape string to be a valid JavaScript string literal between quotes. http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4 @@ -2547,10 +2547,10 @@ http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4 ```javascript escapeJsStr('\"\n'); // -> '\\"\\\\n' -``` - -## escapeRegExp - +``` + +## escapeRegExp + Escape special chars to be used as literals in RegExp constructors. |Name |Type |Desc | @@ -2560,10 +2560,10 @@ Escape special chars to be used as literals in RegExp constructors. ```javascript escapeRegExp('[licia]'); // -> '\\[licia\\]' -``` - -## evalCss - +``` + +## evalCss + Load css into page. |Name|Type |Desc | @@ -2572,10 +2572,10 @@ Load css into page. ```javascript evalCss('body{background:#08c}'); -``` - -## evalJs - +``` + +## evalJs + Execute js in given context. |Name |Type |Desc | @@ -2586,10 +2586,10 @@ Execute js in given context. ```javascript evalJs('5+2'); // -> 7 evalJs('this.a', {a: 2}); // -> 2 -``` - -## every - +``` + +## every + Check if predicate return truthy for all elements. |Name |Type |Desc | @@ -2603,10 +2603,10 @@ Check if predicate return truthy for all elements. every([2, 4], function (val) { return val % 2 === 0; }); // -> false -``` - -## extend - +``` + +## extend + Copy all of the properties in the source objects over to the destination object. |Name |Type |Desc | @@ -2617,10 +2617,10 @@ Copy all of the properties in the source objects over to the destination object. ```javascript extend({name: 'RedHood'}, {age: 24}); // -> {name: 'RedHood', age: 24} -``` - -## extendDeep - +``` + +## extendDeep + Recursive object extending. |Name |Type |Desc | @@ -2642,10 +2642,10 @@ extendDeep({ } }); // -> {name: 'RedHood', family: {mother: 'Jane', father: 'Jack', brother: 'Bruce'}} -``` - -## extendOwn - +``` + +## extendOwn + Like extend, but only copies own properties over to the destination object. |Name |Type |Desc | @@ -2656,10 +2656,10 @@ Like extend, but only copies own properties over to the destination object. ```javascript extendOwn({name: 'RedHood'}, {age: 24}); // -> {name: 'RedHood', age: 24} -``` - -## extractBlockCmts - +``` + +## extractBlockCmts + Extract block comments from source code. |Name |Type |Desc | @@ -2669,10 +2669,10 @@ Extract block comments from source code. ```javascript extractBlockCmts('\/*licia*\/'); // -> ['licia'] -``` - -## extractUrls - +``` + +## extractUrls + Extract urls from plain text. |Name |Type |Desc | @@ -2683,10 +2683,10 @@ Extract urls from plain text. ```javascript var str = '[Official site: http://eustia.liriliri.io](http://eustia.liriliri.io)'; extractUrls(str); // -> ['http://eustia.liriliri.io'] -``` - -## fetch - +``` + +## fetch + Turn XMLHttpRequest into promise like. Note: This is not a complete fetch pollyfill. @@ -2708,10 +2708,10 @@ fetch('test.json', { }).then(function (data) { console.log(data); }); -``` - -## fibonacci - +``` + +## fibonacci + Calculate fibonacci number. |Name |Type |Desc | @@ -2722,10 +2722,10 @@ Calculate fibonacci number. ```javascript fibonacci(1); // -> 1 fibonacci(3); // -> 2 -``` - -## fileSize - +``` + +## fileSize + Turn bytes into human readable file size. |Name |Type |Desc | @@ -2739,10 +2739,10 @@ fileSize(1500); // -> '1.46K' fileSize(1500000); // -> '1.43M' fileSize(1500000000); // -> '1.4G' fileSize(1500000000000); // -> '1.36T' -``` - -## fileType - +``` + +## fileType + Detect file type using magic number. |Name |Type |Desc | @@ -2758,10 +2758,10 @@ jpg, png, gif, webp, bmp, gz, zip, rar, pdf, exe const fs = require('fs'); const file = fs.readFileSync('path/to/file'); console.log(fileType(file)); // -> { ext: 'jpg', mime: 'image/jpeg' } -``` - -## fill - +``` + +## fill + Fill elements of array with value. |Name |Type |Desc | @@ -2775,10 +2775,10 @@ Fill elements of array with value. ```javascript fill([1, 2, 3], '*'); // -> ['*', '*', '*'] fill([1, 2, 3], '*', 1, 2); // -> [1, '*', 3] -``` - -## filter - +``` + +## filter + Iterates over elements of collection, returning an array of all the values that pass a truth test. |Name |Type |Desc | @@ -2792,10 +2792,10 @@ Iterates over elements of collection, returning an array of all the values that filter([1, 2, 3, 4, 5], function (val) { return val % 2 === 0; }); // -> [2, 4] -``` - -## find - +``` + +## find + Find the first value that passes a truth test in a collection. |Name |Type |Desc | @@ -2815,10 +2815,10 @@ find([{ }], function (val) { return val.age === 23; }); // -> {name: 'jane', age: 23} -``` - -## findIdx - +``` + +## findIdx + Return the first index where the predicate truth test passes. |Name |Type |Desc | @@ -2837,10 +2837,10 @@ findIdx([{ }], function (val) { return val.age === 23; }); // -> 1 -``` - -## findKey - +``` + +## findKey + Return the first key where the predicate truth test passes. |Name |Type |Desc | @@ -2854,10 +2854,10 @@ Return the first key where the predicate truth test passes. findKey({a: 1, b: 2}, function (val) { return val === 1; }); // -> a -``` - -## findLastIdx - +``` + +## findLastIdx + Return the last index where the predicate truth test passes. |Name |Type |Desc | @@ -2879,10 +2879,10 @@ findLastIdx([{ }], function (val) { return val.age === 24; }); // -> 2 -``` - -## flatten - +``` + +## flatten + Recursively flatten an array. |Name |Type |Desc | @@ -2892,10 +2892,10 @@ Recursively flatten an array. ```javascript flatten(['a', ['b', ['c']], 'd', ['e']]); // -> ['a', 'b', 'c', 'd', 'e'] -``` - -## fnArgs - +``` + +## fnArgs + Validate function arguments. |Name |Type |Desc | @@ -2920,10 +2920,10 @@ test('test', () => {}, 5); test(); // Throw error test('test', 'test'); // Throw error test('test', () => {}, 5, 'test') // Throw error -``` - -## fnParams - +``` + +## fnParams + Get a function parameter's names. |Name |Type |Desc | @@ -2933,10 +2933,10 @@ Get a function parameter's names. ```javascript fnParams(function (a, b) {}); // -> ['a', 'b'] -``` - -## format - +``` + +## format + Format string in a printf-like format. |Name |Type |Desc | @@ -2956,10 +2956,10 @@ Format string in a printf-like format. ```javascript format('%s_%s', 'foo', 'bar'); // -> 'foo bar' -``` - -## fraction - +``` + +## fraction + Convert number to fraction. |Name |Type |Desc | @@ -2969,10 +2969,10 @@ Convert number to fraction. ```javascript fraction(1.2); // -> '6/5' -``` - -## freeze - +``` + +## freeze + Shortcut for Object.freeze. Use Object.defineProperties if Object.freeze is not supported. @@ -2987,10 +2987,10 @@ var a = {b: 1}; freeze(a); a.b = 2; console.log(a); // -> {b: 1} -``` - -## freezeDeep - +``` + +## freezeDeep + Recursively use Object.freeze. |Name |Type |Desc | @@ -3003,10 +3003,10 @@ var a = {b: {c: 1}}; freezeDeep(a); a.b.c = 2; console.log(a); // -> {b: {c: 1}} -``` - -## fs - +``` + +## fs + Promised version of node.js fs module. ```javascript @@ -3015,10 +3015,10 @@ fs.readFile('test.js').then(function (data) { }).catch(function (err) { // Handle errors }); -``` - -## fullscreen - +``` + +## fullscreen + Fullscreen api wrapper. ### request @@ -3058,10 +3058,10 @@ fullscreen.request(); fullscreen.isActive(); // -> false, not a synchronous api fullscreen.on('error', () => {}); fullscreen.on('change', () => {}); -``` - -## fuzzySearch - +``` + +## fuzzySearch + Simple fuzzy search. |Name |Type |Desc | @@ -3086,10 +3086,10 @@ fuzzySearch('alpha-test', [{ }], { key: 'name' }); // -> [{ name: 'alpha-test-1' }] -``` - -## gcd - +``` + +## gcd + Compute the greatest common divisor using Euclid's algorithm. |Name |Type |Desc | @@ -3100,10 +3100,10 @@ Compute the greatest common divisor using Euclid's algorithm. ```javascript gcd(121, 44); // -> 11 -``` - -## getPort - +``` + +## getPort + Get an available TCP port. |Name |Type |Desc | @@ -3118,10 +3118,10 @@ If preferred ports are not available, a random port will be returned. getPort([3000, 3001], '127.0.0.1').then(port => { console.log(port); }); -``` - -## getProto - +``` + +## getProto + Get prototype of an object. |Name |Type|Desc | @@ -3132,10 +3132,10 @@ Get prototype of an object. ```javascript const a = {}; getProto(Object.create(a)); // -> a -``` - -## getUrlParam - +``` + +## getUrlParam + Get url param. |Name |Type |Desc | @@ -3146,10 +3146,10 @@ Get url param. ```javascript getUrlParam('test', 'http://example.com/?test=true'); // -> 'true' -``` - -## golangify - +``` + +## golangify + Handle errors like golang. |Name |Type |Desc | @@ -3174,10 +3174,10 @@ Handle errors like golang. await golangify(Promise.reject(Error('err'))); // -> [undefined, Error] await golangify(Promise.resolve(4)); // -> [4, null] })(); -``` - -## h - +``` + +## h + Create html with JavaScript. |Name |Type |Desc | @@ -3193,10 +3193,10 @@ const el = h('div#test.title', { title: 'test' }, 'inner text'); document.body.appendChild(el); -``` - -## has - +``` + +## has + Checks if key is a direct property. |Name |Type |Desc | @@ -3207,10 +3207,10 @@ Checks if key is a direct property. ```javascript has({one: 1}, 'one'); // -> true -``` - -## highlight - +``` + +## highlight + Highlight code. |Name |Type |Desc | @@ -3228,10 +3228,10 @@ comment, string, number, keyword, operator highlight('const a = 5;', 'js', { number: 'color:#0086b3;' }); // -> 'const a = 5;' -``` - -## hotkey - +``` + +## hotkey + Capture keyboard input to trigger given events. ### on @@ -3254,10 +3254,10 @@ hotkey.on('k', function () { function keyDown() {} hotkey.on('shift+a, shift+b', keyDown); hotkey.off('shift+a', keyDown); -``` - -## hslToRgb - +``` + +## hslToRgb + Convert hsl to rgb. |Name |Type |Desc | @@ -3267,10 +3267,10 @@ Convert hsl to rgb. ```javascript hslToRgb([165, 59, 50, 0.8]); // -> [52, 203, 165, 0.8] -``` - -## identity - +``` + +## identity + Return the first argument given. |Name |Type|Desc | @@ -3280,10 +3280,10 @@ Return the first argument given. ```javascript identity('a'); // -> 'a' -``` - -## idxOf - +``` + +## idxOf + Get the index at which the first occurrence of value. |Name |Type |Desc | @@ -3295,10 +3295,10 @@ Get the index at which the first occurrence of value. ```javascript idxOf([1, 2, 1, 2], 2, 2); // -> 3 -``` - -## indent - +``` + +## indent + Indent each line in a string. |Name |Type |Desc | @@ -3310,10 +3310,10 @@ Indent each line in a string. ```javascript indent('foo\nbar', ' ', 4); // -> ' foo\n bar' -``` - -## inherits - +``` + +## inherits + Inherit the prototype methods from one constructor into another. |Name |Type |Desc | @@ -3336,10 +3336,10 @@ function Student(name) { inherits(Student, People); var s = new Student('RedHood'); s.getName(); // -> 'RedHood' -``` - -## ini - +``` + +## ini + Ini parser and serializer. ### parse @@ -3380,10 +3380,10 @@ alias[] = red `); // -> {library: 'licia', user: {info: {name: 'surunzi', alias: ['redhoodsu', 'red']}}} ini.stringify(config); -``` - -## insertionSort - +``` + +## insertionSort + Insertion sort implementation. |Name |Type |Desc | @@ -3394,10 +3394,10 @@ Insertion sort implementation. ```javascript insertionSort([2, 1]); // -> [1, 2] -``` - -## intersect - +``` + +## intersect + Compute the list of values that are the intersection of all the arrays. |Name |Type |Desc | @@ -3407,10 +3407,10 @@ Compute the list of values that are the intersection of all the arrays. ```javascript intersect([1, 2, 3, 4], [2, 1, 10], [2, 1]); // -> [1, 2] -``` - -## intersectRange - +``` + +## intersectRange + Intersect two ranges. |Name |Type |Desc | @@ -3424,10 +3424,10 @@ intersectRange({start: 0, end: 12}, {start: 11, end: 13}); // -> {start: 11, end: 12} intersectRange({start: 0, end: 5}, {start: 6, end: 7}); // -> undefined -``` - -## invert - +``` + +## invert + Create an object composed of the inverted keys and values of object. |Name |Type |Desc | @@ -3439,10 +3439,10 @@ If object contains duplicate values, subsequent values overwrite property assign ```javascript invert({a: 'b', c: 'd', e: 'f'}); // -> {b: 'a', d: 'c', f: 'e'} -``` - -## isAbsoluteUrl - +``` + +## isAbsoluteUrl + Check if an url is absolute. |Name |Type |Desc | @@ -3454,10 +3454,10 @@ Check if an url is absolute. isAbsoluteUrl('http://www.surunzi.com'); // -> true isAbsoluteUrl('//www.surunzi.com'); // -> false isAbsoluteUrl('surunzi.com'); // -> false -``` - -## isArgs - +``` + +## isArgs + Check if value is classified as an arguments object. |Name |Type |Desc | @@ -3469,10 +3469,10 @@ Check if value is classified as an arguments object. (function () { isArgs(arguments); // -> true })(); -``` - -## isArr - +``` + +## isArr + Check if value is an `Array` object. |Name |Type |Desc | @@ -3483,10 +3483,10 @@ Check if value is an `Array` object. ```javascript isArr([]); // -> true isArr({}); // -> false -``` - -## isArrBuffer - +``` + +## isArrBuffer + Check if value is an ArrayBuffer. |Name |Type |Desc | @@ -3496,10 +3496,10 @@ Check if value is an ArrayBuffer. ```javascript isArrBuffer(new ArrayBuffer(8)); // -> true -``` - -## isArrLike - +``` + +## isArrLike + Check if value is array-like. |Name |Type |Desc | @@ -3513,10 +3513,10 @@ Function returns false. isArrLike('test'); // -> true isArrLike(document.body.children); // -> true; isArrLike([1, 2, 3]); // -> true -``` - -## isBlob - +``` + +## isBlob + Check if value is a Blob. |Name |Type |Desc | @@ -3527,10 +3527,10 @@ Check if value is a Blob. ```javascript isBlob(new Blob([])); // -> true; isBlob([]); // -> false -``` - -## isBool - +``` + +## isBool + Check if value is a boolean primitive. |Name |Type |Desc | @@ -3542,18 +3542,18 @@ Check if value is a boolean primitive. isBool(true); // -> true isBool(false); // -> true isBool(1); // -> false -``` - -## isBrowser - +``` + +## isBrowser + Check if running in a browser. ```javascript console.log(isBrowser); // -> true if running in a browser -``` - -## isBuffer - +``` + +## isBuffer + Check if value is a buffer. |Name |Type |Desc | @@ -3563,10 +3563,10 @@ Check if value is a buffer. ```javascript isBuffer(new Buffer(4)); // -> true -``` - -## isClose - +``` + +## isClose + Check if values are close(almost equal) to each other. `abs(a-b) <= max(relTol * max(abs(a), abs(b)), absTol)` @@ -3584,10 +3584,10 @@ isClose(1, 1.0000000001); // -> true isClose(1, 2); // -> false isClose(1, 1.2, 0.3); // -> true isClose(1, 1.2, 0.1, 0.3); // -> true -``` - -## isDataUrl - +``` + +## isDataUrl + Check if a string is a valid data url. |Name |Type |Desc | @@ -3598,10 +3598,10 @@ Check if a string is a valid data url. ```javascript isDataUrl('http://eustia.liriliri.io'); // -> false isDataUrl('data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D'); // -> true -``` - -## isDate - +``` + +## isDate + Check if value is classified as a Date object. |Name |Type |Desc | @@ -3611,10 +3611,10 @@ Check if value is classified as a Date object. ```javascript isDate(new Date()); // -> true -``` - -## isEl - +``` + +## isEl + Check if value is a DOM element. |Name |Type |Desc | @@ -3624,10 +3624,10 @@ Check if value is a DOM element. ```javascript isEl(document.body); // -> true -``` - -## isEmail - +``` + +## isEmail + Loosely validate an email address. |Name |Type |Desc | @@ -3637,10 +3637,10 @@ Loosely validate an email address. ```javascript isEmail('surunzi@foxmail.com'); // -> true -``` - -## isEmpty - +``` + +## isEmpty + Check if value is an empty object or array. |Name |Type |Desc | @@ -3652,10 +3652,10 @@ Check if value is an empty object or array. isEmpty([]); // -> true isEmpty({}); // -> true isEmpty(''); // -> true -``` - -## isEqual - +``` + +## isEqual + Performs an optimized deep comparison between the two objects, to determine if they should be considered equal. |Name |Type |Desc | @@ -3666,10 +3666,10 @@ Performs an optimized deep comparison between the two objects, to determine if t ```javascript isEqual([1, 2, 3], [1, 2, 3]); // -> true -``` - -## isErr - +``` + +## isErr + Check if value is an error. |Name |Type |Desc | @@ -3679,10 +3679,10 @@ Check if value is an error. ```javascript isErr(new Error()); // -> true -``` - -## isEven - +``` + +## isEven + Check if number is even. |Name |Type |Desc | @@ -3694,10 +3694,10 @@ Check if number is even. isEven(0); // -> true isEven(1); // -> false isEven(2); // -> true -``` - -## isFile - +``` + +## isFile + Check if value is a file. |Name |Type |Desc | @@ -3707,10 +3707,10 @@ Check if value is a file. ```javascript isFile(new File(['test'], "test.txt", {type: "text/plain"})); // -> true -``` - -## isFinite - +``` + +## isFinite + Check if value is a finite primitive number. |Name |Type |Desc | @@ -3721,10 +3721,10 @@ Check if value is a finite primitive number. ```javascript isFinite(3); // -> true isFinite(Infinity); // -> false -``` - -## isFn - +``` + +## isFn + Check if value is a function. |Name |Type |Desc | @@ -3738,10 +3738,10 @@ Generator function is also classified as true. isFn(function() {}); // -> true isFn(function*() {}); // -> true isFn(async function() {}); // -> true -``` - -## isGeneratorFn - +``` + +## isGeneratorFn + Check if value is a generator function. |Name |Type |Desc | @@ -3752,10 +3752,10 @@ Check if value is a generator function. ```javascript isGeneratorFn(function * () {}); // -> true; isGeneratorFn(function () {}); // -> false; -``` - -## isInt - +``` + +## isInt + Checks if value is classified as a Integer. |Name |Type |Desc | @@ -3767,10 +3767,10 @@ Checks if value is classified as a Integer. isInt(5); // -> true isInt(5.1); // -> false isInt({}); // -> false -``` - -## isIp - +``` + +## isIp + Check if value is an IP address. |Name |Type |Desc | @@ -3792,10 +3792,10 @@ isIp('1:2:3:4:5:6:7:8'); // -> true isIp('test'); // -> false isIp.v4('192.168.191.1'); // -> true isIp.v6('1:2:3:4:5:6:7:8'); // -> true -``` - -## isJson - +``` + +## isJson + Check if value is a valid JSON. It uses `JSON.parse()` and a `try... catch` block. @@ -3808,10 +3808,10 @@ It uses `JSON.parse()` and a `try... catch` block. ```javascript isJson('{"a": 5}'); // -> true isJson("{'a': 5}"); // -> false -``` - -## isLeapYear - +``` + +## isLeapYear + Check if a year is a leap year. |Name |Type |Desc | @@ -3822,10 +3822,10 @@ Check if a year is a leap year. ```javascript isLeapYear(2000); // -> true isLeapYear(2002); // -> false -``` - -## isMap - +``` + +## isMap + Check if value is a Map object. |Name |Type |Desc | @@ -3836,10 +3836,10 @@ Check if value is a Map object. ```javascript isMap(new Map()); // -> true isMap(new WeakMap()); // -> false -``` - -## isMatch - +``` + +## isMatch + Check if keys and values in src are contained in obj. |Name |Type |Desc | @@ -3850,18 +3850,18 @@ Check if keys and values in src are contained in obj. ```javascript isMatch({a: 1, b: 2}, {a: 1}); // -> true -``` - -## isMiniProgram - +``` + +## isMiniProgram + Check if running in wechat mini program. ```javascript console.log(isMiniProgram); // -> true if running in mini program. -``` - -## isMobile - +``` + +## isMobile + Check whether client is using a mobile browser using ua. |Name |Type |Desc | @@ -3871,10 +3871,10 @@ Check whether client is using a mobile browser using ua. ```javascript isMobile(navigator.userAgent); -``` - -## isNaN - +``` + +## isNaN + Check if value is an NaN. |Name |Type |Desc | @@ -3887,10 +3887,10 @@ Undefined is not an NaN, different from global isNaN function. ```javascript isNaN(0); // -> false isNaN(NaN); // -> true -``` - -## isNative - +``` + +## isNative + Check if value is a native function. |Name |Type |Desc | @@ -3901,10 +3901,10 @@ Check if value is a native function. ```javascript isNative(function () {}); // -> false isNative(Math.min); // -> true -``` - -## isNil - +``` + +## isNil + Check if value is null or undefined, the same as value == null. |Name |Type |Desc | @@ -3919,18 +3919,18 @@ isNil(undefined); // -> true isNil(false); // -> false isNil(0); // -> false isNil([]); // -> false -``` - -## isNode - +``` + +## isNode + Check if running in node. ```javascript console.log(isNode); // -> true if running in node -``` - -## isNull - +``` + +## isNull + Check if value is an Null. |Name |Type |Desc | @@ -3940,10 +3940,10 @@ Check if value is an Null. ```javascript isNull(null); // -> true -``` - -## isNum - +``` + +## isNum + Check if value is classified as a Number primitive or object. |Name |Type |Desc | @@ -3955,10 +3955,10 @@ Check if value is classified as a Number primitive or object. isNum(5); // -> true isNum(5.1); // -> true isNum({}); // -> false -``` - -## isNumeric - +``` + +## isNumeric + Check if value is numeric. |Name |Type |Desc | @@ -3974,10 +3974,10 @@ isNumeric(0xFF); // -> true isNumeric(''); // -> false isNumeric('1.1.1'); // -> false isNumeric(NaN); // -> false -``` - -## isObj - +``` + +## isObj + Check if value is the language type of Object. |Name |Type |Desc | @@ -3990,10 +3990,10 @@ Check if value is the language type of Object. ```javascript isObj({}); // -> true isObj([]); // -> true -``` - -## isOdd - +``` + +## isOdd + Check if number is odd. |Name |Type |Desc | @@ -4005,10 +4005,10 @@ Check if number is odd. isOdd(0); // -> false isOdd(1); // -> true isOdd(2); // -> false -``` - -## isPlainObj - +``` + +## isPlainObj + Check if value is an object created by Object constructor. |Name |Type |Desc | @@ -4020,10 +4020,10 @@ Check if value is an object created by Object constructor. isPlainObj({}); // -> true isPlainObj([]); // -> false isPlainObj(function () {}); // -> false -``` - -## isPortFree - +``` + +## isPortFree + Check if a TCP port is free. |Name |Type |Desc | @@ -4036,10 +4036,10 @@ Check if a TCP port is free. isPortFree(3000).then(isFree => { // Do something. }); -``` - -## isPrime - +``` + +## isPrime + Check if the provided integer is a prime number. |Name |Type |Desc | @@ -4050,10 +4050,10 @@ Check if the provided integer is a prime number. ```javascript isPrime(11); // -> true isPrime(8); // -> false -``` - -## isPrimitive - +``` + +## isPrimitive + Check if value is string, number, boolean or null. |Name |Type |Desc | @@ -4065,10 +4065,10 @@ Check if value is string, number, boolean or null. isPrimitive(5); // -> true isPrimitive('abc'); // -> true isPrimitive(false); // -> true -``` - -## isPromise - +``` + +## isPromise + Check if value looks like a promise. |Name |Type |Desc | @@ -4079,10 +4079,10 @@ Check if value looks like a promise. ```javascript isPromise(new Promise(function () {})); // -> true isPromise({}); // -> false -``` - -## isRegExp - +``` + +## isRegExp + Check if value is a regular expression. |Name |Type |Desc | @@ -4092,10 +4092,10 @@ Check if value is a regular expression. ```javascript isRegExp(/a/); // -> true -``` - -## isRelative - +``` + +## isRelative + Check if path appears to be relative. |Name |Type |Desc | @@ -4105,18 +4105,18 @@ Check if path appears to be relative. ```javascript isRelative('README.md'); // -> true -``` - -## isRetina - +``` + +## isRetina + Determine if running on a high DPR device or not. ```javascript console.log(isRetina); // -> true if high DPR -``` - -## isSet - +``` + +## isSet + Check if value is a Set object. |Name |Type |Desc | @@ -4127,10 +4127,10 @@ Check if value is a Set object. ```javascript isSet(new Set()); // -> true isSet(new WeakSet()); // -> false -``` - -## isSorted - +``` + +## isSorted + Check if an array is sorted. |Name |Type |Desc | @@ -4142,10 +4142,10 @@ Check if an array is sorted. ```javascript isSorted([1, 2, 3]); // -> true isSorted([3, 2, 1]); // -> false -``` - -## isStr - +``` + +## isStr + Check if value is a string primitive. |Name |Type |Desc | @@ -4155,10 +4155,10 @@ Check if value is a string primitive. ```javascript isStr('licia'); // -> true -``` - -## isStream - +``` + +## isStream + Check if value is a Node.js stream. |Name |Type |Desc | @@ -4170,10 +4170,10 @@ Check if value is a Node.js stream. var stream = require('stream'); isStream(new stream.Stream()); // -> true -``` - -## isSymbol - +``` + +## isSymbol + Check if value is a symbol. |Name |Type |Desc | @@ -4183,10 +4183,10 @@ Check if value is a symbol. ```javascript isSymbol(Symbol('test')); // -> true -``` - -## isTypedArr - +``` + +## isTypedArr + Check if value is a typed array. |Name |Type |Desc | @@ -4197,10 +4197,10 @@ Check if value is a typed array. ```javascript isTypedArr([]); // -> false isTypedArr(new Uint8Array(8)); // -> true -``` - -## isUndef - +``` + +## isUndef + Check if value is undefined. |Name |Type |Desc | @@ -4211,10 +4211,10 @@ Check if value is undefined. ```javascript isUndef(void 0); // -> true isUndef(null); // -> false -``` - -## isUrl - +``` + +## isUrl + Loosely validate an url. |Name |Type |Desc | @@ -4224,10 +4224,10 @@ Loosely validate an url. ```javascript isUrl('http://www.example.com?foo=bar¶m=test'); // -> true -``` - -## isWeakMap - +``` + +## isWeakMap + Check if value is a WeakMap object. |Name |Type |Desc | @@ -4238,10 +4238,10 @@ Check if value is a WeakMap object. ```javascript isWeakMap(new Map()); // -> false isWeakMap(new WeakMap()); // -> true -``` - -## isWeakSet - +``` + +## isWeakSet + Check if value is a WeakSet object. |Name |Type |Desc | @@ -4252,18 +4252,18 @@ Check if value is a WeakSet object. ```javascript isWeakSet(new Set()); // -> false isWeakSet(new WeakSet()); // -> true -``` - -## isWindows - +``` + +## isWindows + Check if platform is windows. ```javascript console.log(isWindows); // -> true if running on windows -``` - -## jsonp - +``` + +## jsonp + A simple jsonp implementation. |Name|Type |Desc | @@ -4291,10 +4291,10 @@ jsonp({ // ... } }); -``` - -## kebabCase - +``` + +## kebabCase + Convert string to "kebabCase". |Name |Type |Desc | @@ -4307,10 +4307,10 @@ kebabCase('fooBar'); // -> foo-bar kebabCase('foo bar'); // -> foo-bar kebabCase('foo_bar'); // -> foo-bar kebabCase('foo.bar'); // -> foo-bar -``` - -## keyCode - +``` + +## keyCode + Key codes and key names conversion. Get key code's name. @@ -4330,10 +4330,10 @@ Get key name's code. ```javascript keyCode(13); // -> 'enter' keyCode('enter'); // -> 13 -``` - -## keys - +``` + +## keys + Create an array of the own enumerable property names of object. |Name |Type |Desc | @@ -4343,10 +4343,10 @@ Create an array of the own enumerable property names of object. ```javascript keys({a: 1}); // -> ['a'] -``` - -## kill - +``` + +## kill + Kill process. |Name|Type|Desc| @@ -4355,10 +4355,10 @@ Kill process. ```javascript kill(9420); -``` - -## last - +``` + +## last + Get the last element of array. |Name |Type |Desc | @@ -4368,10 +4368,10 @@ Get the last element of array. ```javascript last([1, 2]); // -> 2 -``` - -## lazyRequire - +``` + +## lazyRequire + Require modules lazily. ```javascript @@ -4381,10 +4381,10 @@ var _ = r('underscore'); // underscore is required only when _ is called. _().isNumber(5); -``` - -## levenshtein - +``` + +## levenshtein + Levenshtein distance implementation. |Name |Type |Desc | @@ -4395,10 +4395,10 @@ Levenshtein distance implementation. ```javascript levenshtein('cat', 'cake'); // -> 2 -``` - -## linkify - +``` + +## linkify + Hyperlink urls in a string. |Name |Type |Desc | @@ -4413,10 +4413,10 @@ linkify(str); // -> 'Official site: http://e linkify(str, function (url) { return '' + url + ''; }); -``` - -## loadCss - +``` + +## loadCss + Inject link tag into page with given href value. |Name|Type |Desc | @@ -4428,10 +4428,10 @@ Inject link tag into page with given href value. loadCss('style.css', function (isLoaded) { // Do something... }); -``` - -## loadImg - +``` + +## loadImg + Load image with given src. |Name|Type |Desc | @@ -4443,10 +4443,10 @@ Load image with given src. loadImg('http://eustia.liriliri.io/img.jpg', function (err, img) { console.log(img.width, img.height); }); -``` - -## loadJs - +``` + +## loadJs + Inject script tag into page with given src value. |Name|Type |Desc | @@ -4458,10 +4458,10 @@ Inject script tag into page with given src value. loadJs('main.js', function (isLoaded) { // Do something... }); -``` - -## longest - +``` + +## longest + Get the longest item in an array. |Name |Type |Desc | @@ -4471,10 +4471,10 @@ Get the longest item in an array. ```javascript longest(['a', 'abcde', 'abc']); // -> 'abcde' -``` - -## lowerCase - +``` + +## lowerCase + Convert string to lower case. |Name |Type |Desc | @@ -4484,10 +4484,10 @@ Convert string to lower case. ```javascript lowerCase('TEST'); // -> 'test' -``` - -## lpad - +``` + +## lpad + Pad string on the left side if it's shorter than length. |Name |Type |Desc | @@ -4502,10 +4502,10 @@ lpad('a', 5); // -> ' a' lpad('a', 5, '-'); // -> '----a' lpad('abc', 3, '-'); // -> 'abc' lpad('abc', 5, 'ab'); // -> 'ababc' -``` - -## ltrim - +``` + +## ltrim + Remove chars or white-spaces from beginning of string. |Name |Type |Desc | @@ -4518,10 +4518,10 @@ Remove chars or white-spaces from beginning of string. ltrim(' abc '); // -> 'abc ' ltrim('_abc_', '_'); // -> 'abc_' ltrim('_abc_', ['a', '_']); // -> 'bc_' -``` - -## map - +``` + +## map + Create an array of values by running each element in collection through iteratee. |Name |Type |Desc | @@ -4533,10 +4533,10 @@ Create an array of values by running each element in collection through iteratee ```javascript map([4, 8], function (n) { return n * n; }); // -> [16, 64] -``` - -## mapObj - +``` + +## mapObj + Map for objects. |Name |Type |Desc | @@ -4548,10 +4548,10 @@ Map for objects. ```javascript mapObj({a: 1, b: 2}, function (val, key) { return val + 1 }); // -> {a: 2, b: 3} -``` - -## matcher - +``` + +## matcher + Return a predicate function that checks if attrs are contained in an object. |Name |Type |Desc | @@ -4565,10 +4565,10 @@ const objects = [ {a: 4, b: 5, c: 6 } ]; // filter(objects, matcher({a: 4, c: 6 })); -``` - -## max - +``` + +## max + Get maximum value of given numbers. |Name |Type |Desc | @@ -4578,10 +4578,10 @@ Get maximum value of given numbers. ```javascript max(2.3, 1, 4.5, 2); // 4.5 -``` - -## md5 - +``` + +## md5 + MD5 implementation. |Name |Type |Desc | @@ -4591,10 +4591,10 @@ MD5 implementation. ```javascript md5('licia'); // -> 'e59f337d85e9a467f1783fab282a41d0' -``` - -## memStorage - +``` + +## memStorage + Memory-backed implementation of the Web Storage API. A replacement for environments where localStorage or sessionStorage is not available. @@ -4602,10 +4602,10 @@ A replacement for environments where localStorage or sessionStorage is not avail ```javascript var localStorage = window.localStorage || memStorage; localStorage.setItem('test', 'licia'); -``` - -## memoize - +``` + +## memoize + Memoize a given function by caching the computed result. |Name |Type |Desc | @@ -4618,10 +4618,10 @@ Memoize a given function by caching the computed result. var fibonacci = memoize(function(n) { return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); }); -``` - -## mergeSort - +``` + +## mergeSort + Merge sort implementation. Note: It's not an "in-place" sort. @@ -4634,10 +4634,10 @@ Note: It's not an "in-place" sort. ```javascript mergeSort([2, 1]); // -> [1, 2] -``` - -## meta - +``` + +## meta + 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. @@ -4679,10 +4679,10 @@ meta({ }); meta.remove('d'); meta.remove(['e', 'f']); -``` - -## methods - +``` + +## methods + Return a sorted list of the names of every method in an object. |Name |Type |Desc | @@ -4692,10 +4692,10 @@ Return a sorted list of the names of every method in an object. ```javascript methods(console); // -> ['Console', 'assert', 'dir', ...] -``` - -## mime - +``` + +## mime + Common mime types. |Name |Type |Desc | @@ -4715,10 +4715,10 @@ mime('jpg'); // -> 'image/jpeg' mime('bmp'); // -> 'image/bmp' mime('video/mp4'); // -> 'mp4' mime('test'); // -> null -``` - -## min - +``` + +## min + Get minimum value of given numbers. |Name |Type |Desc | @@ -4728,10 +4728,10 @@ Get minimum value of given numbers. ```javascript min(2.3, 1, 4.5, 2); // 1 -``` - -## mkdir - +``` + +## mkdir + Recursively create directories. |Name |Type |Desc | @@ -4745,10 +4745,10 @@ mkdir('/tmp/foo/bar/baz', function (err) { if (err) console.log(err); else console.log('Done'); }); -``` - -## moment - +``` + +## moment + Tiny moment.js like implementation. It only supports a subset of moment.js api. @@ -4768,10 +4768,10 @@ Note: Format uses dateFormat module, so the mask is not quite the same as moment ```javascript moment('20180501').format('yyyy-mm-dd'); // -> '2018-05-01' -``` - -## ms - +``` + +## ms + Convert time string formats to milliseconds. Turn time string into milliseconds. @@ -4797,10 +4797,10 @@ ms('1y'); // -> 31557600000 ms('1000'); // -> 1000 ms(1500); // -> '1.5s' ms(60000); // -> '1m' -``` - -## negate - +``` + +## negate + Create a function that negates the result of the predicate function. |Name |Type |Desc | @@ -4811,10 +4811,10 @@ Create a function that negates the result of the predicate function. ```javascript function even(n) { return n % 2 === 0 } // filter([1, 2, 3, 4, 5, 6], negate(even)); -> [1, 3, 5] -``` - -## nextTick - +``` + +## nextTick + Next tick for both node and browser. |Name|Type |Desc | @@ -4829,18 +4829,18 @@ Otherwise setImmediate or setTimeout is used as fallback. nextTick(function () { // Do something... }); -``` - -## noop - +``` + +## noop + A no-operation function. ```javascript noop(); // Does nothing -``` - -## normalizeHeader - +``` + +## normalizeHeader + Normalize http header name. |Name |Type |Desc | @@ -4851,10 +4851,10 @@ Normalize http header name. ```javascript normalizeHeader('content-type'); // -> 'Content-Type' normalizeHeader('etag'); // -> 'ETag' -``` - -## normalizePath - +``` + +## normalizePath + Normalize file path slashes. |Name |Type |Desc | @@ -4865,18 +4865,18 @@ Normalize file path slashes. ```javascript normalizePath('\\foo\\bar\\'); // -> '/foo/bar/' normalizePath('./foo//bar'); // -> './foo/bar' -``` - -## now - +``` + +## now + Gets the number of milliseconds that have elapsed since the Unix epoch. ```javascript now(); // -> 1468826678701 -``` - -## objToStr - +``` + +## objToStr + Alias of Object.prototype.toString. |Name |Type |Desc | @@ -4886,10 +4886,10 @@ Alias of Object.prototype.toString. ```javascript objToStr(5); // -> '[object Number]' -``` - -## omit - +``` + +## omit + Opposite of pick. |Name |Type |Desc | @@ -4904,10 +4904,10 @@ omit({a: 1, b: 2, c: 3}, ['b', 'c']) // -> {a: 1} omit({a: 1, b: 2, c: 3, d: 4}, function (val, key) { return val % 2; }); // -> {b: 2, d: 4} -``` - -## once - +``` + +## once + Create a function that invokes once. |Name |Type |Desc | @@ -4920,10 +4920,10 @@ function init() {}; var initOnce = once(init); initOnce(); initOnce(); // -> init is invoked once -``` - -## open - +``` + +## open + Open stuff like url, files. |Name |Type |Desc | @@ -4933,10 +4933,10 @@ Open stuff like url, files. ```javascript open('https://eustia.liriliri.io/'); -``` - -## openFile - +``` + +## openFile + Open file dialog to select file in browser. |Name |Type |Desc | @@ -4955,14 +4955,14 @@ Available options: openFile({multiple: true}).then(fileList => { console.log(fileList) }); -``` - -## optimizeCb - -Used for function context binding. - -## ordinal - +``` + +## optimizeCb + +Used for function context binding. + +## ordinal + Add ordinal indicator to number. |Name |Type |Desc | @@ -4973,10 +4973,10 @@ Add ordinal indicator to number. ```javascript ordinal(1); // -> '1st' ordinal(2); // -> '2nd' -``` - -## orientation - +``` + +## orientation + Screen orientation helper. ### on @@ -4996,10 +4996,10 @@ orientation.on('change', function (direction) { console.log(direction); // -> 'portrait' }); orientation.get(); // -> 'landscape' -``` - -## pad - +``` + +## pad + Pad string on the left and right sides if it's shorter than length. |Name |Type |Desc | @@ -5015,10 +5015,10 @@ pad('a', 5, '-'); // -> '--a--' pad('abc', 3, '-'); // -> 'abc' pad('abc', 5, 'ab'); // -> 'babca' pad('ab', 5, 'ab'); // -> 'ababa' -``` - -## pairs - +``` + +## pairs + Convert an object into a list of [key, value] pairs. |Name |Type |Desc | @@ -5028,10 +5028,10 @@ Convert an object into a list of [key, value] pairs. ```javascript pairs({a: 1, b: 2}); // -> [['a', 1], ['b', 2]] -``` - -## parallel - +``` + +## parallel + Run an array of functions in parallel. |Name |Type |Desc | @@ -5050,10 +5050,10 @@ parallel([ ], function (err, results) { // results -> ['one', 'two'] }); -``` - -## parseArgs - +``` + +## parseArgs + Parse command line argument options, the same as minimist. |Name |Type |Desc | @@ -5081,10 +5081,10 @@ parseArgs(['eustia', '--output', 'util.js', '-w'], { } }); // -> {remain: ['eustia'], output: 'util.js', watch: true} -``` - -## partial - +``` + +## partial + Partially apply a function by filling in given arguments. |Name |Type |Desc | @@ -5096,10 +5096,10 @@ Partially apply a function by filling in given arguments. ```javascript var sub5 = partial(function (a, b) { return b - a }, 5); sub5(20); // -> 15 -``` - -## pascalCase - +``` + +## pascalCase + Convert string to "pascalCase". |Name |Type |Desc | @@ -5112,10 +5112,10 @@ pascalCase('fooBar'); // -> FooBar pascalCase('foo bar'); // -> FooBar pascalCase('foo_bar'); // -> FooBar pascalCase('foo.bar'); // -> FooBar -``` - -## perfNow - +``` + +## perfNow + High resolution time up to microsecond precision. ```javascript @@ -5124,10 +5124,10 @@ var start = perfNow(); // Do something. console.log(perfNow() - start); -``` - -## pick - +``` + +## pick + Return a filtered copy of an object. |Name |Type |Desc | @@ -5142,10 +5142,10 @@ pick({a: 1, b: 2, c: 3}, ['b', 'c']) // -> {b: 2, c: 3} pick({a: 1, b: 2, c: 3, d: 4}, function (val, key) { return val % 2; }); // -> {a: 1, c: 3} -``` - -## pluck - +``` + +## pluck + Extract a list of property values. |Name |Type |Desc | @@ -5161,10 +5161,10 @@ var stooges = [ {name: 'curly', age: 60} ]; pluck(stooges, 'name'); // -> ['moe', 'larry', 'curly'] -``` - -## precision - +``` + +## precision + Find decimal precision of a given number. |Name |Type |Desc | @@ -5174,10 +5174,10 @@ Find decimal precision of a given number. ```javascript precision(1.234); // -> 3; -``` - -## prefetch - +``` + +## prefetch + Fetch a given url. |Name |Type |Desc | @@ -5189,10 +5189,10 @@ It uses `` if possible. ```javascript prefetch('https://eustia.liriliri.io/'); -``` - -## prefix - +``` + +## prefix + Add vendor prefixes to a CSS attribute. |Name |Type |Desc | @@ -5208,10 +5208,10 @@ Create a dasherize version. prefix('text-emphasis'); // -> 'WebkitTextEmphasis' prefix.dash('text-emphasis'); // -> '-webkit-text-emphasis' prefix('color'); // -> 'color' -``` - -## promisify - +``` + +## promisify + Convert callback based functions into Promises. |Name |Type |Desc | @@ -5229,10 +5229,10 @@ var readFile = promisify(fs.readFile); readFile('test.js', 'utf-8').then(function (data) { // Do something with file content. }); -``` - -## property - +``` + +## property + Return a function that will itself return the key property of any passed-in object. |Name |Type |Desc | @@ -5244,10 +5244,10 @@ Return a function that will itself return the key property of any passed-in obje var obj = {a: {b: 1}}; property('a')(obj); // -> {b: 1} property(['a', 'b'])(obj); // -> 1 -``` - -## query - +``` + +## query + Parse and stringify url query strings. ### parse @@ -5272,10 +5272,10 @@ Stringify an object into a query string. query.parse('foo=bar&eruda=true'); // -> {foo: 'bar', eruda: 'true'} query.stringify({foo: 'bar', eruda: 'true'}); // -> 'foo=bar&eruda=true' query.parse('name=eruda&name=eustia'); // -> {name: ['eruda', 'eustia']} -``` - -## quickSort - +``` + +## quickSort + Quick sort implementation. |Name |Type |Desc | @@ -5286,10 +5286,10 @@ Quick sort implementation. ```javascript quickSort([2, 1]); // -> [1, 2] -``` - -## raf - +``` + +## raf + Shortcut for requestAnimationFrame. Use setTimeout if native requestAnimationFrame is not supported. @@ -5300,10 +5300,10 @@ var id = raf(function tick() { raf(tick); }); raf.cancel(id); -``` - -## random - +``` + +## random + Produces a random number between min and max(inclusive). |Name |Type |Desc | @@ -5317,10 +5317,10 @@ Produces a random number between min and max(inclusive). random(1, 5); // -> an integer between 0 and 5 random(5); // -> an integer between 0 and 5 random(1.2, 5.2, true); /// -> a floating-point number between 1.2 and 5.2 -``` - -## randomBytes - +``` + +## randomBytes + Random bytes generator. Use crypto module in node or crypto object in browser if possible. @@ -5332,10 +5332,10 @@ Use crypto module in node or crypto object in browser if possible. ```javascript randomBytes(5); // -> [55, 49, 153, 30, 122] -``` - -## randomId - +``` + +## randomId + A tiny id generator, similar to nanoid. |Name |Type |Desc | @@ -5347,10 +5347,10 @@ A tiny id generator, similar to nanoid. randomId(); // -> 'oKpy4HwU8E6IvU5I03gyQ' randomId(5); // -> 'sM6E9' randomId(5, 'abc'); // -> 'cbbcb' -``` - -## randomItem - +``` + +## randomItem + Get a random item from an array. |Name |Type |Desc | @@ -5360,10 +5360,10 @@ Get a random item from an array. ```javascript randomItem([1, 2, 3]); // -> 2 -``` - -## range - +``` + +## range + Create flexibly-numbered lists of integers. |Name |Type |Desc | @@ -5376,10 +5376,10 @@ Create flexibly-numbered lists of integers. ```javascript range(5); // -> [0, 1, 2, 3, 4] range(0, 5, 2) // -> [0, 2, 4] -``` - -## rc4 - +``` + +## rc4 + RC4 symmetric encryption implementation. ### encrypt @@ -5399,10 +5399,10 @@ RC4 decryption, pass base64 string as input. ```javascript rc4.encrypt('licia', 'Hello world'); // -> 'j9y2VpSfR3AdNN8=' rc4.decrypt('licia', 'j9y2VpSfR3AdNN8='); // -> 'Hello world' -``` - -## ready - +``` + +## ready + Invoke callback when dom is ready, similar to jQuery ready. |Name|Type |Desc | @@ -5413,10 +5413,10 @@ Invoke callback when dom is ready, similar to jQuery ready. ready(function () { // It's safe to manipulate dom here. }); -``` - -## reduce - +``` + +## reduce + Turn a list of values into a single value. |Name |Type |Desc | @@ -5429,18 +5429,18 @@ Turn a list of values into a single value. ```javascript reduce([1, 2, 3], function (sum, n) { return sum + n }, 0); // -> 6 -``` - -## reduceRight - +``` + +## reduceRight + Right-associative version of reduce. ```javascript reduceRight([[1], [2], [3]], function (a, b) { return a.concat(b) }, []); // -> [3, 2, 1] -``` - -## reject - +``` + +## reject + Opposite of filter. |Name |Type |Desc | @@ -5454,10 +5454,10 @@ Opposite of filter. reject([1, 2, 3, 4, 5], function (val) { return val % 2 === 0; }); // -> [1, 3, 5] -``` - -## remove - +``` + +## remove + Remove all elements from array that predicate returns truthy for and return an array of the removed elements. Unlike filter, this method mutates array. @@ -5474,10 +5474,10 @@ var arr = [1, 2, 3, 4, 5]; var evens = remove(arr, function (val) { return val % 2 === 0 }); console.log(arr); // -> [1, 3, 5] console.log(evens); // -> [2, 4] -``` - -## repeat - +``` + +## repeat + Repeat string n-times. |Name |Type |Desc | @@ -5490,10 +5490,10 @@ Repeat string n-times. repeat('a', 3); // -> 'aaa' repeat('ab', 2); // -> 'abab' repeat('*', 0); // -> '' -``` - -## restArgs - +``` + +## restArgs + This accumulates the arguments passed into an array, after a given index. |Name |Type |Desc | @@ -5505,10 +5505,10 @@ This accumulates the arguments passed into an array, after a given index. ```javascript var paramArr = restArgs(function (rest) { return rest }); paramArr(1, 2, 3, 4); // -> [1, 2, 3, 4] -``` - -## rgbToHsl - +``` + +## rgbToHsl + Convert rgb to hsl. |Name |Type |Desc | @@ -5518,10 +5518,10 @@ Convert rgb to hsl. ```javascript rgbToHsl([52, 203, 165, 0.8]); // -> [165, 59, 50, 0.8] -``` - -## ric - +``` + +## ric + Shortcut for requestIdleCallback. Use setTimeout if requestIdleCallback is not supported. @@ -5531,10 +5531,10 @@ const id = ric(function () { // Called during a browser's idle periods }); ric.cancel(id); -``` - -## rmCookie - +``` + +## rmCookie + Loop through all possible path and domain to remove cookie. |Name|Type |Desc | @@ -5543,10 +5543,10 @@ Loop through all possible path and domain to remove cookie. ```javascript rmCookie('test'); -``` - -## rmdir - +``` + +## rmdir + Recursively remove directories. |Name |Type |Desc | @@ -5559,14 +5559,14 @@ rmdir('/tmp/foo/bar/baz', function (err) { if (err) console.log (err); else console.log('Done'); }); -``` - -## root - -Root object reference, `global` in nodeJs, `window` in browser. - -## rpad - +``` + +## root + +Root object reference, `global` in nodeJs, `window` in browser. + +## rpad + Pad string on the right side if it's shorter than length. |Name |Type |Desc | @@ -5581,10 +5581,10 @@ rpad('a', 5); // -> 'a ' rpad('a', 5, '-'); // -> 'a----' rpad('abc', 3, '-'); // -> 'abc' rpad('abc', 5, 'ab'); // -> 'abcab' -``` - -## rtrim - +``` + +## rtrim + Remove chars or white-spaces from end of string. |Name |Type |Desc | @@ -5597,14 +5597,14 @@ Remove chars or white-spaces from end of string. rtrim(' abc '); // -> ' abc' rtrim('_abc_', '_'); // -> '_abc' rtrim('_abc_', ['c', '_']); // -> '_ab' -``` - -## safeCb - -Create callback based on input value. - -## safeDel - +``` + +## safeCb + +Create callback based on input value. + +## safeDel + Delete object property. |Name |Type |Desc | @@ -5618,10 +5618,10 @@ var obj = {a: {aa: {aaa: 1}}}; safeDel(obj, 'a.aa.aaa'); // -> 1 safeDel(obj, ['a', 'aa']); // -> {} safeDel(obj, 'a.b'); // -> undefined -``` - -## safeGet - +``` + +## safeGet + Get object property, don't throw undefined error. |Name |Type |Desc | @@ -5635,10 +5635,10 @@ var obj = {a: {aa: {aaa: 1}}}; safeGet(obj, 'a.aa.aaa'); // -> 1 safeGet(obj, ['a', 'aa']); // -> {aaa: 1} safeGet(obj, 'a.b'); // -> undefined -``` - -## safeSet - +``` + +## safeSet + Set value at path of object. If a portion of path doesn't exist, it's created. @@ -5654,10 +5654,10 @@ var obj = {}; safeSet(obj, 'a.aa.aaa', 1); // obj = {a: {aa: {aaa: 1}}} safeSet(obj, ['a', 'aa'], 2); // obj = {a: {aa: 2}} safeSet(obj, 'a.b', 3); // obj = {a: {aa: 2, b: 3}} -``` - -## safeStorage - +``` + +## safeStorage + Use storage safely in safari private browsing and older browsers. |Name |Type |Desc | @@ -5668,10 +5668,10 @@ Use storage safely in safari private browsing and older browsers. ```javascript var localStorage = safeStorage('local'); localStorage.setItem('licia', 'util'); -``` - -## sample - +``` + +## sample + Sample random values from a collection. |Name |Type |Desc | @@ -5683,10 +5683,10 @@ Sample random values from a collection. ```javascript sample([2, 3, 1], 2); // -> [2, 3] sample({a: 1, b: 2, c: 3}, 1); // -> [2] -``` - -## scrollTo - +``` + +## scrollTo + Scroll to a target with animation. |Name |Type |Desc | @@ -5710,10 +5710,10 @@ scrollTo('body', { easing: 'outQuart', callback: function () {} }); -``` - -## selectionSort - +``` + +## selectionSort + Selection sort implementation. |Name |Type |Desc | @@ -5724,10 +5724,10 @@ Selection sort implementation. ```javascript selectionSort([2, 1]); // -> [1, 2] -``` - -## shellSort - +``` + +## shellSort + Shell sort implementation. |Name |Type |Desc | @@ -5738,10 +5738,10 @@ Shell sort implementation. ```javascript shellSort([2, 1]); // -> [1, 2] -``` - -## shuffle - +``` + +## shuffle + Randomize the order of the elements in a given array. |Name |Type |Desc | @@ -5751,10 +5751,10 @@ Randomize the order of the elements in a given array. ```javascript shuffle([1, 2, 3]); // -> [3, 1, 2] -``` - -## size - +``` + +## size + Get size of object or length of array like object. |Name |Type |Desc | @@ -5765,10 +5765,10 @@ Get size of object or length of array like object. ```javascript size({a: 1, b: 2}); // -> 2 size([1, 2, 3]); // -> 3 -``` - -## sleep - +``` + +## sleep + Resolve a promise after a specified timeout. |Name |Type |Desc | @@ -5779,10 +5779,10 @@ Resolve a promise after a specified timeout. ;(async function () { await sleep(2000); })(); -``` - -## slice - +``` + +## slice + Create slice of source array or array-like object. |Name |Type |Desc | @@ -5793,10 +5793,10 @@ Create slice of source array or array-like object. ```javascript slice([1, 2, 3, 4], 1, 2); // -> [2] -``` - -## snakeCase - +``` + +## snakeCase + Convert string to "snakeCase". |Name |Type |Desc | @@ -5808,10 +5808,10 @@ Convert string to "snakeCase". snakeCase('fooBar'); // -> foo_bar snakeCase('foo bar'); // -> foo_bar snakeCase('foo.bar'); // -> foo_bar -``` - -## some - +``` + +## some + Check if predicate return truthy for any element. |Name |Type |Desc | @@ -5825,10 +5825,10 @@ Check if predicate return truthy for any element. some([2, 5], function (val) { return val % 2 === 0; }); // -> true -``` - -## sortBy - +``` + +## sortBy + Return an array of elements sorted in ascending order by results of running each element through iteratee. |Name |Type |Desc | @@ -5842,10 +5842,10 @@ Return an array of elements sorted in ascending order by results of running each sortBy([1, 2, 3, 4, 5, 6], function (num) { return Math.sin(num); }); // -> [5, 4, 6, 3, 1, 2] -``` - -## spaceCase - +``` + +## spaceCase + Convert string to "spaceCase". |Name |Type |Desc | @@ -5857,10 +5857,10 @@ Convert string to "spaceCase". spaceCase('fooBar'); // -> foo bar spaceCase('foo.bar'); // -> foo bar spaceCase('foo.bar'); // -> foo bar -``` - -## splitCase - +``` + +## splitCase + Split different string case to an array. |Name |Type |Desc | @@ -5875,10 +5875,10 @@ splitCase('foo_bar'); // -> ['foo', 'bar'] splitCase('foo.bar'); // -> ['foo', 'bar'] splitCase('fooBar'); // -> ['foo', 'bar'] splitCase('foo-Bar'); // -> ['foo', 'bar'] -``` - -## splitPath - +``` + +## splitPath + Split path into dir, name and ext. |Name |Type |Desc | @@ -5889,20 +5889,20 @@ Split path into dir, name and ext. ```javascript splitPath('f:/foo/bar.txt'); // -> {dir: 'f:/foo/', name: 'bar.txt', ext: '.txt'} splitPath('/home/foo/bar.txt'); // -> {dir: '/home/foo/', name: 'bar.txt', ext: '.txt'} -``` - -## stackTrace - +``` + +## stackTrace + Get CallSite objects in v8. [Stack trace API](https://v8.dev/docs/stack-trace-api) ```javascript stackTrace(); // -> List of CallSite objects -``` - -## startWith - +``` + +## startWith + Check if string starts with the given target string. |Name |Type |Desc | @@ -5913,10 +5913,10 @@ Check if string starts with the given target string. ```javascript startWith('ab', 'a'); // -> true -``` - -## strHash - +``` + +## strHash + String hash function using djb2. |Name |Type |Desc | @@ -5926,10 +5926,10 @@ String hash function using djb2. ```javascript strHash('test'); // -> 2090770981 -``` - -## strToBytes - +``` + +## strToBytes + Convert string into bytes. |Name |Type |Desc | @@ -5939,10 +5939,10 @@ Convert string into bytes. ```javascript strToBytes('licia'); // -> [108, 105, 99, 105, 97] -``` - -## stringify - +``` + +## stringify + JSON stringify with support for circular object, function etc. Undefined is treated as null value. @@ -5958,10 +5958,10 @@ stringify({a: function () {}}); // -> '{"a":"[Function function () {}]"}' var obj = {a: 1, b: {}}; obj.b = obj; stringify(obj); // -> '{"a":1,"b":"[Circular ~]"}' -``` - -## stringifyAll - +``` + +## stringifyAll + Stringify object into json with types. |Name |Type |Desc | @@ -5985,10 +5985,10 @@ When time is out, all remaining values will all be "Timeout". ```javascript stringifyAll(function test() {}); // -> '{"value":"function test() {}","type":"Function",...}' -``` - -## stripAnsi - +``` + +## stripAnsi + Strip ansi codes from a string. |Name |Type |Desc | @@ -5998,10 +5998,10 @@ Strip ansi codes from a string. ```javascript stripAnsi('\u001b[4mcake\u001b[0m'); // -> 'cake' -``` - -## stripCmt - +``` + +## stripCmt + Strip comments from source code. |Name |Type |Desc | @@ -6011,10 +6011,10 @@ Strip comments from source code. ```javascript stripCmt('// comment \n var a = 5; /* comment2\n * comment3\n *\/'); // -> ' var a = 5; ' -``` - -## stripColor - +``` + +## stripColor + Strip ansi color codes from a string. |Name |Type |Desc | @@ -6024,10 +6024,10 @@ Strip ansi color codes from a string. ```javascript stripColor('\u001b[31mred\u001b[39m'); // -> 'red' -``` - -## stripHtmlTag - +``` + +## stripHtmlTag + Strip html tags from a string. |Name |Type |Desc | @@ -6037,10 +6037,10 @@ Strip html tags from a string. ```javascript stripHtmlTag('

Hello

'); // -> 'Hello' -``` - -## stripIndent - +``` + +## stripIndent + Strip indentation from multi-line strings. |Name |Type |Desc | @@ -6056,10 +6056,10 @@ stripIndent` * item one * item two `; // -> 'Test string\n * item one\n * item two' -``` - -## sum - +``` + +## sum + Compute sum of given numbers. |Name |Type |Desc | @@ -6069,10 +6069,10 @@ Compute sum of given numbers. ```javascript sum(1, 2, 5); // -> 8 -``` - -## swap - +``` + +## swap + Swap two items in an array. |Name |Type |Desc | @@ -6085,10 +6085,10 @@ Swap two items in an array. ```javascript var arr = [1, 2]; swap(arr, 0, 1); // -> [2, 1] -``` - -## template - +``` + +## template + Compile JavaScript template into function that can be evaluated for rendering. |Name |Type |Desc | @@ -6106,10 +6106,10 @@ template('

<%= util["upperCase"](name) %>

', { return str.toLocaleUpperCase(); } })({ name: 'licia' }); // -> '

LICIA

' -``` - -## throttle - +``` + +## throttle + Return a new throttled version of the passed function. |Name |Type |Desc | @@ -6121,10 +6121,10 @@ Return a new throttled version of the passed function. ```javascript const updatePos = throttle(function () {}, 100); // $(window).scroll(updatePos); -``` - -## through - +``` + +## through + Tiny wrapper of stream Transform. |Name |Type |Desc | @@ -6149,10 +6149,10 @@ fs.createReadStream('in.txt') this.push(chunk); cb(); })).pipe(fs.createWriteStream('out.txt')); -``` - -## timeAgo - +``` + +## timeAgo + Format datetime with *** time ago statement. |Name |Type |Desc | @@ -6166,10 +6166,10 @@ var now = new Date().getTime(); timeAgo(now - 1000 * 6); // -> right now timeAgo(now + 1000 * 15); // -> in 15 minutes timeAgo(now - 1000 * 60 * 60 * 5, now); // -> 5 hours ago -``` - -## timeTaken - +``` + +## timeTaken + Get execution time of a function. |Name |Type |Desc | @@ -6181,10 +6181,10 @@ Get execution time of a function. timeTaken(function () { // Do something. }); // -> Time taken to execute given function. -``` - -## times - +``` + +## times + Invoke given function n times. |Name |Type |Desc | @@ -6196,10 +6196,10 @@ Invoke given function n times. ```javascript times(3, String); // -> ['0', '1', '2'] -``` - -## toArr - +``` + +## toArr + Convert value to an array. |Name |Type |Desc | @@ -6212,10 +6212,10 @@ toArr({a: 1, b: 2}); // -> [{a: 1, b: 2}] toArr('abc'); // -> ['abc'] toArr(1); // -> [1] toArr(null); // -> [] -``` - -## toBool - +``` + +## toBool + Convert value to a boolean. |Name |Type |Desc | @@ -6231,10 +6231,10 @@ toBool(0); // -> false toBool('0'); // -> false toBool('1'); // -> true toBool('false'); // -> false -``` - -## toDate - +``` + +## toDate + Convert value to a Date. |Name |Type|Desc | @@ -6246,10 +6246,10 @@ Convert value to a Date. toDate('20180501'); toDate('2018-05-01'); toDate(1525107450849); -``` - -## toEl - +``` + +## toEl + Convert html string to dom elements. There should be only one root element. @@ -6261,10 +6261,10 @@ There should be only one root element. ```javascript toEl('
test
'); -``` - -## toInt - +``` + +## toInt + Convert value to an integer. |Name |Type |Desc | @@ -6275,10 +6275,10 @@ Convert value to an integer. ```javascript toInt(1.1); // -> 1 toInt(undefined); // -> 0 -``` - -## toNum - +``` + +## toNum + Convert value to a number. |Name |Type |Desc | @@ -6288,10 +6288,10 @@ Convert value to a number. ```javascript toNum('5'); // -> 5 -``` - -## toSrc - +``` + +## toSrc + Convert function to its source code. |Name |Type |Desc | @@ -6302,10 +6302,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 | @@ -6318,10 +6318,10 @@ toStr(null); // -> '' toStr(1); // -> '1' toStr(false); // -> 'false' toStr([1, 2, 3]); // -> '1,2,3' -``` - -## topoSort - +``` + +## topoSort + Topological sorting algorithm. |Name |Type |Desc | @@ -6331,10 +6331,10 @@ Topological sorting algorithm. ```javascript topoSort([[1, 2], [1, 3], [3, 2]]); // -> [1, 3, 2] -``` - -## trigger - +``` + +## trigger + Trigger browser events. |Name |Type |Desc | @@ -6346,10 +6346,10 @@ Trigger browser events. ```javascript trigger(document.getElementById('#test'), 'mouseup'); trigger('keydown', {keyCode: 65}); -``` - -## trim - +``` + +## trim + Remove chars or white-spaces from beginning end of string. |Name |Type |Desc | @@ -6362,10 +6362,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 | @@ -6379,10 +6379,10 @@ tryIt(function () { }, function (err, result) { if (err) console.log(err); }); -``` - -## type - +``` + +## type + Determine the internal JavaScript [[Class]] of an object. |Name |Type |Desc | @@ -6398,14 +6398,14 @@ type(function () {}); // -> 'function' type([]); // -> 'array' type([], false); // -> 'Array' type(async function () {}, false); // -> 'AsyncFunction' -``` - -## types - -Used for typescript definitions only. - -## ucs2 - +``` + +## types + +Used for typescript definitions only. + +## ucs2 + UCS-2 encoding and decoding. ### encode @@ -6431,10 +6431,10 @@ ucs2.encode([0x61, 0x62, 0x63]); // -> 'abc' ucs2.decode('abc'); // -> [0x61, 0x62, 0x63] '𝌆'.length; // -> 2 ucs2.decode('𝌆').length; // -> 1 -``` - -## uncaught - +``` + +## uncaught + Handle global uncaught errors and promise rejections. ### start @@ -6466,10 +6466,10 @@ uncaught.start(); uncaught.addListener(err => { // Do something. }); -``` - -## unescape - +``` + +## unescape + Convert HTML entities back, the inverse of escape. |Name |Type |Desc | @@ -6479,10 +6479,10 @@ Convert HTML entities back, the inverse of escape. ```javascript unescape('You & Me'); // -> 'You & Me' -``` - -## union - +``` + +## union + Create an array of unique values, in order, from all given arrays. |Name |Type |Desc | @@ -6492,10 +6492,10 @@ Create an array of unique values, in order, from all given arrays. ```javascript union([2, 1], [4, 2], [1, 2]); // -> [2, 1, 4] -``` - -## uniqId - +``` + +## uniqId + Generate a globally-unique id. |Name |Type |Desc | @@ -6505,10 +6505,10 @@ Generate a globally-unique id. ```javascript uniqId('eusita_'); // -> 'eustia_xxx' -``` - -## unique - +``` + +## unique + Create duplicate-free version of an array. |Name |Type |Desc | @@ -6519,10 +6519,10 @@ Create duplicate-free version of an array. ```javascript unique([1, 2, 3, 1]); // -> [1, 2, 3] -``` - -## unzip - +``` + +## unzip + Opposite of zip. |Name |Type |Desc | @@ -6532,10 +6532,10 @@ Opposite of zip. ```javascript unzip([['a', 1, true], ['b', 2, false]]); // -> [['a', 'b'], [1, 2], [true, false]] -``` - -## upperCase - +``` + +## upperCase + Convert string to upper case. |Name |Type |Desc | @@ -6545,10 +6545,10 @@ Convert string to upper case. ```javascript upperCase('test'); // -> 'TEST' -``` - -## upperFirst - +``` + +## upperFirst + Convert the first character of string to upper case. |Name |Type |Desc | @@ -6558,10 +6558,10 @@ Convert the first character of string to upper case. ```javascript upperFirst('red'); // -> Red -``` - -## use - +``` + +## use + Use modules that is created by define. |Name |Type |Desc | @@ -6574,10 +6574,10 @@ Use modules that is created by define. use(['A'], function (A) { console.log(A + 'B'); // -> 'AB' }); -``` - -## utf8 - +``` + +## utf8 + UTF-8 encoding and decoding. ### encode @@ -6602,20 +6602,20 @@ 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' -``` - -## uuid - +``` + +## uuid + RFC4122 version 4 compliant uuid generator. Check [RFC4122 4.4](http://www.ietf.org/rfc/rfc4122.txt) for reference. ```javascript uuid(); // -> '53ce0497-6554-49e9-8d79-347406d2a88b' -``` - -## values - +``` + +## values + Create an array of the own enumerable property values of object. |Name |Type |Desc | @@ -6625,18 +6625,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 -``` - -## vlq - +``` + +## vlq + Variable-length quantity encoding and decoding. ### encode @@ -6662,10 +6662,10 @@ vlq.encode(123); // -> '2H' vlq.encode([123, 456, 789]); // -> '2HwcqxB' vlq.decode('2H'); // -> [123] vlq.decode('2HwcqxB'); // -> [123, 456, 789] -``` - -## waitUntil - +``` + +## waitUntil + Wait until function returns a truthy value. |Name |Type |Desc | @@ -6680,10 +6680,10 @@ setTimeout(() => a = 10, 500); waitUntil(() => a === 10).then(() => { console.log(a); // -> 10 }); -``` - -## waterfall - +``` + +## waterfall + Run an array of functions in series. |Name |Type |Desc | @@ -6703,10 +6703,10 @@ waterfall([ ], function (err, result) { // result -> 'done' }); -``` - -## workerize - +``` + +## workerize + Move a stand-alone function to a worker thread. |Name |Type |Desc | @@ -6721,10 +6721,10 @@ var worker = workerize(function (a, b) { worker(1, 2).then(function (value) { console.log(value); // -> 3 }); -``` - -## wrap - +``` + +## wrap + Wrap the function inside a wrapper function, passing it as the first argument. |Name |Type |Desc | @@ -6738,20 +6738,20 @@ var p = wrap(escape, function(fn, text) { return '

' + fn(text) + '

'; }); p('You & Me'); // -> '

You & Me

' -``` - -## wx - +``` + +## wx + Promised version of mini program wx object. ```javascript wx.getStorage('test').then(res => { console.log(res.data); }); -``` - -## zip - +``` + +## zip + Merge together the values of each of the arrays with the values at the corresponding position. |Name |Type |Desc | @@ -6761,4 +6761,4 @@ Merge together the values of each of the arrays with the values at the correspon ```javascript zip(['a', 'b'], [1, 2], [true, false]); // -> [['a', 1, true], ['b', 2, false]] -``` +``` diff --git a/index.json b/index.json index 41a45beb..846df931 100644 --- a/index.json +++ b/index.json @@ -1254,7 +1254,8 @@ "test": [ "node", "browser" - ] + ], + "since": "1.5.9" }, "crc32": { "description": "CRC32 implementation.", @@ -1269,7 +1270,8 @@ "test": [ "node", "browser" - ] + ], + "since": "1.5.9" }, "crc8": { "description": "CRC8 implementation.", @@ -1284,7 +1286,8 @@ "test": [ "node", "browser" - ] + ], + "since": "1.5.9" }, "createAssigner": { "description": "Used to create extend, extendOwn and defaults.", diff --git a/package.json b/package.json index 2e0a7c35..684831f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "licia-src", - "version": "1.5.8", + "version": "1.5.9", "description": "Useful utility collection with zero dependencies", "bin": { "licia": "./bin/licia.js" diff --git a/src/c/crc16.js b/src/c/crc16.js index b4371c96..6f8039fd 100644 --- a/src/c/crc16.js +++ b/src/c/crc16.js @@ -14,6 +14,7 @@ /* module * env: all * test: all + * since: 1.5.9 */ /* typescript diff --git a/src/c/crc32.js b/src/c/crc32.js index 059e3894..35ebb8c4 100644 --- a/src/c/crc32.js +++ b/src/c/crc32.js @@ -14,6 +14,7 @@ /* module * env: all * test: all + * since: 1.5.9 */ /* typescript diff --git a/src/c/crc8.js b/src/c/crc8.js index 5dbe88f5..6e9548c6 100644 --- a/src/c/crc8.js +++ b/src/c/crc8.js @@ -14,6 +14,7 @@ /* module * env: all * test: all + * since: 1.5.9 */ /* typescript