Socket
Socket
Sign inDemoInstall

json-buffer

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-buffer - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

16

index.js

@@ -9,6 +9,6 @@ var Buffer = require('buffer').Buffer

if(o && Buffer.isBuffer(o))
o = o.toString('base64')
return JSON.stringify(':base64:' + o.toString('base64'))
if(o && o.toJSON)
o = o.toJSON()
o = o.toJSON()

@@ -33,3 +33,5 @@ if(o && 'object' === typeof o) {

return s
} else
} else if ('string' === typeof o) {
return JSON.stringify(/^:/.test(o) ? ':' + o : o)
} else
return JSON.stringify(o)

@@ -40,6 +42,10 @@ }

return JSON.parse(s, function (key, value) {
if('string' === typeof value && /==$/.test(value))
return new Buffer(value, 'base64')
if('string' === typeof value) {
if(/^:base64:/.test(value))
return new Buffer(value.substring(8), 'base64')
else
return /^:/.test(value) ? value.substring(1) : value
}
return value
})
}
{
"name": "json-buffer",
"description": "",
"version": "1.0.0",
"version": "2.0.0",
"homepage": "https://github.com/dominictarr/json-buffer",

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

@@ -20,2 +20,12 @@

boolean2: false
},
foo: new Buffer('foo'),
foo2: new Buffer('foo2'),
escape: {
buffer: new Buffer('x'),
string: _JSON.stringify(new Buffer('x'))
},
escape2: {
buffer: new Buffer('x'),
string: ':base64:'+ new Buffer('x').toString('base64')
}

@@ -28,5 +38,5 @@ }

var s = _JSON.stringify(value)
console.log(s)
var _value = _JSON.parse(s)
t.deepEqual(toJSON(_value), toJSON(value))
console.log(k, value)
t.end()

@@ -33,0 +43,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