diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/lazy-cache | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/lazy-cache')
-rw-r--r-- | node_modules/lazy-cache/LICENSE | 21 | ||||
-rw-r--r-- | node_modules/lazy-cache/README.md | 195 | ||||
-rw-r--r-- | node_modules/lazy-cache/index.js | 73 | ||||
-rw-r--r-- | node_modules/lazy-cache/package.json | 69 |
4 files changed, 0 insertions, 358 deletions
diff --git a/node_modules/lazy-cache/LICENSE b/node_modules/lazy-cache/LICENSE deleted file mode 100644 index 1e49edf81..000000000 --- a/node_modules/lazy-cache/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015-2016, Jon Schlinkert. - -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/lazy-cache/README.md b/node_modules/lazy-cache/README.md deleted file mode 100644 index 14463180c..000000000 --- a/node_modules/lazy-cache/README.md +++ /dev/null @@ -1,195 +0,0 @@ -# lazy-cache [](https://www.npmjs.com/package/lazy-cache) [](https://npmjs.org/package/lazy-cache) [](https://npmjs.org/package/lazy-cache) [](https://travis-ci.org/jonschlinkert/lazy-cache) - -> Cache requires to be lazy-loaded when needed. - -## Install - -Install with [npm](https://www.npmjs.com/): - -```sh -$ npm install --save lazy-cache -``` - -## Heads up! - -It's suprising how many libraries are in the average dependency tree that don't belong there for one reason or another. Either because they were accidentally listed as `dependencies` instead of `devDepedencies`, or they are required in a file as variables, but the variable is never actually used (poor linting), and so on. Or because the maintainer made the decision to add the deps, even though they will never ([or can't ever](https://github.com/felixge/node-dateformat/issues/36)) be used by 99.9% of users. - -Worse, many libraries like chalk and [shelljs](https://github.com/eslint/eslint/issues/7316) actually execute code when `require()` is called!? (shelljs was modifying the `String.prototype`, and chalk loops over some objects to dynamically create methods). In other words, they do something like this: - -```js -// in the main export of a library, if you do this it will -// automatically modify the String.prototype _globally_, -// the moment node.js loads the dependency tree -String.prototype.foo = function() {}; - -// same if you do something like this -// (dont' do this, ever. wrap this kind of code in a function -// and allow implementors to decide when to call it) -while (foo) { - // do stuff -} -``` - -In any case, just having these libraries in your dependency tree somewhere means that their code will excecute the moment you run your application _even if the libraries are never called by your application or any other code anywhere in the tree_. - -**solution** - -lazy-cache doesn't use any "magic", it uses native, plain-vanilla, tried and true javascript getters to call node's `require()` system. - -**Faster, safer code** - -There main advantage to this, the main is that `require`s are loaded on demand, so only code that is actually used will ever be loaded. As a result, applications will load faster (sometimes much faster - we've seen load times drop from ~1 second to less than 50 milliseconds). - -Moreover, in some cases this also avoids inadvertently loading libraries that execute code or modifies globals, etc. - -**webpack users** - -If you use webpack and are experiencing issues with lazy-cache, this is a known bug caused by webpack, not lazy-cache. There is a solution though, you can use [unlazy-loader](https://github.com/doowb/unlazy-loader), a webpack loader that _fixes the webpack bug_. - -## Usage - -```js -var utils = require('lazy-cache')(require); -``` - -**Use as a property on `lazy`** - -The module is also added as a property to the `lazy` function so it can be called without having to call a function first. - -```js -var utils = require('lazy-cache')(require); - -// `npm install glob` -utils('glob'); - -// glob sync -console.log(utils.glob.sync('*.js')); - -// glob async -utils.glob('*.js', function (err, files) { - console.log(files); -}); -``` - -**Use as a function** - -```js -var utils = require('lazy-cache')(require); -var glob = utils('glob'); - -// `glob` is a now a function that may be called when needed -glob().sync('foo/*.js'); -``` - -## Aliases - -An alias may be passed as the second argument if you don't want to use the automatically camel-cased variable name. - -**Example** - -```js -var utils = require('lazy-cache')(require); - -// alias `ansi-yellow` as `yellow` -utils('ansi-yellow', 'yellow'); -console.log(utils.yellow('foo')); -``` - -Dot notation may also be used in the alias to create an object hierarchy. - -**Example** - -```js -var utils = require('lazy-cache')(require); -utils('ansi-cyan', 'color.cyan'); -utils('ansi-yellow', 'color.yellow'); -utils('ansi-magenta', 'color.magenta'); -console.log(utils.color.cyan('foo')); -console.log(utils.color.yellow('bar')); -console.log(utils.color.magenta('baz')); -``` - -## Browserify usage - -**Example** - -```js -var utils = require('lazy-cache')(require); -// temporarily re-assign `require` to trick browserify -var fn = require; -require = utils; -// list module dependencies (here, `require` is actually `lazy-cache`) -require('glob'); -require = fn; // restore the native `require` function - -/** - * Now you can use glob with the `utils.glob` variable - */ - -// sync -console.log(utils.glob.sync('*.js')); - -// async -utils.glob('*.js', function (err, files) { - console.log(files.join('\n')); -}); -``` - -## Kill switch - -To force lazy-cache to immediately invoke all dependencies, do: - -```js -process.env.UNLAZY = true; -``` - -## About - -### Related projects - -[lint-deps](https://www.npmjs.com/package/lint-deps): CLI tool that tells you when dependencies are missing from package.json and offers you a… [more](https://github.com/jonschlinkert/lint-deps) | [homepage](https://github.com/jonschlinkert/lint-deps "CLI tool that tells you when dependencies are missing from package.json and offers you a choice to install them. Also tells you when dependencies are listed in package.json but are not being used anywhere in your project. Node.js command line tool and API") - -### Contributing - -Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). - -### Contributors - -| **Commits** | **Contributor**<br/> | -| --- | --- | -| 31 | [jonschlinkert](https://github.com/jonschlinkert) | -| 27 | [doowb](https://github.com/doowb) | - -### Building docs - -_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ - -To generate the readme and API documentation with [verb](https://github.com/verbose/verb): - -```sh -$ npm install -g verb verb-generate-readme && verb -``` - -### Running tests - -Install dev dependencies: - -```sh -$ npm install -d && npm test -``` - -### Author - -**Jon Schlinkert** - -* [github/jonschlinkert](https://github.com/jonschlinkert) -* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) - -### License - -Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). -Released under the [MIT license](https://github.com/jonschlinkert/lazy-cache/blob/master/LICENSE). - -*** - -_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on November 07, 2016._
\ No newline at end of file diff --git a/node_modules/lazy-cache/index.js b/node_modules/lazy-cache/index.js deleted file mode 100644 index 751fcbb5c..000000000 --- a/node_modules/lazy-cache/index.js +++ /dev/null @@ -1,73 +0,0 @@ -'use strict'; - -var set = require('set-getter'); - -/** - * Cache results of the first function call to ensure only calling once. - * - * ```js - * var utils = require('lazy-cache')(require); - * // cache the call to `require('ansi-yellow')` - * utils('ansi-yellow', 'yellow'); - * // use `ansi-yellow` - * console.log(utils.yellow('this is yellow')); - * ``` - * - * @param {Function} `fn` Function that will be called only once. - * @return {Function} Function that can be called to get the cached function - * @api public - */ - -function lazyCache(requireFn) { - var cache = {}; - - return function proxy(name, alias) { - var key = alias; - - // camel-case the module `name` if `alias` is not defined - if (typeof key !== 'string') { - key = camelcase(name); - } - - // create a getter to lazily invoke the module the first time it's called - function getter() { - return cache[key] || (cache[key] = requireFn(name)); - } - - // trip the getter if `process.env.UNLAZY` is defined - if (unlazy(process.env)) { - getter(); - } - - set(proxy, key, getter); - return getter; - }; -} - -/** - * Return true if `process.env.LAZY` is true, or travis is running. - */ - -function unlazy(env) { - return env.UNLAZY === 'true' || env.UNLAZY === true || env.TRAVIS; -} - -/** - * Camelcase the the given module `name`. - */ - -function camelcase(str) { - if (str.length === 1) { - return str.toLowerCase(); - } - str = str.replace(/^[\W_]+|[\W_]+$/g, '').toLowerCase(); - return str.replace(/[\W_]+(\w|$)/g, function(_, ch) { - return ch.toUpperCase(); - }); -} - -/** - * Expose `lazyCache` - */ - -module.exports = lazyCache; diff --git a/node_modules/lazy-cache/package.json b/node_modules/lazy-cache/package.json deleted file mode 100644 index 766dd4a36..000000000 --- a/node_modules/lazy-cache/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "lazy-cache", - "description": "Cache requires to be lazy-loaded when needed.", - "version": "2.0.2", - "homepage": "https://github.com/jonschlinkert/lazy-cache", - "author": "Jon Schlinkert (https://github.com/jonschlinkert)", - "contributors": [ - "Brian Woodward <brian.woodward@gmail.com> (https://github.com/doowb)", - "Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)" - ], - "repository": "jonschlinkert/lazy-cache", - "bugs": { - "url": "https://github.com/jonschlinkert/lazy-cache/issues" - }, - "license": "MIT", - "files": [ - "index.js" - ], - "main": "index.js", - "engines": { - "node": ">=0.10.0" - }, - "scripts": { - "test": "mocha" - }, - "dependencies": { - "set-getter": "^0.1.0" - }, - "devDependencies": { - "ansi-cyan": "^0.1.1", - "ansi-magenta": "^0.1.1", - "ansi-yellow": "^0.1.1", - "glob": "^7.0.3", - "gulp-format-md": "^0.1.8", - "mocha": "^2.4.5", - "object.omit": "^2.0.0", - "object.pick": "^1.1.2" - }, - "keywords": [ - "cache", - "caching", - "dependencies", - "dependency", - "lazy", - "require", - "requires" - ], - "verb": { - "related": { - "list": [ - "lint-deps" - ] - }, - "plugins": [ - "gulp-format-md" - ], - "toc": false, - "layout": "default", - "tasks": [ - "readme" - ], - "lint": { - "reflinks": true - }, - "reflinks": [ - "verb" - ] - } -} |