1.0.2 • Published 1 year ago

file-ez v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

F-ez

easy file stuff I suppose

Install

npm i file-ez

Usage

f-ez supports commonjs:

const fz = require('file-ez');

fz.res('./file.txt');

but also exports everything separately for esm:

import { res } from 'file-ez';

res('./file.txt');

Documentation

res(path: string): string

Resolves a path relative to the file it's called in.\ path: an absolute path, or path relative to the current file

async recursive(path: string): Promise<string[]>

Recursively gathers all files in a directory and its subdirectories.\ path: an absolute path, or path relative to the current file

async require(path: string, full = false): Promise<any>

Makes import() feel more like require(), allows mixing esm and commonjs.\ path: an absolute path, path relative to the current file, or name of an installed package\ full: return the entire module instead of only default

async read(path: string): Promise<string>

Returns the contents of a file as a string.\ path: an absolute path, or path relative to the current file

async buffer(path: string): Promise<Buffer>

Returns the contents of a file as a buffer.\ path: an absolute path, or path relative to the current file

async write(path: string, data: Buffer|string): Promise<undefined>

Writes data to a file.\ path: an absolute path, or path relative to the current file\ data: what you want to write to the file

1.0.2

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago

0.2.1

3 years ago

0.2.2

3 years ago

0.2.0

3 years ago

0.1.4

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago