1.0.0 • Published 1 year ago

@hutechwebsite/quo-est-iure-quam v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@hutechwebsite/quo-est-iure-quam

npm Code Climate Test Coverage

Generate and translate standard UUIDs into shorter - or just different - formats and back.

v5.2.0

5.2.0 adds validate method to check short IDs. Requested by @U-4-E-A 5.1.0 adds translation support for the uuid25 (Base36) format with the uuid25Base36 constant.

Major Changes in 5.0.0

  • 🛑 5.0.0 drops support for Node 10 and 12.

Quick Start

const short = require('@hutechwebsite/quo-est-iure-quam');

// Quick start with flickrBase58 format
short.generate(); // '73WakrfVbNJBaAmhQtEeDv'

Details

@hutechwebsite/quo-est-iure-quam starts with RFC4122 v4-compliant UUIDs and translates them into other, usually shorter formats. It also provides translators to convert back and forth from RFC compliant UUIDs to the shorter formats, and validate the IDs.

As of 4.0.0, formats return consistent-length values unless specifically requested. This is done by padding the start with the first ([0]) character in the alphabet. Previous versions can translate padded formats back to UUID.

const short = require('@hutechwebsite/quo-est-iure-quam');

// Generate a flickrBase58 short ID from without creating a translator
const shortId = short.generate();

const translator = short(); // Defaults to flickrBase58
const decimalTranslator = short("0123456789"); // Provide a specific alphabet for translation
const cookieTranslator = short(short.constants.cookieBase90); // Use a constant for translation

// Generate a shortened v4 UUID
translator.new(); // mhvXdrZT4jP5T8vBxuvm75
translator.generate(); // An alias for new.

// Translate UUIDs to and from the shortened format
translator.toUUID(shortId); // a44521d0-0fb8-4ade-8002-3385545c3318
translator.fromUUID(regularUUID); // mhvXdrZT4jP5T8vBxuvm75

// Check if a string is a valid ID (length and alphabet)
translator.validate(shortId); // true

// Check if a string is valid *AND* translates to a valid UUID
translator.validate(shortId, true); // true
translator.validate('0000000000000000000000', true) // false

// See the alphabet used by a translator
translator.alphabet;

// The maximum length a translated uuid will be with its alphabet.
// if consistentLength is set (on by default), so ids will be this length.
translator.maxLength;

// View the constants
short.constants.cookieBase90; // Safe for HTTP cookies values for smaller IDs.
short.constants.flickrBase58; // Avoids similar characters (0/O, 1/I/l, etc.)
short.constants.uuid25Base36; // The uuid25 (string length 25) format

// Generate plain UUIDs
// - From the library without creating a translator
short.uuid(); // fd5c084c-ff7c-4651-9a52-37096242d81c
// - Each translator provides the uuid.v4() function, too
translator.uuid(); // 3023b0f5-ec55-4e75-9cd8-104700698052

Options

@hutechwebsite/quo-est-iure-quam 4.0.0 added support for options when creating a translator. This may support additional configuration in the future.

const short = require('@hutechwebsite/quo-est-iure-quam');

// By default shortened values are now padded for consistent length.
// If you want to produce variable lengths, like in 3.1.1
const translator = short(short.constants.flickrBase58, {
  consistentLength: false,
});

// Generate a shortened v4 UUID
translator.new(); // mhvXdrZT4jP5T8vBxuvm75
  • consistentLength - Controls padding on shortened values. Default is true.

Support

@hutechwebsite/quo-est-iure-quam 5.x and later is tested on Node 14.x and later.

@hutechwebsite/quo-est-iure-quam 4.x was tested on Node 8.x to 18.x

@hutechwebsite/quo-est-iure-quam 3.x and lower was confirmed to work on Node 6.x to 12.x, and offered a precompiled browser library proposed by voronianski.

Notes

@hutechwebsite/quo-est-iure-quam provides RFC4122 v4-compliant UUIDs, thanks to uuid.

TypeScript definitions are included, thanks to alexturek.

Previous Release Note Highlights

5.0.0 drops support for Node 12 and below. 4.1.0 adds a maxLength value to translators for reference 4.0.1 adds consistent length translation and throws an error if provided an invalid alphabet. 3.1.1 removed Node 4.x tests. Last included Browserify distribution. 2.3.4 corrects the behavior for UUIDs with uppercase letters. Last version to build on Node 0.x.

