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

deferred-require

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deferred-require

A require function that defers actual reads until the first use of the required object

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
3
Weekly downloads
 
Created
Source

Deferred Require

Using this module requires that you run node with the --harmony_proxies and --harmony_collections flags.

deferredRequire = require 'deferred-require'
myHugeModule = require 'my-huge-module'

# ... some time later ...

myHugeModule.doSomething() # the module isn't loaded and required until here

This npm exports a single top-level function, deferredRequire, which you can use just as you would use node's global require function. When you require a module with deferredRequire, no code is actually loaded or evaluated until the module you require is first used. This is achieved through the magic of harmony proxies.

Warning: Because of instability in the v8 proxy implementation when combined with "exotic objects" like arrays, strings, and dates, you should only use deferredRequire with modules that export regular objects or functions as their top-level module. This is true of almost every npm module, so in practice this shouldn't be a big issue.

FAQs

Package last updated on 27 Jan 2014

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