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.1.1 to 2.1.2

4

CHANGELOG.md

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

2.1.2 / 2015-06-22
------------------
- fixed if passed `readFileSync(file, 'utf8')`. See: https://github.com/jprichardson/node-jsonfile/issues/25
2.1.1 / 2015-06-19

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

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

options = options || {}
if (typeof options === 'string') {
options = {encoding: options}
}
var shouldThrow = 'throws' in options ? options.throw : true

@@ -27,0 +31,0 @@

2

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

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

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

describe('> when passing null and callback', function () {
it('should not throw an error', function () {
it('should not throw an error', function (done) {
var file = path.join(TEST_DIR, 'somefile.json')

@@ -75,5 +75,23 @@

assert.strictEqual(obj.name, 'jp')
done()
})
})
})
describe('> when passing encoding string as option', function () {
it('should not throw an error', function (done) {
var file = path.join(TEST_DIR, 'somefile.json')
var obj = {
name: 'jp'
}
fs.writeFileSync(file, JSON.stringify(obj))
jf.readFile(file, 'utf8', function (err) {
assert.ifError(err)
assert.strictEqual(obj.name, 'jp')
done()
})
})
})
})

@@ -131,2 +149,20 @@

})
describe('> when passing encoding string as option', function () {
it('should not throw an error', function () {
var file = path.join(TEST_DIR, 'somefile.json')
var obj = {
name: 'jp'
}
fs.writeFileSync(file, JSON.stringify(obj))
try {
var data = jf.readFileSync(file, 'utf8')
} catch (err) {
assert.ifError(err)
}
assert.strictEqual(data.name, 'jp')
})
})
})

@@ -133,0 +169,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