New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

linesert

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linesert

Easily insert line(s) at a specific line number of a file.

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
22
-8.33%
Maintainers
1
Weekly downloads
 
Created
Source

Linesert Build Status

Easily insert line(s) at a specific line number of a file.

Features

Linesert allows you to easily insert lines at a specific line number of a file.

  • Insert a single line or an array of lines.
  • Insert lines before a specific line number.
  • Insert lines after a specific line number.

Getting Started

  • Install with NPM - npm install --save linesert

Usage

var linesert = require( "linesert" );

// file.txt
//=> 1.
//=> 3.

linesert( "file.txt" ).beforeLine( 2 ).insert( "2.", function( err, result ) {
  //=> 1.
  //=> 2.
  //=> 3.
});

API

linesert( path )

NameTypeArgumentDescription
pathstring<required>the path of the file to be modified.

linesert.beforeLine( number )

NameTypeArgumentDescription
numbernumber<required>the line number to insert the new lines before.

linesert.afterLine( number )

NameTypeArgumentDescription
numbernumber<required>the line number to insert the new lines after.

linesert.insert( text, callback )

NameTypeArgumentDescription
text`stringarray`<required>
callbackfunction<required>callback that returns the results of the update.

callback( error, results )

NameTypeArgumentDescription
errorerror<required>any errors that may have occured.
resultsstring<required>the output of the updated file.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.

License

Copyright (c) 2015 Jason Bellamy
Licensed under the MIT license.

Keywords

line

FAQs

Package last updated on 10 Jan 2015

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