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

hbs-editor

v1.0.1

Published

Handlebars-aware autocomplete editor for <textarea> elements

Readme

hbs-editor

Handlebars-aware autocomplete editor for <textarea> elements.

This repo ships:

  • Headless core (Node.js compatible, no DOM required)
  • Browser editor (DOM UI) + UMD bundle for <script> usage

Install

npm i hbs-editor

Build (for this repo)

This repository uses Rollup to produce dist/.

npm i
npm run build

Outputs:

  • dist/core.mjs (ESM)
  • dist/core.cjs (CJS)
  • dist/browser.mjs (ESM)
  • dist/hbs-editor.umd.js (UMD global)

Node.js (headless) usage

The default package entry exports the headless core.

ESM

import {
  getToken,
  filterSuggestions,
  applySuggestion,
  BUILTIN,
} from 'hbs-editor';

const variables = [
  { name: 'firstName', desc: 'User first name' },
  { name: 'integration.cpanel.name', desc: 'Integration name' },
];

const text = 'Hello {{fir';
const cursorPos = text.length;

const tok = getToken(text, cursorPos);
if (tok) {
  const suggestions = filterSuggestions(tok.query, { variables, maxItems: 10 });

  const picked = suggestions[0];
  const res = applySuggestion(text, cursorPos, picked);

  console.log(res.text);
  console.log(res.cursorPos);
}

CommonJS

const { filterSuggestions, applySuggestion } = require('hbs-editor');

Browser usage

1) CDN / <script> (UMD)

The UMD build exposes a global HbsEditor.

<script src="https://unpkg.com/[email protected]/dist/hbs-editor.umd.js"></script>
<script>
  const editor = new HbsEditor(document.getElementById('my-textarea'), {
    variables: [{ name: 'firstName', desc: '...' }],
    helpers: [{ name: 'uppercase', desc: '...', snippet: '{{uppercase $0}}' }],
    onchange: (value) => console.log(value),
  });
</script>

2) Bundlers (ESM)

import HbsEditor from 'hbs-editor/browser';

const editor = new HbsEditor(textareaEl, {
  variables: [{ name: 'firstName', desc: '...' }],
  onchange: (value) => console.log(value),
});

API

Core (headless)

  • getToken(text, cursorPos)
    • returns { query, start } | null
  • filterSuggestions(query, { variables, helpers, maxItems, builtin })
    • returns an array of suggestion items
  • applySuggestion(text, cursorPos, item)
    • returns { text, cursorPos }

Browser editor

  • new HbsEditor(textarea, options)
  • editor.setVariables(vars)
  • editor.setHelpers(helpers)
  • editor.getValue()
  • editor.setValue(str)
  • editor.destroy()

Demo

Open demo.html in a browser.

The demo will try to load ./dist/hbs-editor.umd.js first (generated by npm run build). If it is missing (e.g. you haven't built yet), it will fall back to ./hbs-editor.js.

To generate dist/:

npm i
npm run build