Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dailyrandomphoto/export-lazy-prop
Exporting values that will import lazily.
https://github.com/dailyrandomphoto/export-lazy-prop
Last synced: about 1 month ago
JSON representation
Exporting values that will import lazily.
- Host: GitHub
- URL: https://github.com/dailyrandomphoto/export-lazy-prop
- Owner: dailyrandomphoto
- License: mit
- Created: 2020-07-16T04:27:01.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-05T06:08:19.000Z (over 4 years ago)
- Last Synced: 2024-10-29T15:10:19.713Z (about 2 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# export-lazy-prop
[![NPM Version][npm-version-image]][npm-url]
[![LICENSE][license-image]][license-url]
[![Build Status][travis-image]][travis-url]
[![code style: prettier][code-style-prettier-image]][code-style-prettier-url]Export a [lazily evaluated](https://en.wikipedia.org/wiki/Lazy_evaluation) property.
## Installation
```sh
npm install export-lazy-prop
```## Usages
```js
// util/index.js
exports.foo = require("./foo");
exports.bar = require("./bar");// some.js
const util = require("./util");
// foo.js and bar.js are loadedutil.foo();
```In this case, even if `bar.js` is not used, it will still be loaded from the file system.
With `export-lazy-prop`, modules will be loaded on demand.
```js
// util/index.js
const exportLazyProp = require("export-lazy-prop");
exportLazyProp(exports, "foo", () => require("./foo"));
exportLazyProp(exports, "bar", () => require("./bar"));// some.js
const util = require("./util");
// will not load foo.js and bar.jsutil.foo();
// foo.js is loaded
```Or
```js
// util/index.js
const exportLazyProp = require("export-lazy-prop");
exportLazyProp(exports, {
foo: () => require("./foo"),
bar: () => require("./bar"),
});
```## Related
- [define-lazy-prop](https://github.com/sindresorhus/define-lazy-prop) - Define a lazily evaluated property on an object
- [import-lazy](https://github.com/sindresorhus/import-lazy) - Import a module lazily## License
Copyright (c) 2019 [dailyrandomphoto][my-url]. Licensed under the [MIT license][license-url].
[my-url]: https://github.com/dailyrandomphoto
[npm-url]: https://www.npmjs.com/package/export-lazy-prop
[travis-url]: https://travis-ci.org/dailyrandomphoto/export-lazy-prop
[license-url]: LICENSE
[code-style-prettier-url]: https://github.com/prettier/prettier
[npm-downloads-image]: https://img.shields.io/npm/dm/export-lazy-prop
[npm-version-image]: https://img.shields.io/npm/v/export-lazy-prop
[license-image]: https://img.shields.io/npm/l/export-lazy-prop
[travis-image]: https://img.shields.io/travis/dailyrandomphoto/export-lazy-prop
[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square