New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

file-rw

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-rw

Read and write files more easily

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
567
increased by14.55%
Maintainers
1
Weekly downloads
 
Created
Source

node-file-rw

Read and write multiple files

Installation

npm install file-rw

Usage

readFilesUtf8(files, [options], callback)

Read an array of files. options.encoding defaults to utf-8.

  • files - an array of files
  • options - options for fs.readFile. encoding defaults to utf-8
  • callback - a function which will be called with (err, [ file1Contents, file2Contents, ... ])

mkWriteFile(filePath, contents, [options], callback)

Write a file, creating any directories in its path that do not exist.

  • filePath - path of the file to write
  • contents - contents to write in file
  • options - options for fs.writeFile
  • callback - a function which will be called with (err, filePath)

mkWriteFiles(filePairs, [options], callback)

Write a file, creating any directories in its path that do not exist.

  • filePairs - an array of pairs [ filePath, contents ]. e.g [ ['file1.txt', 'foo'], ['file2.txt', 'bar'] ]
  • options - options for fs.writeFile
  • callback - a function which will be called with (err, [ file1Path, file2Path, ... ])

Examples

var filerw = require('../index');

filerw.readFilesUtf8(['f1.txt', 'f2.txt'], function(err, result) {
  // result[0] == f1Contents
  // result[1] == f2Contents
});

filerw.mkWriteFile('a/b/c.txt', 'foo', function(err, result) {
  // result == 'a/b/c.txt'
});

filerw.mkWriteFiles([[ 'a/b/c.txt', 'foo'], [ 'd/e.txt', 'bar' ]], function(err, result) {
  // result[0] == 'a/b/c.txt'
  // result[1] == 'd/e.txt'
});

Keywords

FAQs

Package last updated on 02 Feb 2014

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc