1.0.0 • Published 9 years ago

@jokeyrhyme/appcache v1.0.0

Weekly downloads
1
License
BSD
Repository
github
Last release
9 years ago

appcache.js npm module AppVeyor Status Travis CI Status

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 by AppCache.parse()

Having a hash is useful for comparing AppCache manifests files.

AppCache#cache

  • @type {String[]} the CACHE entries, populated by AppCache.parse()

AppCache#fallback

  • @type {String[]} the FALLBACK entries, populated by AppCache.parse()

AppCache#network

  • @type {String[]} the NETWORK entries, populated by AppCache.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