Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / lazy-cache / README.md
1 # lazy-cache [![NPM version](https://img.shields.io/npm/v/lazy-cache.svg?style=flat)](https://www.npmjs.com/package/lazy-cache) [![NPM downloads](https://img.shields.io/npm/dm/lazy-cache.svg?style=flat)](https://npmjs.org/package/lazy-cache) [![Build Status](https://img.shields.io/travis/jonschlinkert/lazy-cache.svg?style=flat)](https://travis-ci.org/jonschlinkert/lazy-cache)
2
3 > Cache requires to be lazy-loaded when needed.
4
5 ## Install
6
7 Install with [npm](https://www.npmjs.com/):
8
9 ```sh
10 $ npm install lazy-cache --save
11 ```
12
13 If you use webpack and are experiencing issues, try using [unlazy-loader](https://github.com/doowb/unlazy-loader), a webpack loader that fixes the bug that prevents webpack from working with native javascript getters.
14
15 ## Usage
16
17 ```js
18 var utils = require('lazy-cache')(require);
19 ```
20
21 **Use as a property on `lazy`**
22
23 The module is also added as a property to the `lazy` function
24 so it can be called without having to call a function first.
25
26 ```js
27 var utils = require('lazy-cache')(require);
28
29 // `npm install glob`
30 utils('glob');
31
32 // glob sync
33 console.log(utils.glob.sync('*.js'));
34
35 // glob async
36 utils.glob('*.js', function (err, files) {
37   console.log(files);
38 });
39 ```
40
41 **Use as a function**
42
43 ```js
44 var utils = require('lazy-cache')(require);
45 var glob = utils('glob');
46
47 // `glob` is a now a function that may be called when needed
48 glob().sync('foo/*.js');
49 ```
50
51 ## Aliases
52
53 An alias may be passed as the second argument if you don't want to use the automatically camel-cased variable name.
54
55 **Example**
56
57 ```js
58 var utils = require('lazy-cache')(require);
59
60 // alias `ansi-yellow` as `yellow`
61 utils('ansi-yellow', 'yellow');
62 console.log(utils.yellow('foo'));
63 ```
64
65 ## Browserify usage
66
67 **Example**
68
69 ```js
70 var utils = require('lazy-cache')(require);
71 // temporarily re-assign `require` to trick browserify
72 var fn = require;
73 require = utils;
74 // list module dependencies (here, `require` is actually `lazy-cache`)
75 require('glob');
76 require = fn; // restore the native `require` function
77
78 /**
79  * Now you can use glob with the `utils.glob` variable
80  */
81
82 // sync
83 console.log(utils.glob.sync('*.js'));
84
85 // async
86 utils.glob('*.js', function (err, files) {
87   console.log(files.join('\n'));
88 });
89 ```
90
91 ## Kill switch
92
93 In certain rare edge cases it may be necessary to unlazy all lazy-cached dependencies (5 reported cases after ~30 million downloads).
94
95 To force lazy-cache to immediately invoke all dependencies, do:
96
97 ```js
98 process.env.UNLAZY = true;
99 ```
100
101 ## Related projects
102
103 You might also be interested in these projects:
104
105 [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://www.npmjs.com/package/lint-deps) | [homepage](https://github.com/jonschlinkert/lint-deps)
106
107 ## Contributing
108
109 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/lazy-cache/issues/new).
110
111 ## Building docs
112
113 Generate readme and API documentation with [verb](https://github.com/verbose/verb):
114
115 ```sh
116 $ npm install verb && npm run docs
117 ```
118
119 Or, if [verb](https://github.com/verbose/verb) is installed globally:
120
121 ```sh
122 $ verb
123 ```
124
125 ## Running tests
126
127 Install dev dependencies:
128
129 ```sh
130 $ npm install -d && npm test
131 ```
132
133 ## Author
134
135 **Jon Schlinkert**
136
137 * [github/jonschlinkert](https://github.com/jonschlinkert)
138 * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
139
140 ## License
141
142 Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
143 Released under the [MIT license](https://github.com/jonschlinkert/lazy-cache/blob/master/LICENSE).
144
145 ***
146
147 _This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on April 22, 2016._