Socket
Book a DemoInstallSign in
Socket

hjson-matter

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hjson-matter

Front-matter parser for HJSON.

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

hjson-matter

Extract HJSON front matter from a string.

HJSON is a human-friendly superset of JSON that has some sweet syntactic sugars and multiline strings, which is great! Don't worry, it's not going to overthrow JSON and, yes, we shouldn't encourage developers to slack off in writing proper code with proper commas. However, there are some use cases where HJSON just makes sense. For instance, I think it's a nicer (easier) markup for front matter than YAML when using templating libraries.

Install

npm install hjson-matter

Usage

var hm = require('hjson-matter');
var fs = require('fs');

var file = fs.readFileSync('./some-file.html');
var content;

// pass in file contents as a String
content = hm(file.toString());

// pass in file contents as a Buffer
content = hm(file);

// specify a delimiter
content = hm(file, {delimiters: '***'});

// specify two different delimiters
content = hm(file, {delimiters: ['***', '@@@']});

Keywords

hjson

FAQs

Package last updated on 23 May 2016

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