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

olo-id

v0.1.2

Published

olo id aims provide needed functionality around ids and identifying entities in general: checking if two ids are the same and compiling ids in various formats.

Readme

olo id

olo id aims provide needed functionality around ids and identifying entities in general: checking if two ids are the same and compiling ids in various formats.

Installation

Navigate to your project folder and enter the following in you terminal:

npm i olo-id --save

Usage

You can use the olo id class for ids stored in one parameter of your entity or in multiple identifiaction props. You just need to let the class know the relevant property names.

const user1 = new OloId(
  {
    username: 'albert.einstein',
    domain: 'oloteo.com',
    name: 'Albert Einstein',
    role: 'admin',
  },
  {
    syntax: ['username', 'domain'], // defines the email property as unique identifier
    register: true, // registers the syntax defined for the id app wide, so you don't need to set it again when creating another user.
    separator: '@', // defines the seperator character that is used when the id is rendered into a string, defaults to '/'.
  },
);

const user2 = new OloId({
  email: 'robert.oppermann',
  domain: 'oloteo.com',
  name: 'Robert Oppenheimer',
  role: 'editor',
});

const user3 = new OloId('[email protected]', { syntax: ['username', 'domain'], separator: '@' });

console.log(user1.isSame(user2)); // false
console.log(user1.isSame(user3)); // true
console.log(user1.toString()); // [email protected]
console.log(user2.toJSON()); // { username: 'robert.oppermann', domain: '@oloteo.com' }

OLoIdSet

If there are more then one property or prop-combos that would identify an entity on their one, you can use an id set. To make this work id syntaxes can't be implicitly defined, but need to be configured explicitly.

new OloIdSyntax().registerSyntaxes([['id'], ['username', 'domain']]);

After that sets are used much in the same way as OloIds.

const user1 = new OloIdSet({
  id: 'ae123',
  username: 'albert.einstein',
  domain: 'oloteo.com',
  name: 'Albert Einstein',
  role: 'admin',
});

const user2 = new OloIdSet('ae123', { syntax: ['id'] });

const user3 = new OloIdSet({
  username: 'albert.einstein',
  domain: 'oloteo.com',
});

console.log(user1.isSame(user2)); // true
console.log(user1.isSame(user3)); // true
console.log(user1.toString()); // ae123 [email protected]
console.log(user1.toJSON()); // { id: 'ae123', username: 'albert.einstein', domain: '@oloteo.com' }

Extending olo id classes

Extending one of the olo id classes might be the most convenient way of accessing its functionality, as all structures need to be only setup once.

new OloIdSyntax().registerSyntaxes([['id'], ['username', 'domain']]);

class User extends OloIdSet<[['id'], ['username', 'domain']], string, '@'> {
  public name: string;
  public role: string;

  constructor({
    id,
    username,
    domain,
    name,
    role,
  }: {
    id: string;
    username: string;
    domain: string;
    name: string;
    role: string;
  }) {
    super({ id, username, domain }, { separator: '@' });
    this.name = name;
    this.role = role;
  }
}

const user1 = new User({
  id: 'ae123',
  username: 'albert.einstein',
  domain: 'oloteo.com',
  name: 'Albert Einstein',
  role: 'admin',
});

console.log(
  user1.isSame({
    username: 'albert.einstein',
    domain: 'oloteo.com',
  }),
); // true

This package provides two extensions for common use cases:

  • OloReference for entities that describes links to some other entities.
  • OloRessource for entities describing assets (e.g. images or videos), that should be referenced or embedded.