Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. Copyright 2016 Google Inc. All Rights Reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. import {CacheFirst} from './CacheFirst.mjs';
  14. import {CacheOnly} from './CacheOnly.mjs';
  15. import {NetworkFirst} from './NetworkFirst.mjs';
  16. import {NetworkOnly} from './NetworkOnly.mjs';
  17. import {StaleWhileRevalidate} from './StaleWhileRevalidate.mjs';
  18. import './_version.mjs';
  19. /**
  20. * @function workbox.strategies.cacheFirst
  21. * @param {Object} options See the {@link workbox.strategies.CacheFirst}
  22. * constructor for more info.
  23. */
  24. /**
  25. * @function workbox.strategies.cacheOnly
  26. * @param {Object} options See the {@link workbox.strategies.CacheOnly}
  27. * constructor for more info.
  28. */
  29. /**
  30. * @function workbox.strategies.networkFirst
  31. * @param {Object} options See the {@link workbox.strategies.NetworkFirst}
  32. * constructor for more info.
  33. */
  34. /**
  35. * @function workbox.strategies.networkOnly
  36. * @param {Object} options See the {@link workbox.strategies.NetworkOnly}
  37. * constructor for more info.
  38. */
  39. /**
  40. * @function workbox.strategies.staleWhileRevalidate
  41. * @param {Object} options See the
  42. * {@link workbox.strategies.StaleWhileRevalidate} constructor for more info.
  43. */
  44. const mapping = {
  45. cacheFirst: CacheFirst,
  46. cacheOnly: CacheOnly,
  47. networkFirst: NetworkFirst,
  48. networkOnly: NetworkOnly,
  49. staleWhileRevalidate: StaleWhileRevalidate,
  50. };
  51. const defaultExport = {};
  52. Object.keys(mapping).forEach((keyName) => {
  53. defaultExport[keyName] = (options = {}) => {
  54. const StrategyClass = mapping[keyName];
  55. return new StrategyClass(
  56. Object.assign(options)
  57. );
  58. };
  59. });
  60. export default defaultExport;