Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const count =
Observable
.merge(increase, decrease)
.scan(add)
.startWith(0)
/* ========================== handlers ====================================== */
export const increaseCount =
Observable.of(() => {
dispatch(Actions.COUNTER_INCREASED)
})
export const decreaseCount =
Observable.of(() => {
dispatch(Actions.COUNTER_DECREASED)
})
/* ======================== all together ==================================== */
export default
Observable
.combineLatestObj({count, increaseCount, decreaseCount})
.switchMap(validationContext => {
if (validationContext.isApproved()) {
// if we get the approval, create the meta data
this.createExecutionAndUpdateLabs(invocation, hash);
// and execute the code
return this.codeRunner
.run(invocation, validationContext.labConfiguration)
.map(data => this.processStreamDataToExecutionMessage(data))
.startWith({
kind: MessageKind.ExecutionStarted,
data: 'Execution started... (this might take a little while)'
})
.concat(Observable.of({
kind: MessageKind.ExecutionFinished,
data: ''
}))
.do(msg => {
if (msg.kind === MessageKind.ExecutionFinished){
this.completeExecution(invocation);
}
})
}
// if we don't get an approval, reject it
return Observable.of({
kind: MessageKind.ExecutionRejected,
data: validationContext.approval.message
});
});
.mapTo(1)
const decrease =
getPayload(Actions.COUNTER_DECREASED)
.mapTo(-1)
export const count =
Observable
.merge(increase, decrease)
.scan(add)
.startWith(0)
/* ========================== handlers ====================================== */
export const increaseCount =
Observable.of(() => {
dispatch(Actions.COUNTER_INCREASED)
})
export const decreaseCount =
Observable.of(() => {
dispatch(Actions.COUNTER_DECREASED)
})
/* ======================== all together ==================================== */
export default
Observable
.combineLatestObj({count, increaseCount, decreaseCount})
test('accepts observables to schedule an agenda', t => {
const dispatcher = createDispatcher()
const addThree = Observable
.interval(200)
.take(3)
.map(() => add)
dispatcher.schedule(addThree)
dispatcher.schedule(Observable.of(subtract), Observable.of(subtract))
dispatcher
.reduce(AdderStore)
.bufferCount(6)
.subscribe(x => {
t.same(x, [ 0, 1, 2, 3, 2, 1 ])
}, err => {
t.fail()
}, () => {
t.end()
})
})
test(t => {
t.ok(isObservable(Observable.of('Value')))
t.notOk(isObservable())
t.notOk(isObservable({}))
t.notOk(isObservable(() => {}))
})
toInternalConfig(userId: string, publicConfig: PublicLabConfiguration) {
let config = new InternalLabConfiguration();
if (!publicConfig) {
config.errors.push('Could not parse file');
return Observable.of(config);
}
config.inputs = publicConfig.inputs;
config.parameters = publicConfig.parameters;
config.imageWithDigest = this.dockerImageService.getImageNameWithDigest(publicConfig.dockerImageId);
return this.mountService.validateMounts(userId, publicConfig.mounts)
.do(validated => config.errors.push(...validated.errors))
.do(validated => config.mountPoints = validated.mountPoints)
.map(_ => config)
.map(this.reportError('Invalid parameters', this.hasValidParameters))
.map(this.reportError('Unknown dockerImageId', this.isValidImage))
.map(this.reportError('Invalid inputs', this.hasValidInputs));
}
.switchMap(user => {
let approval = !user || user.isAnonymous ? this.rejectAnonymous(invocation) : this.allow(invocation);
return Observable.of(approval);
});
}
shutdown(params = {}, span = new Span()): Observable {
this.projectManager.dispose();
this.packageManager.dispose();
return Observable.of({ op: 'add', path: '', value: null } as AddPatch);
}
xworkspaceReferencesProvider: true,
xdefinitionProvider: true,
xdependenciesProvider: true,
completionProvider: {
resolveProvider: false,
triggerCharacters: ['.']
},
codeActionProvider: true,
renameProvider: true,
executeCommandProvider: {
commands: []
},
xpackagesProvider: true
}
};
return Observable.of({
op: 'add',
path: '',
value: result
} as OpPatch);
}