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

@bidiscope/core

v0.1.0

Published

Unicode BiDi algorithm engine optimized for mixed code + RTL text

Readme

@bidiscope/core

The Unicode Bidirectional Algorithm engine for developer tools — with code-context awareness.

99.91% Unicode Conformance Bundle Size Zero Dependencies

Features

  • Full UAX #9 — Embedding levels, explicit overrides, isolates, bracket pairing (BD16)
  • Arabic Contextual Shaping — 42 Arabic + 14 Persian/Urdu characters with Lam-Alef ligatures
  • Code-Context Awareness — Detects string literals, comments, paths, URLs — keeps code structure intact
  • ANSI Escape Preservation — Terminal colors survive visual reordering
  • Hebrew, Syriac, NKo Support — Complete RTL script coverage
  • LTR Fast Path — Zero overhead when no RTL characters are present
  • Zero Dependencies — Pure TypeScript, 13.8KB minified

Install

npm install @bidiscope/core

Quick Start

import { resolveBidi } from '@bidiscope/core';

const result = resolveBidi('console.log("مرحباً بالعالم")', {
  baseDirection: 'auto',
  codeContext: true,
  shaping: true,
});

console.log(result.visual);             // Correctly ordered for display
console.log(result.paragraphDirection); // 'ltr' or 'rtl'
console.log(result.levels);            // Embedding levels per character

API

resolveBidi(text, options?)

Main entry point. Resolves bidirectional text for visual display.

Parameters:

| Option | Type | Default | Description | |:---|:---|:---|:---| | baseDirection | 'auto' \| 'ltr' \| 'rtl' | 'auto' | Paragraph base direction | | codeContext | boolean | false | Enable code-aware BiDi (preserves code structure) | | shaping | boolean | true | Enable Arabic contextual shaping | | shapingMode | 'presentation-forms' \| 'logical' | 'presentation-forms' | Shaping output mode | | preserveAnsi | boolean | true | Preserve ANSI escape sequences |

Returns: BidiResult

interface BidiResult {
  visual: string;                    // Visually reordered text
  levels: number[];                  // Embedding level per character
  paragraphDirection: 'ltr' | 'rtl'; // Resolved paragraph direction
  runs: BidiRun[];                   // Directional runs
}

shapeArabic(text)

Apply Arabic contextual shaping to a string. Converts base Arabic codepoints to their positional Presentation Forms.

classifyBidiType(codepoint)

Returns the BiDi character type for a Unicode codepoint. O(1) for ASCII/Arabic/Hebrew (fast table), O(log n) for extended ranges.

Performance

| Input | Time per line | |:---|:---| | Pure LTR (English) | 0.016ms | | Pure Arabic | 0.090ms | | Mixed Arabic + English | 0.096ms | | Complex (code + Arabic + ANSI) | 0.126ms |

All measurements on a standard desktop. Target: < 1ms per line

Unicode Conformance

Tested against the official BidiCharacterTest.txt (91,707 test cases):

| Metric | Result | |:---|:---| | Level Resolution | 99.91% (91,620 / 91,707) | | Visual Reorder | 99.90% (91,619 / 91,707) |

Shaping Modes

| Mode | Use Case | Description | |:---|:---|:---| | presentation-forms | Canvas / WebGL terminals | Converts to Unicode Presentation Forms (U+FE70–U+FEFF) | | logical | Native terminals with HarfBuzz | Keeps base codepoints, relies on font engine for joining |

License

MIT