forked from nathanathan/Interview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmixins.js
24 lines (24 loc) · 803 Bytes
/
mixins.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
define(['underscore'], function(_){
_.mixin({
/**
* Format a times in milliseconds as minutes:seconds
**/
formatTime: function(millis) {
var seconds = Math.floor(millis / 1000) % 60;
var minutes = Math.floor(millis / 60 / 1000);
//if (minutes < 10) {minutes = "0"+minutes;}
if (seconds < 10) {seconds = "0"+seconds;}
return minutes + ':' + seconds;
},
/**
* Create a copy of the object without keys beginning with an underscore
**/
omitUnderscored: function(obj) {
var copy = {};
_.forEach(_.keys(obj), function(key) {
if (key[0] !== '_') copy[key] = obj[key];
});
return copy;
}
});
});