本文整理汇总了TypeScript中@amnisio/rivulet.periodic函数的典型用法代码示例。如果您正苦于以下问题:TypeScript periodic函数的具体用法?TypeScript periodic怎么用?TypeScript periodic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了periodic函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createSinks
const application = (arduino: Sources) => {
const sinks = createSinks();
sinks.D2$ = periodic(100).sample(arduino.D2$).map(invert);
sinks.D3$ = periodic(250).sample(arduino.D3$).map(invert);
sinks.LED$ = periodic(500).sample(arduino.LED$).map(invert);
return sinks;
};
示例2: createSinks
const application = (arduino: Sources) => {
const sinks = createSinks();
sinks.LED$ =
periodic(500)
.sample(arduino.LED$)
.map(led => led == LOW ? HIGH : LOW);
return sinks;
};
示例3: createSinks
const application = (arduino: Sources) => {
const sinks = createSinks();
sinks.LED$ =
periodic(20)
.sample(arduino.D2$)
.map(value => value == LOW ? HIGH : LOW);
return sinks;
};
示例4: createSinks
const application = (arduino: Sources) => {
const sinks = createSinks();
// We do some maths in order to get a stream of brightnesses that allows fading
sinks.D10$ =
// Create a stream that emits an event every 30 ms
periodic(30)
// fold it onto a stream that repeats 0 to 101 forever
// 0-1-2-3-...-100-101-0-1-2-3-4-...->
.fold((brightness, event) => brightness == 101 ? 0 : ++brightness, 0)
// map it to a triangular stream that rises and falls, peaking at 51, forever
// 0-1-2-3-...-50-51-50-...-3-2-1-0-1-2-3-...->
.map(brightness => {
const x = brightness % 51;
return brightness > x ? 51 - x : x;
})
// map it to a stream that multiplies the value by 5, to get increments of 5, peaking at 255
// 0-5-10-15-...-250-255-250-...-15-10-5-0-5-10-15-...->
.map(brightness => 5 * brightness);
return sinks;
};
示例5: createSinks
const application = (arduino: Sources) => {
const sinks = createSinks();
sinks.LED$ = periodic(20).sample(arduino.D2$);
return sinks;
};