0.0.10 • Published 7 months ago

@texoport/lazy v0.0.10

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Lazy

you're lazy, i'm lazy, we're lazy, why isn't your code lazy?

Install

bun add @texoport/lazy

Example

import { appendFile } from 'node:fs/promises'
import { blue, plot } from 'asciichart'
import { lazy } from '@texoport/lazy'

lazy(async function* () {
	while (true) {
		const response = await fetch(
			'https://api.binance.com/api/v3/ticker/price?symbol=DOGEUSDT',
		)
		const data = await response.json()

		yield {
			price: data.price,
			timestamp: Date.now(),
		}

		await new Promise((resolve) => setTimeout(resolve, 500))
	}
})
	.tap((reading) => {
		appendFile('doge.txt', `${reading.timestamp} ${reading.price}\n`)
	})
	.map((reading) => parseFloat(reading.price))
	.window(50)
	.listen((priceHistory) => {
		console.clear()
		console.log(plot(priceHistory, { height: 15, colors: [blue] }))
	})
0.0.10

7 months ago

0.0.9

7 months ago

0.0.8

7 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago