# snakepipe

> A node implementation of the rust snakepipe crate

Latest version **0.2.0** (published 2024-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install snakepipe
pnpm add snakepipe
yarn add snakepipe
bun add snakepipe
```

Provides the command `snakepipenode`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2024-05-29 |
| First published | 2024-02-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 27.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Christophe Rosset |
| Maintainers | topheman |
| Keywords | cli, game, snake, unix, pipe, stream, async generator, zod |

## Links

- npm: https://www.npmjs.com/package/snakepipe
- Repository: https://github.com/topheman/snake-pipe-node
- Homepage: https://github.com/topheman/snake-pipe-node#readme
- Issues: https://github.com/topheman/snake-pipe-node/issues
- npm.io page: https://npm.io/package/snakepipe

## Dependencies (3)

- [zod](https://npm.io/package/zod.md) ^3.22.4
- [commander](https://npm.io/package/commander.md) ^12.0.0
- [tcp-port-used](https://npm.io/package/tcp-port-used.md) ^1.0.2

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.2.0 (latest) — 2024-05-29
- 0.1.4 — 2024-03-03
- 0.1.3 — 2024-03-01
- 0.1.2 — 2024-02-25
- 0.1.1 — 2024-02-25
- 0.1.0 — 2024-02-25

## README

# snake-pipe-node

[![npm](https://img.shields.io/npm/v/snakepipe?color=blue)](https://www.npmjs.com/package/snakepipe)

A partial node implementation of my rust cli [topheman/snake-pipe-rust](https://github.com/topheman/snake-pipe-rust).

## Prerequisites

- Node

## Install

```sh
npm install -g snakepipe # will install snakepipenode
```

Optional: Install the rust version - it will let you pipe original commands

```sh
cargo install snakepipe # will install snakepipe
```

## Usage

This is a partial implementation, for all the commands, see the [rust implementation](https://github.com/topheman/snake-pipe-rust).

### Piping

#### 📎 Validate incomming stream

```sh
# Without piping to render
snakepipe gamestate|snakepipenode validate

# Piping to render
snakepipe gamestate|snakepipenode validate|snakepipe render
```

### IPC (Inter-process communication)

This node version ships with an implementation of IPS supporting tcp and unix domain sockets, just like in the [rust version](https://github.com/topheman/snake-pipe-rust#ipc-inter-process-communication),

#### TCP

Open two terminals. `snakepipenode tcp-play` will expose a process that accepts tcp connections (on port 8050 by default). You can connect to it via [netcat](https://en.wikipedia.org/wiki/Netcat) (the `nc` command), that will pipe the tcp stream output to stdout.

Here are a few commands mixing the rust and node versions.

```sh
# main terminal
snakepipe gamestate|snakepipenode tcp-play|snakepipe render
```

```sh
# mirroring terminal
nc localhost 8050|snakepipe render # with netcat
snakepipenode tcp-watch|snakepipe render # or with snakepipe itself
```

#### Unix domain sockets

Open two terminals. `snakepipenode socket-play` will expose a [unix domain socket](https://en.wikipedia.org/wiki/Unix_domain_socket) (by default on `/tmp/snakepipe.sock`). You can connect to it via [netcat](https://en.wikipedia.org/wiki/Netcat) (the `nc` command), that will pipe the socket stream to stdout.

```sh
# main terminal
snakepipe gamestate|snakepipenode socket-play|snakepipe render
```

```sh
# mirroring terminal
nc -U /tmp/snakepipe.sock|snakepipe render # with netcat
snakepipenode socket-watch|snakepipe render # or with snakepipe itself
```

## Usage as a library

```
npm install snakepipe
```

See example of usage on [topheman/snake-pipe-rust](https://github.com/topheman/snake-pipe-rust/tree/master/node-helpers/dev-server-sse/index.ts).

## Known bugs

- tty issue when piping from `snakepipe gamestate` [#1](https://github.com/topheman/snake-pipe-node/issues/1)

---
_Source: https://npm.io/package/snakepipe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
