Packages
@runtime-edge/ponyfill

Runtime Edge Ponyfill

The @runtime-edge/ponyfill package helps to have the Runtime Edge APIs available in your environment:

  • When running on Runtime Edge, no polyfills will be loaded, and the native implementations will be used.
  • When running on Node.js runtimes, this package will load the polyfills from @runtime-edge/primitives.

Note this is just necessary if you want to run the same code across different environments.

Installation

npm install @runtime-edge/ponyfill

This package includes built-in TypeScript support.

Usage

Rather than use APIs from the global scope:

const data = new TextEncoder().encode('Hello, world')
const digest = await crypto.subtle.digest('SHA-256', content)

Load them from the package instead:

import { crypto, TextEncoder } from '@runtime-edge/ponyfill'
 
const data = new TextEncoder().encode('Hello, world')
const digest = await crypto.subtle.digest('SHA-256', content)

Any Runtime Edge API is available.