Package Exports
- @techor/fs
- @techor/fs/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@techor/fs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Getting Started
npm install @techor/fs
Usage
readFile(source?: fg.Pattern | fg.Pattern[], options?: Options): Buffer
readFileAsStr(source?: fg.Pattern | fg.Pattern[], options?: Options): string
readFileAsJSON(source?: fg.Pattern | fg.Pattern[], options?: Options): any
readFiles(source?: fg.Pattern | fg.Pattern[], options?: Options): Buffer[]
writeToFile(filePath: fs.PathOrFileDescriptor, data: any, options?: WriteToFileOptions): void
a.json
{ "name": "a" }
b.json
{ "name": "b" }
import { readFile, readFiles } from '@techor/fs'
readFile('a.*')
// Buffer
readFile('./fewjiogw/wiefoiwe')
// undefined
readFileAsStr('a.*')
// '{ "name": "a" }'
readFileAsJSON('./package.json')
// { "name": "root", ... }
readFileAsJSON('./package.json', { cwd: path.resolve('./packages/a') })
// { "name": "a", ... }
readFiles('*.json').toString()
// [Buffer, Buffer]
Options
File reading methods inherit fast-glob options
{
cwd: process.cwd()
}
With additional options:
{
encoding?: null
flag?: string
}