jsonscore

0.1.0 • Public • Published

JSONscore

Edit json file with underscore.js chain method

Installation

$ npm install jsonscore

Usage

var jsonscore = require('jsonscore');
 
/* 
 * alter metadata json file in the root directory
 * addnew and filter two new json object
 */
var metadata = jsonscore('metadata.json', {
    // default json file content value
    defaultValue: [],
    // json file encoding 
    encoding: 'utf8',
    // format json with replacer function
    replacer: null,
    // number of space between json object
    space: 4
})
  .extend({
      compile_sass: {
        run: false,
        time: 1405213450
      },
      minify_js: {
        run: true,
        time: 1405213454
      }
  })
  .filter(function(task) {
      return task.run ? false : true;
  })
  .write();
 
console.log(metadata);
 

Using lodash instead of default underscore library

var jsonscore = require('jsonscore');
var _ = require('lodash');
 
jsonscore('metadata.json', {
  engine: _
}).extend(obj).write();

Custom mixin methods

var jsonscore = require('jsonscore');
var _ = require('underscore');
 
_.mixin({
  filterWith: [Function]
});
 
jsonscore('metadata.json', {
  engine: _
}).filterWith(obj).write();

API

jsonscore(filepath, [, options]) return an underscore chain method

  • filepath String
  • options Object

write() write json object back into file return json data

Authors

xmhscratch

License

Licensed under the GPL license.

Package Sidebar

Install

npm i jsonscore

Weekly Downloads

3

Version

0.1.0

License

GPL-2.0

Last publish

Collaborators

  • xmhscratch