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

crequire

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crequire

Get require() & import like node-detective by lexical analysis

  • 1.8.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Get require() like node-requires by lexical analysis

NPM version Build Status

changed name from "searequire"

Installation

npm install crequire

Api

  • parseDependencies(code:String, callback:Function = null, flag:Boolean = false):String
  • parseDependencies(code:String, flag:Boolean = false):String
    • flag means if use "require.async" like, the result should have a property "flag" of ".async"

Example

js:

require('a');
//require('b');
/require('c')/;
'require("d")';
if(true)/require('e')/;
do /require('f')/.test(s); while(false);

parser output:

{
  "string": "require('a')",
  "path": "a",
  "index": 0,
  "flag": null
}

benchmark

crequire: normal x 139,605 ops/sec ±5.29% (80 runs sampled)
detective: normal x 38,301 ops/sec ±7.10% (74 runs sampled)
  Fastest is crequire
crequire: reg & comment x 232,023 ops/sec ±0.88% (95 runs sampled)
detective: reg & comment x 72,712 ops/sec ±1.39% (93 runs sampled)
  Fastest is crequire
crequire: after return x 138,280 ops/sec ±1.05% (95 runs sampled)
detective: after return x 17,690 ops/sec ±2.43% (77 runs sampled)
  Fastest is crequire
crequire: in quote x 1,122,979 ops/sec ±1.88% (94 runs sampled)
detective: in quote x 165,281 ops/sec ±5.10% (85 runs sampled)
  Fastest is crequire
crequire: in comment x 1,183,076 ops/sec ±1.21% (95 runs sampled)
detective: in comment x 415,236 ops/sec ±1.42% (97 runs sampled)
  Fastest is crequire
crequire: in multi comment x 1,165,799 ops/sec ±1.29% (88 runs sampled)
detective: in multi comment x 375,485 ops/sec ±1.15% (91 runs sampled)
  Fastest is crequire
crequire: in reg x 879,704 ops/sec ±0.90% (94 runs sampled)
detective: in reg x 118,294 ops/sec ±1.65% (93 runs sampled)
  Fastest is crequire
crequire: in ifstmt with no {} x 311,524 ops/sec ±1.06% (95 runs sampled)
detective: in ifstmt with no {} x 77,100 ops/sec ±1.15% (93 runs sampled)
  Fastest is crequire
crequire: in dostmt with no {} x 150,815 ops/sec ±1.52% (92 runs sampled)
detective: in dostmt with no {} x 47,510 ops/sec ±1.30% (91 runs sampled)
  Fastest is crequire
crequire: reg / reg x 656,564 ops/sec ±0.91% (94 runs sampled)
detective: reg / reg:
  Fastest is crequire
crequire: ignore variable x 270,350 ops/sec ±3.61% (87 runs sampled)
detective: ignore variable x 60,427 ops/sec ±1.29% (91 runs sampled)
  Fastest is crequire

Keywords

FAQs

Package last updated on 02 May 2017

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