napi-rs/cli/src/utils.ts

16 lines
505 B
TypeScript
Raw Normal View History

2021-11-21 22:39:36 +09:00
import { readFile, writeFile, copyFile, mkdir, unlink } from 'fs'
2020-09-04 17:22:15 +09:00
import { promisify } from 'util'
export const readFileAsync = promisify(readFile)
export const writeFileAsync = promisify(writeFile)
export const unlinkAsync = promisify(unlink)
export const copyFileAsync = promisify(copyFile)
export const mkdirAsync = promisify(mkdir)
export function pick<O, K extends keyof O>(o: O, ...keys: K[]): Pick<O, K> {
return keys.reduce((acc, key) => {
acc[key] = o[key]
return acc
}, {} as O)
}