Comparing version 1.2.7 to 1.2.8
150
doc/API.md
@@ -6,5 +6,5 @@ ### array | ||
- _item_ \<*\> | ||
remove an element from array\nit removes only the first occurrence | ||
remove an element from array | ||
it removes only the first occurrence | ||
@@ -22,3 +22,2 @@ _Example_ | ||
- _index_ \<number\> | ||
@@ -37,3 +36,3 @@ remove an element from array at position | ||
- _array_ \<Array<*>\> | ||
- _return:_ * last element of the array or undefined | ||
- _return:_ * last element of the array or undefined | ||
@@ -52,3 +51,3 @@ get last element of array or undefined | ||
- _array_ \<Array<*>\> | ||
- _return:_ * nth element of array; if negative, start from end: -1 = last element; undefined if missing | ||
- _return:_ * nth element of array; if negative, start from end: -1 = last element; undefined if missing | ||
@@ -67,3 +66,3 @@ get nth element of array | ||
- _array_ \<Array<*>\> | ||
- _return:_ * first element of the array or undefined | ||
- _return:_ * first element of the array or undefined | ||
@@ -83,3 +82,3 @@ get first element of array or undefined | ||
- _item_ \<*\> | ||
- _return:_ boolean | ||
- _return:_ boolean | ||
@@ -100,3 +99,2 @@ check if array contains an element | ||
- _item_ \<*\> | ||
@@ -115,3 +113,3 @@ insert an item into array at index position | ||
- _arrays_ \<...Array<*>\> to chain | ||
- _return:_ Array\<*\> chained arrays | ||
- _return:_ Array\<*\> chained arrays | ||
@@ -130,3 +128,2 @@ concat arrays | ||
@@ -147,3 +144,2 @@ empty array - need to keep references | ||
- _[unique=false]_ \<boolean\> | ||
@@ -167,3 +163,3 @@ push item into array, optionally check if already exists | ||
- _path_ \<string\> file path | ||
- _return:_ Promise.\<boolean\> true if file exists - and it's a file | ||
- _return:_ Promise.\<boolean\> true if file exists - and it's a file | ||
@@ -183,3 +179,3 @@ replace deprecated fs.exists | ||
- _[mode=0o666]_ \<number\> | ||
- _return:_ Promise.\<void\> | ||
- _return:_ Promise.\<void\> | ||
@@ -199,3 +195,3 @@ create an empty file if not exists | ||
- _[safe=true]_ \<boolean\> if safe do not throw exception | ||
- _return:_ Promise.\<void\> | ||
- _return:_ Promise.\<void\> | ||
@@ -219,3 +215,3 @@ delete file, optionally in safe mode | ||
- _data_ \<string\> any string | ||
- _return:_ string sha256 in hex format | ||
- _return:_ string sha256 in hex format | ||
@@ -239,3 +235,3 @@ Generate hash using sha256 in hex format | ||
- _obj_ \<Object\> | ||
- _return:_ Object | ||
- _return:_ Object | ||
@@ -252,6 +248,11 @@ flat keys in object | ||
#### object._rflat() | ||
#### object.merge(a, b) | ||
- _a_ \<Object\> | ||
- _b_ \<Object\> | ||
@@ -270,3 +271,3 @@ merge b into a | ||
- _obj_ \<Object|Array\> The array or the object to clone | ||
- _return:_ Object|Array | ||
- _return:_ Object|Array | ||
@@ -285,3 +286,3 @@ Clone an array or an object in input | ||
- _obj_ \<Object\> | ||
- _return:_ Array\<string\> | ||
- _return:_ Array\<string\> | ||
@@ -301,3 +302,2 @@ | ||
- _source_ \<Object\> | ||
@@ -316,3 +316,2 @@ it use ``Object.getOwnPropertyNames`` to inherits child from parent, without prototype | ||
- _obj_ \<Object\> | ||
@@ -331,3 +330,3 @@ empty object - need to keep references | ||
- _flat_ \<Object\> | ||
- _return:_ Object | ||
- _return:_ Object | ||
@@ -347,3 +346,3 @@ restore flat object | ||
- _fkey_ \<string\> | ||
- _return:_ Object | ||
- _return:_ Object | ||
@@ -364,3 +363,2 @@ get value in object using a flat key | ||
- _val_ \<*\> | ||
@@ -384,3 +382,3 @@ set value in object using a flat key | ||
- _val_ \<*\> | ||
- _return:_ bool | ||
- _return:_ bool | ||
@@ -391,5 +389,4 @@ check if ``val`` is setted, means it's not ``null`` or ``undefined`` | ||
#### util.onBrowser() | ||
- _return:_ bool | ||
- _return:_ bool | ||
check if you are on browser or not | ||
@@ -407,5 +404,6 @@ | ||
- _[remove=false]_ \<boolean\> remove missing placeholders from obj, default false | ||
- _return:_ string | ||
- _return:_ string | ||
replace placeholders inside graph brackets {} with obj dictionary\n~ES6 template string without $ | ||
replace placeholders inside graph brackets {} with obj dictionary | ||
~ES6 template string without $ | ||
@@ -423,3 +421,3 @@ _Example_ | ||
- _cuts_ \<Array<string>\> | ||
- _return:_ string | ||
- _return:_ string | ||
@@ -440,3 +438,3 @@ trim string | ||
- _to_ \<string\> | ||
- _return:_ string | ||
- _return:_ string | ||
@@ -455,3 +453,3 @@ | ||
- _str_ \<string\> | ||
- _return:_ string | ||
- _return:_ string | ||
@@ -471,3 +469,3 @@ | ||
- _str_ \<string\> | ||
- _return:_ string | ||
- _return:_ string | ||
@@ -484,3 +482,11 @@ | ||
#### string.matchAll(str, regexp) | ||
- _str_ \<string\> | ||
- _regexp_ \<RegExp\> | ||
- _return:_ String []} | ||
--- | ||
@@ -492,3 +498,3 @@ | ||
- _max_ \<number\> | ||
- _return:_ number | ||
- _return:_ number | ||
@@ -508,3 +514,3 @@ get random int from 0 to max | ||
- _max_ \<number\> | ||
- _return:_ number | ||
- _return:_ number | ||
@@ -524,3 +530,3 @@ get random int from min to max | ||
- _[set=abcdefghijklmnopqrstuvwxyz]_ \<Array\> | ||
- _return:_ string | ||
- _return:_ string | ||
@@ -539,3 +545,3 @@ get random string | ||
- _[length=8]_ \<number\> | ||
- _return:_ string | ||
- _return:_ string | ||
@@ -554,3 +560,3 @@ get random hex string | ||
- _salt_ \<?string\> | ||
- _return:_ string | ||
- _return:_ string | ||
@@ -570,3 +576,3 @@ get random hash string | ||
- _not_ \<Array<*>\> | ||
- _return:_ * element | ||
- _return:_ * element | ||
@@ -589,6 +595,68 @@ get random element from array | ||
#### sys.isRoot() | ||
- _return:_ bool is root or not | ||
- _return:_ bool is root or not | ||
check if running user is root | ||
--- | ||
### time | ||
#### time.chrono.set([tag=chrono]) | ||
- _[tag=chrono]_ \<string\> identifier | ||
start a timer identified by tag | ||
_Example_ | ||
````js | ||
tools.time.chrono.set('query') | ||
```` | ||
#### time.chrono.reset([tag=chrono]) | ||
- _[tag=chrono]_ \<string\> identifier | ||
reset the timer identified by tag | ||
_Example_ | ||
````js | ||
tools.time.chrono.reset('query') | ||
```` | ||
#### time.chrono.clear([tag=chrono]) | ||
- _[tag=chrono]_ \<string\> identifier | ||
discard the timer identified by tag | ||
_Example_ | ||
````js | ||
tools.time.chrono.clear('query') | ||
```` | ||
#### time.chrono.get([tag=chrono]) | ||
- _[tag=chrono]_ \<string\> identifier | ||
- _return:_ number ms | ||
get the timer in ms from start (or reset) identified by tag | ||
_Example_ | ||
````js | ||
tools.time.chrono.get('query') | ||
// > 11 | ||
```` | ||
#### time.gc() | ||
clear timers (if you care about memory) | ||
{ | ||
"name": "a-toolbox", | ||
"version": "1.2.7", | ||
"version": "1.2.8", | ||
"description": "javascript lightweight basic tools, isomorphic", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -70,6 +70,5 @@ # a-toolbox | ||
- [sys](#sys) | ||
- [time](#time) | ||
- [task](#task) | ||
todo | ||
- [time](#time) | ||
todo | ||
@@ -634,3 +633,64 @@ | ||
--- | ||
### time | ||
#### time.chrono.set([tag=chrono]) | ||
- _[tag=chrono]_ \<string\> | ||
start a timer identified by tag | ||
_Example_ | ||
````js | ||
tools.time.chrono.set('query') | ||
```` | ||
#### time.chrono.reset([tag=chrono]) | ||
- _[tag=chrono]_ \<string\> | ||
reset the timer identified by tag | ||
_Example_ | ||
````js | ||
tools.time.chrono.reset('query') | ||
```` | ||
#### time.chrono.clear([tag=chrono]) | ||
- _[tag=chrono]_ \<string\> | ||
discard the timer identified by tag | ||
_Example_ | ||
````js | ||
tools.time.chrono.clear('query') | ||
```` | ||
#### time.chrono.get([tag=chrono]) | ||
- _[tag=chrono]_ \<string\> | ||
- _return:_ number ms | ||
get the timer in ms from start (or reset) identified by tag | ||
_Example_ | ||
````js | ||
tools.time.chrono.get('query') | ||
// > 11 | ||
```` | ||
#### time.gc() | ||
clear timers (if you care about memory) | ||
--- | ||
@@ -637,0 +697,0 @@ |
@@ -13,4 +13,6 @@ const object = require('./object') | ||
/** | ||
* start a timer identified by tag | ||
* @method tools.time.chrono.set | ||
* @param {string} [tag=chrono] | ||
* @param {string} [tag=chrono] identifier | ||
* @test.case 'query' | ||
*/ | ||
@@ -25,4 +27,6 @@ set: function (tag = 'chrono') { | ||
/** | ||
* reset the timer identified by tag | ||
* @method tools.time.chrono.reset | ||
* @param {string} [tag=chrono] | ||
* @param {string} [tag=chrono] identifier | ||
* @test.case 'query' | ||
*/ | ||
@@ -33,4 +37,6 @@ reset: function (tag = 'chrono') { | ||
/** | ||
* discard the timer identified by tag | ||
* @method tools.time.chrono.clear | ||
* @param {string} [tag=chrono] | ||
* @param {string} [tag=chrono] identifier | ||
* @test.case 'query' | ||
*/ | ||
@@ -41,5 +47,7 @@ clear: function (tag = 'chrono') { | ||
/** | ||
* get the timer in ms from start (or reset) identified by tag | ||
* @method tools.time.chrono.get | ||
* @param {string} [tag=chrono] | ||
* @param {string} [tag=chrono] identifier | ||
* @return {number} ms | ||
* @test.case 'query' > (11) | ||
*/ | ||
@@ -53,4 +61,3 @@ get: function (tag = 'chrono') { | ||
/** | ||
* clear counters | ||
* if you care about memory leaks | ||
* clear timers (if you care about memory) | ||
* @method tools.time.chrono.gc | ||
@@ -57,0 +64,0 @@ */ |
19
time.js
@@ -13,4 +13,6 @@ const object = require('./object') | ||
/** | ||
* start a timer identified by tag | ||
* @method tools.time.chrono.set | ||
* @param {string} [tag=chrono] | ||
* @param {string} [tag=chrono] identifier | ||
* @test.case 'query' | ||
*/ | ||
@@ -25,4 +27,6 @@ set: function (tag = 'chrono') { | ||
/** | ||
* reset the timer identified by tag | ||
* @method tools.time.chrono.reset | ||
* @param {string} [tag=chrono] | ||
* @param {string} [tag=chrono] identifier | ||
* @test.case 'query' | ||
*/ | ||
@@ -33,4 +37,6 @@ reset: function (tag = 'chrono') { | ||
/** | ||
* discard the timer identified by tag | ||
* @method tools.time.chrono.clear | ||
* @param {string} [tag=chrono] | ||
* @param {string} [tag=chrono] identifier | ||
* @test.case 'query' | ||
*/ | ||
@@ -41,5 +47,7 @@ clear: function (tag = 'chrono') { | ||
/** | ||
* get the timer in ms from start (or reset) identified by tag | ||
* @method tools.time.chrono.get | ||
* @param {string} [tag=chrono] | ||
* @param {string} [tag=chrono] identifier | ||
* @return {number} ms | ||
* @test.case 'query' > (11) | ||
*/ | ||
@@ -53,4 +61,3 @@ get: function (tag = 'chrono') { | ||
/** | ||
* clear counters | ||
* if you care about memory leaks | ||
* clear timers (if you care about memory) | ||
* @method tools.time.chrono.gc | ||
@@ -57,0 +64,0 @@ */ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
292927
3803
740