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

@pohodnik/seq-encoder

v1.0.1

Published

Compact encoding for sequences of non-negative integers using delta + RLE over the Unicode BMP.

Readme

@pohodnik/seq-encoder

Compact encoding for sequences of non-negative integers using delta encoding and RLE over the Unicode BMP. Designed for telemetry, GPS tracks, time series and any data where consecutive values change by small amounts.

  • 🪶 Zero runtime dependencies
  • ⚡ O(n) encode and decode
  • 🧮 Works in any JavaScript runtime with String.fromCodePoint (Node 18+, all modern browsers)
  • 🖥️ CLI included
  • 📘 TypeScript types included
  • 🧪 100% test coverage of public API

Installation

npm install @pohodnik/seq-encoder

Usage

Library

import {
  encodePositiveIntegerSeq,
  decodePositiveIntegerSeq,
} from "@pohodnik/seq-encoder";

const lat = [5322314, 5322313, 5322313, 5322314, 5322315];
const encoded = encodePositiveIntegerSeq(lat);
// "5322314:193:ÀÁÂ..."

const decoded = decodePositiveIntegerSeq(encoded);
// [5322314, 5322313, 5322313, 5322314, 5322315]

CLI

# encode from arguments
seq encode 1 2 3 4 5

# decode
seq decode "1:192:ÀÁÂÃÄ"

# round-trip check
seq roundtrip 1 2 3 4 5 6 7 8 9

# stats
seq encode -s -f numbers.json

# from stdin
echo "[1,2,3,4,5]" | seq encode -i

Aliases: seq-encode, seq-decode.

How it works

  1. Delta encoding: последовательность заменяется на разности numbers[i] - numbers[i-1].
  2. Unicode mapping: все diff'ы сдвигаются в диапазон code points ≥ U+00C0 (192). Сдвиг выбирается так, чтобы минимальный diff попал ровно в U+00C0 (или выше, если minDif >= 0).
  3. RLE: последовательность code points сжимается run-length encoding. Счётчики пишутся десятичными цифрами после символа.

Формат результата: first:zeroUnicodeIndex:rle

API

encodePositiveIntegerSeq(numbers)

Кодирует массив неотрицательных целых чисел.

  • numbers: number[] — массив неотрицательных целых чисел, длина ≥ 1
  • Returns: string
  • Throws:
    • TypeError если вход не массив, пуст, или содержит нецелые/отрицательные значения
    • Error если данные выходят за пределы BMP (U+FFFF)

decodePositiveIntegerSeq(str)

Декодирует строку, полученную из encodePositiveIntegerSeq.

  • str: string
  • Returns: number[]
  • Throws:
    • TypeError если вход не строка
    • Error если формат строки некорректен

Вспомогательные

  • rleEncodeOptimized(str): string
  • rleDecodeOptimized(str): string
  • S_OFFSET, S_DIV — константы формата

CLI

| Команда | Описание | |---|---| | seq encode [numbers...] | Кодирует последовательность | | seq decode <string> | Декодирует строку | | seq roundtrip [numbers...] | Кодирует и проверяет декодирование | | seq info [numbers...] | Статистика сжатия |

| Опция | Описание | |---|---| | -f, --file <path> | Читать из файла (JSON или CSV) | | -i, --stdin | Читать из stdin | | -j, --json | Вход — JSON-массив | | -c, --csv | Вход — CSV | | -o, --out <path> | Записать в файл | | -s, --stats | Показать статистику сжатия | | -v, --version | Версия пакета | | -h, --help | Справка |

Format guarantees

  • Все code points в закодированной строке ≥ 192 (U+00C0).
  • Символы не пересекаются с ASCII-цифрами 0..9 (48–57), поэтому RLE-счётчики не конфликтуют с данными.
  • Разделитель : (58) также не пересекается с данными.

Constraints

  • Данные должны влезать в BMP: zeroUnicodeIndex + maxDif ≤ 0xFFFF.
  • Для разностей > ~65300 encode бросит ошибку!

Testing

npm test               # node:test
npm run test:types     # tsc --noEmit
npm run test:all       # both

Benchmark

npm run bench

License

MIT