Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.js « json-parse-helpfulerror « node_modules - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 15648b017b3db5008e20aa8b86ece5dca85c980b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'use strict';

var jju = require('jju');

function parse(text, reviver) {
    try {
        return JSON.parse(text, reviver);
    } catch (err) {
        // we expect this to throw with a more informative message
        jju.parse(text, {
            mode: 'json',
            reviver: reviver
        });

        // backup if jju is not as strict as JSON.parse; re-throw error
        // data-dependent code path, I do not know how to cover it
        throw err;
    }
}

exports.parse = parse;