Re: [slightlyoff/ServiceWorker] Provide cache.putAll() method (#867)

Here is possible polyfill to this problem:

```js
function putAll(cache, entries) {
  const operation = entries.map((entry) => {
    return cache.put(entry[0], entry[1]);
  });

  return Promise.all(operation).then(() => {
    return cache.put('/__data_is_safe__', new Response(''));
  });
}

function hasCache(storage, cacheName) {
  return storage.open(cacheName, (cache) => {
    return cache.match('/__data_is_safe__')
  }).then((response) => {
    return !!response;
  });
}
```

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/867#issuecomment-211406237

Received on Monday, 18 April 2016 14:35:58 UTC