npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kesplus/crequire

v1.8.1

Published

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

Downloads

5

Readme

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