New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hkid

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hkid

Generate and Validate HKID

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
decreased by-62.5%
Maintainers
1
Weekly downloads
 
Created
Source

hkid

Generate and Validate HKID

npm version Node.js CI codecov Known Vulnerabilities FOSSA Status

Installation

yarn add hkid

Usage

import * as hkid from "hkid";

random()

generate valid HKID randomly

console.log(hkid.random()); // H3497811

validate(candidate: string, option?: { checkPrefix?: boolean})

validate HKID

  • checkPrefix: check candidate against the known prefix list. If the prefix of candidate is not in the list, consider it as validation failure. (default: false)

    Note: the known prefix list may be incomplete, so false negative may be returned if checkPrefix is set to true.

console.log(hkid.validate("H3497811")); // true
console.log(hkid.validate("h3497811")); // true
console.log(hkid.validate("H349781(1)")); // true

console.log(hkid.validate("H3497810")); // false

console.log(hkid.validate("YK1597716")); // true
console.log(hkid.validate("YK1597716", { checkPrefix: false})); // true
console.log(hkid.validate("YK1597716", { checkPrefix: true})); // false

CodeSandbox

References

License

FOSSA Status

Keywords

FAQs

Package last updated on 20 Dec 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc