0.1.0 • Published 1 year ago

@lesomnus/io v0.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

io

Provides a Golang io-like I/O interface with a JS stream API wrapper.

Usage

import io from '@lesomnus/io'

io.fetch('http://worldtimeapi.org/api/timezone/Asia/Seoul').then(async r => {
	const b = io.make(512)
	const n = await io.readFull(r, b)
	if (n === null) {
		console.error(r)
		throw new Error('what is wrong?')
	}

	const body = new TextDecoder().decode(b.subarray(0, n).data)
	console.log(body)
	// {"abbreviation":"KST","datetime":"2024-02-27T01:09:43.098317+09:00" ...
})
0.1.0

1 year ago