Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I serialize the structure to a file? #2

Closed
brunobg opened this issue Oct 26, 2018 · 1 comment
Closed

How can I serialize the structure to a file? #2

brunobg opened this issue Oct 26, 2018 · 1 comment

Comments

@brunobg
Copy link

brunobg commented Oct 26, 2018

I have a very big application and I want to save the computed tree to a file. How can I do that?

@RebaekSoparkKitchen
Copy link

hi,

This works for me...

const ac = new AhoCorasick(['he', 'his']);
// stringify and save it.
const str = JSON.stringify(ac);

// read the string and parse it.
const savedObj = JSON.parse(str);
// initialize a new object
let ac2 = new AhoCorasick([]);
// overwrite the attributes within ac2
ac2 = Object.assign(ac2, savedObj);
let result = ac2.search('he is his wife');

@BrunoRB BrunoRB closed this as completed Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants