Push dev work to master #2

Merged
sixteenmillimeter merged 416 commits from dev into master 2018-07-19 15:29:02 +00:00
1 changed files with 9 additions and 2 deletions
Showing only changes of commit e1a54c10e0 - Show all commits

View File

@ -1,5 +1,6 @@
'use strict'
const uuid = require('uuid').v4
const log = require('../log')('seq')
/** Object sequence features */
@ -22,6 +23,10 @@ sequence._loop = {
}
sequence.start = function (options, cb) {
if (sequence._state.active) {
return false
}
sequence._state.active = true
sequence._state.count = 0
@ -41,6 +46,8 @@ sequence.start = function (options, cb) {
}
sequence._state.stop = cb
sequence.step()
sequence._state.id = uuid()
return sequence._state.id
}
sequence.setStop = function () {
@ -76,7 +83,7 @@ sequence.step = function () {
if (sequence._state.count > sequence._state.arr.length - 1) {
return sequence.stop()
}
log.info('step', sequence._state.count)
log.info('step', { count : sequence._state.count, id : sequence._state.id })
return sequence._state.arr[sequence._state.count](() => {
sequence._state.count++
sequence.step()
@ -89,7 +96,7 @@ sequence.step = function () {
if (sequence._loop.max > 0 && sequence._loop.count > sequence._loop.max) {
return sequence.stop()
}
log.info('step', sequence._state.count)
log.info('step', { count : sequence._state.count, id : sequence._state.id })
return sequence._loop.arr[sequence._state.count](() => {
sequence._state.count++
sequence.step()