Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-json-stringify

Package Overview
Dependencies
Maintainers
2
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.10.0 to 0.10.1

51

index.js

@@ -18,4 +18,2 @@ 'use strict'

${$asString.toString()}
${$asStringSmall.toString()}
${$asStringLong.toString()}
${$asNumber.toString()}

@@ -90,45 +88,5 @@ ${$asNull.toString()}

if (str.length < 42) {
return $asStringSmall(str)
} else {
return $asStringLong(str)
}
return JSON.stringify(str)
}
function $asStringLong (str) {
var result = ''
var l = str.length
var i
for (;(i = str.indexOf('"')) >= 0 && i < l;) {
result += str.slice(0, i) + '\\"'
str = str.slice(i + 1)
l = str.length
}
if (l > 0) {
result += str
}
return '"' + result + '"'
}
function $asStringSmall (str) {
var result = ''
var last = 0
var l = str.length
for (var i = 0; i < l; i++) {
if (str[i] === '"') {
result += str.slice(last, i) + '\\"'
last = i + 1
}
}
if (last === 0) {
result = str
} else {
result += str.slice(last)
}
return '"' + result + '"'
}
function $asRegExp (reg) {

@@ -311,3 +269,3 @@ reg = reg.source

laterCode = result.laterCode
/* eslint-disable no-useless-escape */
if (i < a.length - 1) {

@@ -318,2 +276,3 @@ code += `

}
/* eslint-enable no-useless-escape */

@@ -405,3 +364,3 @@ if (schema.required && schema.required.indexOf(key) !== -1) {

case 'object':
funcName = (name + key).replace(/[-.\[\]]/g, '')
funcName = (name + key).replace(/[-.\[\]]/g, '') // eslint-disable-line
laterCode = buildObject(schema, laterCode, funcName, externalSchema)

@@ -413,3 +372,3 @@ code += `

case 'array':
funcName = (name + key).replace(/[-.\[\]]/g, '')
funcName = (name + key).replace(/[-.\[\]]/g, '') // eslint-disable-line
laterCode = buildArray(schema, laterCode, funcName, externalSchema)

@@ -416,0 +375,0 @@ code += `

2

package.json
{
"name": "fast-json-stringify",
"version": "0.10.0",
"version": "0.10.1",
"description": "Stringify your JSON at max speed",

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

# fast-json-stringify&nbsp;&nbsp;[![Build Status](https://travis-ci.org/mcollina/fast-json-stringify.svg)](https://travis-ci.org/mcollina/fast-json-stringify)
__fast-json-stringify__ is x1-5 times faster than `JSON.stringify()`.
__fast-json-stringify__ is x1-4 times faster than `JSON.stringify()`.
It is particularly suited if you are sending small JSON payloads, the

@@ -10,10 +10,10 @@ advantages reduces on large payloads.

```
JSON.stringify array x 3,500 ops/sec ±0.91% (85 runs sampled)
fast-json-stringify array x 4,456 ops/sec ±1.68% (87 runs sampled)
JSON.stringify long string x 13,395 ops/sec ±0.88% (91 runs sampled)
fast-json-stringify long string x 95,488 ops/sec ±1.04% (90 runs sampled)
JSON.stringify short string x 5,059,316 ops/sec ±0.86% (92 runs sampled)
fast-json-stringify short string x 12,219,967 ops/sec ±1.16% (91 runs sampled)
JSON.stringify obj x 1,763,980 ops/sec ±1.30% (88 runs sampled)
fast-json-stringify obj x 5,085,148 ops/sec ±1.56% (89 runs sampled)
JSON.stringify array x 3,679 ops/sec ±1.01% (85 runs sampled)
fast-json-stringify array x 4,618 ops/sec ±1.64% (87 runs sampled)
JSON.stringify long string x 13,303 ops/sec ±1.01% (89 runs sampled)
fast-json-stringify long string x 13,489 ops/sec ±0.88% (90 runs sampled)
JSON.stringify short string x 4,974,749 ops/sec ±1.14% (86 runs sampled)
fast-json-stringify short string x 11,030,700 ops/sec ±0.82% (89 runs sampled)
JSON.stringify obj x 1,774,593 ops/sec ±1.07% (90 runs sampled)
fast-json-stringify obj x 4,976,369 ops/sec ±1.00% (89 runs sampled)
```

@@ -20,0 +20,0 @@

@@ -54,2 +54,7 @@ 'use strict'

buildTest({
title: 'string',
type: 'string'
}, 'hello\nworld')
buildTest({
title: 'string with quotes',

@@ -56,0 +61,0 @@ type: 'string'

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