v1.0 with SW PWA enabled
This commit is contained in:
92
frontend/node_modules/read-cache/README.md
generated
vendored
92
frontend/node_modules/read-cache/README.md
generated
vendored
@ -1,46 +1,46 @@
|
||||
# read-cache [](https://travis-ci.org/TrySound/read-cache)
|
||||
|
||||
Reads and caches the entire contents of a file until it is modified.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm i read-cache
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// foo.js
|
||||
var readCache = require('read-cache');
|
||||
|
||||
readCache('foo.js').then(function (contents) {
|
||||
console.log(contents);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### readCache(path[, encoding])
|
||||
|
||||
Returns a promise that resolves with the file's contents.
|
||||
|
||||
### readCache.sync(path[, encoding])
|
||||
|
||||
Returns the content of the file.
|
||||
|
||||
### readCache.get(path[, encoding])
|
||||
|
||||
Returns the content of cached file or null.
|
||||
|
||||
### readCache.clear()
|
||||
|
||||
Clears the contents of the cache.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)
|
||||
# read-cache [](https://travis-ci.org/TrySound/read-cache)
|
||||
|
||||
Reads and caches the entire contents of a file until it is modified.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm i read-cache
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// foo.js
|
||||
var readCache = require('read-cache');
|
||||
|
||||
readCache('foo.js').then(function (contents) {
|
||||
console.log(contents);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### readCache(path[, encoding])
|
||||
|
||||
Returns a promise that resolves with the file's contents.
|
||||
|
||||
### readCache.sync(path[, encoding])
|
||||
|
||||
Returns the content of the file.
|
||||
|
||||
### readCache.get(path[, encoding])
|
||||
|
||||
Returns the content of cached file or null.
|
||||
|
||||
### readCache.clear()
|
||||
|
||||
Clears the contents of the cache.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)
|
||||
|
||||
156
frontend/node_modules/read-cache/index.js
generated
vendored
156
frontend/node_modules/read-cache/index.js
generated
vendored
@ -1,78 +1,78 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var pify = require('pify');
|
||||
|
||||
var stat = pify(fs.stat);
|
||||
var readFile = pify(fs.readFile);
|
||||
var resolve = path.resolve;
|
||||
|
||||
var cache = Object.create(null);
|
||||
|
||||
function convert(content, encoding) {
|
||||
if (Buffer.isEncoding(encoding)) {
|
||||
return content.toString(encoding);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
module.exports = function (path, encoding) {
|
||||
path = resolve(path);
|
||||
|
||||
return stat(path).then(function (stats) {
|
||||
var item = cache[path];
|
||||
|
||||
if (item && item.mtime.getTime() === stats.mtime.getTime()) {
|
||||
return convert(item.content, encoding);
|
||||
}
|
||||
|
||||
return readFile(path).then(function (data) {
|
||||
cache[path] = {
|
||||
mtime: stats.mtime,
|
||||
content: data
|
||||
};
|
||||
|
||||
return convert(data, encoding);
|
||||
});
|
||||
}).catch(function (err) {
|
||||
cache[path] = null;
|
||||
return Promise.reject(err);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.sync = function (path, encoding) {
|
||||
path = resolve(path);
|
||||
|
||||
try {
|
||||
var stats = fs.statSync(path);
|
||||
var item = cache[path];
|
||||
|
||||
if (item && item.mtime.getTime() === stats.mtime.getTime()) {
|
||||
return convert(item.content, encoding);
|
||||
}
|
||||
|
||||
var data = fs.readFileSync(path);
|
||||
|
||||
cache[path] = {
|
||||
mtime: stats.mtime,
|
||||
content: data
|
||||
};
|
||||
|
||||
return convert(data, encoding);
|
||||
} catch (err) {
|
||||
cache[path] = null;
|
||||
throw err;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports.get = function (path, encoding) {
|
||||
path = resolve(path);
|
||||
if (cache[path]) {
|
||||
return convert(cache[path].content, encoding);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
module.exports.clear = function () {
|
||||
cache = Object.create(null);
|
||||
};
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var pify = require('pify');
|
||||
|
||||
var stat = pify(fs.stat);
|
||||
var readFile = pify(fs.readFile);
|
||||
var resolve = path.resolve;
|
||||
|
||||
var cache = Object.create(null);
|
||||
|
||||
function convert(content, encoding) {
|
||||
if (Buffer.isEncoding(encoding)) {
|
||||
return content.toString(encoding);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
module.exports = function (path, encoding) {
|
||||
path = resolve(path);
|
||||
|
||||
return stat(path).then(function (stats) {
|
||||
var item = cache[path];
|
||||
|
||||
if (item && item.mtime.getTime() === stats.mtime.getTime()) {
|
||||
return convert(item.content, encoding);
|
||||
}
|
||||
|
||||
return readFile(path).then(function (data) {
|
||||
cache[path] = {
|
||||
mtime: stats.mtime,
|
||||
content: data
|
||||
};
|
||||
|
||||
return convert(data, encoding);
|
||||
});
|
||||
}).catch(function (err) {
|
||||
cache[path] = null;
|
||||
return Promise.reject(err);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.sync = function (path, encoding) {
|
||||
path = resolve(path);
|
||||
|
||||
try {
|
||||
var stats = fs.statSync(path);
|
||||
var item = cache[path];
|
||||
|
||||
if (item && item.mtime.getTime() === stats.mtime.getTime()) {
|
||||
return convert(item.content, encoding);
|
||||
}
|
||||
|
||||
var data = fs.readFileSync(path);
|
||||
|
||||
cache[path] = {
|
||||
mtime: stats.mtime,
|
||||
content: data
|
||||
};
|
||||
|
||||
return convert(data, encoding);
|
||||
} catch (err) {
|
||||
cache[path] = null;
|
||||
throw err;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports.get = function (path, encoding) {
|
||||
path = resolve(path);
|
||||
if (cache[path]) {
|
||||
return convert(cache[path].content, encoding);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
module.exports.clear = function () {
|
||||
cache = Object.create(null);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user