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('');
await url('').hard.write('');
await url('').soft.overwrite('');
await url('').hard.overwrite('');
await url('').soft.read('');
await url('').hard.read('');
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.