json-expressible
Advanced tools
Comparing version 1.0.2 to 1.0.3
10
index.js
@@ -6,7 +6,7 @@ var check = require("check-types"); | ||
var jsonExpressible = function(val) { | ||
var jsonExpressible = function (val) { | ||
return !hasCircular(val, []) && onlyJsonValues(val); | ||
}; | ||
var onlyJsonValues = function(val) { | ||
var onlyJsonValues = function (val) { | ||
if ( | ||
@@ -21,3 +21,3 @@ check.string(val) || | ||
var ret = true; | ||
_each(val, function(subval) { | ||
_each(val, function (subval) { | ||
ret = onlyJsonValues(subval); | ||
@@ -32,3 +32,3 @@ return ret; // stop if bad | ||
var hasCircular = function(value, ancestors) { | ||
var hasCircular = function (value, ancestors) { | ||
if (!check.object(value) && !check.array(value)) { | ||
@@ -45,3 +45,3 @@ return false; | ||
var ret = false; | ||
_each(value, function(child) { | ||
_each(value, function (child) { | ||
ret = hasCircular(child, newAncestors); | ||
@@ -48,0 +48,0 @@ return !ret; // stop if bad |
{ | ||
"name": "json-expressible", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Micro library that determines whether a value can be expressed as JSON.", | ||
@@ -23,14 +23,14 @@ "main": "index.js", | ||
"dependencies": { | ||
"check-types": "^10.0.0", | ||
"ghooks": "^2.0.4", | ||
"lodash": "^4.17.15" | ||
"check-types": "^11.2.3", | ||
"lodash": "^4.17.21" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^5.12.0", | ||
"eslint-config-prettier": "^3.1.0", | ||
"eslint-plugin-es5": "^1.3.1", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-prettier": "^3.0.1", | ||
"jasmine": "^3.4.0", | ||
"prettier": "^1.14.3" | ||
"eslint": "^8.56.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-es5": "^1.5.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"ghooks": "^2.0.4", | ||
"jasmine": "^5.1.0", | ||
"prettier": "^3.2.4" | ||
}, | ||
@@ -37,0 +37,0 @@ "config": { |
@@ -1,2 +0,2 @@ | ||
[![Build Status](https://travis-ci.com/aarong/json-expressible.svg?branch=master)](https://travis-ci.com/github/aarong/json-expressible) | ||
[![CI-CD](https://github.com/aarong/json-expressible/actions/workflows/built-test-deploy.yml/badge.svg)](https://github.com/aarong/json-expressible/actions/workflows/built-test-deploy.yml) | ||
@@ -3,0 +3,0 @@ # JSON-Expressible |
16
tests.js
var jsonExpressible = require("."); | ||
describe("The jsonExpressible() function", function() { | ||
it("should return correctly for non-objects/arrays", function() { | ||
describe("The jsonExpressible() function", function () { | ||
it("should return correctly for non-objects/arrays", function () { | ||
expect(jsonExpressible(null)).toBe(true); | ||
@@ -12,3 +12,3 @@ expect(jsonExpressible("string")).toBe(true); | ||
expect(jsonExpressible(NaN)).toBe(false); | ||
expect(jsonExpressible(function() {})).toBe(false); | ||
expect(jsonExpressible(function () {})).toBe(false); | ||
expect(jsonExpressible(new Date())).toBe(false); | ||
@@ -23,3 +23,3 @@ expect(jsonExpressible(Infinity)).toBe(false); | ||
it("should return correctly for objects", function() { | ||
it("should return correctly for objects", function () { | ||
expect(jsonExpressible({ a: 123 })).toBe(true); | ||
@@ -33,3 +33,3 @@ expect(jsonExpressible({ a: undefined })).toBe(false); | ||
it("should return correctly for arrays", function() { | ||
it("should return correctly for arrays", function () { | ||
expect(jsonExpressible([123])).toBe(true); | ||
@@ -43,3 +43,3 @@ expect(jsonExpressible([undefined])).toBe(false); | ||
it("should correctly detect circular references", function() { | ||
it("should correctly detect circular references", function () { | ||
expect(jsonExpressible({ a: true, b: 123 })).toBe(true); | ||
@@ -79,3 +79,3 @@ expect(jsonExpressible([true, 123])).toBe(true); | ||
it("sample code should work", function() { | ||
it("sample code should work", function () { | ||
// The following return true | ||
@@ -94,3 +94,3 @@ | ||
console.log(jsonExpressible(NaN)); | ||
console.log(jsonExpressible(function() {})); | ||
console.log(jsonExpressible(function () {})); | ||
console.log(jsonExpressible(new Date())); | ||
@@ -97,0 +97,0 @@ console.log(jsonExpressible(Infinity)); |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2
0
9642
8
+ Addedcheck-types@11.2.3(transitive)
- Removedghooks@^2.0.4
- Removedcheck-types@10.1.2(transitive)
- Removedcolors@0.6.2(transitive)
- Removedcommander@2.1.02.9.0(transitive)
- Removedfindup@0.1.5(transitive)
- Removedghooks@2.0.4(transitive)
- Removedgraceful-readlink@1.0.1(transitive)
- Removedlodash._baseclone@4.5.7(transitive)
- Removedlodash.clone@4.3.24.5.0(transitive)
- Removedmanage-path@2.0.0(transitive)
- Removedopt-cli@1.5.1(transitive)
- Removedpath-exists@3.0.0(transitive)
- Removedspawn-command@0.0.2(transitive)
Updatedcheck-types@^11.2.3
Updatedlodash@^4.17.21