CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-ulid

A universally-unique, lexicographically-sortable, identifier generator

78

1.34x
Overview
Eval results
Files

task.mdevals/scenario-1/

Binary Data Encoder

Build a utility that converts binary data to and from a URL-safe text representation using Base32 encoding.

Requirements

Your implementation should provide functionality to:

  1. Encode binary data: Convert binary data (Uint8Array) into a Base32-encoded string
  2. Decode encoded strings: Convert Base32-encoded strings back into binary data (Uint8Array)

The encoded strings should be:

  • URL-safe (no special characters)
  • Case-insensitive
  • Compact and efficient

Test Cases

  • Encoding a Uint8Array containing [72, 101, 108, 108, 111] produces the string "91JPRV3F" @test
  • Decoding the string "91JPRV3F" produces a Uint8Array containing [72, 101, 108, 108, 111] @test
  • Encoding an empty Uint8Array produces an empty string @test
  • Decoding an empty string produces an empty Uint8Array @test

Implementation

@generates

API

/**
 * Encodes binary data into a Base32 string
 * @param input - Binary data as Uint8Array
 * @returns Base32-encoded string
 */
export function encode(input: Uint8Array): string;

/**
 * Decodes a Base32 string back into binary data
 * @param input - Base32-encoded string
 * @returns Binary data as Uint8Array
 */
export function decode(input: string): Uint8Array;

Dependencies { .dependencies }

ulid { .dependency }

Provides Base32 encoding utilities.

Install with Tessl CLI

npx tessl i tessl/npm-ulid

tile.json