JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16287
  • Score
    100M100P100Q136007F
  • License MIT

Package Exports

  • didyoumean3

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (didyoumean3) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

didyoumean3

1.0.0 beta, i will update in future.

notice: The algorithm is a bit weird on strings less than 2 in length, and I'm still looking for a solution

usage

type Options = {
  ignore?: boolean, // 'A' -> 'a'
  trim?: boolean, // ' A' -> 'A'
  normalize?: boolean, // '😄' -> '😄'.normalize()
  key?: string | GetVal // string key when you pass a object list, or a function with param the object item
}
didyoumean3(input: string, list: string[] | object[], options: Options)

for example:

import { didyoumean3 } from 'didyoumean3'

let input = 'insargrm'
let list = ['dasd', 'facebook', 'twitter', 'instagram', 'linkedin'];

didyoumean3(input, list)
// output
//  {
//    first: 'instagram',
//    matches: [{"score": 0.35294117647058826, "target": "instagram"}, {"score": 0.125, "target": "linkedin"}...]
//  }

// also you can pass a object list
list = [{id: 'facebook'}, {id: 'twitter'}, ...]
didyoumean3(input, list, {key: 'id'})