UNPKG

736 BJavaScriptView Raw
1/*
2 Copyright 2018 Google LLC
3
4 Use of this source code is governed by an MIT-style
5 license that can be found in the LICENSE file or at
6 https://opensource.org/licenses/MIT.
7*/
8
9const prettyBytes = require('pretty-bytes');
10
11module.exports = (maximumFileSizeToCacheInBytes) => {
12 return (originalManifest) => {
13 const warnings = [];
14 const manifest = originalManifest.filter((entry) => {
15 if (entry.size <= maximumFileSizeToCacheInBytes) {
16 return true;
17 }
18
19 warnings.push(`${entry.url} is ${prettyBytes(entry.size)}, and won't ` +
20 `be precached. Configure maximumFileSizeToCacheInBytes to change ` +
21 `this limit.`);
22 return false;
23 });
24
25 return {manifest, warnings};
26 };
27};