Skip to content

Instantly share code, notes, and snippets.

@akainth015
Last active November 4, 2017 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akainth015/c94510d9d1a11aa01b26293353a739c4 to your computer and use it in GitHub Desktop.
Save akainth015/c94510d9d1a11aa01b26293353a739c4 to your computer and use it in GitHub Desktop.
A definition file for WebStorm to index
;
throw new Error("ServiceWorkerAPI is not meant to be run in the browser, it is just for IDEs to index for autocompletion");
const caches = {
_cache: function() {
/**
* A list of files to add to this cache
* @param files An array containing a list of files to add to cache
*/
this.addAll = function(files) {
};
/**
* Add a response to the cache
* @param url The url of the response
* @param {Response} data The data of the Response
*/
this.put = function(url, data) {
}
},
/**
* Return the specified resource
* @param url The URL of the specified resource
*/
match: function(url) {
},
/**
* Open the specified cache
* @param version The cache version to open
* @returns {Promise}
*/
open: function(version) {
return new Promise(function() {
});
}
};
/**
* Fetch a resource
* @param url The URL of the resource to fetch
*/
const fetch = function(url) {
};
/**
* This is an event fired when a page in the ServiceWorker's scope makes a request
* @constructor
*/
const FetchEvent = function() {
};
/**
* Respond to the request with the specified resource
* @param resource
*/
FetchEvent.prototype.respondWith = function(resource) {
};
FetchEvent.prototype.request = "";
/**
* This is an event fired when a service worker is installed on the device
* @constructor
*/
const InstallEvent = function() {
};
/**
* Wait for the function provided to complete
*/
InstallEvent.prototype.waitUntil = function(operationToComplete) {
};
const navigator = {
serviceWorker: {
register: function(url) {
return new Promise();
}
}
};
/**
* Create a new promise
* @param functionToExecute The function to run asynchronously
* @constructor
*/
const Promise = function(functionToExecute) {
};
/**
* Run onSuccess when functionToExecute executes successfully
* @param onSuccess The function to run on success
*/
Promise.prototype.then = function(onSuccess) {
};
/**
* Run onFailure when functionToExecute executes unsuccessfully or fails
* @param onFailure The function to run on failure
*/
Promise.prototype.catch = function(onFailure) {
};
const Response = function(content, config) {
};
/**
* Clone the response
*/
Response.prototype.clone = function() {
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment