aboutsummaryrefslogtreecommitdiff
path: root/node_modules/import-lazy
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-06-04 08:51:01 +0200
committerMinteck <contact@minteck.org>2022-06-04 08:51:01 +0200
commit383285ecd5292bf9a825e05904955b937de84cc9 (patch)
tree0a53b6f02c1604b078044567c03dc1b6c944c8c2 /node_modules/import-lazy
downloadequestriadb-383285ecd5292bf9a825e05904955b937de84cc9.tar.gz
equestriadb-383285ecd5292bf9a825e05904955b937de84cc9.tar.bz2
equestriadb-383285ecd5292bf9a825e05904955b937de84cc9.zip
Initial commit
Diffstat (limited to 'node_modules/import-lazy')
-rw-r--r--node_modules/import-lazy/index.js53
-rw-r--r--node_modules/import-lazy/license21
-rw-r--r--node_modules/import-lazy/package.json44
-rw-r--r--node_modules/import-lazy/readme.md64
4 files changed, 182 insertions, 0 deletions
diff --git a/node_modules/import-lazy/index.js b/node_modules/import-lazy/index.js
new file mode 100644
index 0000000..307f08f
--- /dev/null
+++ b/node_modules/import-lazy/index.js
@@ -0,0 +1,53 @@
+'use strict';
+const lazy = (mod, fn, id) => mod === undefined ? fn(id) : mod;
+
+module.exports = fn => {
+ return id => {
+ let mod;
+
+ return function () {
+ if (arguments.length === 0) {
+ mod = lazy(mod, fn, id);
+ return mod;
+ }
+
+ const ret = {};
+
+ [].forEach.call(arguments, prop => {
+ Object.defineProperty(ret, prop, {
+ get: () => {
+ mod = lazy(mod, fn, id);
+ if (typeof mod[prop] === 'function') {
+ return function () {
+ return mod[prop].apply(mod, arguments);
+ };
+ }
+
+ return mod[prop];
+ }
+ });
+ });
+
+ return ret;
+ };
+ };
+};
+
+module.exports.proxy = fn => {
+ return id => {
+ let mod;
+
+ const handler = {
+ get: (target, property) => {
+ mod = lazy(mod, fn, id);
+ return Reflect.get(mod, property);
+ },
+ apply: (target, thisArg, argumentsList) => {
+ mod = lazy(mod, fn, id);
+ return Reflect.apply(mod, thisArg, argumentsList);
+ }
+ };
+
+ return new Proxy(() => {}, handler);
+ };
+};
diff --git a/node_modules/import-lazy/license b/node_modules/import-lazy/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/node_modules/import-lazy/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node_modules/import-lazy/package.json b/node_modules/import-lazy/package.json
new file mode 100644
index 0000000..89d80b6
--- /dev/null
+++ b/node_modules/import-lazy/package.json
@@ -0,0 +1,44 @@
+{
+ "name": "import-lazy",
+ "version": "2.1.0",
+ "description": "Import modules lazily",
+ "license": "MIT",
+ "repository": "sindresorhus/import-lazy",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "contributors": [
+ {
+ "name": "Jorge Bucaran",
+ "email": "jbucaran@me.com"
+ }
+ ],
+ "engines": {
+ "node": ">=4"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "import",
+ "require",
+ "load",
+ "module",
+ "modules",
+ "lazy",
+ "lazily",
+ "defer",
+ "deferred",
+ "proxy",
+ "proxies"
+ ],
+ "devDependencies": {
+ "ava": "*",
+ "xo": "*"
+ }
+}
diff --git a/node_modules/import-lazy/readme.md b/node_modules/import-lazy/readme.md
new file mode 100644
index 0000000..233e42e
--- /dev/null
+++ b/node_modules/import-lazy/readme.md
@@ -0,0 +1,64 @@
+# import-lazy [![Build Status](https://travis-ci.org/sindresorhus/import-lazy.svg?branch=master)](https://travis-ci.org/sindresorhus/import-lazy)
+
+> Import modules lazily
+
+
+## Install
+
+```
+$ npm install --save import-lazy
+```
+
+
+## Usage
+
+```js
+// Pass in `require` or a custom import function
+const importLazy = require('import-lazy')(require);
+const _ = importLazy('lodash');
+
+// Where you would normally do
+_.isNumber(2);
+
+// You now instead call it as a function
+_().isNumber(2);
+
+// It's cached on consecutive calls
+_().isString('unicorn');
+
+// Extract lazy variations of the props you need
+const members = importLazy('lodash')('isNumber', 'isString');
+
+// Useful when using destructuring assignment in ES2015
+const {isNumber, isString} = importLazy('lodash')('isNumber', 'isString');
+
+// Works out of the box for functions and regular properties
+const stuff = importLazy('./math-lib')('sum', 'PHI');
+console.log(stuff.sum(1, 2)); // => 3
+console.log(stuff.PHI); // => 1.618033
+```
+
+### Proxy support in Node.js 6 or later
+
+If you use Node.js 6 or later, you can take advantage of ES2015 proxies and don't need to call it as a function.
+
+```js
+const importLazy = require('import-lazy').proxy(require);
+const _ = importLazy('lodash');
+
+// No need to call it as a function but still lazily imported
+_.isNumber(2);
+```
+
+## Related
+
+- [resolve-from](https://github.com/sindresorhus/resolve-from) - Resolve the path of a module from a given path
+- [import-from](https://github.com/sindresorhus/import-from) - Import a module from a given path
+- [resolve-pkg](https://github.com/sindresorhus/resolve-pkg) - Resolve the path of a package regardless of it having an entry point
+- [lazy-value](https://github.com/sindresorhus/lazy-value) - Create a lazily evaluated value
+- [define-lazy-prop](https://github.com/sindresorhus/define-lazy-prop) - Define a lazily evaluated property on an object
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)