@stopify/higher-order-functions
TypeScript icon, indicating that this package has built-in type declarations

0.7.3 • Public • Published

@stopify/higher-order-functions

JavaScript programs that use native higher-order functions (e.g., Array.prototype.map, Array.prototype.filter, etc.) are not compatible with Stopify, since Stopify cannot instrument native functions to capture continuations. This package provides polyfills for these functions that work with Stopify.

Usage

Before compiling the program with Stopify, use the compiler in this library to call the polyfill functions:

const ast = babylon.parse(code);
const polyfilled = polyfillHofFromAst(ast.program);
const runner = stopify.stopifyLocallyFromAst(polyfilled,
    undefined, compilerOpts, runtimeOpts);

This wraps arrays to call $stopifyArray, which needs to be a global:

runner.g.$stopifyArray: function(array: any) {
    return require('@stopify/higher-order/functions/dist/ts/mozillaHofPolyfill.lazy')
        .stopifyArray(array);
}

Readme

Keywords

none

Package Sidebar

Install

npm i @stopify/higher-order-functions

Weekly Downloads

2

Version

0.7.3

License

BSD-3-Clause

Unpacked Size

735 kB

Total Files

27

Last publish

Collaborators

  • arjunguha
  • joydeepb
  • jpolitz
  • emilyaherbert