Socket
Socket
Sign inDemoInstall

jsonfile

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonfile - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

index.js

5

CHANGELOG.md

@@ -0,1 +1,6 @@

2.1.0 / 2015-06-19
------------------
- cleanup: JavaScript Standard Style, rename files, dropped terst for assert
- methods now support JSON revivers/replacers
2.0.1 / 2015-05-24

@@ -2,0 +7,0 @@ ------------------

16

package.json
{
"name": "jsonfile",
"version": "2.0.1",
"version": "2.1.0",
"description": "Easily read/write JSON files.",

@@ -13,3 +13,5 @@ "repository": {

"file",
"json"
"json",
"fs",
"fs-extra"
],

@@ -20,10 +22,10 @@ "author": "JP Richardson <jprichardson@gmail.com>",

"devDependencies": {
"testutil": "^0.7.0",
"mocha": "*",
"terst": "^0.2.0"
"mocha": "2.x",
"rimraf": "^2.4.0",
"standard": "4.x"
},
"main": "./lib/jsonfile.js",
"main": "index.js",
"scripts": {
"test": "mocha test"
"test": "standard && mocha test"
}
}

@@ -1,9 +0,9 @@

[![build status](https://secure.travis-ci.org/jprichardson/node-jsonfile.png)](http://travis-ci.org/jprichardson/node-jsonfile)
Node.js - jsonfile
================
Easily read/write JSON files.
Easily read/write JSON files.
[![build status](https://secure.travis-ci.org/jprichardson/node-jsonfile.png)](http://travis-ci.org/jprichardson/node-jsonfile)
Why?

@@ -28,3 +28,6 @@ ----

```javascript
`options`: Pass in any `fs.readFile` options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse).
```js
var jf = require('jsonfile')

@@ -35,3 +38,3 @@ var util = require('util')

jf.readFile(file, function(err, obj) {
console.log(util.inspect(obj))
console.dir(obj)
})

@@ -43,3 +46,6 @@ ```

```javascript
`options`: Pass in any `fs.readFileSync` options or set `reviver` for a [JSON reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse). Also `throws` set to `false` if you don't ever want this method
to throw on invalid JSON. Will return `null` instead. Defaults to `true`.
```js
var jf = require('jsonfile')

@@ -50,11 +56,12 @@ var util = require('util')

console.log(util.inspect(jf.readFileSync(file)))
console.dir(jf.readFileSync(file))
```
**options**: `throws`. Set to `false` if you don't ever want this method to throw on invalid JSON. Will return `null` instead. Defaults to `true`. Others passed directly to `fs.readFileSync`.
### writeFile(filename, [options], callback)
```javascript
`options`: Pass in any `fs.writeFile` options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify).
```js
var jf = require('jsonfile')

@@ -70,5 +77,8 @@

### writeFileSync(filename, [options])
```javascript
`options`: Pass in any `fs.writeFileSync` options or set `replacer` for a [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify).
```js
var jf = require('jsonfile')

@@ -85,7 +95,7 @@

Number of spaces to indent JSON files.
Number of spaces to indent JSON files.
**default:** 2
**default:** `null`
```
```js
var jf = require('jsonfile')

@@ -127,3 +137,3 @@

Copyright 2012-2014, JP Richardson <jprichardson@gmail.com>
Copyright 2012-2015, JP Richardson <jprichardson@gmail.com>

@@ -130,0 +140,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc