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

glost-utils

v0.2.0

Published

Framework-agnostic utilities for GLOST manipulation, conversion, and merging

Readme

glost-utils

Framework-agnostic utilities for GLOST manipulation, conversion, and merging.

Overview

This package provides practical utilities for working with GLOST documents:

  • Text-to-GLOST conversion - Convert plain text into GLOST documents
  • Document manipulation - Extract words, sentences, metadata
  • Data merging - Merge transcription and metadata into existing documents
  • Script conversion - Handle ruby text and text format conversion

Installation

npm install glost-utils
# or
pnpm add glost-utils

Usage

Text to GLOST

import { convertTextToGLOST } from "glost-utils";

const doc = await convertTextToGLOST({
  text: "Hello world",
  language: "en",
  strategy: myLanguageStrategy  // Your tokenization logic
});

Document Queries

import { 
  getAllWordsFromDocument,
  getFirstSentenceFromDocument,
  hasTranscriptionData 
} from "glost-utils";

// Get all word nodes
const words = getAllWordsFromDocument(doc);

// Get first sentence
const sentence = getFirstSentenceFromDocument(doc);

// Check for transcription
if (hasTranscriptionData(doc, "ipa")) {
  // Document has IPA transcription
}

Merging Data

import { 
  mergeTranscriptionDataIntoDocument,
  extendGLOSTDocumentWithMetadata 
} from "glost-utils";

// Merge transcription into existing document
const withTranscription = mergeTranscriptionDataIntoDocument(doc, {
  "hello": { ipa: "həˈloʊ" },
  "world": { ipa: "wɜːld" }
});

// Add metadata
const withMetadata = extendGLOSTDocumentWithMetadata(doc, {
  "hello": { frequency: "very-common", difficulty: "beginner" },
  "world": { frequency: "very-common", difficulty: "beginner" }
});

Script Conversion

import { 
  convertScriptToString,
  type RubySegment 
} from "glost-utils";

// Convert ruby text to plain string
const ruby: RubySegment[] = [
  { base: "漢字", ruby: "かんじ" }
];
const plain = convertScriptToString(ruby);  // "漢字"

API

Text Conversion

  • convertTextToGLOST(options) - Convert text to GLOST document

Document Utilities

  • getAllWordsFromDocument(doc) - Extract all word nodes
  • getFirstSentenceFromDocument(doc) - Get first sentence
  • getWordsFromFirstSentence(doc) - Get words from first sentence
  • getDocumentTranscriptionSystems(doc) - List transcription systems
  • hasTranscriptionData(doc, system) - Check for transcription
  • getDocumentMetadata(doc) - Get document metadata
  • getSentenceTranslation(sentence, lang) - Get sentence translation

Merging Utilities

  • mergeTranscriptionData(word, data) - Merge transcription into word
  • mergeTranscriptionDataIntoDocument(doc, data) - Merge into document
  • extendGLOSTWithMetadata(word, metadata) - Add metadata to word
  • extendGLOSTDocumentWithMetadata(doc, data) - Add metadata to document
  • hydrateGLOSTDocument(doc, data) - Hydrate with all data types
  • filterGLOSTByGender(doc, gender) - Filter words by gender

Script Conversion

  • convertScriptToString(script) - Convert to plain string
  • isRubyScript(script) - Check if ruby text
  • isPlainTextScript(script) - Check if plain text
  • ensureArrayFormat(script) - Convert to array format
  • ensureStringFormat(script) - Convert to string format
  • getPlainText(script) - Extract plain text

Exports

// Main utilities
import { ... } from "glost-utils";

// Text-to-GLOST
import { convertTextToGLOST } from "glost-utils/text-to-glost";

// Merging
import { mergeTranscriptionDataIntoDocument } from "glost-utils/merger";

// Document utilities
import { getAllWordsFromDocument } from "glost-utils/document";

// Script conversion
import { convertScriptToString } from "glost-utils/script";

// Interfaces
import type { ILanguageStrategy } from "glost-utils/interfaces";

Related Packages

  • glost - Core GLOST types and nodes
  • glost-common - Common utilities
  • glost-extensions - Extension system

License

MIT