Galerie und tage
This commit is contained in:
36
node_modules/lazy-req/index.js
generated
vendored
Normal file
36
node_modules/lazy-req/index.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
module.exports = function (fn) {
|
||||
return function (id) {
|
||||
var mod;
|
||||
|
||||
return function () {
|
||||
if (!arguments.length) {
|
||||
mod = lazy(mod, fn, id);
|
||||
return mod;
|
||||
}
|
||||
|
||||
var ret = {};
|
||||
|
||||
[].forEach.call(arguments, function (prop) {
|
||||
Object.defineProperty(ret, prop, {
|
||||
get: function () {
|
||||
mod = lazy(mod, fn, id);
|
||||
if (typeof mod[prop] === 'function') {
|
||||
return function () {
|
||||
return mod[prop].apply(mod, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
return mod[prop];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
|
||||
function lazy(mod, fn, id) {
|
||||
return mod !== undefined ? mod : fn(id);
|
||||
}
|
||||
};
|
||||
21
node_modules/lazy-req/license
generated
vendored
Normal file
21
node_modules/lazy-req/license
generated
vendored
Normal file
@@ -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.
|
||||
41
node_modules/lazy-req/package.json
generated
vendored
Normal file
41
node_modules/lazy-req/package.json
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "lazy-req",
|
||||
"version": "1.1.0",
|
||||
"description": "Require modules lazily",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/lazy-req",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "http://sindresorhus.com"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Jorge Bucaran",
|
||||
"email": "jbucaran@me.com"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && node test.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"require",
|
||||
"load",
|
||||
"module",
|
||||
"modules",
|
||||
"lazy",
|
||||
"lazily",
|
||||
"defer",
|
||||
"deferred"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "0.0.4",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
44
node_modules/lazy-req/readme.md
generated
vendored
Normal file
44
node_modules/lazy-req/readme.md
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# lazy-req [](https://travis-ci.org/sindresorhus/lazy-req)
|
||||
|
||||
> Require modules lazily
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save lazy-req
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// pass in `require` or a custom require function
|
||||
var lazyReq = require('lazy-req')(require);
|
||||
var _ = lazyReq('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
|
||||
var members = lazyReq('lodash')('isNumber', 'isString');
|
||||
|
||||
// useful when using destructuring assignment in ES2015
|
||||
const { isNumber, isString } = lazyReq('lodash')('isNumber', 'isString');
|
||||
|
||||
// works out of the box for functions and regular properties
|
||||
var stuff = lazyReq('./math-lib')('sum', 'PHI');
|
||||
console.log(stuff.sum(1, 2)); // => 3
|
||||
console.log(stuff.PHI); // => 1.618033
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
Reference in New Issue
Block a user