Skip to content

πŸ“™ A tiny, zero dependency ES5 require parser

Notifications You must be signed in to change notification settings

molnarmark/require-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Require Parser

A tiny, zero dependency ES5 require parser.

require-parser provides a simple and easy way to parse EcmaScript 5 require statements.

Installation

npm install --save require-parser

Usage

You can find a working example in tester.js.

const RequireParser = require('./index');

const testCode = `
const moduleA = require('./moduleA');
const moduleB = require('./moduleB');
const moduleC = require('./moduleC');

const fs = require('fs');
`;

const requires = RequireParser(testCode);
console.log(requires);
/* =>
[ { originalMatch: 'require(\'./moduleA\')',
    modulePath: './moduleA',
    isInstalledModule: false },
  { originalMatch: 'require(\'./moduleB\')',
    modulePath: './moduleB',
    isInstalledModule: false },
  { originalMatch: 'require(\'./moduleC\')',
    modulePath: './moduleC',
    isInstalledModule: false },
  { originalMatch: 'require(\'fs\')',
    modulePath: 'fs',
    isInstalledModule: true } ]
*/

License

  • MIT

About

πŸ“™ A tiny, zero dependency ES5 require parser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published