Comparing version 1.15.0 to 1.15.1
1.15.1 / 2019-03-13 | ||
================== | ||
**features** | ||
* [[`b092817`](http://github.com/node-modules/utility/commit/b092817be0c4de459bde180e754ba4872e715027)] - feat: support for ts (#45) (yyge <<33921398+ddzy@users.noreply.github.com>>) | ||
**others** | ||
* [[`09bd9d0`](http://github.com/node-modules/utility/commit/09bd9d061b57a2ef6b24a39b41063f51cf251fc1)] - chore: package.json files add [index.d.ts] (#46) (ccccQ <<chenqiuws@gmail.com>>) | ||
* [[`7c102f4`](http://github.com/node-modules/utility/commit/7c102f4aff81e44b96629d692ce74f22cc02919f)] - test: travis support windows (#40) (fengmk2 <<fengmk2@gmail.com>>) | ||
* [[`fdd2d27`](http://github.com/node-modules/utility/commit/fdd2d27ce99c25458795ad1e7555370498c051bd)] - chore: fix typo function name of sha256 (#39) (fengmk2 <<fengmk2@gmail.com>>) | ||
1.15.0 / 2018-09-12 | ||
@@ -3,0 +14,0 @@ ================== |
@@ -56,3 +56,3 @@ 'use strict'; | ||
*/ | ||
exports.sha256 = function sha1(s, format) { | ||
exports.sha256 = function sha256(s, format) { | ||
return exports.hash('sha256', s, format); | ||
@@ -95,3 +95,3 @@ }; | ||
if (!Buffer.isBuffer(s)) { | ||
s = new Buffer(s); | ||
s = typeof Buffer.from === 'function' ? Buffer.from(s) : new Buffer(s); | ||
} | ||
@@ -118,3 +118,3 @@ var encode = s.toString('base64'); | ||
} | ||
var buf = new Buffer(encodeStr, 'base64'); | ||
var buf = typeof Buffer.from === 'function' ? Buffer.from(encodeStr, 'base64') : new Buffer(encodeStr, 'base64'); | ||
if (encoding === 'buffer') { | ||
@@ -121,0 +121,0 @@ return buf; |
@@ -27,3 +27,12 @@ 'use strict'; | ||
/** | ||
* @description Deal with typescript | ||
*/ | ||
exports.UNSTABLE_METHOD = { | ||
try: exports.try, | ||
}; | ||
/** | ||
* avoid if (a && a.b && a.b.c) | ||
@@ -30,0 +39,0 @@ * @param {Object} obj |
{ | ||
"name": "utility", | ||
"version": "1.15.0", | ||
"version": "1.15.1", | ||
"description": "A collection of useful utilities.", | ||
"main": "lib/utility.js", | ||
"files": [ | ||
"lib" | ||
"lib", | ||
"index.d.ts" | ||
], | ||
"scripts": { | ||
"test": "npm run lint && npm run test-local", | ||
"test-ts": "npm run test-local-ts", | ||
"test-local": "ava test/**/*.test.js", | ||
"test-local-ts": "ava-ts test_ts/**/*.test.ts", | ||
"test-cov": "nyc ava test/**/*.test.js && nyc report --reporter=lcov", | ||
"lint": "jshint .", | ||
"ci": "npm run lint && npm run test-cov", | ||
"ci": "npm run lint && npm run test-cov && npm run test-ts", | ||
"autod": "autod -w --prefix '^' -e benchmark", | ||
@@ -26,4 +29,7 @@ "test-optimized": "node --allow-natives-syntax --trace_opt --trace_deopt test/optimized.js" | ||
"devDependencies": { | ||
"@types/escape-html": "0.0.20", | ||
"@types/node": "^10.12.12", | ||
"autod": "*", | ||
"ava": "^0.25.0", | ||
"ava-ts": "^0.25.2", | ||
"beautify-benchmark": "*", | ||
@@ -37,3 +43,5 @@ "benchmark": "^2.1.0", | ||
"optimized": "^1.2.0", | ||
"rimraf": "^2.6.2" | ||
"rimraf": "^2.6.2", | ||
"ts-node": "^7.0.1", | ||
"typescript": "^3.2.2" | ||
}, | ||
@@ -40,0 +48,0 @@ "homepage": "https://github.com/node-modules/utility", |
@@ -36,2 +36,6 @@ # utility | ||
``` | ||
Also you can use it within typescript, like this ↓ | ||
```js | ||
import * as utility from 'utility'; | ||
``` | ||
@@ -42,3 +46,3 @@ ### md5 | ||
utils.md5('苏千').should.equal('5f733c47c58a077d61257102b2d44481'); | ||
utils.md5(new Buffer('苏千')).should.equal('5f733c47c58a077d61257102b2d44481'); | ||
utils.md5(Buffer.from('苏千')).should.equal('5f733c47c58a077d61257102b2d44481'); | ||
// md5 base64 format | ||
@@ -55,3 +59,3 @@ utils.md5('苏千', 'base64'); // 'X3M8R8WKB31hJXECstREgQ==' | ||
utils.sha1('苏千').should.equal('0a4aff6bab634b9c2f99b71f25e976921fcde5a5'); | ||
utils.sha1(new Buffer('苏千')).should.equal('0a4aff6bab634b9c2f99b71f25e976921fcde5a5'); | ||
utils.sha1(Buffer.from('苏千')).should.equal('0a4aff6bab634b9c2f99b71f25e976921fcde5a5'); | ||
// sha1 base64 format | ||
@@ -67,3 +71,3 @@ utils.sha1('苏千', 'base64'); // 'Ckr/a6tjS5wvmbcfJel2kh/N5aU=' | ||
```js | ||
utils.sha256(new Buffer('苏千')).should.equal('75dd03e3fcdbba7d5bec07900bae740cc8e361d77e7df8949de421d3df5d3635'); | ||
utils.sha256(Buffer.from('苏千')).should.equal('75dd03e3fcdbba7d5bec07900bae740cc8e361d77e7df8949de421d3df5d3635'); | ||
``` | ||
@@ -215,3 +219,10 @@ | ||
``` | ||
```Note``` that when you use ```typescript```, you must use the following methods to call ' Try ' | ||
```js | ||
import * as utility from 'utility'; | ||
utility.UNSTABLE_METHOD.try(...); | ||
... | ||
``` | ||
### argumentsToArray | ||
@@ -218,0 +229,0 @@ |
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
53941
17
1335
321
16