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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@owsp/js

v0.12.7

Published

Runtime utilities for OpenWinSpec schemas: projection via `x-partial`, canonical stringification (4-decimal numbers), hashing, and validation helpers.

Downloads

240

Readme

@owsp/js

Runtime utilities for OpenWinSpec schemas: projection via x-partial, canonical stringification (4-decimal numbers), hashing, and validation helpers.

Quick usage

import {
  listSerializeFields,
  extractBySerializeGroup,
  hashBySerializeGroup,
} from "@owsp/js";

const alias = "Material Profile System"; // schema title

// Inspect which fields participate in a group
const fields = listSerializeFields(alias, "summary");

// Build a projection and hash it deterministically
const projection = extractBySerializeGroup(alias, data, "summary");
const hash = hashBySerializeGroup(alias, data, "summary");

See docs: ../../docs/guide-x-partial.md.

Schema property ordering (x-order)

The package exposes helpers to order object properties according to x-order annotations in schemas. This is useful for stable serialization/UI forms.

APIs:

  • Auto-detect schema and order:
import { orderObject } from "@owsp/js";

const ordered = orderObject(data);
  • Order by bundle type (when known):
import { orderObjectByType, BundleType } from "@owsp/js";

const ordered = orderObjectByType(BundleType.MaterialSystem, data);
  • Order by schema $id (internal tools):
import { orderObjectBySchemaId } from "@owsp/js";

const ordered = orderObjectBySchemaId(
  "https://openwinspec.org/schemas/v1/material/profile/profile-system.json",
  data
);

Details: ../../docs/schema-ordering.md.

Behavior notes:

  • If some known properties have x-order, they come first by x-order value, then known properties without x-order (sorted by key), then unknown properties (sorted by key).
  • If at a given object level none of the known properties have x-order, the original key order is preserved at that level; nested values are still processed recursively and may be ordered if their schemas specify x-order.

Build & test

nx build js
nx test js

Projection & Sorting Details

  • Deep projection: extractBySerializeGroup() walks nested objects/arrays, resolving $ref, oneOf, and allOf to collect fields annotated with x-partial.
  • Array sorting: If a schema property has x-partial.sortArrayBy: [key1, ...], arrays are sorted deterministically by these keys. Numeric keys sort ascending numerically; otherwise comparison falls back to canonical JSON strings.
  • Post-projection sort: Arrays are re-sorted after projecting inner items to ensure final ordering matches sorting rules.
  • Targeted fallback for glazing: For glazing assemblies, inner arrays glazings[*].seals and glazings[*].glazing_beads project as {vendor, id} when no x-partial fields are present, with thickness included when available. This avoids changing schema structure.
  • Scope: The glazing fallback is deliberate and not applied to other assemblies (e.g., sash_seal). Behavior for other assemblies depends on their x-partial annotations.