npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

byte-data-stream

v2.3.3

Published

Readable & writable byte data stream

Downloads

6

Readme

byte-data-stream

바이트 데이터를 읽고 쓸 수 있는 스트림

API 문서
English README

사용법

CommonJS의 require() 함수는 2.0.0 이상 버전부터 더 이상 지원되지 않습니다.

import fs from 'fs';
import { ByteStream, ByteStreamSimulator } from 'byte-data-stream';

// ArrayBuffer, Uint8Array 혹은 nodejs Buffer
let buf = fs.readFileSync('......');
let stream = new ByteStream(buf);

stream.readInt8(); // 부호 있는 8비트 정수를 읽음
stream.readUint8(); // 부호 없는 8비트 정수를 읽음
stream.readBytes(8); // 8바이트 길이의 데이터를 읽음
stream.readInt16(); // 부호 있는 빅 엔디언 16비트 정수를 읽음
stream.readUint16(true); // 부호 없는 리틀 엔디언 16비트 정수를 읽음
stream.readVarUint(); // 부호 없는 빅 엔디언 가변 길이 정수를 읽음
// ...

let stream2 = new ByteStream();
stream2.writeInt8(96); // 부호 있는 8비트 정수 기록
stream2.writeUint8(192); // 부호 없는 8비트 정수 기록
stream2.writeBytes([19, 72, 11, 21, 19, 72, 11, 21]); // 8바이트 길이의 데이터 기록
stream2.writeInt16(1972); // 부호 있는 빅 엔디언 16비트 정수 기록
stream2.writeUint16(49861, true); // 부호 없는 리틀 엔디언 16비트 정수 기록
stream2.writeVarUint(92736296525); // 부호 없는 빅 엔디언 가변 길이 정수 기록
// ...

// 테스트용 클래스
// ArrayBuffer에 데이터를 기록하지 않고
// 길이만 증가시키기 때문에
// 길이를 미리 측정해서 기록하도록 할 수 있음
let simulator = new ByteStreamSimulator();

simulator.length;

전체 함수 목록

// 속성
stream.i; // 현재 위치
stream.buffer; // ArrayBuffer
stream.length; // stream.buffer의 길이
stream.isDataAvailable; // stream.i < stream.length

new ByteStream(length, littleEndian = false);
new ByteStream(buf, littleEndian = false);

// 데이터를 읽는 메서드
stream.readInt8();
stream.readUint8();
stream.readBytes(length);
stream.readBytesUntilEnd();
stream.readInt16(oppositeEndian = false);
stream.readUint16(oppositeEndian = false);
stream.readInt32(oppositeEndian = false);
stream.readUint32(oppositeEndian = false);
stream.readBigInt64(oppositeEndian = false);
stream.readBigUint64(oppositeEndian = false);
stream.readFloat32(oppositeEndian = false);
stream.readFloat64(oppositeEndian = false);
stream.readVarInt(oppositeEndian = false, maxByteLength = Infinity);
stream.readVarUint(oppositeEndian = false, maxByteLength = Infinity);

// 데이터를 기록하는 메서드
stream.writeInt8(val);
stream.writeUint8(val);
stream.writeBytes(bytes);
stream.writeInt16(val, oppositeEndian = false);
stream.writeUint16(val, oppositeEndian = false);
stream.writeInt32(val, oppositeEndian = false);
stream.writeUint32(val, oppositeEndian = false);
stream.writeBigInt64(val, oppositeEndian = false);
stream.writeBigUint64(val, oppositeEndian = false);
stream.writeFloat32(val, oppositeEndian = false);
stream.writeFloat64(val, oppositeEndian = false);
stream.writeVarInt(val, oppositeEndian = false);
stream.writeVarUint(val, oppositeEndian = false);