Security News
OpenJS: “XZ Utils Cyberattack Likely Not an Isolated Incident”
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
Weekly downloads
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 211,516 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.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
Company News
Come meet the Socket team at BSidesSF and RSA! We're sponsoring several fun networking events and we would love to see you there.
Security News
OSI is starting a conversation aimed at removing the excuse of the SaaS loophole for companies navigating licensing and the complexities of doing business with open source.