Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appendit

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appendit

Appendit allows you easily to add text at a specific line. It will works with any plain text format like ```.txt``` ```.md``` ```.js``` ...

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

#Appendit NPM version Build Status Coverage Status Dependency Status

Appendit allows you easily to add text at a specific line. It will works with any plain text format like .txt .md .js ...

Installation

npm install --save appendit

Example

Below a quick example how to use appendit:

The index.html looks like that:

<html>
	<head>
		<title></title>
		<!-- anchor -->
	</head>
	<body>
	</body>
</html>

Call the appendit function with the following parameters:

var fs = require('fs');
var appendit = require('appendit');

var content = appendit({
  source: fs.readFileSync('index.html', 'utf8'),
  anchor: '<!-- anchor -->',
  content: [
    '<script src="main.js"></script>'
  ]
});

fs.writeFileSync('index.html', content);

Output:

<html>
	<head>
		<title></title>
		<script src="main.js"></script>
		<!-- anchor -->
	</head>
	<body>
	</body>
</html>

###One more

Let's add a headline to the body:

appendit({
  source: fs.readFileSync('index.html', 'utf8'),
  anchor: '</body>',
  content: [
    '<h1>Hello Node!</h1>'
  ]
})

Output:

<html>
	<head>
		<title></title>
		<script src="main.js"></script>
		<!-- anchor -->
	</head>
	<body>
		<h1>Hello Node!</h1>
	</body>
</html>

Testing

Running npm testwill run the unit tests with mocha

FAQs

Package last updated on 25 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