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

adofai-lib

v1.2.6

Published

A TypeScript library for advanced manipulation and analysis of ADOFAI level files.

Readme

ADOFAI Library

A TypeScript library for working with ADOFAI level files. This library provides a simple interface for reading, modifying, and writing ADOFAI level files. Ported from M1n3c4rt's adofaipy lib and expanded by V0W4N

Installation

npm install adofai-lib

Usage

import LevelDict, {LevelJSON, Action} from 'adofai-lib';

// Load an ADOFAI level file
const level = new LevelDict('path/to/level.adofai');

// Get all angles in the level
const angles = level.getAngles();

// Get relative angles (degrees between each pair of tiles)
const relativeAngles = level.getAnglesRelative();

// Get all actions in the level
const actions = level.getActions();

// Get actions with a filter condition
const twirlActions = level.getActions(action => action.eventType === 'Twirl');

// Get all floor decorations
const floorDecorations = level.getDecorations();

// Get all decorations including non-floor decorations
const allDecorations = level.getDecorations(() => true, true);

// Get decorations with a filter condition
const backgroundDecos = level.getDecorations(deco => deco.decorationType === 'Background');

// Get tiles in a range
const tilesInRange = level.getTiles(1, 4);

// Get tiles at specific indices
const specificTiles = level.getTiles([0, 2, 4]);

// Modify the level...

// Save the modified level
level.writeToFile('path/to/output.adofai');

Features

  • Read and write ADOFAI level files
  • Get and set tile angles
  • Get relative angles between tiles
  • Manage actions and decorations
  • Support for both angle-based and path-based level formats
  • Flexible tile, action, and decoration retrieval with filtering options

API Reference

LevelDict

The main class for working with ADOFAI level files.

Constructor

new LevelDict(filename?: string, encoding?: string)
  • filename: Path to the ADOFAI level file (optional)
  • encoding: File encoding (default: 'utf-8')

Methods

Tile Management
  • getAngles(): Returns an array of all tile angles
  • setAngles(angles: number[]): Sets the angles for all tiles
  • getAnglesRelative(ignoreTwirls?: boolean, padMidspins?: boolean): Returns relative angles between tiles
  • getTiles(start: number, end: number): Returns tiles in the specified range
  • getTiles(indices: number[]): Returns tiles at the specified indices
Action Management
  • getActions(condition?: (action: Action) => boolean): Returns actions matching the condition
  • setActions(actions: Action[]): Sets all actions in the level
  • insertAction(floor: number, action: Action): Inserts an action at the specified floor
  • removeAction(floor: number, actionIndex: number): Removes an action at the specified floor and index
  • updateAction(floor: number, actionIndex: number, newAction: Partial<Action>): Updates an action
  • insertActionAt(floor: number, actionIndex: number, action: Action): Inserts an action at a specific position
Decoration Management
  • getDecorations(condition?: (decoration: Decoration) => boolean, includeNonFloor?: boolean): Returns decorations matching the condition
  • setDecorations(decorations: Decoration[]): Sets all decorations in the level
  • insertDecoration(floor: number | undefined, decoration: Decoration): Inserts a decoration
  • removeDecoration(floor: number | undefined, decorationIndex: number): Removes a decoration
  • updateDecoration(floor: number | undefined, decorationIndex: number, newDecoration: Partial<Decoration>): Updates a decoration
  • insertDecorationAt(floor: number | undefined, decorationIndex: number, decoration: Decoration): Inserts a decoration at a specific position
File Operations
  • writeToFile(filename?: string): Saves the level to a file
  • toJSON(): Returns the level data as a JSON object
  • static fromJSON(json: string): Creates a LevelDict instance from JSON data
Utility Methods
  • copy(): Creates a deep copy of the level
  • compareWith(other: LevelDict): Compares two levels and returns differences

Error Handling

The library includes comprehensive error handling for invalid operations:

  • Invalid tile indices
  • Invalid floor indices
  • Invalid action/decoration indices
  • Invalid range selections
  • Invalid file operations

License

MIT