-
-
Notifications
You must be signed in to change notification settings - Fork 932
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
feat: Add random binary and octal number generation #191
Conversation
✔️ Deploy Preview for vigilant-wescoff-04e480 ready! 🔨 Explore the source changes: c8b0625 🔍 Inspect the deploy log: https://app.netlify.com/sites/vigilant-wescoff-04e480/deploys/61e77b26c7a2e90008e8ed85 😎 Browse the preview: https://deploy-preview-191--vigilant-wescoff-04e480.netlify.app |
src/datatype.ts
Outdated
* @param count defaults to 1 | ||
*/ | ||
octal(count: number = 1): string { | ||
let wholeString = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let wholeString = ''; | |
let octalString = ''; |
src/datatype.ts
Outdated
* @param count defaults to 1 | ||
*/ | ||
binary(count: number = 1): string { | ||
let wholeString = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let wholeString = ''; | |
let binaryString = ''; |
test/datatype.unit.js
Outdated
|
||
it('generates a random binary string', function () { | ||
var hex = binary(12); | ||
assert.ok(hex.match(/^(0b)[01]+$/i)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.ok(hex.match(/^(0b)[01]+$/i)); | |
assert.ok(hex.match(/^0b[01]{12}$/i)); |
test/datatype.unit.js
Outdated
|
||
it('generates a single binary charcter when no additional argument is provided', function () { | ||
var binaryNum = binary(); | ||
assert.ok(binaryNum.match(/^(0b)[01]{1}$/i)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.ok(binaryNum.match(/^(0b)[01]{1}$/i)); | |
assert.ok(binaryNum.match(/^0b[01]$/i)); |
src/datatype.ts
Outdated
* @method faker.datatype.octal | ||
* @param count defaults to 1 | ||
*/ | ||
octal(count: number = 1): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest length
, but it's OK for consistency with hexaDecimal
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I'll update this
…gth of returned string matches provided argument
… instead of `count`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great!
src/datatype.ts
Outdated
*/ | ||
hexaDecimal(count: number = 1): string { | ||
hexaDecimal(length: number = 1): string { | ||
let wholeString = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe hexaString
too? It's very minor though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll edit it
We're starting work on the |
Could we also provide a version without the Buffer.from(faker.datatype.hexadecimal(20).substring(2), 'hex') |
Don't have to much time yet to go into details and I have other prios right now, but yes I would like to not prefix it by default at all but have just the option to add the prefix on demand via an option argument. Consistent for all of these functions! => #954 |
I will close this PR since it's heavily outdated. I suggest opening another PR that at least has the 'new' test strategy and directory structure implemented. If anyone really wants to keep this alive, feel free to reopen it. |
closes #184