Comparing version 0.9.3 to 0.10.0
@@ -1,10 +0,7 @@ | ||
var _, actions; | ||
const _ = require('lodash'); | ||
_ = require('underscore'); | ||
actions = { | ||
sum: function(collection, field) { | ||
var total; | ||
total = 0; | ||
_.each(collection, function(item) { | ||
const actions = { | ||
sum(collection, field) { | ||
let total = 0; | ||
_.forEach(collection, function(item) { | ||
if (_.isFunction(item[field])) { | ||
@@ -20,4 +17,4 @@ total = total + item[field](); | ||
}, | ||
set: function(collection, field, value) { | ||
var i, item, len; | ||
set(collection, field, value) { | ||
let i, item, len; | ||
for (i = 0, len = collection.length; i < len; i++) { | ||
@@ -24,0 +21,0 @@ item = collection[i]; |
@@ -1,11 +0,8 @@ | ||
var Interval, _, timeFormatter; | ||
//NUM_INTERVALS X DISTANCE TYPE @ TIME | ||
const timeFormatter = require('./timeFormatter'); | ||
timeFormatter = require('./timeFormatter'); | ||
_ = require('underscore'); | ||
module.exports = Interval = (function() { | ||
function Interval(options) { | ||
class Interval { | ||
constructor(options) { | ||
if (options) { | ||
this.distance = options.distance, this.type = options.type, this.time = options.time, this.rest = options.rest; | ||
({distance: this.distance, type: this.type, time: this.time, rest: this.rest} = options); | ||
} | ||
@@ -22,7 +19,7 @@ if (this.distance == null) { | ||
Interval.prototype.isEmpty = function() { | ||
isEmpty() { | ||
return this.distance === 0 && this.type === '' && timeFormatter.isEmpty(this.time) && timeFormatter.isEmpty(this.rest); | ||
}; | ||
} | ||
Interval.prototype.toJSON = function() { | ||
toJSON() { | ||
return { | ||
@@ -34,5 +31,5 @@ time: timeFormatter.toJSON(this.time), | ||
}; | ||
}; | ||
} | ||
Interval.prototype.toString = function() { | ||
toString() { | ||
var time; | ||
@@ -43,17 +40,17 @@ if (!timeFormatter.isEmpty(this.time) || !timeFormatter.isEmpty(this.rest)) { | ||
if (!timeFormatter.isEmpty(this.time)) { | ||
time = " @ " + (timeFormatter.toString(this.time)); | ||
time = ` @ ${timeFormatter.toString(this.time)}`; | ||
} else if (!timeFormatter.isEmpty(this.rest)) { | ||
time = " +" + (timeFormatter.toString(this.rest)); | ||
time = ` +${timeFormatter.toString(this.rest)}`; | ||
} | ||
return this.distance + " " + this.type + time; | ||
return `${this.distance} ${this.type}${time}`; | ||
} else { | ||
return (timeFormatter.toString(this.time)) + " " + this.type; | ||
return `${timeFormatter.toString(this.time)} ${this.type}`; | ||
} | ||
} else { | ||
return this.distance + " " + this.type; | ||
return `${this.distance} ${this.type}`; | ||
} | ||
}; | ||
} | ||
return Interval; | ||
}; | ||
})(); | ||
module.exports = Interval; |
@@ -1,22 +0,11 @@ | ||
var Interval, IntervalSet, Set, _, int, moment, propertyFactory, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty; | ||
const _ = require('lodash'); | ||
const Interval = require('./interval'); | ||
const Set = require('./set'); | ||
const propertyFactory = require('./propertyFactory'); | ||
const int = require('./parser/handlers/int'); | ||
moment = require('moment'); | ||
_ = require('underscore'); | ||
Interval = require('./interval'); | ||
Set = require('./set'); | ||
propertyFactory = require('./propertyFactory'); | ||
int = require('./parser/handlers/int'); | ||
IntervalSet = (function(superClass) { | ||
extend(IntervalSet, superClass); | ||
function IntervalSet(intervals) { | ||
class IntervalSet extends Set { | ||
constructor(intervals) { | ||
var i; | ||
super(); | ||
this.intervals = []; | ||
@@ -35,8 +24,6 @@ propertyFactory(this, this.intervals, 'distance'); | ||
} | ||
if (_(intervals).isArray()) { | ||
intervals.map((function(_this) { | ||
return function(interval) { | ||
return _this.intervals.push(new Interval(interval)); | ||
}; | ||
})(this)); | ||
if (_.isArray(intervals)) { | ||
intervals.map((interval) => { | ||
return this.intervals.push(new Interval(interval)); | ||
}); | ||
} | ||
@@ -46,7 +33,7 @@ } | ||
IntervalSet.prototype.isEmpty = function() { | ||
isEmpty() { | ||
return this.intervals.length === 0; | ||
}; | ||
} | ||
IntervalSet.prototype.add = function(intervalToAdd) { | ||
add(intervalToAdd) { | ||
if (intervalToAdd === null) { | ||
@@ -60,13 +47,13 @@ throw new Error('Invalid interval given'); | ||
return intervalToAdd; | ||
}; | ||
} | ||
IntervalSet.prototype.toString = function() { | ||
toString() { | ||
if (this.intervals.length) { | ||
return this.intervals.length + "x" + (this.current().toString()); | ||
return `${this.intervals.length}x${this.current().toString()}`; | ||
} else { | ||
return ''; | ||
} | ||
}; | ||
} | ||
IntervalSet.prototype.toJSON = function() { | ||
toJSON() { | ||
return { | ||
@@ -77,8 +64,6 @@ intervals: this.intervals.map(function(interval) { | ||
}; | ||
}; | ||
} | ||
return IntervalSet; | ||
}; | ||
})(Set); | ||
module.exports = IntervalSet; |
@@ -7,1 +7,3 @@ module.exports = { | ||
}; | ||
//do nothing |
@@ -1,23 +0,11 @@ | ||
var empty, number, rest, set, setDivider, string, time, timeDivider, weightInterval, weightTitle; | ||
empty = require('./empty'); | ||
number = require('./number'); | ||
setDivider = require('./setDivider'); | ||
set = require('./set'); | ||
timeDivider = require('./timeDivider'); | ||
time = require('./time'); | ||
rest = require('./rest'); | ||
weightTitle = require('./weightTitle'); | ||
weightInterval = require('./weightInterval'); | ||
string = require('./string'); | ||
const empty = require('./empty'); | ||
const number = require('./number'); | ||
const setDivider = require('./setDivider'); | ||
const set = require('./set'); | ||
const timeDivider = require('./timeDivider'); | ||
const time = require('./time'); | ||
const rest = require('./rest'); | ||
const weightTitle = require('./weightTitle'); | ||
const weightInterval = require('./weightInterval'); | ||
const string = require('./string'); | ||
module.exports = [empty, number, setDivider, set, timeDivider, time, rest, weightInterval, weightTitle, string]; |
@@ -0,1 +1,3 @@ | ||
// code snippets stolen from | ||
// http://usefulscripts.wordpress.com/2008/10/02/integer-parsing-in-javascript/ | ||
var integer; | ||
@@ -2,0 +4,0 @@ |
@@ -1,8 +0,6 @@ | ||
var int; | ||
const _ = require('./int'); | ||
int = require('./int'); | ||
module.exports = { | ||
canHandle: function(token, currentSet) { | ||
return !currentSet.current().distance && int.isNumber(token); | ||
return !currentSet.current().distance && _.isNumber(token); | ||
}, | ||
@@ -9,0 +7,0 @@ act: function(tokens, token, currentSet) { |
@@ -1,16 +0,12 @@ | ||
var timeFormatter, tokenActions; | ||
const tokenActions = require('./tokens'); | ||
const timeFormatter = require('../../timeFormatter'); | ||
tokenActions = require('./tokens'); | ||
timeFormatter = require('../../timeFormatter'); | ||
module.exports = { | ||
canHandle: function(token) { | ||
canHandle(token) { | ||
return tokenActions.isRest(token); | ||
}, | ||
act: function(tokens, token, currentSet) { | ||
var rest; | ||
rest = tokenActions.getRest(token); | ||
act(tokens, token, currentSet) { | ||
const rest = tokenActions.getRest(token); | ||
return currentSet.setRest(timeFormatter.toDuration(rest)); | ||
} | ||
}; |
@@ -1,5 +0,3 @@ | ||
var tokenActions; | ||
const tokenActions = require('./tokens'); | ||
tokenActions = require('./tokens'); | ||
module.exports = { | ||
@@ -6,0 +4,0 @@ canHandle: function(token) { |
@@ -1,5 +0,3 @@ | ||
var tokenActions; | ||
const tokenActions = require('./tokens'); | ||
tokenActions = require('./tokens'); | ||
module.exports = { | ||
@@ -6,0 +4,0 @@ canHandle: function(token) { |
@@ -7,7 +7,8 @@ module.exports = { | ||
var name; | ||
//string token handler | ||
if (currentSet.current().isEmpty()) { | ||
currentSet.intervals.pop(); | ||
tokens.unshift(token); | ||
name = tokens.join(' '); | ||
tokens.length = 0; | ||
currentSet.intervals.pop(); //Delete created interval - not needed | ||
tokens.unshift(token); //add token back to tokens | ||
name = tokens.join(' '); //generate name from all strings | ||
tokens.length = 0; //empty tokens - we're done | ||
if (currentSet.name.isEmpty()) { | ||
@@ -14,0 +15,0 @@ return currentSet.name = name; |
@@ -1,7 +0,4 @@ | ||
var timeFormatter, tokenActions; | ||
const tokenActions = require('./tokens'); | ||
const timeFormatter = require('../../timeFormatter'); | ||
tokenActions = require('./tokens'); | ||
timeFormatter = require('../../timeFormatter'); | ||
module.exports = { | ||
@@ -8,0 +5,0 @@ canHandle: function(token) { |
@@ -11,1 +11,3 @@ var tokenActions; | ||
}; | ||
//do nothing |
@@ -1,7 +0,3 @@ | ||
var integer, moment; | ||
const _ = require('./int'); | ||
moment = require('moment'); | ||
integer = require('./int'); | ||
module.exports = { | ||
@@ -12,18 +8,18 @@ setDividerRegex: /[xX\\*]/, | ||
isTimeRegex: /^(([0-9])|([0-9][0-9]))?:?(([0-9])|([0-9][0-9]))?:?(([0-9])|([0-5][0-9]))$/, | ||
isSet: function(str) { | ||
isSet(str) { | ||
return this.isSetRegex.test(str); | ||
}, | ||
isSetDivider: function(str) { | ||
isSetDivider(str) { | ||
return this.isSetDividerRegex.test(str); | ||
}, | ||
isTimeDivider: function(str) { | ||
isTimeDivider(str) { | ||
return str === '@'; | ||
}, | ||
isTime: function(str) { | ||
isTime(str) { | ||
return this.isTimeRegex.test(str); | ||
}, | ||
isRest: function(str) { | ||
isRest(str) { | ||
return this.getRest(str).length > 0; | ||
}, | ||
getRest: function(str) { | ||
getRest(str) { | ||
var isRemainderNumber, isRemainderTime, justTime, plusPosition; | ||
@@ -33,6 +29,6 @@ plusPosition = str.indexOf('+'); | ||
isRemainderTime = this.isTime(justTime); | ||
isRemainderNumber = integer.isNumber(justTime); | ||
isRemainderNumber = _.isNumber(justTime); | ||
if (plusPosition > -1) { | ||
if (isRemainderNumber) { | ||
return ":" + justTime; | ||
return `:${justTime}`; | ||
} else if (isRemainderTime) { | ||
@@ -39,0 +35,0 @@ return justTime; |
@@ -1,15 +0,8 @@ | ||
var Interval, WeightSet, convertToTimedInterval, timeFormatter; | ||
const WeightSet = require('../../weightSet'); | ||
const Interval = require('../../interval'); | ||
const timeFormatter = require('../../timeFormatter'); | ||
WeightSet = require('../../weightSet'); | ||
Interval = require('../../interval'); | ||
timeFormatter = require('../../timeFormatter'); | ||
convertToTimedInterval = function(currentSet, time, distance) { | ||
function convertToTimedInterval(currentSet, time, distance) { | ||
currentSet.intervals.pop(); | ||
return currentSet.intervals.push(new Interval({ | ||
time: time, | ||
distance: distance | ||
})); | ||
return currentSet.intervals.push(new Interval({time, distance})); | ||
}; | ||
@@ -22,2 +15,3 @@ | ||
act: function(tokens, token, currentSet) { | ||
//weight token handler | ||
if (tokens.length === 5) { | ||
@@ -36,4 +30,4 @@ currentSet.current().weight = parseFloat(tokens[0]); | ||
} | ||
return tokens.length = 0; | ||
return tokens.length = 0; //empty tokens - we're done | ||
} | ||
}; |
@@ -1,7 +0,4 @@ | ||
var WeightSet, Workout; | ||
const Workout = require('../../workout'); | ||
const WeightSet = require('../../weightSet'); | ||
Workout = require('../../workout'); | ||
WeightSet = require('../../weightSet'); | ||
module.exports = { | ||
@@ -12,13 +9,13 @@ canHandle: function(token) { | ||
act: function(tokens, token, currentSet, workout) { | ||
var name; | ||
tokens.unshift(token); | ||
name = tokens.join(' '); | ||
tokens.length = 0; | ||
//weight token handler | ||
tokens.unshift(token); //add token back to tokens | ||
const name = tokens.join(' '); //generate name from all strings | ||
tokens.length = 0; //empty tokens - we're done | ||
if (!(workout.current() instanceof WeightSet)) { | ||
workout.sets.pop(); | ||
workout.sets.pop(); //remove created set | ||
} else { | ||
workout.current().intervals.pop(); | ||
} | ||
return currentSet = workout.addSet(name); | ||
return currentSet = workout.addSet(name); //recreate as correct type | ||
} | ||
}; |
@@ -1,21 +0,12 @@ | ||
var Workout, _, handlers, moment, parseLine, parser, processTokens; | ||
const _ = require('lodash'); | ||
const Workout = require('../workout'); | ||
const handlers = require('./handlers'); | ||
moment = require('moment'); | ||
//NUM_INTERVALS X DISTANCE TYPE @ TIME | ||
function parseLine(lines, work) { | ||
while (lines.length > 0) { | ||
const line = lines.shift().trim(); | ||
const tokens = line.split(/[ \t]/); | ||
const notAllEmpty = _.compact(tokens).length > 0; | ||
_ = require('underscore'); | ||
require('./string'); | ||
Workout = require('../workout'); | ||
handlers = require('./handlers'); | ||
parseLine = function(lines, work) { | ||
var line, notAllEmpty, tokens; | ||
while (lines.length > 0) { | ||
line = lines.shift().trim(); | ||
tokens = line.split(/[ \t]/); | ||
notAllEmpty = !_.all(tokens, function(item) { | ||
return item.isEmpty(); | ||
}); | ||
if (notAllEmpty) { | ||
@@ -27,35 +18,25 @@ processTokens(tokens, work); | ||
processTokens = function(tokens, work) { | ||
var currentSet, handler, numStartTokens, results, token; | ||
numStartTokens = tokens.length; | ||
currentSet = work.current(); | ||
function processTokens(tokens, work) { | ||
const currentSet = work.current(); | ||
currentSet.add(); | ||
results = []; | ||
while (tokens.length > 0) { | ||
token = tokens.shift(); | ||
results.push((function() { | ||
var i, len, results1; | ||
results1 = []; | ||
for (i = 0, len = handlers.length; i < len; i++) { | ||
handler = handlers[i]; | ||
if (handler.canHandle(token, currentSet)) { | ||
handler.act(tokens, token, currentSet, work); | ||
break; | ||
} else { | ||
results1.push(void 0); | ||
} | ||
const token = tokens.shift(); | ||
for (const handler of handlers) { | ||
if (handler.canHandle(token, currentSet)) { | ||
handler.act(tokens, token, currentSet, work); | ||
break; | ||
} | ||
return results1; | ||
})()); | ||
} | ||
} | ||
return results; | ||
}; | ||
parser = function(stringToParse) { | ||
var lines, workToMake; | ||
function parser(stringToParse) { | ||
if (stringToParse == null) { | ||
throw new Error('You must provide a valid string to parse to continue.'); | ||
} | ||
lines = stringToParse.split('\n'); | ||
workToMake = new Workout(); | ||
const lines = stringToParse.split('\n'); | ||
const workToMake = new Workout(); | ||
parseLine(lines, workToMake); | ||
@@ -62,0 +43,0 @@ return workToMake; |
@@ -5,6 +5,6 @@ var Set, actions; | ||
Set = (function() { | ||
function Set(options) { | ||
Set = class Set { | ||
constructor(options) { | ||
if (options != null) { | ||
this.name = options.name, this.intervals = options.intervals; | ||
({name: this.name, intervals: this.intervals} = options); | ||
} | ||
@@ -19,3 +19,3 @@ if (this.intervals == null) { | ||
Set.prototype.toString = function() { | ||
toString() { | ||
var output; | ||
@@ -30,5 +30,5 @@ output = ''; | ||
return output; | ||
}; | ||
} | ||
Set.prototype.toJSON = function() { | ||
toJSON() { | ||
return { | ||
@@ -40,9 +40,9 @@ name: this.name, | ||
}; | ||
}; | ||
} | ||
Set.prototype.add = function() { | ||
add() { | ||
throw new Error('Must implement'); | ||
}; | ||
} | ||
Set.prototype.current = function() { | ||
current() { | ||
var currentInterval, intervalLength; | ||
@@ -57,5 +57,5 @@ currentInterval = null; | ||
return currentInterval; | ||
}; | ||
} | ||
Set.prototype.totalIntervals = function() { | ||
totalIntervals() { | ||
var i, interval, len, ref, total; | ||
@@ -73,8 +73,6 @@ total = 0; | ||
return total; | ||
}; | ||
} | ||
return Set; | ||
}; | ||
})(); | ||
module.exports = Set; |
@@ -1,4 +0,2 @@ | ||
var Interval, IntervalSet, Set, TimedSet, actions, timeFormatter, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty; | ||
var Interval, IntervalSet, Set, TimedSet, actions, timeFormatter; | ||
@@ -15,7 +13,6 @@ Interval = require('./interval'); | ||
TimedSet = (function(superClass) { | ||
extend(TimedSet, superClass); | ||
function TimedSet(options) { | ||
TimedSet.__super__.constructor.call(this, options); | ||
TimedSet = class TimedSet extends Set { | ||
constructor(options) { | ||
//this isn't the right way to do this | ||
super(options); | ||
this.intervals = this.intervals.map(function(interval) { | ||
@@ -30,3 +27,3 @@ if (interval.intervals) { | ||
TimedSet.prototype.add = function(intervalToAdd) { | ||
add(intervalToAdd) { | ||
if (intervalToAdd === null) { | ||
@@ -40,39 +37,39 @@ throw new Error('Invalid interval given'); | ||
return intervalToAdd; | ||
}; | ||
} | ||
TimedSet.prototype.changeToMulti = function() { | ||
changeToMulti() { | ||
var numIntervals; | ||
numIntervals = this.current().distance; | ||
//remove single interval | ||
this.intervals.pop(); | ||
//replace with interval set | ||
return this.add(new IntervalSet(numIntervals)); | ||
}; | ||
} | ||
TimedSet.prototype.setRest = function(rest) { | ||
setRest(rest) { | ||
return this.current().rest = rest; | ||
}; | ||
} | ||
TimedSet.prototype.setDistance = function(distance) { | ||
setDistance(distance) { | ||
return this.current().distance = distance; | ||
}; | ||
} | ||
TimedSet.prototype.setTime = function(time) { | ||
setTime(time) { | ||
return this.current().time = timeFormatter.toDuration(time); | ||
}; | ||
} | ||
TimedSet.prototype.setType = function(type) { | ||
setType(type) { | ||
return this.current().type = type; | ||
}; | ||
} | ||
TimedSet.prototype.totalDistance = function() { | ||
totalDistance() { | ||
return actions.sum(this.intervals, 'distance'); | ||
}; | ||
} | ||
TimedSet.prototype.totalTime = function() { | ||
totalTime() { | ||
return actions.sum(this.intervals, 'time'); | ||
}; | ||
} | ||
return TimedSet; | ||
}; | ||
})(Set); | ||
module.exports = TimedSet; |
@@ -1,8 +0,6 @@ | ||
var _, getDurationFromString, isEmpty, moment, noTime, toDuration, toJSON, toString; | ||
const moment = require('moment'); | ||
moment = require('moment'); | ||
const _ = require('lodash'); | ||
_ = require('underscore'); | ||
noTime = { | ||
const noTime = { | ||
milliseconds: 0, | ||
@@ -17,11 +15,15 @@ seconds: 0, | ||
isEmpty = function(time) { | ||
function isEmpty(time) { | ||
return !time._milliseconds > 0; | ||
}; | ||
getDurationFromString = function(str) { | ||
var duration, timeTokens, timeTypes, token, type; | ||
timeTokens = str.split(':'); | ||
timeTypes = ['hours', 'minutes', 'seconds']; | ||
duration = {}; | ||
function getDurationFromString(str) { | ||
let token, type; | ||
const timeTypes = ['hours', 'minutes', 'seconds']; | ||
const timeTokens = _.compact(str.split(':')); | ||
const duration = {}; | ||
while (timeTokens.length) { | ||
@@ -32,13 +34,14 @@ token = timeTokens.pop(); | ||
} | ||
return moment.duration(duration); | ||
}; | ||
toDuration = function(time) { | ||
if (_(time).isString()) { | ||
function toDuration(time) { | ||
if (_.isString(time)) { | ||
time = getDurationFromString(time); | ||
} | ||
if ((_(time).isObject() || _(time).isNumber()) && !_(time.hours).isFunction()) { | ||
if ((_.isObject(time) || _.isNumber(time)) && !_(time.hours).isFunction()) { | ||
time = moment.duration(time); | ||
} | ||
if (_(time).isNull() || _(time).isUndefined()) { | ||
if (_.isNull(time) || _.isUndefined(time)) { | ||
time = moment.duration(_(noTime).clone()); | ||
@@ -49,3 +52,3 @@ } | ||
toString = function(time) { | ||
function toString(time) { | ||
var format; | ||
@@ -63,3 +66,3 @@ format = ''; | ||
} | ||
format += (time.minutes()) + ":"; | ||
format += `${time.minutes()}:`; | ||
if (time.seconds() < 10) { | ||
@@ -72,5 +75,6 @@ format += '0'; | ||
toJSON = function(time) { | ||
function toJSON(time) { | ||
var retValue; | ||
retValue = _(noTime).clone(); | ||
retValue = _.cloneDeep(noTime); | ||
//if time is number, set milliseconds? | ||
if ((time != null ? time._data : void 0) != null) { | ||
@@ -82,8 +86,2 @@ retValue = time._data; | ||
module.exports = { | ||
isEmpty: isEmpty, | ||
toString: toString, | ||
toJSON: toJSON, | ||
toDuration: toDuration, | ||
noTime: noTime | ||
}; | ||
module.exports = {isEmpty, toString, toJSON, toDuration, noTime}; |
var Weight; | ||
module.exports = Weight = (function() { | ||
function Weight(options) { | ||
module.exports = Weight = class Weight { | ||
constructor(options) { | ||
if (options) { | ||
this.reps = options.reps, this.weight = options.weight; | ||
({reps: this.reps, weight: this.weight} = options); | ||
} | ||
@@ -16,27 +16,22 @@ if (this.reps == null) { | ||
Weight.prototype.isEmpty = function() { | ||
isEmpty() { | ||
return this.reps === 0 && this.weight === 0; | ||
}; | ||
} | ||
Weight.prototype.toJSON = function() { | ||
return { | ||
reps: this.reps, | ||
weight: this.weight | ||
}; | ||
}; | ||
toJSON() { | ||
return {reps: this.reps, weight: this.weight}; | ||
} | ||
Weight.prototype.oneRepMax = function() { | ||
oneRepMax() { | ||
return this.weight / (1.0278 - (0.0278 * this.reps)); | ||
}; | ||
} | ||
Weight.prototype.toString = function() { | ||
toString() { | ||
if (this.weight) { | ||
return "- " + this.weight + " lbs x " + this.reps + " reps"; | ||
return `- ${this.weight} lbs x ${this.reps} reps`; | ||
} else { | ||
return "- " + this.reps + " reps"; | ||
return `- ${this.reps} reps`; | ||
} | ||
}; | ||
} | ||
return Weight; | ||
})(); | ||
}; |
@@ -1,4 +0,2 @@ | ||
var Interval, Set, Weight, WeightSet, actions, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty; | ||
var Interval, Set, Weight, WeightSet, actions; | ||
@@ -13,9 +11,8 @@ Weight = require('./weight'); | ||
WeightSet = (function(superClass) { | ||
extend(WeightSet, superClass); | ||
function WeightSet(options) { | ||
WeightSet.__super__.constructor.call(this, options); | ||
WeightSet = class WeightSet extends Set { | ||
constructor(options) { | ||
//this isn't the right way to do this | ||
super(options); | ||
this.intervals = this.intervals.map(function(interval) { | ||
if (interval.reps) { | ||
if (interval.reps) { //always will have reps | ||
return new Weight(interval); | ||
@@ -28,3 +25,3 @@ } else { | ||
WeightSet.prototype.add = function(weightToAdd) { | ||
add(weightToAdd) { | ||
if (weightToAdd === null) { | ||
@@ -36,21 +33,21 @@ throw new Error('Invalid weight given'); | ||
return weightToAdd; | ||
}; | ||
} | ||
WeightSet.prototype.setWeight = function(weight) { | ||
setWeight(weight) { | ||
return this.current().weight = weight; | ||
}; | ||
} | ||
WeightSet.prototype.setReps = function(reps) { | ||
setReps(reps) { | ||
return this.current().reps = reps; | ||
}; | ||
} | ||
WeightSet.prototype.totalReps = function() { | ||
totalReps() { | ||
return actions.sum(this.intervals, 'reps'); | ||
}; | ||
} | ||
WeightSet.prototype.totalWeight = function() { | ||
totalWeight() { | ||
return actions.sum(this.intervals, 'weight'); | ||
}; | ||
} | ||
WeightSet.prototype.oneRepMax = function() { | ||
oneRepMax() { | ||
return this.intervals.reduce(function(prev, next) { | ||
@@ -66,8 +63,6 @@ var max, nextMax; | ||
}); | ||
}; | ||
} | ||
return WeightSet; | ||
}; | ||
})(Set); | ||
module.exports = WeightSet; |
@@ -13,6 +13,6 @@ var TimedSet, WeightSet, Workout, actions, isWeightSet; | ||
Workout = (function() { | ||
function Workout(options) { | ||
Workout = class Workout { | ||
constructor(options) { | ||
if (options != null) { | ||
this.sets = options.sets; | ||
({sets: this.sets} = options); | ||
} | ||
@@ -31,9 +31,9 @@ if (this.sets == null) { | ||
Workout.prototype.toString = function() { | ||
toString() { | ||
return this.sets.map(function(set) { | ||
return set.toString(); | ||
}).join('\n'); | ||
}; | ||
} | ||
Workout.prototype.toJSON = function() { | ||
toJSON() { | ||
return { | ||
@@ -44,5 +44,5 @@ sets: this.sets.map(function(set) { | ||
}; | ||
}; | ||
} | ||
Workout.prototype.addSet = function(setName) { | ||
addSet(setName) { | ||
var newSet; | ||
@@ -60,5 +60,5 @@ if (isWeightSet(setName)) { | ||
return newSet; | ||
}; | ||
} | ||
Workout.prototype.current = function() { | ||
current() { | ||
var currentSet, setLength; | ||
@@ -73,13 +73,13 @@ currentSet = null; | ||
return currentSet; | ||
}; | ||
} | ||
Workout.prototype.totalDistance = function() { | ||
totalDistance() { | ||
return actions.sum(this.sets, 'totalDistance'); | ||
}; | ||
} | ||
Workout.prototype.totalTime = function() { | ||
totalTime() { | ||
return actions.sum(this.sets, 'totalTime'); | ||
}; | ||
} | ||
Workout.prototype.totalIntervals = function() { | ||
totalIntervals() { | ||
var i, len, ref, set, total; | ||
@@ -93,10 +93,8 @@ total = 0; | ||
return total; | ||
}; | ||
} | ||
return Workout; | ||
}; | ||
})(); | ||
Workout.isWeightSet = isWeightSet; | ||
module.exports = Workout; |
{ | ||
"name": "fit-parser", | ||
"version": "0.9.3", | ||
"version": "0.10.0", | ||
"description": "Parse a written workout into a set of workout objects", | ||
@@ -25,21 +25,23 @@ "keywords": [ | ||
"scripts": { | ||
"test": "gulp test", | ||
"pretest": "gulp" | ||
"test": "nyc --reporter=lcov --reporter=text-summary mocha 'test/**/*.spec.js'" | ||
}, | ||
"dependencies": { | ||
"moment": "^2.15.1", | ||
"underscore": "^1.7.0" | ||
"lodash": "^4.17.21", | ||
"moment": "^2.29.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.13.15", | ||
"@babel/preset-env": "^7.13.15", | ||
"chai": "^3.5.0", | ||
"coffee-errors": "^0.8.6", | ||
"coffee-script": "^1.11.1", | ||
"gulp": "^3.9.1", | ||
"coffeescript": "^2.5.1", | ||
"gulp": "^4.0.2", | ||
"gulp-clean": "^0.3.2", | ||
"gulp-coffee": "^2.3.2", | ||
"gulp-coffee": "^3.0.3", | ||
"gulp-coffeelint": "^0.6.0", | ||
"gulp-istanbul": "^1.1.1", | ||
"gulp-mocha": "^3.0.1", | ||
"gulp-istanbul": "^1.1.3", | ||
"gulp-mocha": "^8.0.0", | ||
"gulp-util": "^3.0.7", | ||
"mocha": "^3.1.2", | ||
"mocha": "^8.3.2", | ||
"nyc": "^15.1.0", | ||
"sinon": "^1.17.6", | ||
@@ -46,0 +48,0 @@ "sinon-chai": "^2.8.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2492
83064
16
45
1
+ Addedlodash@^4.17.21
+ Addedlodash@4.17.21(transitive)
- Removedunderscore@^1.7.0
- Removedunderscore@1.13.7(transitive)
Updatedmoment@^2.29.1