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

python-rencode

v2.0.0

Published

Arbitrary data encoder/decoder that matches python rencode (the format used by Deluge's RPC API).

Readme

python-rencode

A TypeScript encoder/decoder for the rencode wire format used by Deluge's RPC API. Output matches the reference Python rencode library.

CI

Install

bun add python-rencode
# or: npm install python-rencode

Usage

import { encode, decode } from 'python-rencode';

const encoded = encode({ hello: 'world', n: 42 });
//                 ↳ Buffer<...>

const back = decode(encoded);
//                 ↳ { hello: 'world', n: 42 }

Both encode and decode are also exported as dumps and loads (matching the Python API naming).

Float precision

Floats encode to 64 bits by default. Pass 32 to encode as IEEE-754 single-precision:

encode(1.5, 32);

Decoding to bytes instead of UTF-8

decode decodes string typecodes as UTF-8 by default. Pass false to keep raw ASCII:

decode(buf, false);

What's supported

Numbers (int8 / int16 / int32 / int48 / float32 / float64, picked automatically based on the value), booleans, null, strings (UTF-8), arrays, and plain objects. undefined, functions, and Symbols throw — there's no rencode typecode for them.

Numbers larger than ~2^47 round-trip through the variable-length integer typecode but are read as JavaScript numbers, so precision is bound by Number.MAX_SAFE_INTEGER (2^53 - 1). BigInt is not supported.

Migrating from 1.x

The public API (encode / decode / dumps / loads) is unchanged. v2 is a toolchain refresh:

  • ESM only. The published dist/rencode.js is ESM with a .d.ts. CJS consumers on Node 22+ can still require() it via require(ESM).
  • Bun for development. bun install, bun test, bun run build (which still calls tsc for the published output).
  • engines.node bumped to 22+ (also engines.bun >= 1.2).
  • The hand-maintained dist-extras.ts machinery and private: true + publish-from-dist/ hack are gone. Standard files field in package.json controls what ships.

Development

bun install
bun test src        # unit tests
bun run lint        # tsc --noEmit
bun run build       # emits dist/
bun run format      # prettier

CI runs all of those on push.

Python parity tests

The original repo also had Python integration tests that round-tripped values through the actual python-rencode library (via python-shell + pipenv). They've been moved to legacy-python-tests/ and are no longer wired into CI — they were brittle and required pipenv + Python in CI for marginal value over the unit tests. If you want to verify Python parity, see the legacy directory for the setup pattern.

Publishing

Tag v* and push. CI publishes to npm via trusted publishing with provenance — no NPM_TOKEN needed.

Change log

v2.0.0

Toolchain refresh; API unchanged. See "Migrating from 1.x" above.

v1.4.0

API change: undefined is no longer accepted as a value (throws). null should be used instead.

v1.3.0

Exported RencodableData type.

v1.2.0

TypeScript declarations.

v1.1.0

Decode UTF-8 by default.

License

ISC.