Socket
Book a DemoInstallSign in
Socket

esi-service-worker

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esi-service-worker

ESI stream parser for service and cloudflare workers

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

esi-service-worker

This package contains a minimal implementation of Edge Side Includes that run on both serviceworkers and cloudflare workers.

ESI compatibility

See full specs here

This package only implements esi:include and esi:remove.

<esi:include src="/cgi-bin/date.cgi" />
<esi:remove> This is removed</esi:remove>

It doesn't implement:

  • attributes on esi:includes
  • Variable sostitutions
  • recursion

Implementation details

Most of the basic code infrastructure is in place. It can be easily extended with the part of the specs we want to implement.

How to use

The package includes a prebundled version serviceworker.js A serviceworker can also be implemented with:

import fetchAndStream from "esi-stream-parser"

self.addEventListener("fetch", onFetch)

function onFetch(event) {
  event.respondWith(fetchAndStream(event.request))
  // the following is implemented in Cloudflare workers
  if ("passThroughOnException" in event) {
    event.passThroughOnException()
  }
}

Keywords

serviceworker

FAQs

Package last updated on 10 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts