Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
771 bytes
|
Line | |
---|
1 | # read-cache [![Build Status](https://travis-ci.org/TrySound/read-cache.svg?branch=master)](https://travis-ci.org/TrySound/read-cache)
|
---|
2 |
|
---|
3 | Reads and caches the entire contents of a file until it is modified.
|
---|
4 |
|
---|
5 |
|
---|
6 | ## Install
|
---|
7 |
|
---|
8 | ```
|
---|
9 | $ npm i read-cache
|
---|
10 | ```
|
---|
11 |
|
---|
12 |
|
---|
13 | ## Usage
|
---|
14 |
|
---|
15 | ```js
|
---|
16 | // foo.js
|
---|
17 | var readCache = require('read-cache');
|
---|
18 |
|
---|
19 | readCache('foo.js').then(function (contents) {
|
---|
20 | console.log(contents);
|
---|
21 | });
|
---|
22 | ```
|
---|
23 |
|
---|
24 |
|
---|
25 | ## API
|
---|
26 |
|
---|
27 | ### readCache(path[, encoding])
|
---|
28 |
|
---|
29 | Returns a promise that resolves with the file's contents.
|
---|
30 |
|
---|
31 | ### readCache.sync(path[, encoding])
|
---|
32 |
|
---|
33 | Returns the content of the file.
|
---|
34 |
|
---|
35 | ### readCache.get(path[, encoding])
|
---|
36 |
|
---|
37 | Returns the content of cached file or null.
|
---|
38 |
|
---|
39 | ### readCache.clear()
|
---|
40 |
|
---|
41 | Clears the contents of the cache.
|
---|
42 |
|
---|
43 |
|
---|
44 | ## License
|
---|
45 |
|
---|
46 | MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.