JSPM

@sequentialos/sequential-fetch

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q22387F
  • License MIT

Pure JavaScript VM that pauses on every fetch() call. Drop-in replacement for fetchflow. Works in Node.js, Bun, Deno, and Google Apps Script with zero dependencies.

Package Exports

  • @sequentialos/sequential-fetch

Readme

Sequential Fetch

Implicit xstate VM - automatic pause/resume on every fetch() call.

Installation

npm install sequential-fetch

Usage

const { SequentialFetchVM, executeCode } = require('sequential-fetch');

const result = await executeCode('const x = 10; x * 2');

const vm = new SequentialFetchVM();
await vm.initialize();

const pauseResult = await vm.executeCode(`
  const userId = 123;
  const user = fetch('https://api.example.com/user/' + userId);
  user.name
`);

const finalResult = await vm.resumeExecution(pauseResult.state, { name: 'Alice' });

vm.dispose();

API

SequentialFetchVM

new SequentialFetchVM(options)

Methods:

  • initialize() - Initialize VM
  • executeCode(code) - Execute code, returns pause/complete/error result
  • resumeExecution(fetchId, response) - Resume from paused fetch
  • dispose() - Clean up

Result Types

Pause (fetch encountered):

{ type: 'pause', state: fetchId, fetchRequest: { id, url, options } }

Complete (execution finished):

{ type: 'complete', result: value }

Supported

  • Variable assignment
  • Expressions and arithmetic
  • Property access
  • String concatenation
  • Objects and arrays
  • Fetch pausing

Not Supported (by design)

  • Loops
  • Conditionals
  • Functions
  • async/await
  • Closures

Cross-runtime compatible: Node.js, Bun, Deno.

License

MIT