Skip to content

outputs the shortest unique prefixes of elements in an array

License

Notifications You must be signed in to change notification settings

aesrael/shortest-unique-prefix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shortest-unique-prefix

outputs the shortest unique prefixes of elements in an array

shortest-unique-prefix stable

Usage

NPM

shortest-unique-prefix(arrayOfStrings, options)

example usage:

const items = ["5973", "2883", "5808", "7150",
               "3276", "4461", "4147", "8354",
               "7492", "4580", "9620", "5570"]

> shortest-unique-prefix(items)
//returns an array of shortest unique prefixes

>  ["59", "2", "58", "71", "3", "44", "41", "8", "74", "45", "9", "55"]

> shortest-unique-prefix(items, { alias:true })

> { 2: "2883", 3: "3276", 8: "8354", 9: "9620", 41: "4147", 44: "4461", 45: "4580",
    55: "5570", 58: "5808", 59: "5973", 71: "7150", 74: "7492"}

About

outputs the shortest unique prefixes of elements in an array

Resources

License

Stars

Watchers

Forks

Packages