Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

requires-regex

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

requires-regex

Regular expression for matching javascript require statements.

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

requires-regex NPM version

Regular expressions for matching javascript require statements.

Install

Install with npm

$ npm i requires-regex --save

Usage

var re = require('requires-regex');

re().exec('var foo = require(\'bar\');');
//=>
// [ 'var foo = require(\'bar\')',
//   'foo',
//   'bar',
//   index: 0,
//   input: 'var foo = require(\'bar\');' ]

var str = '    var path = require(\'path\');\n\nvar foo = require(\'bar\');';
var regex = new RegExp(re().source, 'gm');
console.log(str.match(regex));
//=> [ 'var path = require(\'path\')', 'var foo = require(\'bar\')' ]

re().test('require(\'foo\');');
//=> true
  • lint-deps: CLI tool that tells you when dependencies are missing from package.json and offers you a… more
  • match-requires: Match require statements in a string. Returns an array of matching require statements. Each match… more
  • regex-cache: Memoize the results of a call to the RegExp constructor, avoiding repetitious runtime compilation of… more

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on August 19, 2015.

Keywords

FAQs

Package last updated on 19 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc