![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@basic-streams/from-iterable
Advanced tools
fromIterable<T>(
iterable: Iterable<T>,
interval?: number,
scheduler?: (time: number) => Stream<void>
): Stream<T>
Transforms an iterable
into a stream.
import fromIterable from "@basic-streams/from-iterable"
fromIterable([1, 2, 3])(x => {
console.log(x)
})
// > 1
// > 2
// > 3
If an interval
is provided the items will be spread in time by that ammount of
milliseconds, with the first one delayed. If the interval is 0
the items will
be produced as soon as possible but still asynchronously.
import fromIterable from "@basic-streams/from-iterable"
fromIterable([1, 2, 3], 5000)(x => {
console.log(x)
})
// > 1
// > 2
// > 3
// ____1____2____3
Note that iterable is consumed lazily, meaning that next()
is called only when
value is needed.
import fromIterable from "@basic-streams/from-iterable"
function* generator() {
const startTime = Date.now()
yield Date.now() - startTime
yield Date.now() - startTime
yield Date.now() - startTime
}
fromIterable(generator(), 5000)(x => {
console.log(x)
})
// > 0
// > 5000
// > 10000
// 0 5000 10000
// ____.____.____.
You can provide a custom scheduler
, a function that creates a stream producing
an event after a given time. By default later
is used as a scheduler.
import fromIterable from "@basic-streams/from-iterable"
import later from "@basic-streams/later"
function scheduler(time) {
return later(time / 2)
}
fromIterable([1, 2, 3], 6000, scheduler)(x => {
console.log(x)
})
// > 1
// > 2
// > 3
// __1__2__3
FAQs
fromIterable operator for basic-streams
We found that @basic-streams/from-iterable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.