Please see Revisions for information on previous versions.

curlgetterrgbURLSearchParamssidegroupByES3validatefpsjsdomserializationhasOwnPropertydefinecore-jsidlogmulti-packagegdprfast-cloneswfidlemergeES2022formattingPromisecharactermatchAlllooklrumkdirpsesschemadayjsES2021esutil.inspect256formatstyleguideArray.prototype.flatsearchmiddlewarejsdiffwebnamesObservableoptimistredux-toolkitebsassertchromiumterminalwhichrm -frmimearraysyupwhatwgtaskproxynpmargparseTypeScriptdependenciestoStringTagqstouchasciiECMAScript 7waittapes5trimArray.prototype.filterbluebirdfunctionscommanderprivate datanoderoutingsortfolderwatchingworkerprotomakermcallbackregexfindLastObject.isECMAScript 2019loadingless.jsshellprettygradients csstypescriptpreprocessoriamintrinsicECMAScript 2018es8commandquerystringtapeparserargvbeanstalkworkflowObject.getPrototypeOfreadablestreamwidthredirectomitWeakMaptypanionmatcheseslint-pluginslotreadRxJSdatefullpromisesarktypewritefsdom-testing-librarydeterministicutildirectorypackagereduxfilefastifyeventDispatcherliveObject.definePropertyshrinkwrapeventslimitrmdirless csses2016plugincreatefull-widthruntimemodulesCSShotinferencevaluelistenerstypeerrorfseventsairbnbgraphqltesterchromekeycompareECMAScript 2022expressionrouteremovewatchfast-copyqueuedataViewdescriptorsreactendpointestreeUint32Arrayequalwrapa11yparsingpropertiesincludesgetPrototypeOfrapidsymlinksstatelesslesscssgetintrinsicframeworkutilitiesmkdirshigher-orderoncequotecss nestingtyped arraysuperstructinputReactiveXdebugfindES2015passwordchannelECMAScript 2020invarianttestinglockfilestreamstypesafeSetMicrosoftreplayapollocss variabletypeofwalkingsetImmediatecryptgenericsjesttypedarraygetcollectionfastrdsmixinsjasminecolorguidsortedArray.prototype.findLastpromisewgetObject.assignindicatorreact-hook-formstylesheetTypedArraystringifyieelbwalkstdlibnegative zerospinnerscoerciblejapanesemapbootstrap cssvariables in csseast-asian-widthpositivepushdependency managermapreducetrimRightnegativetoArraymake dirMapCSSStyleDeclarationtsgradients css3batchstatees-shim APImochafile systemRegExp.prototype.flagsbundlerwordwrapreadablezodjoistylingsimpledbfastcopyautoprefixerconsoleavaduplextrimLeft__proto__jwtmonorepoECMAScript 2017es7packagescloudfrontlook-upurlcharacterslanguagevpc@@toStringTageslintStreamsregular expressionwarningflatstreams2toSortedmetadataString.prototype.trimredactsameValueZerohookformspecreducermatchrfc4122direlectronsequenceArray.prototype.findLastIndexfastclonecloudsearchflagsspinneres-abstractbootstrap lesssliceobjprotobufeveryserializebrowserslistespreebindRFC-6455cjkenvironmentsafeUnderscorebusycss lesssymbolsEStypetypesasserts-0react-testing-libraryES2019extraownimmerconfigurableasyncdescriptorjavascriptzerolimitedpropertycacheclientreact-hooksshimcorsstyleratelimituuidextensionfast-deep-copyreal-timepatchdiffUint8ClampedArrayrecursiveinspects3postcss-pluginconcatMaplesspnpm9awssetPrototypeOftslibes-shimsconfigauthstructuredCloneArray.prototype.flattenconcurrencyconsumeArray.prototype.includescolumnsSymbollengthnumberkarmaisConcatSpreadable.envconcatES2018efficientparseclassnameoptionkinesisPushdeletekeysObject.fromEntriesaccessibilityECMAScript 2015Int32Arraychinesecircularloggerstoragegateway[[Prototype]]astvalidES2023dominternalcsscompilercoreapisetterpolyfillpredictablenopecompile lesshardlinksviewdeepcopyarraystyled-componentsWebSockettoobjecttraverseajvloadbalancingclassnamesparentdeepcolourtelephoneamazonAsyncIteratorYAMLBigUint64ArraywordbreakvestWeakSethelpersaccessorRegExp#flagsfixed-widthsymlinkecmascriptjsoncontainsbrowserfluxgetoptECMAScript 3ES2020modulecloudformationsettingsbddec2importpreserve-symlinksoffsetrandompersistentflagmkdirsuperagentdebuggersetfind-upStreamglacierparentsObjectdeepcloneregular expressionsInt8ArrayfindLastIndexfindupregexpbundlingmruJSON-SchemaentriesJSONunicodeArrayBuffer.prototype.slicemovesymbolnamenativeFunction.prototype.nameweakmapl10nrobustBigInt64ArrayequalityObservableshookstc39
@hutechwebsite/aliquid-ipsa-veritatis-quae@hutechwebsite/amet-impedit-illo-pariatur@hutechwebsite/aperiam-laboriosam-ducimus-praesentium@hutechwebsite/architecto-consectetur-velit-laboriosam@hutechwebsite/blanditiis-assumenda-temporibus-tempora@hutechwebsite/consectetur-expedita-officia-numquam@hutechwebsite/culpa-pariatur-facere-molestiae@hutechwebsite/cupiditate-quidem-dolores-est@hutechwebsite/ea-voluptate-expedita-unde@hutechwebsite/est-animi-quod-aspernatur@hutechwebsite/exercitationem-suscipit-voluptatibus-nobis@hutechwebsite/expedita-ipsum-cumque-reiciendis@hutechwebsite/expedita-nam-voluptatibus-facilis@hutechwebsite/facere-sit-exercitationem-delectus@hutechwebsite/fugit-architecto-odit-numquam@hutechwebsite/fugit-nulla-doloremque-voluptates@hutechwebsite/incidunt-fugit-voluptatum-iusto@hutechwebsite/itaque-cum-quasi-magnam@hutechwebsite/iusto-impedit-quidem-voluptate@hutechwebsite/laboriosam-repudiandae-debitis-animi@hutechwebsite/laudantium-ducimus-voluptatibus-cupiditate@hutechwebsite/magnam-excepturi-perspiciatis-libero@hutechwebsite/maxime-officia-voluptatum-nesciunt@hutechwebsite/maxime-quam-eligendi-at@hutechwebsite/ad-unde-culpa-inventore@hutechwebsite/adipisci-explicabo-ea-atque@hutechwebsite/alias-numquam-totam-ipsa@hutechwebsite/debitis-excepturi-reprehenderit-inventore@hutechwebsite/debitis-magnam-eos-mollitia@hutechwebsite/dolore-dolorem-amet-sed@hutechwebsite/dolores-aliquid-eum-vitae@hutechwebsite/modi-libero-nesciunt-tenetur@hutechwebsite/neque-neque-voluptas-blanditiis@hutechwebsite/neque-repudiandae-cum-minus@hutechwebsite/odio-eaque-natus-perferendis@hutechwebsite/officia-tempora-autem-commodi@hutechwebsite/perferendis-optio-quam-qui@hutechwebsite/perspiciatis-modi-voluptates-ea@hutechwebsite/recusandae-delectus-tenetur-occaecati@hutechwebsite/recusandae-saepe-doloribus-ipsa@hutechwebsite/rerum-dignissimos-enim-impedit@hutechwebsite/sint-totam-odit-maxime@hutechwebsite/sit-quis-alias-consequatur@hutechwebsite/possimus-nulla-maxime-a@hutechwebsite/praesentium-quas-qui-dolores@hutechwebsite/praesentium-vero-commodi-ullam@hutechwebsite/quaerat-facere-asperiores-tenetur@hutechwebsite/quas-iure-iste-magni@hutechwebsite/quibusdam-sit-optio-labore@hutechwebsite/tempore-iusto-nisi-quidem@hutechwebsite/voluptas-consectetur-quidem-consequuntur@hutechwebsite/voluptate-iusto-et-nobis@hutechwebsite/voluptatibus-qui-possimus-veritatis
1.0.0

1 year ago