This repository has been archived by the owner on Sep 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Babel and ES6 Utilities Class #54
Open
nickwph
wants to merge
14
commits into
master
Choose a base branch
from
es6
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
63d15a5
Added babel to the dev-dependencies.
nickwph c7da959
Converted utilities to use ES6.
nickwph a19be0e
Updated launching read me.
nickwph 49fc07e
Updated launching command.
nickwph cd01cba
Added back engine.
nickwph 23e4d0b
Updated commands and fixed tests.
nickwph 457f38f
Fixed unit tests.
nickwph 10b36ff
Reverted changes.
nickwph 7fc3f41
Reverted changes.
nickwph 5f7abf2
Updated code to check existence.
nickwph 25f0213
Updated test + coverage tools to support babeljs.
seyeojumu 2d5846f
Removed unnecessary ```--compilers js:babel-core/register```
seyeojumu c649097
Updated utilities file.
nickwph c572581
Reverted changes.
nickwph File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "presets": ["es2015"] } |
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
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 |
---|---|---|
|
@@ -6,40 +6,36 @@ | |
* Utility and helper functions used across the application. | ||
*/ | ||
|
||
var path = require('path'); | ||
var util = require('util'); | ||
|
||
function Utilities () { | ||
} | ||
|
||
Utilities.prototype.formatMilliseconds = function (ms) { | ||
var secNum = parseInt(ms / 1000, 10); | ||
var hours = Math.floor(secNum / 3600); | ||
var minutes = Math.floor((secNum - (hours * 3600)) / 60); | ||
var seconds = secNum - (hours * 3600) - (minutes * 60); | ||
|
||
if (minutes < 10) | ||
minutes = '0' + minutes; | ||
if (seconds < 10) | ||
seconds = '0' + seconds; | ||
|
||
var time = hours + ':' + minutes + ':' + seconds; | ||
return time; | ||
} | ||
|
||
Utilities.prototype.isDictionary = function (obj) { | ||
return !(!obj || Array.isArray(obj) || obj.constructor != Object); | ||
} | ||
|
||
Utilities.prototype.exists = function (v) { | ||
return !(typeof v == 'undefined' || v == null); | ||
} | ||
|
||
Utilities.prototype.stringify = function (obj) { | ||
if (typeof obj === 'object') | ||
return util.inspect(obj, { showHidden: true, depth: null }); | ||
else | ||
return obj; | ||
} | ||
|
||
module.exports = new Utilities(); | ||
import * as util from 'util'; | ||
|
||
export default class Utilities { | ||
|
||
static formatMilliseconds(ms) { | ||
var secNum = parseInt(ms / 1000, 10); | ||
var hours = Math.floor(secNum / 3600); | ||
var minutes = Math.floor((secNum - (hours * 3600)) / 60); | ||
var seconds = secNum - (hours * 3600) - (minutes * 60); | ||
if (minutes < 10) { | ||
minutes = '0' + minutes; | ||
} | ||
if (seconds < 10) { | ||
seconds = '0' + seconds; | ||
} | ||
return hours + ':' + minutes + ':' + seconds; | ||
} | ||
|
||
static isDictionary(obj) { | ||
return !(!obj || Array.isArray(obj) || obj.constructor != Object); | ||
} | ||
|
||
static exists(v) { | ||
return !(typeof v == 'undefined' || v == null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return !(v === undefined || v === null)` |
||
} | ||
|
||
static stringify(obj) { | ||
if (typeof obj === 'object') | ||
return util.inspect(obj, {showHidden: true, depth: null}); | ||
else | ||
return obj; | ||
} | ||
} |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seyeojumu does it make sense to format this file so
java
-like?i think it also works if i make each method
export function formatMilliseconds(ms) {}
In that case i can import only the methods i want... like...
import {formatMilliseconds, isDictionary} from './utilities'