Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.2.0 to 2.2.1

4

CHANGELOG.md

@@ -0,1 +1,5 @@

2.2.1 / 2015-06-25
------------------
- fixed regression when passing in string as encoding for options in `writeFile()` and `writeFileSync()`. See: https://github.com/jprichardson/node-jsonfile/issues/28
2.2.0 / 2015-06-25

@@ -2,0 +6,0 @@ ------------------

11

index.js

@@ -45,6 +45,6 @@ var fs = require('fs')

callback = options
options = options || {}
options = {}
}
var spaces = options
var spaces = typeof options === 'object' && options !== null
? 'spaces' in options

@@ -66,3 +66,8 @@ ? options.spaces : this.spaces

options = options || {}
var spaces = 'spaces' in options ? options.spaces : this.spaces
var spaces = typeof options === 'object' && options !== null
? 'spaces' in options
? options.spaces : this.spaces
: this.spaces
var str = JSON.stringify(obj, options.replacer, spaces) + '\n'

@@ -69,0 +74,0 @@ // not sure if fs.writeFileSync returns anything, but just in case

{
"name": "jsonfile",
"version": "2.2.0",
"version": "2.2.1",
"description": "Easily read/write JSON files.",

@@ -5,0 +5,0 @@ "repository": {

@@ -68,4 +68,4 @@ Node.js - jsonfile

jsonfile.writeFile(file, obj, function(err) {
console.log(err)
jsonfile.writeFile(file, obj, function (err) {
console.error(err)
})

@@ -83,3 +83,3 @@ ```

jsonfile.writeFile(file, obj, {spaces: 2}, function(err) {
console.log(err)
console.error(err)
})

@@ -129,4 +129,5 @@ ```

jsonfile.writeFile(file, obj, function(err) { //json file has four space indenting now
console.log(err)
// json file has four space indenting now
jsonfile.writeFile(file, obj, function (err) {
console.error(err)
})

@@ -133,0 +134,0 @@ ```

@@ -205,3 +205,3 @@ var assert = require('assert')

describe('> when JSON replacer is set', function () {
it('should replace JSON', function () {
it('should replace JSON', function (done) {
var file = path.join(TEST_DIR, 'somefile.json')

@@ -225,2 +225,3 @@ var sillyReplacer = function (k, v) {

assert.strictEqual(data.reg, 'regex:/hello/g')
done()
})

@@ -233,6 +234,3 @@ })

var file = path.join(TEST_DIR, 'somefile.json')
var obj = {
name: 'jp'
}
var obj = { name: 'jp' }
jf.writeFile(file, obj, null, function (err) {

@@ -257,2 +255,15 @@ assert.ifError(err)

})
describe('> when passing encoding string as options', function () {
it('should not error', function (done) {
var file = path.join(TEST_DIR, 'somefile.json')
var obj = { name: 'jp' }
jf.writeFile(file, obj, 'utf8', function (err) {
assert.ifError(err)
var data = fs.readFileSync(file, 'utf8')
assert.strictEqual(data, JSON.stringify(obj) + '\n')
done()
})
})
})
})

@@ -319,2 +330,12 @@

})
describe('> when passing encoding string as options', function () {
it('should not error', function () {
var file = path.join(TEST_DIR, 'somefile6.json')
var obj = { name: 'jp' }
jf.writeFileSync(file, obj, 'utf8')
var data = fs.readFileSync(file, 'utf8')
assert.strictEqual(data, JSON.stringify(obj) + '\n')
})
})
})

@@ -321,0 +342,0 @@

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