fast-levenshtein icon indicating copy to clipboard operation
fast-levenshtein copied to clipboard

Use import instead of require

Open kunjesh1 opened this issue 4 years ago • 2 comments

I want to import the npm in the client side instead of require.How to do that?

kunjesh1 avatar Jun 05 '20 21:06 kunjesh1

@kunjesh1 I was facing a similar issue as well. I was able to import with the following code

import { get as levenshtein } from 'fast-levenshtein';
levenshtein('cat', 'bat');

Hope that helps!

ironprice91 avatar Jun 17 '20 16:06 ironprice91

Why not just do

import * as levenshtein from 'fast-levenshtein';

And use it the same way as with require

levenshtein.get('cat', 'bat');

KonkretneKosteczki avatar Aug 13 '20 09:08 KonkretneKosteczki