Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Readme
Generate random IDs and avoid collisions.
var hat = require('hat');
var id = hat();
console.log(id);
output:
0c82a54f22f775a3ed8b97b2dea74036
var hat = require('hat');
var rack = hat.rack();
console.log(rack());
console.log(rack());
output:
1c24171393dc5de04ffcb21f1182ab28
fabe2323acc1b559dee43d4a1e16cbeb
var hat = require('hat');
Generate a random ID string with bits
of data in a base
.
Leading zeros are appended such that all outputs for a given number of bits have equal length.
Make a new hat rack. Call rack()
repeatedly to generate new IDs which are
checked for collisions.
If expandBy
is specified, increment bits
by this amount if too many
collisions occur. If expandBy
isn't specified, rack()
will throw if too many
collisions occur during generation.
Optionally call var id = rack(data)
to store data
at the new ID.
You can get the data out again with rack.get(id)
and set the data with
rack.set(id, value)
.
FAQs
generate random IDs and avoid collisions
The npm package hat receives a total of 226,591 weekly downloads. As such, hat popularity was classified as popular.
We found that hat demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.