0.0.10 • Published 10 months ago

@texoport/lazy v0.0.10

Weekly downloads
-
License
MIT
Repository
github
Last release
10 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

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago