node.jsfaker.js

Faker.js v7 clear store


I use faker.js in gulp to create a lot of unique data

faker.helpers.unique

Due to debugging, the store is often full and displays the error

Error: Exceeded maxRetries: 1000 for uniqueness check.

So I need to clear the store so that faker.js can recreate unique data.

I can't find an instruction to clear the store from the docs, how should I reset/clear the store?


Solution

  • There is not a builtin method for resetting the store. Right now, your best option is probably to use your own store implementation. You could change maxRetries, override compare, use a store that resets on a timer, or have a catch looking for a FakerError with that message, and use that to trigger the reset.