1.1.7 • Published 8 months ago

@alwatr/node-fs v1.1.7

Weekly downloads
-
License
AGPL-3.0-only
Repository
github
Last release
8 months ago

Node FS

Enhanced file system operations in Node.js with asynchronous queue to prevent parallel writes.

Installation

yarn add @alwatr/node-fs

Features

  • Checks if a directory exists. If it doesn't, it creates the directory and all necessary subdirectories.
  • Before writing a file successfully, first writes it to a temporary path (path.tmp).
  • If a file already exists, renames and keeps the existing file at a backup path (path.bak).
  • If a write operation fails, the original file remains unchanged.
  • Includes readJson and writeJson functions that automatically parse and stringify JSON data.
  • Supports both synchronous and asynchronous read/write operations.
  • An asynchronous queue is used to prevent simultaneous write operations.
  • Fully written in TypeScript, includes type definitions.
  • Separate builds are provided for ESModule and CommonJS.
  • Zero dependencies, except for the nanolib library.
  • Includes a beautiful log feature, which uses the logger package from nanolib.

Usage

import {writeJson} from '@alwatr/node-fs';

const path = 'file.json';
await writeJson(path, {a: 1}); // wait to finish
writeJson(path, {a: 2}); // asynchronous write in queue
writeJson(path, {a: 3}); // asynchronous write in queue

const data = await readJson(path); // automatically wait for the queue to finish
console.log(data.a); // 3
1.1.7

8 months ago

1.1.1

8 months ago

1.1.0

9 months ago

1.1.6

8 months ago

1.1.5

8 months ago

1.1.4

8 months ago

1.1.3

8 months ago

1.1.2

8 months ago

1.0.9

10 months ago

1.0.11

10 months ago

1.0.10

10 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.8

12 months ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

1.0.0-beta.0

1 year ago