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

@itrocks/unique

v0.0.2

Published

Marks domain properties as members of unique keys through runtime metadata

Readme

npm version npm downloads GitHub issues discord

unique

Marks domain properties as members of unique keys through runtime metadata.

This package only records the uniqueness declaration. Schema converters, storage adapters, and other consumers decide how to name, group, validate, or enforce unique keys.

This documentation was written by an artificial intelligence and may contain errors or approximations. It has not yet been fully reviewed by a human. If anything seems unclear or incomplete, please feel free to contact the author of this package.

Requirements

  • Node.js 24 or newer.
  • TypeScript projects using decorator syntax must enable experimentalDecorators.

Installation

npm i @itrocks/unique

Usage

import { Unique }   from '@itrocks/unique'
import { uniqueOf } from '@itrocks/unique'

class Contact
{

	@Unique()
	email = ''

	name = ''

}

uniqueOf(Contact, 'email') // ''
uniqueOf(Contact, 'name')  // false

An empty string means that the consumer must choose the unique-key name. Pass a non-empty name when several properties must refer to the same logical key:

class Membership
{

	@Unique('organization_user')
	organization = ''

	@Unique('organization_user')
	user = ''

}

The package stores the same explicit name on both properties. Whether that represents a composite key, and in which property order, remains the responsibility of the metadata consumer.

Behaviour

  • @Unique() stores an empty string to request consumer-defined naming.
  • @Unique(name) stores name unchanged, including an explicitly empty string.
  • uniqueOf() returns false when a property has no uniqueness metadata.
  • Metadata declared on a base class is visible from derived classes and their instances. Decorating the same property on a derived class overrides the inherited value for that derived class.
  • Importing the package only defines the metadata API; it does not register infrastructure or mutate schemas.

API

Unique

function Unique<T extends object>(name?: string): DecorateCaller<T>

Returns a property decorator that records unique-key metadata.

Parameters:

  • name: Logical unique-key name. It defaults to '', which delegates naming to the consumer.

The decorator only records metadata and has no validation or persistence side effect.

uniqueOf

function uniqueOf<T extends object>(target: ObjectOrType<T>, property: keyof T): string | false

Reads the unique-key metadata associated with one property.

Parameters:

  • target: Class or instance that owns or inherits the property.
  • property: Property whose metadata is requested.

Returns:

  • false when neither the target nor its inheritance chain declares the property unique.
  • '' when the decorator delegates naming to the consumer.
  • The explicit unique-key name otherwise.