This package has been deprecated

Author message:

WARNING: This project has been renamed to zoo-ids. Install using zoo-ids instead.

gfycat-ids
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Gfycat IDs

Generate predictable and unique identifiers in the same style used by gfycat.com, with the ability to seed the random identifiers.

Range of IDs

Currently, there are 1347 adjectives and 221 animals. The more adjectives used, the more possible combinations of IDs available.

For a quick reference, with 2 adjectives used, there are 400,984,389 possible unique IDs.

With 3 adjectives, there are 540,125,971,983 possible unique IDs.

Installation

$ npm install gfycat-ids

Usage

Examples

const { generateId } = require('gfycat-ids');
 
generateId('short seed'); // KnobbyNauticalKingfisher
 
/* Any object can be used as a seed. */
generateId({ key: 'value' }, 2, {
  caseStyle: 'camelcase'
}); // weeklyGreatRacoon
 
/* Defaults to the current time if seed is null. */
generateId(null, 2, {
  caseStyle: 'lowercase',
  delimiter: '🍓',
}); // enchanted🍓narrow🍓wallaby

Documentation

generateId(seed, [adjectiveCount, [{opts}]])

seed: any

The seed used to generate the id. This allows us to generate predictable, but random and unique identifiers.

Defaults to the current time in milliseconds.

adjectiveCount: integer

The number of adjectives to use in the identifier.

Defaults to 2.

opts.delimiter: string

The delimiter used between words. The delimiter will also be used between multi-word adjectives.

Defaults to ''.

opts.caseStyle: enum

The case style for the words. Possible options are 'titlecase', 'camelcase', 'uppercase', 'lowercase', and 'togglecase'.

generateId('titlecase', 2, { caseStyle: 'titlecase' }); // FineAntiqueElk
 
generateId('camelcase', 2, { caseStyle: 'camelcase' }); // pertinentPoshGoldfinch
 
generateId('uppercase', 2, { caseStyle: 'uppercase' }); // PIERCINGRESPONSIBLECAMEL
 
generateId('lowercase', 2, { caseStyle: 'lowercase' }); // imaginarywingedsalamander
 
generateId('togglecase', 2, { caseStyle: 'togglecase' }); // STUnnINGDesCrIPtiVePeaFOwL

Defaults to 'titlecase'.

Credits

This project was inspired by gfycat-style-urls.

The seeded random number generator used is powered by the alea algorithm by Johannes Baagøe <baagoe@baagoe.com>, ported by nquinlan/better-random-numbers-for-javascript-mirror.

This repository is not affiliated with gfycat.com.

Package Sidebar

Install

npm i gfycat-ids

Weekly Downloads

2

Version

1.0.2

License

ISC

Unpacked Size

27.9 kB

Total Files

7

Last publish

Collaborators

  • bryanmylee