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

hapi-good-mongostore

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-good-mongostore - npm Package Compare versions

Comparing version

to
0.4.0

lib/safe-json.js

5

lib/index.js

@@ -6,2 +6,3 @@ 'use strict'

const get = require('lodash.get')
const safeJson = require('./safe-json')

@@ -76,6 +77,6 @@ /**

if (this.conn.db) {
return this.conn.collection.insertMany(records, this.insertOptions || {})
return this.conn.collection.insertMany(safeJson(records), this.insertOptions || {})
} else {
return this._connect()
.then(() => this.conn.collection.insertMany(records, this.insertOptions || {}))
.then(() => this.conn.collection.insertMany(safeJson(records), this.insertOptions || {}))
}

@@ -82,0 +83,0 @@ }

3

package.json
{
"name": "hapi-good-mongostore",
"version": "0.3.5",
"version": "0.4.0",
"repository": {

@@ -36,2 +36,3 @@ "type": "git",

"dependencies": {
"circular-json": "^0.3.1",
"lodash.get": "^4.4.2",

@@ -38,0 +39,0 @@ "mongodb": "^2.2.26"

@@ -0,1 +1,3 @@

'use strict'
const should = require('should')

@@ -82,2 +84,26 @@ const Stream = require('stream')

})
describe('handle circular json', () => {
it('Should safely parse circular json', (done) => {
const circularObj = { foo: 'bar' }
circularObj.self = circularObj
const record = {
tags: ['error'],
data: circularObj
}
const options = { batchSize: 1 }
const reporter = new MongoStoreStream(url, options)
const stream = readStream()
stream.pipe(reporter)
reporter._insert = function (records) {
should(records.length).be.equal(options.batchSize)
should(records[0]).be.equal(record)
done()
}
stream.push(record)
})
})
})