cute-fs

0.9.0 • Public • Published

available on npmjs

cute-fs

This package solves the issue of file read/writes being confusing with vague syntax. Using the idea of URLs for local paths.

Install

npm install cute-fs

There are some basic concepts.

await url('').soft.write(''); // write never overwrites
await url('').hard.write(''); // hard creates directories along the way
await url('').soft.overwrite(''); // overwrite will overwrite
await url('').hard.overwrite(''); // hard will create the dirs along the way
await url('').soft.read(''); // it also works with web urls
await url('').hard.read(''); // hard will create an empty file + dirs if the file is not there

Examples

import url from 'cute-fs';
await url('C:\\WindowsLikePathOr\\LinuxLike\\Path.txt').soft.write('any text');
await url('path/to/file.txt').hard.overwrite(`any text`);
await url('https://raw.githubusercontent.com/planetrenox/cute-npm-init/main/index.js').soft.read();
  • soft will not create dirs along the way and will error.
  • hard will create dirs along the way if they dont exist.
  • write does not overwrite.
  • overwrite overwrites.
  • hard.read will create the dirs and an empty file if its not there.

The writing functionality for web URLs is not documented because it is still in testing. Feel free to look at the repo.

Readme

Keywords

Package Sidebar

Install

npm i cute-fs

Weekly Downloads

4

Version

0.9.0

License

CC-BY-4.0

Unpacked Size

5.52 kB

Total Files

4

Last publish

Collaborators

  • planetrenox