Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

46 righe
1.4 KiB

  1. /*
  2. Copyright 2018 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 './_version.mjs';
  14. let cachedIsSupported = undefined;
  15. /**
  16. * This is a utility method that determines whether the current browser supports
  17. * the features required to create streamed responses. Currently, it checks if
  18. * [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)
  19. * can be created.
  20. *
  21. * @return {boolean} `true`, if the current browser meets the requirements for
  22. * streaming responses, and `false` otherwise.
  23. *
  24. * @memberof workbox.streams
  25. */
  26. function isSupported() {
  27. if (cachedIsSupported === undefined) {
  28. // See https://github.com/GoogleChrome/workbox/issues/1473
  29. try {
  30. new ReadableStream({start() {}});
  31. cachedIsSupported = true;
  32. } catch (error) {
  33. cachedIsSupported = false;
  34. }
  35. }
  36. return cachedIsSupported;
  37. }
  38. export {isSupported};