(text: Buffer | string, length = 8)
| 44 | * @internal |
| 45 | */ |
| 46 | export function getHash(text: Buffer | string, length = 8): string { |
| 47 | const h = createHash('sha256').update(text).digest('hex').substring(0, length); |
| 48 | if (length <= 64) { |
| 49 | return h; |
| 50 | } |
| 51 | return h.padEnd(length, '_'); |
| 52 | } |
| 53 | |
| 54 | // https://github.com/vitejs/vite/blob/b7ddfae5f852c2948fab03e94751ce56f5f31ce0/packages/vite/src/shared/utils.ts#L40 |
| 55 | /** |
no test coverage detected