(value: ArrayBuffer | ArrayBufferView | Buffer | string)
| 85 | } |
| 86 | |
| 87 | function toBuffer(value: ArrayBuffer | ArrayBufferView | Buffer | string): Buffer { |
| 88 | if (Buffer.isBuffer(value)) return value; |
| 89 | if (typeof value === 'string') return Buffer.from(value); |
| 90 | if (ArrayBuffer.isView(value)) { |
| 91 | return Buffer.from(value.buffer, value.byteOffset, value.byteLength); |
| 92 | } |
| 93 | return Buffer.from(value); |
| 94 | } |
| 95 | |
| 96 | function sha256(bytes: Buffer | Uint8Array | string): string { |
| 97 | return createHash('sha256').update(bytes).digest('hex'); |
no outgoing calls
no test coverage detected