Giter Club home page Giter Club logo

json-content-demux's Introduction

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.

json-content-demux's People

Contributors

twolfson avatar

Stargazers

Charlike Mike Reagent avatar  avatar John Wright avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

ezeeyahoo

json-content-demux's Issues

Error: No such module: evals

I am using npm version:- 6.14.5 and node version:- 12.16.1
Following are steps to build and test the json-content-demux package:

git clone https://github.com/twolfson/json-content-demux.git
npm install
npm test

After performing npm test, I am getting following error, so can you help me please in this or suggest me steps if I missing something.:

Loading "test.js" tasks and helpers...ERROR

Error: No such module: evals
Task "test" not found. Use --force to continue.

Aborted due to warnings.
npm ERR! Test failed. See above for more details.

CoffeeScript support

How hard would it be for me to attempt adding coffee-script support? I want my clients to be able to edit their products in a markdown file and for the properties I would love to use straight JSON but don't want all the bracket cruft.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.