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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@twlibn/core

v0.0.5

Published

twlibn core

Readme

@twlibn/core

низкоуровневые примитивы teeworlds/DDNet протокола. основа для остальных пакетов twlibn.

0374flop MIT

начало

установка

npm install @twlibn/core

импорт

import { Huffman, States, createTwMD5Hash, UUIDManager, BufReader, BufWriter, intsToStr, strToInts, VarIntReader, packInt, packInts, varintToLE, MsgPacker, MsgUnpacker } from '@twlibn/core';
const { Huffman, States, createTwMD5Hash, UUIDManager, BufReader, BufWriter, intsToStr, strToInts, VarIntReader, packInt, packInts, varintToLE, MsgPacker, MsgUnpacker } = require('@twlibn/core');

документация

Huffman

DDNet huffman (https://github.com/swarfeya/teeworlds-library-ts/ нагло украл отсюда)

import { Huffman } from '@twlibn/core';

const huff = new Huffman();

const compressed = huff.compress(Buffer.from([1, 2, 3]));
const decompressed = huff.decompress(compressed);

new Huffman(frequencies?) - по умолчанию используется таблица DDNet.

huff.compress(buf, start?, size?): Buffer

huff.decompress(buf, size?): Buffer

Msg

(https://github.com/swarfeya/teeworlds-library-ts/ нагло украл отсюда)

MsgPacker

import { MsgPacker, NETMSG } from '@twlibn/core';

const packer = new MsgPacker(NETMSG.System.NETMSG_INFO, true, 0);
packer.AddString('0.7 802f1be60a05665f');
packer.AddString('');
packer.AddInt(0);

const buf = packer.buffer; // Buffer

new MsgPacker(msg, sys, flag) - создать паккер, msg - id сообщения, sys - системное или игровое

packer.AddString(str) - добавить null-terminated строку

packer.AddInt(i) - добавить varint

packer.AddBuffer(buf) - добавить сырые байты

packer.buffer - итоговый буфер Buffer

packer.size - размер в байтах

MsgUnpacker

import { MsgUnpacker } from '@twlibn/core';

const unpacker = new MsgUnpacker(buf);
const version = unpacker.unpackString();
const password = unpacker.unpackString();
const reserved = unpacker.unpackInt();

new MsgUnpacker(buf) - создать унпаккер из буфера

unpacker.unpackInt() - прочитать varint number

unpacker.unpackString() - прочитать null-terminated строку string

unpacker.unpackRaw(size) - прочитать size байт Buffer

unpacker.remaining - сколько байт осталось

VarIntReader / packInt

DDNet varint кодирование

import { VarIntReader, packInt, packInts, varintToLE } from '@twlibn/core';

const reader = new VarIntReader(buf);
const value = reader.readInt();
const values = reader.readInts(5);

const encoded = packInt(-42);
const encodedMany = packInts([1, 2, 3]);

const asLE = varintToLE(buf); // конвертировать varint-буфер в little-endian int32

BufReader / BufWriter

удобное чтение/запись бинарных данных

import { BufReader, BufWriter } from '@twlibn/core';

const r = new BufReader(buf);
const a = r.u8();
const b = r.i32be();
const s = r.cstring(64);

const w = new BufWriter();
w.u8(1).i32be(1234).cstring('hello', 64);
const result = w.build();

методы BufReader: u8, u16le, i32be, i32le, raw(size), cstring(size), remaining

методы BufWriter: u8, u16le, i32be, i32le, raw(buf), cstring(str, size), build(), size

intsToStr / strToInts

конвертация строк в ddnet packed int формат

import { intsToStr, strToInts } from '@twlibn/core';

const name = intsToStr([...clientInfo.name]); // int[] → string
const ints = strToInts('nameless tee', 4);    // string → int[] (4 слота = 15 байт)

NETMSG

enum всех системных и игровых сообщений ddnet протокола (включая UUID-расширения). (https://github.com/swarfeya/teeworlds-library-ts/ нагло украл отсюда)

import { NETMSG } from '@twlibn/core';

NETMSG.System.NETMSG_INFO       // 1
NETMSG.System.NETMSG_SNAP       // 5
NETMSG.Game.SV_CHAT             // 3
NETMSG.UUID.SV_DDRACETIME       // ...

SnapshotItemIDs

(https://github.com/swarfeya/teeworlds-library-ts/ нагло украл отсюда)

import { SnapshotItemIDs } from '@twlibn/core';

SnapshotItemIDs.OBJ_CHARACTER   // 9
SnapshotItemIDs.OBJ_CLIENT_INFO // 11

UUIDManager / createTwMD5Hash

менеджер UUID расширений DDNet протокола. (https://github.com/swarfeya/teeworlds-library-ts/ нагло украл отсюда)

import { UUIDManager, createTwMD5Hash } from '@twlibn/core';

const manager = new UUIDManager(65536);
manager.RegisterName('[email protected]');

const entry = manager.LookupName('[email protected]');
// { name, hash: Buffer, type_id }

const hash = createTwMD5Hash('[email protected]'); // Buffer (16 байт)

new UUIDManager(offset?, snapshot?) - создать менеджер. snapshot меняет направление счётчика type_id

manager.RegisterName(name, type_id?) - зарегистрировать UUID по имени

manager.LookupUUID(hash) - найти по хешу

manager.LookupName(name) - найти по имени

manager.LookupType(id) - найти по type_id