New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsoner

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsoner - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

15

lib/append.js

@@ -79,2 +79,7 @@ var _ = require('lodash');

if (element.length === 0) {
// nothing to write
return;
}
options = _.extend({

@@ -85,11 +90,11 @@ replacer: null,

function stringify(object) {
function stringify(object) {
return JSON.stringify(object, options.replacer, options.space);
}
try {
try {
fs.accessSync(filename, fs.R_OK | fs.W_OK);
} catch (err) {
} catch (err) {
if (err.toString().match(/ENOENT/)) {
fs.writeFileSync(filename, '[]');
fs.writeFileSync(filename, '[]');
} else {

@@ -96,0 +101,0 @@ throw err;

{
"name": "jsoner",
"version": "0.1.4",
"version": "0.1.5",
"description": "Simple, fast, minimalist JSON library for node",

@@ -5,0 +5,0 @@ "keywords": [

@@ -125,3 +125,48 @@ var _ = require('lodash');

it('appends multiple JSON arrays', function(done) {
var array1 = [
{ user: 'foo' },
{ user: 'bar' }
];
var array2 = [
{ user: 'fizz' },
{ user: 'buzz' }
];
fs.writeFileSync(tmpFilename, '[]');
jsoner.appendFileSync(tmpFilename, array1);
jsoner.appendFileSync(tmpFilename, array2);
var stream = fs.createReadStream(tmpFilename);
var results = [];
jsoner.parse(stream)
.on('object', function(object) {
results.push(object);
})
.on('end', function() {
expect(results).to.deep.equal(array1.concat(array2));
done();
})
.on('error', function(err) {
done(err);
});
});
it('appends empty JSON arrays', function() {
var array1 = [
{ user: 'foo' },
{ user: 'bar' }
];
var array2 = [];
fs.writeFileSync(tmpFilename, '[]');
jsoner.appendFileSync(tmpFilename, array1);
jsoner.appendFileSync(tmpFilename, array2);
var jsonString = fs.readFileSync(tmpFilename).toString();
var results = JSON.parse(jsonString);
expect(results).to.deep.equal(array1.concat(array2));
});
});
});
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