UNPKG

342 BJavaScriptView Raw
1var $;
2
3$ = {};
4
5$.type = require('../dist/type');
6
7module.exports = function(ipt) {
8 var type;
9 switch (type = $.type(ipt)) {
10 case 'array':
11 case 'object':
12 return ipt;
13 case 'string':
14 case 'uint8array':
15 return JSON.parse(ipt);
16 default:
17 throw new Error(`parseJson/error: invalid type '${type}'`);
18 }
19};