Skip to content

Instantly share code, notes, and snippets.

@saulshanabrook
Created September 8, 2015 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saulshanabrook/8dc6e6f66d24b9576dc0 to your computer and use it in GitHub Desktop.
Save saulshanabrook/8dc6e6f66d24b9576dc0 to your computer and use it in GitHub Desktop.
{
local: {
cues: {
new: newCue(),
$newValid: [
['local', 'cues', 'new'],
['local', 'cues', '$allNames'],
(cue, allCueNames) => cue && (cue.name || '').length > 0 && !_.includes(allCueNames, cue.name)
],
$count: [
['synced', 'cues'],
cues => (cues || []).length
],
$maxIndex: [
['local', 'cues', '$count'],
count => count - 1
],
expanded: {},
$allNames: [
['synced', 'cues'],
(cues = []) => cues.map(p => p.name)
],
live: {
current: {
$uuid: [
['synced', 'live', 'cue'],
currentCue => currentCue ? currentCue.uuid || '' : ''
],
$duration: [
['local', 'cues', 'live', 'current', '$uuid'],
['synced', 'cues'],
(uuid, cues) => uuid ? _.find(cues, {uuid}).duration : null
],
$index: [
['local', 'cues', 'live', 'current', '$uuid'],
['synced', 'cues'],
(uuid, cues) => nullIfNotFound(_.findIndex(cues, {uuid}))
],
$percent: [
['synced', 'live', 'cue', 'percent'],
['synced', 'live', 'cue', 'time'],
['local', 'now'],
['local', 'cues', 'live', 'current', '$duration'],
(percent, startTime, now, duration) => {
if (startTime) {
var elapsedMS = parse(now).diff(parse(startTime))
percent = elapsedMS / duration
if (percent > 1) {
percent = 1
}
if (percent < 0) {
percent = 0
}
}
return percent
}
]
},
next: {
$index: [
['local', 'cues', 'live', 'current', '$index'],
currentIndex => currentIndex === null ? 0 : currentIndex + 1
],
$available: [
['local', 'cues', 'live', 'next', '$index'],
['local', 'cues', '$maxIndex'],
(index, maxIndex) => index <= maxIndex
],
$uuid: [
['local', 'cues', 'live', 'next', '$index'],
['synced', 'cues'],
(index, cues) => cues ? (cues[index] || {uuid: ''}).uuid : ''
]
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment