Big update!Announcing Socket for GitHub 1.0. Learn more
Socket
BlogLoveFAQ
Install
Log in

import-lazy

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Issues
File Explorer

Advanced tools

import-lazy

Import a module lazily

    4.0.0latest

Version published
Maintainers
1
Weekly downloads
11,851,790
decreased by-4.09%

Weekly downloads

Changelog

Source

Breaking:

  • Require Node.js 8 (#18) 428051f

Enhancements:

  • Add TypeScript definition (#18) 428051f

https://github.com/sindresorhus/import-lazy/compare/v3.1.0...v4.0.0

Readme

Source

import-lazy Build Status

Import a module lazily

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'); // 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

Warning: Destructuring will cause it to fetch eagerly

While you may be tempted to do leverage destructuring, like this:

const {isNumber, isString} = importLazy('lodash');

Note that this will cause immediate property access, negating the lazy loading, and is equivalent to:

import {isNumber, isString} from 'lodash';
  • 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

What is import-lazy?

Import a module lazily

Is import-lazy popular?

The npm package import-lazy receives a total of 9,585,256 weekly downloads. As such, import-lazy popularity was classified as popular.

Is import-lazy well maintained?

We found that import-lazy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 27 Apr 2019
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc