Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit efb1eee

Browse files
run verb to generate readme documentation
1 parent 8192061 commit efb1eee

File tree

3 files changed

+293
-143
lines changed

3 files changed

+293
-143
lines changed

‎.verb.md‎

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,91 @@
1-
## Usage
1+
## Quickstart
22

33
```js
4-
const Cache = require('cache-base');
4+
const CacheBase = require('cache-base');
5+
const app = new CacheBase();
6+
7+
app.set('a.b', 'c');
8+
9+
console.log(app.cache.a); //=> { b: 'c' }
10+
console.log(app.cache.a.b); //=> 'c'
11+
12+
console.log(app.get('a')); //=> { b: 'c' }
13+
console.log(app.get('a.b')); //=> 'c'
514
```
615

7-
**Instantiate**
16+
More [usage examples](#usage-examples) below.
17+
18+
19+
## API
20+
21+
{%= apidocs("index.js") %}
22+
23+
24+
## Usage examples
25+
26+
**Create an instance of cache-base**
827

928
```js
10-
// instantiate
11-
const cache = new Cache();
29+
const app = new CacheBase();
1230

13-
// set values
14-
cache.set('a', 'b');
15-
cache.set('c.d', 'e');
31+
app.set('a', 'b');
32+
app.set('c.d', 'e');
1633

17-
// get values
18-
console.log(cache.get('a'));
34+
console.log(app.get('a'));
1935
//=> 'b'
20-
console.log(cache.get('c'));
36+
console.log(app.get('c'));
2137
//=> { d: 'e' }
22-
console.log(cache);
23-
//=> Cache { a: 'b' }
38+
console.log(app);
39+
//=> CacheBase { a: 'b' }
2440
```
2541

2642
**Initialize with an object**
2743

2844
```js
29-
// instantiate
30-
const cache = new Cache({ a: 'b', c: { d: 'e' } });
45+
const app = new CacheBase({ a: 'b', c: { d: 'e' } });
3146

32-
// get values
33-
console.log(cache.get('a'));
47+
console.log(app.get('a'));
3448
//=> 'b'
35-
console.log(cache.get('c'));
49+
console.log(app.get('c'));
3650
//=> { d: 'e' }
37-
console.log(cache.get('c.d'));
51+
console.log(app.get('c.d'));
3852
//=> 'e'
39-
console.log(cache);
40-
//=> Cache { a: 'b' }
53+
console.log(app);
54+
//=> CacheBase { cache: { a: 'b' } }
4155
```
4256

4357
**Inherit**
4458

4559
```js
46-
class MyApp extends Cache {}
60+
class MyApp extends CacheBase {}
4761

48-
var cache = new MyApp();
49-
cache.set('a', 'b');
50-
console.log(cache.get('a'));
62+
const app = new MyApp();
63+
app.set('a', 'b');
64+
app.set('c', 'd');
65+
66+
console.log(app.get('a'));
5167
//=> 'b'
68+
69+
console.log(app);
70+
//=> MyApp { cache: { a: 'b', c: 'd' } }
5271
```
5372

5473
**Custom namespace**
5574

56-
Define a custom property name for storing values. By default, values are stored directly on the instance (for example, when `cache.set('foo', 'bar')` is used, `cache.foo` would be `bar`).
75+
Pass a string as the first value to the contructor to define a custom property name to use for the cache. By default values are stored on the `cache` property.
5776

5877
```js
59-
const Cache = require('cache-base');
60-
const cache = new Cache('data', { a: 'b' });
61-
cache.set('c.d', 'e');
78+
const CacheBase = require('cache-base');
79+
const app = new CacheBase('data', { a: 'b' });
80+
app.set('c.d', 'e');
6281

6382
// get values
64-
console.log(cache.get('a'));
83+
console.log(app.get('a'));
6584
//=> 'b'
66-
console.log(cache.get('c'));
85+
console.log(app.get('c'));
6786
//=> { d: 'e' }
68-
console.log(cache.data);
87+
console.log(app.data);
6988
//=> { a: 'b', c: { d: 'e' } }
70-
console.log(cache);
71-
//=> Cache { data: { a: 'b', c: { d: 'e' } } }
89+
console.log(app);
90+
//=> CacheBase { data: { a: 'b', c: { d: 'e' } } }
7291
```
73-
74-
## API
75-
76-
{%= apidocs("index.js") %}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /