source: trip-planner-front/node_modules/fragment-cache/README.md@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.5 KB
RevLine 
[6a3a178]1# fragment-cache [![NPM version](https://img.shields.io/npm/v/fragment-cache.svg?style=flat)](https://www.npmjs.com/package/fragment-cache) [![NPM downloads](https://img.shields.io/npm/dm/fragment-cache.svg?style=flat)](https://npmjs.org/package/fragment-cache) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/fragment-cache.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/fragment-cache)
2
3> A cache for managing namespaced sub-caches
4
5## Install
6
7Install with [npm](https://www.npmjs.com/):
8
9```sh
10$ npm install --save fragment-cache
11```
12
13## Usage
14
15```js
16var Fragment = require('fragment-cache');
17var fragment = new Fragment();
18```
19
20## API
21
22### [FragmentCache](index.js#L24)
23
24Create a new `FragmentCache` with an optional object to use for `caches`.
25
26**Example**
27
28```js
29var fragment = new FragmentCache();
30```
31
32**Params**
33
34* `cacheName` **{String}**
35* `returns` **{Object}**: Returns the [map-cache](https://github.com/jonschlinkert/map-cache) instance.
36
37### [.cache](index.js#L49)
38
39Get cache `name` from the `fragment.caches` object. Creates a new `MapCache` if it doesn't already exist.
40
41**Example**
42
43```js
44var cache = fragment.cache('files');
45console.log(fragment.caches.hasOwnProperty('files'));
46//=> true
47```
48
49**Params**
50
51* `cacheName` **{String}**
52* `returns` **{Object}**: Returns the [map-cache](https://github.com/jonschlinkert/map-cache) instance.
53
54### [.set](index.js#L67)
55
56Set a value for property `key` on cache `name`
57
58**Example**
59
60```js
61fragment.set('files', 'somefile.js', new File({path: 'somefile.js'}));
62```
63
64**Params**
65
66* `name` **{String}**
67* `key` **{String}**: Property name to set
68* `val` **{any}**: The value of `key`
69* `returns` **{Object}**: The cache instance for chaining
70
71### [.has](index.js#L93)
72
73Returns true if a non-undefined value is set for `key` on fragment cache `name`.
74
75**Example**
76
77```js
78var cache = fragment.cache('files');
79cache.set('somefile.js');
80
81console.log(cache.has('somefile.js'));
82//=> true
83
84console.log(cache.has('some-other-file.js'));
85//=> false
86```
87
88**Params**
89
90* `name` **{String}**: Cache name
91* `key` **{String}**: Optionally specify a property to check for on cache `name`
92* `returns` **{Boolean}**
93
94### [.get](index.js#L115)
95
96Get `name`, or if specified, the value of `key`. Invokes the [cache](#cache) method, so that cache `name` will be created it doesn't already exist. If `key` is not passed, the entire cache (`name`) is returned.
97
98**Example**
99
100```js
101var Vinyl = require('vinyl');
102var cache = fragment.cache('files');
103cache.set('somefile.js', new Vinyl({path: 'somefile.js'}));
104console.log(cache.get('somefile.js'));
105//=> <File "somefile.js">
106```
107
108**Params**
109
110* `name` **{String}**
111* `returns` **{Object}**: Returns cache `name`, or the value of `key` if specified
112
113## About
114
115### Related projects
116
117* [base](https://www.npmjs.com/package/base): base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… [more](https://github.com/node-base/base) | [homepage](https://github.com/node-base/base "base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting with a handful of common methods, like `set`, `get`, `del` and `use`.")
118* [map-cache](https://www.npmjs.com/package/map-cache): Basic cache object for storing key-value pairs. | [homepage](https://github.com/jonschlinkert/map-cache "Basic cache object for storing key-value pairs.")
119
120### Contributing
121
122Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
123
124### Building docs
125
126_(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).)_
127
128To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
129
130```sh
131$ npm install -g verb verb-generate-readme && verb
132```
133
134### Running tests
135
136Install dev dependencies:
137
138```sh
139$ npm install -d && npm test
140```
141
142### Author
143
144**Jon Schlinkert**
145
146* [github/jonschlinkert](https://github.com/jonschlinkert)
147* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
148
149### License
150
151Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
152Released under the [MIT license](https://github.com/jonschlinkert/fragment-cache/blob/master/LICENSE).
153
154***
155
156_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 17, 2016._
Note: See TracBrowser for help on using the repository browser.