edit-file

Read=>Edit=>Write a file

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
edit-file
0.3.07 years ago7 years agoMinified + gzip package size for edit-file in KB

Readme

Edit (read, edit, write) a file in Node.js ``` npm install edit-file ```

API

editFile(file, edit=text=>text, callback=done)

  • file is the filename path you want to edit. It may be relative or absolute.
  • edit is the editing function you use to change the text. The default returns the original text.
  • callback is a function to call after editing. The default throws errors and logs success.

Usage

```js const editFile = require("edit-file") ``` ```js editFile("example.txt") ``` ```js editFile("example.txt", text => text.trim()) ``` ```js editFile("example.txt", text => text.trim(), err => { if (err) throw err // ... }) ```