inference-server
Version:
Libraries and server to build AI applications. Adapters to various native bindings allowing local inference. Integrate it with your application, or use as a microservice.
18 lines (17 loc) • 477 B
text/typescript
import fs from 'node:fs'
import crypto from 'node:crypto'
export function calculateFileChecksum(filePath: string, hashType = 'sha256'): Promise<string> {
return new Promise((resolve, reject) => {
const fileStream = fs.createReadStream(filePath)
const result = crypto.createHash(hashType)
fileStream.on('error', reject)
fileStream.on('data', (chunk) => {
result.update(chunk)
})
fileStream.on('end', () => {
resolve(
result.digest('hex')
)
})
})
}