-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
121 additions
and
97 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
Binary file not shown.
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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* chrome-jironimo | ||
* | ||
* @author Kanstantsin Kamkou <2ka.by> | ||
* @link http://github.com/kkamkou/chrome-jironimo | ||
* @license http://opensource.org/licenses/BSL-1.0 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
/*final public*/class /* */ TimerWorkLogEntry { | ||
constructor(id, state, timestamp) { | ||
this._id = id; | ||
this._state = state || 'STOPPED'; | ||
this._timestamp = timestamp || Date.now(); | ||
|
||
if (!~['STOPPED', 'STARTED'].indexOf(this._state)) { | ||
throw new TypeError('Unknown state: ' + this._state); | ||
} | ||
} | ||
|
||
get id() { | ||
return this._id; | ||
} | ||
|
||
get started() { | ||
return this._state === 'STARTED'; | ||
} | ||
|
||
get stopped() { | ||
return this._state === 'STOPPED'; | ||
} | ||
|
||
get duration() { | ||
return Date.now() - this._timestamp; | ||
} | ||
|
||
resume() { | ||
this._state = 'STARTED'; | ||
} | ||
|
||
start() { | ||
this._timestamp = Date.now(); | ||
this._state = 'STARTED'; | ||
} | ||
|
||
stop() { | ||
this._state = 'STOPPED'; | ||
} | ||
|
||
toJSON() { | ||
return {id: this._id, state: this._state, timestamp: this._timestamp}; | ||
} | ||
} |
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