Initial implementation for generating thread JSON files
This commit is contained in:
@@ -78,8 +78,11 @@ export abstract class Iterable<T> {
|
||||
throw new Error('Chunk size must be at least 1')
|
||||
}
|
||||
|
||||
const total = await this.count()
|
||||
while ( true ) {
|
||||
const items = await this.range(this.index, this.index + size - 1)
|
||||
// Bound the RHS index by the max # of items in case the source
|
||||
// doesn't gracefully handle out-of-bounds access
|
||||
const items = await this.range(this.index, Math.min(this.index + size - 1, total - 1))
|
||||
this.index += items.count()
|
||||
|
||||
try {
|
||||
|
||||
8
src/bones/crypto.ts
Normal file
8
src/bones/crypto.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
const hasher = new Bun.CryptoHasher('sha256')
|
||||
export function sha256(val: string|Uint8Array|ArrayBuffer): string {
|
||||
hasher.update(val)
|
||||
const digest = hasher.digest('base64')
|
||||
hasher.update('')
|
||||
return digest
|
||||
}
|
||||
Reference in New Issue
Block a user