Create Binary To Decimal Converter.js#456
Create Binary To Decimal Converter.js#456Pradeep567iaf wants to merge 2 commits intoServiceNowDevProgram:mainfrom
Conversation
This parser is a Binary to Decimal Converter designed to parse user input in a specific format and convert binary values to decimal. By providing a command with a binary code, this parser uses an external API to fetch and return the decimal equivalent. Activation Example To use this converter, simply enter the command in this format: !converttoDecimal <binary_code> For example: !converttoDecimal 1011 Features Regex-based Command Parsing: The parser validates the input command using a regular expression, ensuring only binary codes are accepted. Binary Validation: It checks the user input for valid binary numbers. API Call for Conversion: It uses the https://networkcalc.com/api/binary/<binary_code> API to convert binary to decimal. Slackbot Integration: Once the conversion is complete, the decimal value is sent back to the user in formatted message. *Binary to Decimal Conversion:* • Binary value: 1011 • Decimal value: 11
SapphicFire
left a comment
There was a problem hiding this comment.
Thanks for your contribution. I have applied the hacktoberfest-accepted label which will mark this PR as accepted for you. However, there is a few changes that would be required before we can merge this.
| activation_example:!converttoDecimal <binary_code> | ||
| regex:^!converttoDecimal |
There was a problem hiding this comment.
Please remove this capitalisation, as this adds confusion when compared to all other parsers. Additionally, it is not clear that this parser converts from binary to decimal. It might be worthwhile making it something like !bin2dec
There was a problem hiding this comment.
ok I wil make changes
| var match = input.match(/!converttoDecimal (\d+)/); // check input format | ||
| var expression = match ? match[1] : ""; |
There was a problem hiding this comment.
It's not clear from other details about this parser, that this will not support multiple bytes (i.e. 00110101 11111111) or breaks in the binary
There was a problem hiding this comment.
Ok I will rectify the code
| // check the valid binary code in if statement | ||
| if(binaryCheckregx.test(expression)){ | ||
| var result = evaluateBinaryExpression(expression); // call to evaluateBinaryExpression | ||
| var DecimalresultSlackMessage = "* Binary to Decimal Conversion :*\n" + "• *Binary value*: " + expression + "\n" + "• *Decimal value*: " + result.converted + "\n"; // slack markdown message format |
There was a problem hiding this comment.
This does not use unordered lists so does not use slack markdown
Resolve the Issue raised 1) Please remove this capitalisation, as this adds confusion when compared to all other parsers. Additionally, it is not clear that this parser converts from binary to decimal. It might be worthwhile making it something like !bin2dec 2) It's not clear from other details about this parser, that this will not support multiple bytes (i.e. 00110101 11111111) or breaks in the binary 3) This does not use unordered lists so does not use slack markdown Now, this parser will accept the binary code with spaces and give output as a decimal value. Change the activation to !bin2dec <binary code> and also remove the slack markdown and show output as normal text.
Pradeep567iaf
left a comment
There was a problem hiding this comment.
I make some changes in the file. Please review the changes and accept it.
This parser is a Binary to Decimal Converter designed to parse user input in a specific format and convert binary values to decimal. By providing a command with a binary code, this parser uses an external API to fetch and return the decimal equivalent.
Activation Example
To use this converter, simply enter the command in this format:
!converttoDecimal <binary_code>
For example:
!converttoDecimal 1011
Features
Regex-based Command Parsing: The parser validates the input command using a regular expression, ensuring only binary codes are accepted.
Binary Validation: It checks the user input for valid binary numbers.
API Call for Conversion: It uses the https://networkcalc.com/api/binary/<binary_code> API to convert binary to decimal.
Slackbot Integration: Once the conversion is complete, the decimal value is sent back to the user in formatted message.
Binary to Decimal Conversion:
• Binary value: 1011
• Decimal value: 11