Skip to content

Commit

Permalink
Merge pull request #72 from simon-jentzsch/master
Browse files Browse the repository at this point in the history
added Error when dealing with negativ integers for
  • Loading branch information
holgerd77 authored Mar 19, 2019
2 parents 6fc71bc + 46b358f commit e063575
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ function stripHexPrefix(str: string): string {

/** Transform an integer into its hexadecimal value */
function intToHex(integer: number): string {
if (integer < 0) {
throw new Error('Invalid integer as argument, must be unsigned!')
}
const hex = integer.toString(16)
return hex.length % 2 ? `0${hex}` : hex
}
Expand Down

0 comments on commit e063575

Please sign in to comment.