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

data-section

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

data-section

Read data from comment, like as perl's Data::Section::Simple.

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by33.33%
Maintainers
1
Weekly downloads
 
Created
Source

node-data-section

Read data from comment, like a perl's Data::Section::Simple.

Install

$ npm install data-section

Usage

basic

var dataSection = require('data-section');

// getAll
dataSection.get(function(err, data) {
  console.log(data.data1); // foo
  console.log(data.data2); // bar\nbaz
});

// get
dataSection.get('data1', function(err, data) {
  console.log(data); // foo
});

// getAllSync
var data = dataSection.getSync();
console.log(data.data1); // foo
console.log(data.data2); // bar\nbaz

// getSync
console.log( dataSection.getSync('data1') ); // foo
console.log( dataSection.getSync('data2') ); // bar\nbaz

/* __DATA__
@@ data1
foo
@@ data2
bar
baz
__DATA__*/

set filename

// data1.js
/*__DATA__
@@ foo
bar
__DATA__*/

Read from data1.js.

var dataSection = require('data-section');
var data1js = __dirname + '/data1.js';

// getAll
dataSection.get({ filename: data1js }, function(err, data) {
  console.log(data.foo); // bar
});

// get
dataSection.get({ key: 'foo', filename: data1js }, function(err, data) {
  console.log(data); // bar
});

// getAllSync
var data = dataSection.getSync({ filename: data1js });
console.log(data.foo); // bar

// getSync
var data = dataSection.getSync({ key: 'foo', filename: data1js });
console.log(data); // bar

test

Using nodeunit.

$ nodeunit test

Keywords

FAQs

Package last updated on 05 Nov 2011

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