@@ -17,7 +17,7 @@ A collection of useful utilities.
1717## Install
1818
1919``` bash
20- $ npm install utility
20+ npm install utility
2121```
2222
2323## Usage
@@ -29,7 +29,7 @@ const utils = require('utility');
2929Also you can use it within typescript, like this ↓
3030
3131``` ts
32- import utility from ' utility' ;
32+ import * as utility from ' utility' ;
3333```
3434
3535### md5
@@ -212,7 +212,9 @@ const res = utils.try(function () {
212212// {error: undefined, value: {foo: 'bar'}}
213213// {error: Error, value: undefined}
214214```
215+
215216``` Note ``` that when you use ``` typescript ``` , you must use the following methods to call ' Try '
217+
216218``` js
217219import * as utility from ' utility' ;
218220
@@ -223,7 +225,7 @@ utility.UNSTABLE_METHOD.try(...);
223225### argumentsToArray
224226
225227``` js
226- function () {
228+ function foo () {
227229 const arr = utility .argumentsToArray (arguments );
228230 console .log (arr .join (' , ' ));
229231}
@@ -251,21 +253,19 @@ async () => {
251253}
252254```
253255
254- > ** Hint: ** In ` utils.writeJSON*() ` , if ` pkg ` is an object, the ** optional ** third parameter ` options ` may contain two
256+ > __ Hint: __ In ` utils.writeJSON*() ` , if ` pkg ` is an object, the __ optional __ third parameter ` options ` may contain two
255257> keys.
256258>
257259> + ` replacer ` : Equals to ` JSON.stringify() ` 's second parameter;
258260> + ` space ` : Equals to ` JSON.stringify() ` 's third parameter. Defaults to ` 2 ` .
259261>
260262> Refs:
261263>
262- > + https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter
263- > + https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_space_argument
264-
264+ > + < https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter >
265+ > + < https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_space_argument >
265266
266267### Object.assign
267268
268-
269269``` js
270270// assign object
271271utility .assign ({}, { a: 1 });
@@ -276,11 +276,11 @@ utility.assign({}, [ { a: 1 }, { b: 1 } ]);
276276
277277## benchmark
278278
279- * [ jsperf: access log date format] ( http://jsperf.com/access-log-date-format )
280- * [ benchmark/date_format.js] ( https://github.com/fengmk2 /utility/blob/master/benchmark/date_format.js )
279+ + [ jsperf: access log date format] ( http://jsperf.com/access-log-date-format )
280+ + [ benchmark/date_format.js] ( https://github.com/node-modules /utility/blob/master/benchmark/date_format.cjs )
281281
282282``` bash
283- $ node benchmark/date_format.js
283+ $ node benchmark/date_format.cjs
284284
285285moment ().format(" DD/MMM/YYYY:HH:mm:ss ZZ" ): " 16/Apr/2013:21:12:32 +0800"
286286utils.accessLogDate (): " 16/Apr/2013:21:12:32 +0800"
@@ -300,10 +300,10 @@ Date.now() x 8,327,685 ops/sec ±1.85% (94 runs sampled)
300300Fastest is Date.now ()
301301```
302302
303- [ benchmark/date_YYYYMMDD.js] ( https://github.com/fengmk2 /utility/blob/master/benchmark/date_YYYYMMDD.js )
303+ [ benchmark/date_YYYYMMDD.js] ( https://github.com/node-modules /utility/blob/master/benchmark/date_YYYYMMDD.cjs )
304304
305305``` bash
306- $ node benchmark/date_YYYYMMDD.js
306+ $ node benchmark/date_YYYYMMDD.cjs
307307
308308parseInt(moment ().format(" YYYYMMDD" ), 10): 20130416
309309utils.datestruct ().YYYYMMDD: 20130416
@@ -319,11 +319,12 @@ Fastest is utils.datestruct().YYYYMMDD
319319
320320## Contributors
321321
322- | [ <img src =" https://avatars0 .githubusercontent.com/u/156269?v=4 " width =" 100px; " /><br /><sub ><b >fengmk2</b ></sub >] ( https://github.com/fengmk2 ) <br />| [ <img src =" https://avatars3 .githubusercontent.com/u/985607?v=4 " width =" 100px; " /><br /><sub ><b >dead-horse</b ></sub >] ( https://github.com/dead-horse ) <br />| [ <img src =" https://avatars1 .githubusercontent.com/u/1147375?v=4 " width =" 100px; " /><br /><sub ><b >alsotang</b ></sub >] ( https://github.com/alsotang ) <br />| [ <img src =" https://avatars1 .githubusercontent.com/u/360661?v=4 " width =" 100px; " /><br /><sub ><b >popomore</b ></sub >] ( https://github.com/popomore ) <br />| [ <img src =" https://avatars2 .githubusercontent.com/u/1207064?v=4 " width =" 100px; " /><br /><sub ><b >gxcsoccer</b ></sub >] ( https://github.com/gxcsoccer ) <br />| [ <img src =" https://avatars3 .githubusercontent.com/u/2842176 ?v=4 " width =" 100px; " /><br /><sub ><b >XadillaX </b ></sub >] ( https://github.com/XadillaX ) <br />|
322+ | [ <img src =" https://avatars .githubusercontent.com/u/156269?v=4 " width =" 100px; " /><br /><sub ><b >fengmk2</b ></sub >] ( https://github.com/fengmk2 ) <br />| [ <img src =" https://avatars .githubusercontent.com/u/985607?v=4 " width =" 100px; " /><br /><sub ><b >dead-horse</b ></sub >] ( https://github.com/dead-horse ) <br />| [ <img src =" https://avatars .githubusercontent.com/u/1147375?v=4 " width =" 100px; " /><br /><sub ><b >alsotang</b ></sub >] ( https://github.com/alsotang ) <br />| [ <img src =" https://avatars .githubusercontent.com/u/360661?v=4 " width =" 100px; " /><br /><sub ><b >popomore</b ></sub >] ( https://github.com/popomore ) <br />| [ <img src =" https://avatars .githubusercontent.com/u/1207064?v=4 " width =" 100px; " /><br /><sub ><b >gxcsoccer</b ></sub >] ( https://github.com/gxcsoccer ) <br />| [ <img src =" https://avatars .githubusercontent.com/u/5127897 ?v=4 " width =" 100px; " /><br /><sub ><b >danielsss </b ></sub >] ( https://github.com/danielsss ) <br />|
323323| :---: | :---: | :---: | :---: | :---: | :---: |
324- [ <img src =" https://avatars1.githubusercontent.com/u/24466804?v=4 " width =" 100px; " /><br /><sub ><b >mosikoo</b ></sub >] ( https://github.com/mosikoo ) <br />|[ <img src =" https://avatars2.githubusercontent.com/u/2569835?v=4 " width =" 100px; " /><br /><sub ><b >haoxins</b ></sub >] ( https://github.com/haoxins ) <br />|[ <img src =" https://avatars1.githubusercontent.com/u/546535?v=4 " width =" 100px; " /><br /><sub ><b >leoner</b ></sub >] ( https://github.com/leoner ) <br />|[ <img src =" https://avatars3.githubusercontent.com/u/33921398?v=4 " width =" 100px; " /><br /><sub ><b >ddzy</b ></sub >] ( https://github.com/ddzy ) <br />
324+ | [ <img src =" https://avatars.githubusercontent.com/u/2842176?v=4 " width =" 100px; " /><br /><sub ><b >XadillaX</b ></sub >] ( https://github.com/XadillaX ) <br />| [ <img src =" https://avatars.githubusercontent.com/u/23133919?v=4 " width =" 100px; " /><br /><sub ><b >ulivz</b ></sub >] ( https://github.com/ulivz ) <br />| [ <img src =" https://avatars.githubusercontent.com/u/24466804?v=4 " width =" 100px; " /><br /><sub ><b >mosikoo</b ></sub >] ( https://github.com/mosikoo ) <br />| [ <img src =" https://avatars.githubusercontent.com/u/546535?v=4 " width =" 100px; " /><br /><sub ><b >leoner</b ></sub >] ( https://github.com/leoner ) <br />| [ <img src =" https://avatars.githubusercontent.com/u/8603442?v=4 " width =" 100px; " /><br /><sub ><b >legend80s</b ></sub >] ( https://github.com/legend80s ) <br />| [ <img src =" https://avatars.githubusercontent.com/u/32174276?v=4 " width =" 100px; " /><br /><sub ><b >semantic-release-bot</b ></sub >] ( https://github.com/semantic-release-bot ) <br />|
325+ [ <img src =" https://avatars.githubusercontent.com/u/33921398?v=4 " width =" 100px; " /><br /><sub ><b >ddzy</b ></sub >] ( https://github.com/ddzy ) <br />|[ <img src =" https://avatars.githubusercontent.com/u/8896314?v=4 " width =" 100px; " /><br /><sub ><b >zhanghengyao</b ></sub >] ( https://github.com/zhanghengyao ) <br />
325326
326- This project follows the git-contributor [ spec] ( https://github.com/xudafeng/git-contributor ) , auto updated at ` Sat Mar 23 2019 12:09:41 GMT+0800` .
327+ This project follows the git-contributor [ spec] ( https://github.com/xudafeng/git-contributor ) , auto updated at ` Mon Dec 11 2023 00:23:06 GMT+0800` .
327328
328329<!-- GITCONTRIBUTOR_END -->
329330
0 commit comments