You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Uncaught TypeError: Cannot read property 'comparator' of undefined
at Chance.unique (node_modules/chance/chance.js:306:33)
at generateUsers (test/fixtures.js:43:31)
[many more, but irrelevant]
Going to the source:
Chance.prototype.unique=function(fn,num,options){testRange(typeoffn!=="function","Chance: The first argument must be a function.");varcomparator=options.comparator||function(arr,val){returnarr.indexOf(val)!==-1;};// ...
It tries to access comparator of the object options, but options might not be defined. So, a proposed fix:
Chance.prototype.unique=function(fn,num,options){testRange(typeoffn!=="function","Chance: The first argument must be a function.");// NEWoptions=options||{};varcomparator=options.comparator||function(arr,val){returnarr.indexOf(val)!==-1;};// ...
And my temporary fix is just doing this:
chance.unique(chance.state,5,{});
Sorry I cannot make the PR right now, I'm super tight on a deadline to read and follow any process in place. Might try to do so in a couple of days (or if anyone else wants, sure, go ahead 😄 ).
The text was updated successfully, but these errors were encountered:
franciscop
changed the title
.unique() forces the options
.unique() requires the options
May 1, 2016
When I try the example in Node.js:
It gives me the following error:
Going to the source:
It tries to access comparator of the object
options
, but options might not be defined. So, a proposed fix:And my temporary fix is just doing this:
Sorry I cannot make the PR right now, I'm super tight on a deadline to read and follow any process in place. Might try to do so in a couple of days (or if anyone else wants, sure, go ahead 😄 ).
The text was updated successfully, but these errors were encountered: