Socket
Socket
Sign inDemoInstall

import-lazy

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    import-lazy

Import a module lazily


Version published
Weekly downloads
11M
decreased by-1.51%
Maintainers
1
Install size
4.74 kB
Created
Weekly downloads
 

Readme

Source

import-lazy Build Status

Import a module lazily

Note: Version 3 is exclusively Proxy-based and requires Node.js 6+. Use version 2 if you need Node.js <=5 support.

Install

$ npm install import-lazy

Usage

// Pass in `require` or a custom import function
const importLazy = require('import-lazy')(require);
const _ = importLazy('lodash');

// Instead of referring to its exported properties directly…
_.isNumber(2);

// …it's cached on consecutive calls
_.isNumber('unicorn');

// It also works using destructuring assignment in ES2015
const {isNumber, isString} = importLazy('lodash');

// Works out of the box for functions and regular properties
const stuff = importLazy('./math-lib');
console.log(stuff.sum(1, 2)); // => 3
console.log(stuff.PHI); // => 1.618033
  • resolve-from - Resolve the path of a module from a given path
  • import-from - Import a module from a given path
  • resolve-pkg - Resolve the path of a package regardless of it having an entry point
  • lazy-value - Create a lazily evaluated value
  • define-lazy-prop - Define a lazily evaluated property on an object

License

MIT © Sindre Sorhus

Keywords

FAQs

Last updated on 14 Jun 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc