extra-compatible
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -1,1 +0,2 @@ | ||
export declare function sha256(text: string): Promise<string>; | ||
import { TypedArray } from '@blackglory/prelude'; | ||
export declare function sha256(input: string | DataView | TypedArray): Promise<string>; |
@@ -5,9 +5,20 @@ "use strict"; | ||
const buffer_to_hex_1 = require("./utils/buffer-to-hex"); | ||
async function sha256(text) { | ||
const encoder = new TextEncoder(); | ||
const buffer = encoder.encode(text); | ||
const hashBuffer = await crypto.subtle.digest('SHA-256', buffer); | ||
const prelude_1 = require("@blackglory/prelude"); | ||
async function sha256(input) { | ||
const hashBuffer = await crypto.subtle.digest('SHA-256', toArrayBufferView(input)); | ||
return (0, buffer_to_hex_1.bufferToHex)(hashBuffer); | ||
} | ||
exports.sha256 = sha256; | ||
function toArrayBufferView(input) { | ||
if ((0, prelude_1.isString)(input)) { | ||
const encoder = new TextEncoder(); | ||
return encoder.encode(input); | ||
} | ||
else if (input instanceof DataView) { | ||
return input; | ||
} | ||
else { | ||
return new DataView(input); | ||
} | ||
} | ||
//# sourceMappingURL=sha256.browser.js.map |
@@ -1,1 +0,2 @@ | ||
export declare function sha256(text: string): Promise<string>; | ||
import { TypedArray } from '@blackglory/prelude'; | ||
export declare function sha256(input: string | DataView | TypedArray): Promise<string>; |
@@ -5,5 +5,5 @@ "use strict"; | ||
const crypto = require("crypto"); | ||
async function sha256(text) { | ||
async function sha256(input) { | ||
return crypto.createHash('sha256') | ||
.update(text) | ||
.update(input) | ||
.digest('hex'); | ||
@@ -10,0 +10,0 @@ } |
{ | ||
"name": "extra-compatible", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "", | ||
@@ -38,3 +38,2 @@ "keywords": [], | ||
"devDependencies": { | ||
"@blackglory/prelude": "^0.1.7", | ||
"@commitlint/cli": "^17.2.0", | ||
@@ -57,3 +56,6 @@ "@commitlint/config-conventional": "^17.2.0", | ||
}, | ||
"dependencies": {} | ||
"dependencies": { | ||
"@blackglory/prelude": "^0.1.7", | ||
"iterable-operator": "^2.1.0" | ||
} | ||
} |
@@ -22,3 +22,3 @@ # extra-compatible | ||
```ts | ||
function sha256(text: string): Promise<string> | ||
function sha256(input: string | DataView | TypedArray): Promise<string> | ||
``` |
Sorry, the diff of this file is not supported yet
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
10805
16
112
2
+ Added@blackglory/prelude@^0.1.7
+ Addediterable-operator@^2.1.0
+ Added@blackglory/errors@2.4.3(transitive)
+ Added@blackglory/go@1.1.3(transitive)
+ Added@blackglory/log@1.3.5(transitive)
+ Added@blackglory/pass@1.1.1(transitive)
+ Added@blackglory/prelude@0.1.100.2.4(transitive)
+ Added@blackglory/structures@0.11.8(transitive)
+ Added@blackglory/types@1.4.0(transitive)
+ Addedextra-compatible@0.1.8(transitive)
+ Addedextra-fsm@0.1.1(transitive)
+ Addedextra-generator@0.2.23(transitive)
+ Addedextra-json-stable-stringify@0.1.2(transitive)
+ Addedextra-lazy@1.3.1(transitive)
+ Addedextra-promise@4.4.1(transitive)
+ Addedextra-rand@0.1.5(transitive)
+ Addedextra-timers@0.2.6(transitive)
+ Addedextra-utils@3.7.04.0.1(transitive)
+ Addedfast-stable-stringify@1.0.0(transitive)
+ Addedhotypes@0.5.1(transitive)
+ Addediterable-operator@2.5.0(transitive)
+ Addedjustypes@2.3.03.1.24.4.1(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedreturn-style@1.0.1(transitive)
+ Addedrxjs@7.8.1(transitive)
+ Addedtslib@2.8.1(transitive)