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

@symbo.ls/shorthand

v2.34.35

Published

Shorthand syntax transpiler for Symbols properties

Readme

@symbo.ls/shorthand

Bidirectional shorthand transpiler for Symbols component properties. Compresses DOMQL component objects using abbreviated property names and compact string encoding — and losslessly expands them back.

Install

npm install @symbo.ls/shorthand

API

Six functions in three complementary pairs:

| Pair | Forward | Inverse | Description | | ---------- | ----------- | -------- | ------------------------------------------------------------ | | String | encode | decode | Flat object ↔ single-line shorthand string | | Object | shorten | expand | Recursive key abbreviation preserving structure | | Hybrid | stringify | parse | Primitive props → in string, structural props stay as keys |

encode / decode

Converts flat primitive props into a compact single-line string.

import { encode, decode } from '@symbo.ls/shorthand'

encode({ padding: 'A B', background: 'red', hidden: true })
// → 'p:A_B bg:red hid'

decode('p:A_B bg:red hid')
// → { padding: 'A B', background: 'red', hidden: true }

Syntax rules:

  • abbr:value — key-value pair
  • _ — represents spaces inside values
  • , — array separator (ext:Flex,Boxextends: ['Flex', 'Box'])
  • bare abbr — boolean true
  • !abbr — boolean false

Functions, objects, and other non-serializable values are skipped.

shorten / expand

Recursively abbreviates (or expands) property keys throughout the component tree while preserving the full object structure — child components, selectors, functions, arrays, and everything else stays intact.

import { shorten, expand } from '@symbo.ls/shorthand'

const component = {
  extends: 'Flex',
  padding: 'A B',
  gap: 'C',
  flexDirection: 'column',
  onClick: (e, el) => {},
  Header: { fontSize: 'B' },
  ':hover': { background: 'blue' }
}

shorten(component)
// {
//   ext: 'Flex',
//   p: 'A B',
//   g: 'C',
//   fxd: 'column',
//   '@ck': (e, el) => {},
//   Header: { fs: 'B' },
//   ':hover': { bg: 'blue' }
// }

expand(shorten(component)) // deeply equals original

Preservation rules:

  • PascalCase keys (child components) — key kept as-is, value recursed
  • Selector keys (:hover, @dark, .isActive, > *) — key kept, value recursed
  • state, scope, attr, style, data, context, query, class — values preserved as-is (no key abbreviation inside)
  • Functions — preserved, only the key is shortened

stringify / parse

Hybrid encoding: flat primitive props go into a compact in string, while structural props (functions, nested objects, child components, selectors) remain as shortened object keys.

import { stringify, parse } from '@symbo.ls/shorthand'

const component = {
  extends: 'Flex',
  padding: 'A',
  background: 'surface',
  borderRadius: 'B',
  onClick: (e, el) => {},
  Header: { fontSize: 'B', color: 'title' }
}

stringify(component)
// {
//   in: 'ext:Flex p:A bg:surface bdr:B',
//   '@ck': (e, el) => {},
//   Header: { in: 'fs:B c:title' }
// }

parse(stringify(component)) // deeply equals original

What goes into in:

  • String props (except text, html, content, placeholder, src, href)
  • Boolean props
  • Primitive arrays (length > 1)

What stays as object keys:

  • Functions, null, undefined
  • Nested objects, arrays of objects
  • PascalCase children, selector keys
  • Preserved keys (state, scope, style, etc.)
  • Skip-inline keys (text, html, content, placeholder, src, href)
  • Numbers (to preserve type through round-trip)
  • Strings containing , or _ (to avoid encoding ambiguity)

Registry

The package ships with 300+ bidirectional abbreviation mappings covering:

  • DOMQL coreextendsext, childExtendscex, statest, tagtg
  • Symbols shorthandflowfl, alignaln, roundrnd, boxSizebsz
  • CSS propertiespaddingp, backgroundbg, flexDirectionfxd, zIndexzi
  • HTML attributesplaceholderphd, disableddis, requiredreq
  • ARIA attributesariaLabelalb, ariaHiddenahid, rolerole
  • EventsonClick@ck, onRender@rn, onSubmit@sm, onKeyDown@kd

Access the maps directly:

import { propToAbbr, abbrToProp } from '@symbo.ls/shorthand'

propToAbbr['padding'] // 'p'
propToAbbr['onClick'] // '@ck'
abbrToProp['bg'] // 'background'
abbrToProp['@rn'] // 'onRender'

Helpers

import {
  isComponentKey,
  isSelectorKey,
  PRESERVE_VALUE_KEYS,
  SKIP_INLINE_KEYS
} from '@symbo.ls/shorthand'

isComponentKey('Header') // true  (PascalCase)
isComponentKey('padding') // false

isSelectorKey(':hover') // true
isSelectorKey('@dark') // true
isSelectorKey('.isActive') // true
isSelectorKey('> *') // true
isSelectorKey('padding') // false

Round-trip guarantee

All three pairs are lossless — the inverse function always reproduces the original:

decode(encode(obj)) // ≈ obj (flat primitives only)
expand(shorten(obj)) // ≡ obj (full structure)
parse(stringify(obj)) // ≡ obj (full structure)

The test suite verifies round-trip correctness against 200+ real-world Symbols components.

License

ISC