3.1.2 • Published 8 years ago

json-statham v3.1.2

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

json-statham

Build Status

Kick your JSON's ass, with json-statham's help. Extends Homefront.

Statham is awesome man

Makes working with javascript objects and json easy.

Installation

npm i --save json-statham

Tests

npm test

Usage

This module extends Homefront. It's essentially the same, except for some additional methods, and an extended constructor.

Using Statham

All arguments are optional.

let Statham = require('json-statham').Statham;
let statham = new Statham({data: 'here'}, Statham.MODE_NESTED, 'path/to/file');

Using .setFileLocation()

let Statham = require('json-statham').Statham;
let statham = new Statham();

statham.setFileLocation('./foo/ray-liotta.json'); // Used by .save()

Using .save()

let Statham = require('json-statham').Statham;
let statham = new Statham();

statham.save().then(() => {/* Really does return a promise, I promise. */});
statham.save('./json-flemyng.json');        // Specific file
statham.save(true);                         // Create path for file, too
statham.save('./matt-schulze.json', true);  // Both options

Using .fromFile(fileName, ensureFileExists=false)

This method allows you to tell Statham to fetch the contents of a file itself. When ensure has been set to true, statham will create the provided file if it doesn't exist yet. This method returns a promise, and resolves with a statham instance (as described above).

let Statham = require('json-statham').Statham;

Statham.fromFile(__dirname + '/my-data.json').then(statham => {
  // Yeeeaaah, we have a statham instance now.
});
3.1.2

8 years ago

3.1.1

8 years ago

3.1.0

8 years ago

2.1.0

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.6.1

8 years ago

1.6.0

8 years ago

1.5.0

8 years ago

1.4.0

8 years ago

1.3.0

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

0.1.0

8 years ago