-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates modules for two space indentation.
- Loading branch information
Showing
8 changed files
with
566 additions
and
566 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import uuid from './uuidv4'; | ||
|
||
export default class Job { | ||
constructor(spec) { | ||
if (!spec) { | ||
throw new Error('Spec must be an object'); | ||
} | ||
constructor(spec) { | ||
if (!spec) { | ||
throw new Error('Spec must be an object'); | ||
} | ||
|
||
if (spec.message === undefined) { | ||
throw new Error('Message argument must be populated.'); | ||
} | ||
if (spec.message === undefined) { | ||
throw new Error('Message argument must be populated.'); | ||
} | ||
|
||
this.time = spec.time instanceof Date ? spec.time.getTime() : parseInt(spec.time, 10); | ||
this.time = spec.time instanceof Date ? spec.time.getTime() : parseInt(spec.time, 10); | ||
|
||
if (!this.time) { | ||
throw new TypeError('Time must be a Date object or an integer.'); | ||
} | ||
if (!this.time) { | ||
throw new TypeError('Time must be a Date object or an integer.'); | ||
} | ||
|
||
this.message = spec.message; | ||
this.message = spec.message; | ||
|
||
this.uuid = spec.uuid || uuid(); | ||
} | ||
this.uuid = spec.uuid || uuid(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
function randomHexByte() { | ||
const hexByte = Math.floor(Math.random() * 256).toString(16); | ||
const hexByte = Math.floor(Math.random() * 256).toString(16); | ||
|
||
return hexByte.length === 2 ? hexByte : '0' + hexByte; | ||
return hexByte.length === 2 ? hexByte : `0${hexByte}`; | ||
} | ||
|
||
function bytes(num) { | ||
let randomHex = ''; | ||
let randomHex = ''; | ||
|
||
for (let i = 0; i < num; i++) { | ||
randomHex += randomHexByte(); | ||
} | ||
for (let i = 0; i < num; i++) { | ||
randomHex += randomHexByte(); | ||
} | ||
|
||
return randomHex; | ||
return randomHex; | ||
} | ||
|
||
function special() { | ||
return ['8', '9', 'a', 'b'][Math.floor(Math.random() * 4)]; | ||
return ['8', '9', 'a', 'b'][Math.floor(Math.random() * 4)]; | ||
} | ||
|
||
export default function uuidv4() { | ||
return `${bytes(4)}-${bytes(2)}-4${bytes(3)}-${special()}${bytes(3)}-${bytes(6)}`; | ||
return `${bytes(4)}-${bytes(2)}-4${bytes(3)}-${special()}${bytes(3)}-${bytes(6)}`; | ||
} |
Oops, something went wrong.