@buzuli/json
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -26,7 +26,7 @@ const json = require('./lib/json') | ||
D: {}, | ||
"\"E\"": '"quoted"', | ||
"\\F\\": "\\escaped\\", | ||
"\\G\\": "\nnewlines\n", | ||
"\\H\\": '"', | ||
"\\I\\": '', | ||
'"E"': '"quoted"', | ||
'\\F\\': '\\escaped\\', | ||
'\\G\\': '\nnewlines\n', | ||
'\\H\\': '"', | ||
'\\I\\': '', | ||
'some-thing': 'hyphenated' | ||
@@ -33,0 +33,0 @@ } |
module.exports = json | ||
const {blue, green, orange, purple, yellow} = require('@buzuli/color') | ||
const { blue, green, orange, purple, yellow } = require('@buzuli/color') | ||
@@ -9,2 +9,6 @@ function json (obj) { | ||
if (typeof obj === 'string') { | ||
obj = JSON.parse(obj) | ||
} | ||
_json(obj, null, 0) | ||
@@ -36,4 +40,4 @@ | ||
entries.length > 0 | ||
? `\n${' '.repeat(depth)}]${suffix}` | ||
: `]${suffix}` | ||
? `\n${' '.repeat(depth)}]${suffix}` | ||
: `]${suffix}` | ||
) | ||
@@ -40,0 +44,0 @@ } else if (typeof value === 'boolean') { |
{ | ||
"name": "@buzuli/json", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "", | ||
@@ -26,5 +26,5 @@ "main": "lib/json.js", | ||
"devDependencies": { | ||
"standard": "^11.0.1", | ||
"tap": "^11.1.2" | ||
"standard": "^12.0.1", | ||
"tap": "^12.1.1" | ||
} | ||
} |
const tap = require('tap') | ||
const json = require('../lib/json') | ||
tap.test('', t => { | ||
tap.test('Should format an object', async assert => { | ||
const obj = { | ||
@@ -28,5 +28,7 @@ A: [ | ||
t.ok(typeof json(obj) === 'string') | ||
assert.ok(typeof json(obj) === 'string') | ||
}) | ||
t.done() | ||
tap.test('Should parse a string then format', async assert => { | ||
assert.ok(typeof json('{}') === 'string') | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3499
116