baiji-normalizer
Advanced tools
Comparing version 1.0.3 to 1.0.4
17
index.js
@@ -139,2 +139,3 @@ /** | ||
* boolean | ||
* object | ||
* any | ||
@@ -257,7 +258,4 @@ */ | ||
/** | ||
* any converter | ||
* any => any | ||
*/ | ||
Normalizer.define('any', function convertAny(val, opts) { | ||
// convert object/any type | ||
function convertAny(val, opts) { | ||
if (!opts) opts = {}; | ||
@@ -267,2 +265,9 @@ // use maxCoerceLevel to prevent circular reference parse error | ||
return coerceAll(val, maxCoerceLevel); | ||
}); | ||
} | ||
/** | ||
* object/any converter | ||
* object/any => object/any | ||
*/ | ||
Normalizer.define('any', convertAny); | ||
Normalizer.define('object', convertAny); |
{ | ||
"name": "baiji-normalizer", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Baiji Normalizer", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -20,3 +20,3 @@ Baiji Normalizer | ||
// Built-in Types | ||
// number, string, date, boolean | ||
// number, string, date, boolean, object, any | ||
@@ -23,0 +23,0 @@ |
@@ -70,2 +70,3 @@ var chai = require('chai'); | ||
it('should be converted as any', function() { | ||
@@ -89,2 +90,20 @@ expect(new Normalizer(undefined).to('any')).to.equal(undefined); | ||
it('should be converted as object', function() { | ||
expect(new Normalizer(undefined).to('object')).to.equal(undefined); | ||
expect(new Normalizer('undefined').to('object')).to.equal(undefined); | ||
expect(new Normalizer(null).to('object')).to.equal(null); | ||
expect(new Normalizer('null').to('object')).to.equal(null); | ||
expect(new Normalizer('123').to('object')).to.equal(123); | ||
expect(new Normalizer(123).to('object')).to.equal(123); | ||
expect(new Normalizer([123]).to('object')).to.eql([123]); | ||
expect(new Normalizer({ a: 1 }).to('object')).to.eql({ a: 1 }); | ||
expect(new Normalizer({ a: '1' }).to('object')).to.eql({ a: 1 }); | ||
var circularExample = {}; | ||
circularExample.anotherCircularReference = circularExample; | ||
expect(function() { | ||
new Normalizer(circularExample).to('object'); | ||
}).not.to.throw(Error); | ||
}); | ||
it('should be converted as boolean', function() { | ||
@@ -91,0 +110,0 @@ expect(new Normalizer(undefined).to('boolean')).to.equal(undefined); |
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
16194
347