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

eftojs

v1.0.1

Published

Token-efficiency SDK for LLMs — compress prompts, manage context, and cut token usage up to 70%.

Readme

Eftojs

Token-efficiency SDK for LLMs. Compress prompts, manage context, and cut token usage 40–70% — without losing meaning.

npm version license


What is Eftojs?

Eftojs is a tiny, zero-dependency TypeScript SDK that helps you:

  • Build compact, structured prompts from plain inputs
  • Compress verbose prompts while preserving intent
  • Reuse modes so you stop re-sending the same boilerplate rules
  • Manage incremental context so you only send what changed
  • Estimate token counts before you hit the API

It works with any LLM — Claude, GPT-5, Gemini, local models — because all it does is give you a smaller, smarter string.

Why token efficiency matters

Every token you send costs money and latency. Most prompts contain 30–60% filler: restated instructions, hedging language ("please note that…"), verbose phrasing ("in order to" vs "to"), and duplicated rules. Eftojs strips that out, so your model gets the signal and you stop paying for the noise.

Installation

npm install eftojs

Requires Node 18+.

Quick start

import { createPrompt, estimateTokens, compareTokens } from "eftojs";

const prompt = createPrompt({
  mode: "ENG_V1",
  task: "build a login system",
  constraints: ["secure", "scalable"],
  output: "typescript",
});

console.log(prompt);
console.log("tokens:", estimateTokens(prompt));

Features

1. Prompt Builder

Turn structured input into a compact, section-tagged prompt:

import { createPrompt } from "eftojs";

const prompt = createPrompt({
  mode: "ENG_V1",
  task: "build login system",
  constraints: ["secure", "scalable"],
  context: "Existing Express + Postgres stack",
  examples: ["POST /login → { token }"],
  output: "typescript",
});

2. Modes

Register reusable rule sets once, reference them by name:

import { registerMode, createPrompt } from "eftojs";

registerMode("ENG_V1", {
  persona: "Senior software engineer.",
  rules: ["modular", "production-ready", "no pseudo code"],
});

createPrompt({ mode: "ENG_V1", task: "add rate limiting" });

Built-in modes: ENG_V1, DOC_V1, REVIEW_V1, DATA_V1.

3. Compression engine

import { compress, compareTokens } from "eftojs";

const verbose = `
In order to build a login system, please note that you really need to
make use of secure password hashing. It is important to note that you
should basically use bcrypt or argon2. Please note that you really need
to make use of secure password hashing.
`;

const tight = compress(verbose);
console.log(compareTokens(verbose, tight));
// { before: 62, after: 24, saved: 38, savedPercent: 61.3 }

The compressor:

  • Removes filler words (very, just, really, basically, …)
  • Tightens verbose phrases (in order toto, is able tocan)
  • Drops duplicate sentences and bullet points
  • Normalizes whitespace and punctuation

4. Context Manager

Send base instructions once, then stream deltas:

import { createContext } from "eftojs";

const ctx = createContext();
ctx.setBase("You are a senior engineer. Respond in TypeScript only.");

const turn1 = ctx.next("Add authentication");
const turn2 = ctx.next("Now add rate limiting");

// Send only `turn1` / `turn2` to the model on each call.
// ctx.full() is available if you need the replay.

5. Token estimator

import { estimateTokens, compareTokens } from "eftojs";

estimateTokens("Hello, world!");             // ~4
compareTokens(original, compressed);          // { before, after, saved, savedPercent }

The estimator is a calibrated heuristic — typically within ~10% of real tokenizer counts, without pulling a multi-megabyte tokenizer into your bundle.

Before vs after

Before (118 tokens):
  "In order to build a production-ready login system, please note that
   you really need to make use of secure password hashing. It is
   important to note that the system should basically be able to scale.
   Please note that you really need to make use of secure hashing."

After (42 tokens, −64%):
  "To build a production-ready login system, use secure password
   hashing. The system must scale."

CLI

npx eftojs optimize "In order to build a login system, please note that..."
npx eftojs tokens "your prompt here"
echo "a long prompt" | npx eftojs optimize

The CLI prints the optimized prompt on stdout and the token delta on stderr, so you can pipe the result into another command.

API

| Export | Description | | ----------------- | ---------------------------------------------------- | | createPrompt | Build an optimized prompt from structured input | | compress | Run the compression pipeline on any string | | createContext | Factory for an incremental Context | | Context | Base + delta context manager class | | registerMode | Register a named mode | | getMode | Look up a registered mode | | listModes | List all registered mode names | | clearModes | Reset registry to defaults | | estimateTokens | Heuristic token count | | compareTokens | Before/after token delta |

All types are exported. See dist/index.d.ts.

Contributing

See CONTRIBUTING.md. Eftojs stays small on purpose — PRs that reduce code or dependencies are especially welcome.

License

MIT