appcache.js
parse and manipulate AppCache manifests
What is this?
This module exports an AppCache
constructor, and a parser function so that
your JavaScript code can understand and manipulate the string contents of an
AppCache Manifest.
Supported Environments
This is module is not designed to work in web browsers as-is, due to the use of
the CommonJS module pattern, and Node.js' crypto
built-in.
You should be able to use this in Node.js as-is, or in web browsers with a CommonJS-compatible bundler like WebPack or Browserify.
API
AppCache
- @constructor
AppCache#sha1
- @type {
String
} a handy SHA1 hash, populated byAppCache.parse()
Having a hash is useful for comparing AppCache manifests files.
AppCache#cache
- @type {
String[]
} the CACHE entries, populated byAppCache.parse()
AppCache#fallback
- @type {
String[]
} the FALLBACK entries, populated byAppCache.parse()
AppCache#network
- @type {
String[]
} the NETWORK entries, populated byAppCache.parse()
AppCache.parse(contents)
- @param {
String
} the AppCache manifest file's contents - @returns {
AppCache
} the parsed result
Usage
var AppCache = require('@jokeyrhyme/appcache');
var appCache = AppCache.parse(/* string downloaded from an AppCache URL */);
console.log(appCache.cache);
// [ ... ] Array of URL Strings from all CACHE sections of the AppCache manifest