prepend-file-promise
TypeScript icon, indicating that this package has built-in type declarations

1.3.3 • Public • Published

NPM version Build Status Dependency Status

Prepend data to a file, creating the file if it not yet exists.

Install

$ npm install --save prepend-file

Usage

var prependFile = require('prepend-file');
 
prependFile('message.txt', 'data to prepend', function (err) {
    if (err) {
        // Error
    }
 
    // Success
    console.log('The "data to prepend" was prepended to file!');
});

API

prependFile(filename, data, [options], callback)

    * filename String
    * data String | Buffer
    * options Object
        encoding String | Null default = 'utf8'
        mode Number default = 438 (aka 0666 in Octal)
    * callback Function

Asynchronously prepend data to a file, creating the file if it not yet exists. The data can be a string or a buffer.

prependFile.sync(filename, data, [options])

The synchronous version of prependFile. Returns undefined.

Related

License

MIT © Hemanth.HM

Readme

Keywords

Package Sidebar

Install

npm i prepend-file-promise

Weekly Downloads

32

Version

1.3.3

License

MIT

Unpacked Size

6.27 kB

Total Files

5

Last publish

Collaborators

  • darlansbjr