Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

json-content-demux

twolfson149.6kMIT0.2.0

Break up JSON from content in a JSON-first file

json, content, demux, combined, splitter, breaker, break up

readme

json-content-demux

Break up JSON from content in a JSON-first file

Getting Started

Install the module with: npm install json-content-demux

// muxed.md
{
  "title": "This is some muxed JSON and content",
  "options": {
    "Hello": "World!"
  }
}

Here is some content
Om nom nom


// app.js
var jsonContentDemux = require('json-content-demux'),
    muxedContent = fs.readFileSync('muxed.md', 'utf8'),
    demuxedObj = jsonContentDemux(muxedStr);
demuxedObj.json; // {"title":"This is some muxed...","options"}
demuxedObj.content; // "Here is some content\nOm nom nom"

Documentation

jsonContentDemux is currently a single function module with a single purpose.

/**
 * @param {String} muxStr Muxed content to break up
 * @returns {Object} retObj
 * @returns {Object} retObj.json JSON found at the head of the content
 * @returns {String} retObj.content Content found in the body
 */

At some point, the scope may increasee to encapsulate any markup language as well as multiple sets of delimited items.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via npm run lint and test via npm test.

Donating

Support this project and others by twolfson via donations.

http://twolfson.com/support-me

License

Copyright (c) 2012 Todd Wolfson Licensed under the MIT license.

changelog

json-content-demux changelog

0.2.0 - Touched up repo (removed Grunt for JSHint, added CHANGELOG/foundry, updated README)

0.1.4 - Repaired test runner for later Node.js version, fixed #2

0.1.3 - See git log