toolkit
Load .json file synchronous. Don't use require('.json')
to load *.json files, it will cached in process.
方法签名
方法 | exports.loadJSONSync() | ||
参数 | filename(String) | absolute file path |
|
返回 | Object | a parsed object |
Encoding a string to Buffer safely
方法签名
方法 | exports.encode() | ||
参数 | str(String) | string. |
|
参数 | encoding.(String) | optional. |
|
返回 | Buffer | encoded buffer |
Generate a haser with specfied algorithm
方法签名
方法 | exports.makeHasher() | ||
参数 | algorithm(String) | can be md5, etc. |
|
返回 | Function | a haser with specfied algorithm |
Get md5 hash digests of data
方法签名
属性 | exports.md5 | ||
参数 | data(String,Buffer) | data. |
|
参数 | encoding(String) | optionnal. can be 'hex', 'binary', 'base64'. |
|
返回 | String,Buffer | if no encoding is provided, a buffer is returned. |
Get sha1 hash digests of data
方法签名
方法 | exports.sha1() | ||
参数 | data(String,Buffer) | data. |
|
参数 | key(String) | the key. |
|
参数 | encoding(String) | optionnal. can be 'hex', 'binary', 'base64'. |
|
返回 | String,Buffer | if no encoding is provided, a buffer is returned. |
Get a random value in a range
方法签名
方法 | exports.random() | ||
参数 | min(Number) | range start. |
|
参数 | max(Number) | range end. |
Generate a nonce string
方法签名
属性 | exports.makeNonce | ||
返回 | String | a nonce string. |
Pad a number as \d\d format
方法签名
方法 | exports.pad2() | ||
参数 | num(Number) | a number that less than 100. |
|
返回 | String | if number less than 10, pad with 0, otherwise, returns string of number. |
Pad a number as \d\d\d format
方法签名
方法 | exports.pad3() | ||
参数 | num(Number) | a number that less than 1000. |
|
返回 | String | if number less than 100, pad with 0, otherwise, returns string of number. |
Return the YYYYMMDD format of a date.
方法签名
方法 | exports.getYYYYMMDD() | ||
参数 | date(Date) | a Date object. |
|
返回 | String | the YYYYMMDD format. |
sleep a while.
方法签名
方法 | exports.sleep() | ||
参数 | in(Number) | milliseconds |
|
返回 | Promise | a Promise |
Get the IPv4 address
方法签名
方法 | exports.getIPv4() | ||
返回 | String | the IPv4 address, or empty string |
Get the Mac address
方法签名
方法 | exports.getMac() | ||
返回 | String | the Mac address |