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 🙏

© 2024 – Pkg Stats / Ryan Hefner

uusym

v0.0.4

Published

Universally-Unique-Symbols (like UUIDs) based on natural language and yet small and efficient in protocols

Downloads

2

Readme

This module implements uusyms, an alternative to uuids. As with a uuid, a uusym has one essential property:

  • You can use it identify something, without ambiguity, across time and space. In a generic sense, a uusym is also a 'univerally unique identifier', like uuid, but it uses an utterly different approach from RFC 4122 standard uuids.

These identifiers (uusyms or uuids) are important for decentralized systems, where parts change independently over time. When your software needs to talk to other software about something (a function, method, attribute, file, person, etc) and the two programs are not necessarily evolving in close coordination, you can use a uuid or uusym to avoid accidentally referring to the wrong thing.

In practice in the Internet/IETF/W3C community there is some reliance on central coordination, eg with systems like the IETF Message Headers Registry. Most of the rest of the industry just lets one provider manage things, as with npm controlling the package.json format.

Two advantages to uusyms, compared too uuids:

  • They are intrinsically documented. Instead of seeing an inscrutable expression like 8fb51cf4-be30-11e6-a1af-204747e0006a, developers see text explaining what the item is.
  • In a given context, such as a file or protocol stream, they can be much smaller, typically a byte or two, after the first use in that context. (This is perhaps a trivial point, because you could do the same re-use compression trick with uuids.)

This is a distillation of some concepts explored earlier in GrowJSON.

Install

Install with

npm install --save uusym

Should work fine via browserfy, but not tested yet.

Example

Use some in output:

const uusym = require('uusym')

const alice = uusym('Alice, the protagonist of the 1865 novel _Alice In Wonderland_, by Lewis Carroll.')
const bob = uusym('Microsoft Bob, a 1995 software product intended to provide a more user-friendly interface to Microsoft Windows.')

...

// come up with a better example, please!   But it needs more context.

setUserInfo(alice.key, 'Alice')
setUserInfo(bob.key, 'Bob')

Definitions

The heart of uusyms is that idea that a natural language definition that is sufficient for clear human understand is also textually distinct from every other such definition. There's nothing mechanically stopping you from using a definition like 'My Cat', but if you do that, your systems are unlikely to work as well.

Multiple Definitions

A uusym can have multiple definitions. All are considered to be synonymous, of equal semantic weight. The last one added is considered to be "primary", and is preferencially displayed when a definition is needed.

The plan is that during system evolution, one leaves in all the old definitions that might be in use somewhere, eg in other software or in data files.

Local Identifiers (Not Implemented)

If you just need a local identifier, which will be meaningless to other parties, including the same program run later, you can skip giving a definition.

const myThing = uusym()

References (Not Implemented)

A definition can be an array (including sub-arrays, recursively) containing both strings and uusyms. Strings are automatically concatenated, but uusyms are resolved logically as references to other items.

const alicebook = uusym('The 1865 novel _Alice In Wonderland_, by Charles Lutwidge Dodgson, writing under the pseudonym Lewis Carroll')
const alice = uusym(['Alice, the protagonist of', alicebook])

Loops are allowed:

const alicebook = uusym.deferred()
const carroll = uusym.deferred()
// using .key property would throw an Error at this point

alicebook.addDef(['The 1865 novel _Alice In Wonderland_, by', carroll])
// alicebook.key is still not usable
carroll.addDef(['Charles Lutwidge Dodgson, who wrote under the pseudonym Lewis Carroll, famous author of', alicebook])
// now alicebook.key and carroll.key should both work

Registries

The uusym module value is a function (called uusym in these examples) which creates new uusyms in a default registry.

Additional registries can be created:

const uusym = require('uusym')
const reg2 = new uusym.Registry()
const reg3 = new uusym.Registry()

console.log(uusym('First Example Definition').key) // => 1
console.log(reg2.uusym('Second Example Definition').key)  // => 1
console.log(reg3.uusym('Third Example Definition').key)  // => 1

Markup (not implemented)

For output/display of the definitions, use HTML if it starts with '<' and CommonMark otherwise. The underlying matching system doesn't care.

Whitespace (issue; not implemented)

Should matching be done with whitespace compressed, removed, normalized, or left untouched? For what is whitespace, see https://github.com/w3c/findtext/issues/5

Maybe issue warnings when def's differ only in whitespace? But that might not show up in the right place -- ie the user gets it in five years.

Internationalization (issue; not implemented)

Languages may be tagged to allow the right definition to be displayed to users. This is done by replacing str with [{lang: langtag}, str] in the definition, where langtag is a BCP-47 language tag. Language direction can be specified similarly, with {dir: 'ltr'}.

Alternatively, we could parse HTML to see what lang attribute is set, but that seems less likely to be maintained, I think, maybe.