You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
817 B

2 years ago
  1. # read-cache [![Build Status](https://travis-ci.org/TrySound/read-cache.svg?branch=master)](https://travis-ci.org/TrySound/read-cache)
  2. Reads and caches the entire contents of a file until it is modified.
  3. ## Install
  4. ```
  5. $ npm i read-cache
  6. ```
  7. ## Usage
  8. ```js
  9. // foo.js
  10. var readCache = require('read-cache');
  11. readCache('foo.js').then(function (contents) {
  12. console.log(contents);
  13. });
  14. ```
  15. ## API
  16. ### readCache(path[, encoding])
  17. Returns a promise that resolves with the file's contents.
  18. ### readCache.sync(path[, encoding])
  19. Returns the content of the file.
  20. ### readCache.get(path[, encoding])
  21. Returns the content of cached file or null.
  22. ### readCache.clear()
  23. Clears the contents of the cache.
  24. ## License
  25. MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)