MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / parse

Method parse

src/ext/intercept.js:55–90  ·  view source on GitHub ↗
(parser)

Source from the content-addressed store, hash-verified

53 }
54
55 static parse(parser) {
56 if (!parser.matchToken("intercept")) return;
57
58 var scope = consumeNakedPath(parser);
59 var config = { scope: scope, precache: null, routes: [], offlineFallback: null };
60
61 while (parser.hasMore() && parser.currentToken().value !== "end") {
62 if (parser.matchToken("precache")) {
63 var urls = [];
64 do {
65 urls.push(consumeStringOrPath(parser));
66 } while (parser.matchOpToken(","));
67 var version = null;
68 if (parser.matchToken("as")) {
69 version = parser.requireTokenType("STRING").value;
70 }
71 config.precache = { urls: urls, version: version };
72 } else if (parser.matchToken("on")) {
73 var patterns = [];
74 do {
75 patterns.push(consumeNakedPath(parser));
76 } while (parser.matchOpToken(","));
77 parser.requireToken("use");
78 var strategy = consumeStrategy(parser);
79 config.routes.push({ patterns: patterns, strategy: strategy });
80 } else if (parser.matchToken("offline")) {
81 parser.requireToken("fallback");
82 config.offlineFallback = consumeStringOrPath(parser);
83 } else {
84 parser.raiseError("Expected precache, on, offline, or end");
85 }
86 }
87 parser.requireToken("end");
88
89 return new InterceptFeature(config);
90 }
91
92 install(target, source, args, runtime) {
93 if (!('serviceWorker' in navigator)) {

Callers

nothing calls this directly

Calls 10

consumeNakedPathFunction · 0.85
consumeStringOrPathFunction · 0.85
consumeStrategyFunction · 0.85
matchTokenMethod · 0.45
hasMoreMethod · 0.45
currentTokenMethod · 0.45
matchOpTokenMethod · 0.45
requireTokenTypeMethod · 0.45
requireTokenMethod · 0.45
raiseErrorMethod · 0.45

Tested by

no test coverage detected