ian-parse-json
Advanced tools
Comparing version 1.0.1 to 2.0.0
13
index.js
@@ -1,3 +0,12 @@ | ||
module.exports = { | ||
JSON: (json) => JSON.parse(json) | ||
/** | ||
* Ian parses JSON | ||
* @param {String} json some JSON for Ian to parse | ||
* @return {Object} the JSON, parsed by Ian | ||
*/ | ||
class Ian { | ||
parse(json) { | ||
return JSON.parse(json); | ||
} | ||
} | ||
module.exports = Ian; |
{ | ||
"name": "ian-parse-json", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "supermooi", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,7 +8,9 @@ # ian-parse-json | ||
```javascript | ||
const parse = require('ian-parse-json'); | ||
const Ian = require('ian-parse-json'); | ||
const parsedJSON = parse.JSON("{\"name\":\"ian\"}"); | ||
const ian = new Ian(); | ||
const parsedJSON = ian.parse("{\"name\":\"ian\"}"); | ||
console.log(parsedJSON); // {name: 'ian'} | ||
``` |
@@ -1,12 +0,14 @@ | ||
const parse = require('../index'); | ||
const Ian = require('../index'); | ||
const expect = require('chai').expect; | ||
const ian = new Ian(); | ||
describe('JSON parser', () => { | ||
it('parses JSON', () => { | ||
expect(parse.JSON("{\"name\":\"ian\"}")).to.deep.equal({name: 'ian'}); | ||
expect(ian.parse("{\"name\":\"ian\"}")).to.deep.equal({name: 'ian'}); | ||
}); | ||
it('fails when no valid JSON is given', () => { | ||
expect(() => { parse.JSON('malle henkie'); }).to.throw(SyntaxError); | ||
expect(() => { ian.parse('malle henkie'); }).to.throw(SyntaxError); | ||
}); | ||
}); |
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
3214
25
16