Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Removed: unecessary casting from base-convert() BIF

Removed: non-standard parameter assertion for second parameter to base-convert() BIF (base)
Added: standard parameter assertion for first two parameters for base-convert() BIF (num, base)
  • Loading branch information...
commit 760e2de9f2d58218c52a9ffbc7950067a7202443 1 parent 1a5d157
@mythril authored
Showing with 3 additions and 4 deletions.
  1. +3 −4 lib/functions/index.js
View
7 lib/functions/index.js
@@ -597,15 +597,14 @@ exports.trace = function trace(){
*/
(exports['base-convert'] = function(num, base, width) {
- if (base === undefined) {
- throw new Error('Base provided to base-convert is undefined, cannot convert to undefined...');
- }
+ utils.assertPresent(num, 'number');
+ utils.assertPresent(base, 'base');
num = utils.unwrap(num).nodes[0].val;
base = utils.unwrap(base).nodes[0].val;
width = (width && utils.unwrap(width).nodes[0].val) || 2;
var result = Number(num).toString(base);
while (result.length < width) {
- result = "0" + (String(result));
+ result = "0" + result;
}
return new nodes.Literal(result);
}).raw = true;
Please sign in to comment.
Something went wrong with that request. Please try again.