I’m trying to use the fuzzball.js library to create an action for detecting duplicate drafts. But I’m not sure I know exactly the right way to include it and use its functions in my script. I’m getting an error and I don’t know whether I’m not using the library right or not referencing it right in Drafts.
Here’s what I’ve done:
- I saved this file as “fuzzball.js” and placed it in
/Library/Scripts
folder in Drafts’ iCloud folder - I wrote my own “dupes.js” script and made it an action.
- I run the action and get this error: Script Error: TypeError: undefined is not an object (evaluating ‘fuzz.extract’) Line number: 8, Column 19
dupes.js:
// Find dupes
const fuzz = require("fuzzball.js");
let query = draft.content;
let choices = ["testing","testing duplicates"];
let results = fuzz.extract(query,choices);
alert(results + JSON.stringify(results));
From the documentation, “extract” should give me an array of arrays with results regarding the matches.