Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('only subscribes to sinks with matching drivers', () => {
let testSubscribed: boolean = false;
let otherSubscribed: boolean = false;
const test = most.of(1).tap(() => {
testSubscribed = true;
});
const other = most.of(2).tap(() => {
otherSubscribed = true;
});
function main () {
return {
test,
other,
};
}
const drivers = {
test: () => { return {}; },
};
Motorcycle.run<{ test: any }, any>(main, drivers);
it('returns an object with property `sinks` with named keys given by main return', () => {
const test = most.of(1);
function main () {
return {
test,
};
}
const drivers = {};
const { sinks } = Motorcycle.run(main, drivers);
assert.ok(sinks.hasOwnProperty('test'));
assert.strictEqual((sinks.test.source as any).source, test.source);
});
let main = () => ({
bot: most.from([
most.of(sendLocation(
{ chat_id: GROUP_ID, latitude: 55.751244, longitude: 37.618423 },
{}))
])
})
let { sources, run } = Cycle(main, { bot: basicDriver })
let main = () => ({
bot: most.from([
most.of(getChatMembersCount({ chat_id: GROUP_ID }, {}))
])
})
let { sources, run } = Cycle(main, { bot: basicDriver })
let main = () => ({
bot: most.from([
most.of(sendContact(
{ chat_id: GROUP_ID, phone_number: '+42470', first_name: 'Telegram' },
{}))
])
})
let { sources, run } = Cycle(main, { bot: basicDriver })
let main = () => ({
bot: most.from([
most.of(getChatAdministrators({ chat_id: GROUP_ID }, {}))
])
})
let { sources, run } = Cycle(main, { bot: basicDriver })
.flatMapError(error=>{
console.log('[ERROR]:', error);
return most.of({message:error.error,className:'display'})
.merge(most.of({className:'hidden'}).delay(3000))
.map(error=>state=>({error}))
})
.flatMapError(error=>{
console.log('[CRITICAL ERROR]:', error);
return most.of({message:error.error,className:'display'})
.merge(most.of({className:'hidden'}).delay(3000))
.map(error=>state=>({error}))
})
consumeUntilMs(ms = 1000, finishedCallback = null) {
super.multicast();
this.stream$ = this.stream$.until(most.of().delay(ms));
if (!this.finalised) {
this.finalise(finishedCallback);
}
return this;
}
streams.map($stream => {
const $start = most.of(SKIP_TOKEN).until($stream)
return $start.concat($stream)
})
)