Skip to content

Force value to either min or max #42

@GreenImp

Description

@GreenImp

I know this might be an odd question for a random library but, is there any way of forcing an engine to return the min or max value when using integer or real?

e.g.:

// force this to always return the min, 1
integer(1, 4);

// force this to always return the max, 4
integer(1, 4);

I've looked at creating a custom engine, and if the next() method returns 0 it seems to always return the min value:

const engine = {
  next() {
    return 0;
  },
};

integer(1, 4); // returns 1
integer(1, 4); // returns 1
integer(1, 4); // returns 1

I'm assuming it works by returning the number from the range, by index of the response from next(). But I can't find a way of forcing the max value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions