Socket
Socket
Sign inDemoInstall

fast-json-stringify

Package Overview
Dependencies
Maintainers
1
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-json-stringify - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

3

example.js

@@ -19,3 +19,4 @@ 'use strict'

now: {
type: 'string'
type: 'string',
required: true
},

@@ -22,0 +23,0 @@ reg: {

@@ -205,2 +205,8 @@ 'use strict'

var funcName
if (schema.required) {
code += `
if (!obj.hasOwnProperty('${key.slice(1)}')) {
throw new Error('${key} is required!')
}`
}
const type = schema.type

@@ -207,0 +213,0 @@ switch (type) {

{
"name": "fast-json-stringify",
"version": "0.4.0",
"version": "0.5.0",
"description": "Stringify your JSON at max speed",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -257,1 +257,39 @@ 'use strict'

})
test('object with required field', (t) => {
t.plan(3)
const schema = {
title: 'object with required field',
type: 'object',
properties: {
str: {
type: 'string',
required: true
},
num: {
type: 'integer'
}
}
}
const stringify = build(schema)
try {
stringify({
str: 'string'
})
t.pass()
} catch (e) {
t.fail()
}
try {
stringify({
num: 42
})
t.fail()
} catch (e) {
t.is(e.message, '.str is required!')
t.pass()
}
})
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