Skip to content

Comments

feat(candid): add random value generator#458

Merged
hansl merged 5 commits intomasterfrom
candid-random
Mar 16, 2020
Merged

feat(candid): add random value generator#458
hansl merged 5 commits intomasterfrom
candid-random

Conversation

@chenyan-dfinity
Copy link
Contributor

@chenyan-dfinity chenyan-dfinity commented Mar 13, 2020

Add a "Lucky" button to generate random primitive values when the field is empty.

@chenyan-dfinity chenyan-dfinity requested a review from a team as a code owner March 13, 2020 23:05
}

try {
if (this.input.value === '') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really the behaviour we want? I would say fields are mandatory.

Also, empty string is still a valid string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment on lines +105 to +110
const num = Math.floor(Math.random() * 100);
if (signed && Math.random() < 0.5) {
return -num;
} else {
return num;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const num = Math.floor(Math.random() * 100);
if (signed && Math.random() < 0.5) {
return -num;
} else {
return num;
}
return 100 - Math.floor(Math.random() * 200);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want negative numbers for Nat.

@hansl hansl merged commit f965aa1 into master Mar 16, 2020
@lwshang lwshang deleted the candid-random branch July 29, 2022 18:59
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

Successfully merging this pull request may close these issues.

2 participants