Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 

JSON-file-pointer

Simply returns line/column location in a js-file with JSON from path:

const jsonPointer = require('json-file-pointer');

const jsonExample = require('fs').readFileSync('simple.deps.js');

/**
 * ({
 *     shouldDeps: [
 *         { block: 'js' },
 *         { block: 'page', elem: ['header', 'body'] }
 *     ]
 * });
 */

console.log(
    jsonPointer.getLocationOf(jsonExample, ['shouldDeps', 1, 'elem', 0])
    // or: getLocationOf(jsonExample, 'shouldDeps[1].elem[0]')
);

// { line: 4, column: 33 }

Also works with module.exports and exports form.

About

Returns line/column location from path in json

Resources

Releases

No releases published

Packages

No packages published