Comparing version 2.3.0 to 2.3.1
@@ -0,1 +1,5 @@ | ||
2.3.1 / 2016-05-13 | ||
------------------ | ||
- fix to support BOM. [#45][#45] | ||
2.3.0 / 2016-04-16 | ||
@@ -73,2 +77,3 @@ ------------------ | ||
[#45]: https://github.com/jprichardson/node-jsonfile/issues/45 "Reading of UTF8-encoded (w/ BOM) files fails" | ||
[#44]: https://github.com/jprichardson/node-jsonfile/issues/44 "Extra characters in written file" | ||
@@ -75,0 +80,0 @@ [#43]: https://github.com/jprichardson/node-jsonfile/issues/43 "Prettyfy json when written to file" |
10
index.js
@@ -27,2 +27,4 @@ var _fs = require('fs') | ||
data = stripBom(data) | ||
var obj | ||
@@ -61,2 +63,3 @@ try { | ||
var content = fs.readFileSync(file, options) | ||
content = stripBom(content) | ||
@@ -112,2 +115,9 @@ try { | ||
function stripBom (content) { | ||
// we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified | ||
if (Buffer.isBuffer(content)) content = content.toString('utf8') | ||
content = content.replace(/^\uFEFF/, '') | ||
return content | ||
} | ||
var jsonfile = { | ||
@@ -114,0 +124,0 @@ spaces: null, |
{ | ||
"name": "jsonfile", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "Easily read/write JSON files.", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16722
105