Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NanoHash

Creates an instance of nanohash based on size and alphabet needs

example
const nhash = nanohash({ size: 6, alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" })

Hierarchy

  • NanoHash

Index

Type aliases

Static BulkMethod

BulkMethod: (...args: any[]) => any

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

Static DehashMethod

DehashMethod: (...args: any[]) => any

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

Static FaunaCode

FaunaCode: string

Static FaunaCodeMethod

FaunaCodeMethod: (...args: any[]) => any

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

Static FaunaID

FaunaID: string

Static FaunaIdMethod

FaunaIdMethod: (...args: any[]) => any

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

Static GenerateMethod

GenerateMethod: (...args: any[]) => any

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

Static HashMethod

HashMethod: (...args: any[]) => any

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

Static ID

ID: string

Static code

code: string

Constructors

constructor

Properties

alphabet

alphabet: string = presets.SHORT_REF.alphabet

codetable

codetable: object

codetable99

codetable99: object

hashtable

hashtable: object

hashtable99

hashtable99: object

maxSize

maxSize: number = 9

prefix

prefix: string = "1"

size

size: number = 6

Methods

bulk

  • bulk(n?: number): ID[]
  • Generates n iterations of unique numeric string ID (each reversible to code)

    example

    const code = nhash.bulk(5) // output: [ '1075226254449', '1563743314555', '1015201022261', '1271320203729', '1465116152533' ]

    Parameters

    • Default value n: number = 10

    Returns ID[]

dehash

  • Returns a code from an ID (made from .hash() or .generate())

    example

    const countryName = nhash.dehash("1412710231214") // output: France

    Parameters

    • Default value id: ID = ""

    Returns code

faunaCode

  • Returns a code from a Fauna ID (generated by Fauna)

    example

    const code = nhash.faunaCode("258296287713034771") // output: эh3ъmöýRt

    Parameters

    Returns FaunaCode

faunaId

  • Returns a Fauna ID from a code (from .faunaCode())

    example

    const faunaID = nhash.faunaId("эh3ъmöýRt") // output: 258296287713034771

    Parameters

    Returns FaunaID

generate

  • generate(): ID
  • Generates a unique numeric string ID (reversible to code)

    example

    const code = nhash.generate() // output: Xe7ZRY

    Returns ID

hash

  • Convert a string code to a numeric string ID (reversible)

    example

    const countryID = nhash.hash("France") // output: 1412710231214

    Parameters

    Returns ID

Generated using TypeDoc