JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 293
  • Score
    100M100P100Q113850F
  • License MIT

Extract JSON front matter from strings and files

Package Exports

  • json-front-matter

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (json-front-matter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

json-front-matter

Extract JSON front matter from strings and files

Installing

  • npm install json-front-matter

Methods

  • parse( s ) Parses string s, returning an object with properties attributes, containing the JSON front matter, and body containing the rest.
  • parseFile( path, callback( err, data )) Parses file at path, calling the callback upon completion with data object containing attribuets and body, like the string parse method.

Using

var fm = require('json-front-matter');

var string = '{{{ "title" : "some title", "array" : [ 1, 2, 3 ] }}} bodybodybody';
var out = fm.parse( string );

console.log( out.body ) // 'bodybodybody'
console.log( out.attributes.title ) // 'some title'
console.log( out.attributes.array ) // [ 1, 2, 3 ]

Testing

Run node tests/runTests.js from project root -- testing uses nodeunit