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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@chlorophytum/hltt-next

v0.50.0

Published

HlTT is an embedded DSL for TrueType Instructions written in TypeScript.

Downloads

43

Readme

Chlorophytum/HlTT

HlTT is an embedded DSL for TrueType Instructions written in TypeScript.

TrueType instructions form a stack-oriented programming language, operating at a very low level.

SVTCA[y-axis]
PUSHB_3 18 1 0
CALL
PUSHB_2 15 4
MIRP[min,black]
PUSHB_3 7 3 0
CALL

HlTT defines a convenient way to write those binaries by using an embedded DSL in TypeScript (as well as JavaScript):

import CreateDSL, { TextInstr } from "@chlorophytum/HlTT"
const eg = CreateDSL()

// Define a function
const inc = eg.declareFunction("increase", function*(e) {
    const [x] = e.args(1);
    yield e.return(e.add(x, 1));
});

// Define a program
const glyph = eg.program(function*(e) {
    yield e.call(inc, e.call(inc, 1));
});

// Compile functions
const fpgm = eg.compileFunctions(TextInstr);
console.log(fpgm.get(inc));
// PUSHB_1 0
// FDEF
// DUP
// PUSHB_1 1
// ADD
// PUSHB_1 2
// MINDEX
// POP
// ENDF
console.log(eg.compileProgram(glyph, TextInstr))
// PUSHB_2 1 0
// CALL
// PUSHB_1 0
// CALL

Global DSL

CreateDSL() crates a global DSL (type Edsl.GlobalDsl) that you can declare functions and programs (for glyphs, FPGM or PREP).

  • GlobalDsl::createFunction(f: string, b: () => Iterable<Statement>): Variable
    • Define a function.
  • GlobalDsl::createProgram(b: () => Iterable<Statement>): ProgramRecord
    • Define a glyph program, or program for FPGM and PREP.
  • GlobalDsl::compileFunctions<R>(format: InstrFormat<R>): Map<Variable, R>
    • Compile the functions defined so far.
  • GlobalDsl::compileProgram<R>(pr: ProgramRecord, format: InstrFormat<R>): R
    • Compile a glyph program, or program for FPGM and PREP.

Program/Function DSL

Program/Function DSL (type Edsl.ProgramDsl) is used to define the body of a function or a program.

  • Variables
    • ProgramDsl::args(qty: number): Variable[]
      • Declare argument variables, only usable in function DSLs
    • ProgramDsl::local(size = 1): Variable
      • Define a local variable, return the expression representing it.
      • Providing a size will define an array.
    • ProgramDsl::twilight(): Variable
      • Declare a local Twilight Zone point.
      • Only usable in program DSLs. Using it in a function DSL will cause an runtime error.
    • ProgramDsl::set(a: Variable, x: number | Expression): Statement
      • Assigns an expression to a variable.
      • Not all variables are assignable (for example arguments are not).
  • Graphic statements
    • The following statements are used to create graphic states.
    • Type NE denotes either a number or an Expression, while NPE denotes either a number or a PointerExpression. NPEs are often used when referencing a CVT index.
    • All point numbers are interpreted as long points, i.e.:
      • Glyph point numbers are referenced as-is;
      • Twilight point numbers are referenced using bitwise negation.
    • ProgramDsl::mdap(p: NE): Statement
    • ProgramDsl::miap(p: NE, cv: NPE): Statement
    • ProgramDsl::mdrp(rp0: NE, p: NE): Statement
    • ProgramDsl::mirp(rp0: NE, p: NE, cv: NPE): Statement
    • ProgramDsl::ip(rp1: NE, rp2: NE, ...p: NE[]): Statement
    • ProgramDsl::delta.p1(...a: [NE, NE][]): Statement
    • ProgramDsl::delta.p2(...a: [NE, NE][]): Statement
    • ProgramDsl::delta.p3(...a: [NE, NE][]): Statement
    • ProgramDsl::delta.c1(...a: [NPE, NE][]): Statement
    • ProgramDsl::delta.c2(...a: [NPE, NE][]): Statement
    • ProgramDsl::delta.c3(...a: [NPE, NE][]): Statement
  • Binary functions
    • ProgramDsl::add(a: NE, b: NE): Expression
    • ProgramDsl::sub(a: NE, b: NE): Expression
    • ProgramDsl::mul(a: NE, b: NE): Expression
    • ProgramDsl::div(a: NE, b: NE): Expression
    • ProgramDsl::max(a: NE, b: NE): Expression
    • ProgramDsl::min(a: NE, b: NE): Expression
    • ProgramDsl::lt(a: NE, b: NE): Expression
    • ProgramDsl::lteq(a: NE, b: NE): Expression
    • ProgramDsl::gt(a: NE, b: NE): Expression
    • ProgramDsl::gteq(a: NE, b: NE): Expression
    • ProgramDsl::eq(a: NE, b: NE): Expression
    • ProgramDsl::neq(a: NE, b: NE): Expression
    • ProgramDsl::and(a: NE, b: NE): Expression
    • ProgramDsl::or(a: NE, b: NE): Expression
  • Unary functions
    • ProgramDsl::abs(a: NE): Expression
    • ProgramDsl::neg(a: NE): Expression
    • ProgramDsl::floor(a: NE): Expression
    • ProgramDsl::ceiling(a: NE): Expression
    • ProgramDsl::even(a: NE): Expression
    • ProgramDsl::odd(a: NE): Expression
    • ProgramDsl::not(a: NE): Expression
    • ProgramDsl::round.gray(a: NE): Expression
    • ProgramDsl::round.black(a: NE): Expression
    • ProgramDsl::round.white(a: NE): Expression
    • ProgramDsl::round.mode3(a: NE): Expression
    • ProgramDsl::nRound.gray(a: NE): Expression
    • ProgramDsl::nRound.black(a: NE): Expression
    • ProgramDsl::nRound.white(a: NE): Expression
    • ProgramDsl::nRound.mode3(a: NE): Expression
    • ProgramDsl::getInfo(a: NE): Expression