You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set a default value to be used when `.get()` is called and the value is not defined on the cache. Returns a value from the defaults when only a key is passed.
Assign `value` to `key`. Also emits `set` with the key and value.
111
-
112
-
**Params**
113
-
114
-
*`key`**{String|Array}**: The name of the property to set. Dot-notation may be used to set nested properties.
115
-
*`value`**{any}**
116
-
*`returns`**{Object}**: Returns the instance for chaining.
117
-
118
-
**Events**
119
-
120
-
*`emits`: `set` with `key` and `value` as arguments.
121
-
122
-
**Example**
123
-
124
-
```js
125
-
app.on('set', function(key, val) {
126
-
// do something when `set` is emitted
127
-
});
128
-
129
-
app.set('admin', true);
130
-
131
-
// also takes an object or an array of objects
132
-
app.set({ name:'Brian' });
133
-
app.set([{ foo:'bar' }, { baz:'quux' }]);
134
-
console.log(app);
135
-
//=> { name: 'Brian', foo: 'bar', baz: 'quux' }
136
-
```
137
-
138
-
### [.union](index.js#L173)
159
+
### [.union](index.js#L199)
139
160
140
161
Set an array of unique values on cache `key`.
141
162
@@ -155,28 +176,7 @@ console.log(app.get('a'));
155
176
//=> { b: { c: ['foo', 'bar', 'baz'] } }
156
177
```
157
178
158
-
### [.get](index.js#L194)
159
-
160
-
Return the value of `key`.
161
-
162
-
**Params**
163
-
164
-
*`key`**{String|Array}**: The name of the property to get. Dot-notation may be used to set nested properties.
165
-
*`returns`**{any}**: Returns the value of `key`
166
-
167
-
**Events**
168
-
169
-
*`emits`: `get` with `key` and `value` as arguments.
170
-
171
-
**Example**
172
-
173
-
```js
174
-
app.set('a.b.c', 'd');
175
-
app.get('a.b');
176
-
//=> { c: 'd' }
177
-
```
178
-
179
-
### [.has](index.js#L224)
179
+
### [.has](index.js#L223)
180
180
181
181
Return true if the value of property `key` is not `undefined`.
182
182
@@ -185,10 +185,6 @@ Return true if the value of property `key` is not `undefined`.
185
185
*`key`**{String|Array}**: The name of the property to check. Dot-notation may be used to set nested properties.
186
186
*`returns`**{Boolean}**
187
187
188
-
**Events**
189
-
190
-
*`emits`: `has` with `key` and true or false as arguments.
191
-
192
188
**Example**
193
189
194
190
```js
@@ -201,7 +197,7 @@ app.has('bar'); //=> true
201
197
app.has('baz'); //=> false
202
198
```
203
199
204
-
### [.hasOwn](index.js#L254)
200
+
### [.hasOwn](index.js#L253)
205
201
206
202
Returns true if the specified property is an own (not inherited) property. Similar to [.has()](#has), but returns true if the key exists, even if the value is `undefined`.
207
203
@@ -228,7 +224,7 @@ app.hasOwn('z'); //=> true
228
224
app.hasOwn('lslsls'); //=> false
229
225
```
230
226
231
-
### [.del](index.js#L279)
227
+
### [.del](index.js#L278)
232
228
233
229
Delete one or more properties from the instance.
234
230
@@ -255,6 +251,10 @@ app.del('foo');
255
251
app.del(['foo', 'bar']);
256
252
```
257
253
254
+
### [.clear](index.js#L301)
255
+
256
+
Reset the entire cache to an empty object. Note that this does not also clear the `defaults` object, since you can manually do `cache.defaults = {}` if you want to reset that object as well.
257
+
258
258
**Example**
259
259
260
260
```js
@@ -270,10 +270,14 @@ given object or array.
270
270
271
271
**Params**
272
272
273
-
*`key`**{String|Array}**: The name of the method to visit. Dot-notation may be used to set nested properties.
273
+
*`key`**{String|Array}**: The name of the method to visit.
274
274
*`val`**{Object|Array}**: The object or array to iterate over.
275
275
*`returns`**{Object}**: Returns the instance for chaining.
276
276
277
+
### [.keys](index.js#L338)
278
+
279
+
Gets an array of names of all enumerable properties on the cache.
280
+
277
281
**Example**
278
282
279
283
```js
@@ -285,6 +289,10 @@ console.log(app.keys);
285
289
//=> ['user', 'admin']
286
290
```
287
291
292
+
### [.size](index.js#L357)
293
+
294
+
Gets the length of [keys](#keys).
295
+
288
296
**Example**
289
297
290
298
```js
@@ -431,4 +439,4 @@ Released under the [MIT License](LICENSE).
431
439
432
440
***
433
441
434
-
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on March 03, 2018._
442
+
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on March 23, 2018._
0 commit comments