Skip to main content
Home

latest

Framework for Nostr on Deno and web. 🛸

This package works with Deno, BrowsersIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
This package works with Browsers
JSR Score
94%
Published
2 months ago (0.46.5)
class Machina
implements AsyncIterable<T>

Infinite async generator. Iterates messages pushed to it until closed. Only one consumer is expected to use a Machina instance at a time.

Examples

Example 1

// Create the Machina instance
const machina = new Machina<string>();

// Async generator loop
async function getMessages() {
  for await (const msg of machina.stream()) {
    console.log(msg);
  }
}

// Start the generator
getMessages();

// Push messages to it
machina.push('hello!');
machina.push('whats up?');
machina.push('greetings');

Constructors

new
Machina(signal?: AbortSignal)

Type Parameters

Methods

Get messages as an AsyncIterable.

private
abort(): void

Stops streaming and throws an error to the consumer.

push(data: T): void

Push a message into the Machina instance, making it available to the consumer of stream().

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@nostrify/nostrify

Import symbol

import { Machina } from "@nostrify/nostrify/utils";
or

Import directly with a jsr specifier

import { Machina } from "jsr:@nostrify/nostrify/utils";

Add Package

pnpm i jsr:@nostrify/nostrify
or (using pnpm 10.8 or older)
pnpm dlx jsr add @nostrify/nostrify

Import symbol

import { Machina } from "@nostrify/nostrify/utils";

Add Package

yarn add jsr:@nostrify/nostrify
or (using Yarn 4.8 or older)
yarn dlx jsr add @nostrify/nostrify

Import symbol

import { Machina } from "@nostrify/nostrify/utils";

Add Package

vlt install jsr:@nostrify/nostrify

Import symbol

import { Machina } from "@nostrify/nostrify/utils";

Add Package

npx jsr add @nostrify/nostrify

Import symbol

import { Machina } from "@nostrify/nostrify/utils";

Add Package

bunx jsr add @nostrify/nostrify

Import symbol

import { Machina } from "@nostrify/nostrify/utils";