Socket
Book a DemoInstallSign in
Socket

safe-read-write

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

safe-read-write

Uses lockfile and mz (mz/fs) to write and read simple text files safely

1.0.5
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

safe-read-write

Uses lockfile and mz to safely read and write simple text files.

Use case: Needed for a node based http server application that does many small read/write operations. The server accepts requests and returns a 202 - Accepted. The server contains a worker process that is executed using spawn that does a potenaillay long (up to many minutes) process; during the process, the worker writes status information in JSON to a file. The client then polls for the status could get malformed JSON without safe-read-write.

Install, develop, test, use

# install
npm install safe-read-write

# develop
npm run compile
npm run dev # watch

# test
npm test
npm run tdd # watch

# use
const saferw = require('safe-read-write');
import saferw from 'safe-read-write';

...

safeWrite('/path/to/textfile', 'text content', 'utf8');

...

safeRead('/path/to/textfile')
  .then(data => ...);

Keywords

lock

FAQs

Package last updated on 07 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.