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

cocina-display

v0.1.0

Published

Browser-ready vanilla JavaScript helpers for Cocina display metadata

Readme

Cocina Display JS

Browser-ready, dependency-free JavaScript helpers for rendering Stanford Cocina metadata. The package uses standard ES modules and does not use a UI framework.

Use

import { CocinaRecord, DisplayData } from '@sul-dlss/cocina-display-js';

const response = await fetch('https://purl.stanford.edu/bb112zx3193.json');
const record = new CocinaRecord(await response.json());

console.log(record.displayTitle);
console.log(record.iiifManifestUrl());
console.log(DisplayData.toHash(record.subjectDisplayData));

You can also load src/core.js directly as a module in a browser. All data lookups are bundled as local JavaScript modules, so no network request is needed for labels or controlled vocabularies. CocinaRecord.fetch(druid) is async and uses the browser's fetch API.

The API uses JavaScript camel case: Ruby's record.short_title becomes record.shortTitle, and predicate record.collection? becomes record.isCollection. Methods that take options accept an object, for example record.titleDisplayData({excludePrimary: true}).

DisplayData exposes label, objects, and values. DisplayData.toHash(...) converts one or more display data objects to a plain object.

Current compatibility

This is an initial browser port of the Ruby gem's record access, display data, title, contributor, subject, note, form, identifier, language, access, event, related resource, file, URL, and geospatial helpers. It includes the gem's English labels, MARC relators, language names, and license descriptions.

The Ruby gem's full Janeway JSONPath syntax, full EDTF date parsing, and all coordinate input formats have not been ported. path() supports basic child, wildcard, and recursive selectors. Date parsing handles common ISO-style dates and structured start/end ranges. For records relying on more advanced syntax or uncommon date formats, check output against the Ruby gem before replacing it in production.

Development

npm test

The package has no runtime or development dependencies. The test suite uses Node's built-in test runner.