Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
event(args: {fullName: string, runner: Function}): GraphiteMeta {
const unit = Cmd.emit({
subtype: 'event',
fullName: args.fullName,
runner: args.runner,
})
const cmd = Step.single(unit)
const nextSteps = Step.multi([])
const stepFull = Step.seq([cmd, nextSteps])
const graphite = {next: nextSteps, seq: stepFull}
return graphite
},
prependEvent(args: {|
push(step: Cmd.Cmd): this {
const solo = Step.single(step)
this.current.data.push(solo)
return this
}
compute(reduce: (oldValue: any, newValue: any, ctx: any) => any): this {
graphite: GraphiteMeta,
parentGraphite: GraphiteMeta,
|}): GraphiteMeta {
const {fn, graphite, parentGraphite} = args
const unitCompute = Cmd.compute({
reduce(_, newValue, ctx): mixed {
return fn(newValue)
},
})
const unitFilter = Cmd.filter({
filter(result, ctx: TypeDef<'emitCtx', 'ctx'>): boolean {
return result !== undefined
},
})
const cmdCompute = Step.single(unitCompute)
const cmdFilter = Step.single(unitFilter)
const stepFull = Step.seq([cmdCompute, cmdFilter, graphite.seq])
parentGraphite.next.data.push(stepFull)
return graphite
},
}
mapEvent(args: {|
fn: Function,
graphite: GraphiteMeta,
parentGraphite: GraphiteMeta,
|}): GraphiteMeta {
const {fn, graphite, parentGraphite} = args
const unit = Cmd.compute({
reduce(_, newValue, ctx): mixed {
return fn(newValue)
},
})
const cmd = Step.single(unit)
const stepFull = Step.seq([cmd, graphite.seq])
parentGraphite.next.data.push(stepFull)
return graphite
},
filterEvent(args: {|
fn: Function,
graphite: GraphiteMeta,
parentGraphite: GraphiteMeta,
|}): GraphiteMeta {
const {fn, graphite, parentGraphite} = args
const unitCompute = Cmd.compute({
reduce(_, newValue, ctx): mixed {
return fn(newValue)
},
})
const unitFilter = Cmd.filter({
filter(result, ctx: TypeDef<'emitCtx', 'ctx'>): boolean {
return result !== undefined
},
})
const cmdCompute = Step.single(unitCompute)
const cmdFilter = Step.single(unitFilter)
const stepFull = Step.seq([cmdCompute, cmdFilter, graphite.seq])
parentGraphite.next.data.push(stepFull)
return graphite
},
}