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

@novasamatech/scale

v0.5.4

Published

additional scale-ts bindings

Readme

@novasamatech/scale

Additional SCALE codecs based on scale-ts library.

Installation

npm install @novasamatech/scale --save -E

Usage

Hex

Wrapper around Bytes codec with mapping to hex strings.

import { Hex, toHex, fromHex } from '@novasamatech/scale';

// Create a Hex codec (byte array size, not hex string length)
const hexCodec = Hex(32); // 32 bytes

// Encode to hex string
const encoded = hexCodec.enc(new Uint8Array([1, 2, 3, 4]));
// Result: "0x01020304"

// Decode from hex string
const decoded = hexCodec.dec("0x01020304");
// Result: Uint8Array([1, 2, 3, 4])

// Helper functions
const hexString = toHex(new Uint8Array([255, 0, 128]));
// Result: "0xff0080"

const bytes = fromHex("0xff0080");
// Result: Uint8Array([255, 0, 128])

Nullable

Codec for nullable values (null -> _void mapping).

import { Nullable } from '@novasamatech/scale';
import { u32 } from 'scale-ts';

const nullableCodec = Nullable(u32);

// Encode null as _void
const encoded = nullableCodec.enc(null);

// Decode _void as null
const decoded = nullableCodec.dec(encoded);
// Result: null

Status

Enum without values - maps a list of constants to u8 indices.

import { Status } from '@novasamatech/scale';

const ConnectionStatus = Status('Connecting', 'Connected', 'Disconnected');

// Encode status to u8
const encoded = ConnectionStatus.enc('Connected');
// Result: 1

// Decode u8 to status
const decoded = ConnectionStatus.dec(1);
// Result: 'Connected'

Enum

Type-safe enum codec wrapper.

import { Enum, enumValue, isEnumVariant, assertEnumVariant } from '@novasamatech/scale';
import { u32, str } from 'scale-ts';

const MyEnum = Enum({
  Text: str,
  Number: u32,
});

// Create enum values
const textValue = enumValue('Text', 'hello');
const numberValue = enumValue('Number', 42);

// Encode/decode
const encoded = MyEnum.enc(textValue);
const decoded = MyEnum.dec(encoded);

// Check variant type
if (isEnumVariant(decoded, 'Text')) {
  console.log(decoded.value); // Type is string
}

// Assert variant type
assertEnumVariant(decoded, 'Number', 'Expected Number variant');
console.log(decoded.value); // Type is number

Err

Custom error codec with typed payloads.

import { Err } from '@novasamatech/scale';
import { u32 } from 'scale-ts';

const InvalidId = Err(
  'InvalidId',
  u32,
  (id) => `Invalid ID: ${id}`
);

// Create error instance
const error = new InvalidId(42);
console.log(error.name); // 'InvalidId'
console.log(error.message); // 'Invalid ID: 42'
console.log(error.payload); // 42

// Encode/decode errors
const encoded = InvalidId.enc(error);
const decoded = InvalidId.dec(encoded);

ErrEnum

Enum of error types.

import { ErrEnum } from '@novasamatech/scale';
import { u32, str } from 'scale-ts';

const ApiError = ErrEnum('ApiError', {
  NotFound: [u32, (id) => `Resource ${id} not found`],
  InvalidInput: [str, (msg) => `Invalid input: ${msg}`],
});

// Create error instances
const notFoundError = new ApiError.NotFound(123);
const invalidInputError = new ApiError.InvalidInput('bad data');

// Encode/decode
const encoded = ApiError.enc(notFoundError);
const decoded = ApiError.dec(encoded);

Result Helpers

Helper functions for working with Result types.

import { resultOk, resultErr, unwrapResultOrThrow } from '@novasamatech/scale';

// Create results
const success = resultOk(42);
// Result: { success: true, value: 42 }

const failure = resultErr('error message');
// Result: { success: false, value: 'error message' }

// Unwrap or throw
const value = unwrapResultOrThrow(
  success,
  (err) => new Error(`Operation failed: ${err}`)
);
// Result: 42

// Throws error if result is failure
unwrapResultOrThrow(
  failure,
  (err) => new Error(`Operation failed: ${err}`)
);