0.0.2 • Published 7 years ago

json-file-pointer v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

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.

0.0.2

7 years ago

0.0.1

7 years ago