(value: ArrayBuffer | ArrayBufferView | Buffer | string)
| 50 | } |
| 51 | |
| 52 | function toBuffer(value: ArrayBuffer | ArrayBufferView | Buffer | string): Buffer { |
| 53 | if (Buffer.isBuffer(value)) return value; |
| 54 | if (typeof value === 'string') return Buffer.from(value); |
| 55 | if (ArrayBuffer.isView(value)) { |
| 56 | return Buffer.from(value.buffer, value.byteOffset, value.byteLength); |
| 57 | } |
| 58 | return Buffer.from(value); |
| 59 | } |
| 60 | |
| 61 | function sha256(bytes: Buffer | Uint8Array | string): string { |
| 62 | return createHash('sha256').update(bytes).digest('hex'); |
no outgoing calls
no test coverage detected