MCPcopy Index your code
hub / github.com/Effect-TS/effect / fromIterable

Function fromIterable

packages/effect/src/List.ts:285–300  ·  view source on GitHub ↗
(prefix: Iterable<A>)

Source from the content-addressed store, hash-verified

283 * @category constructors
284 */
285export const fromIterable = <A>(prefix: Iterable<A>): List<A> => {
286 const iterator = prefix[Symbol.iterator]()
287 let next: IteratorResult<A>
288 if ((next = iterator.next()) && !next.done) {
289 const result = makeCons(next.value, _Nil)
290 let curr = result
291 while ((next = iterator.next()) && !next.done) {
292 const temp = makeCons(next.value, _Nil)
293 curr.tail = temp
294 curr = temp
295 }
296 return result
297 } else {
298 return _Nil
299 }
300}
301
302/**
303 * Constructs a new `List<A>` from the specified values.

Callers 4

makeFunction · 0.70
List.tsFile · 0.70
makeFunction · 0.70
makeFunction · 0.70

Calls 2

makeConsFunction · 0.85
nextMethod · 0.65

Tested by

no test coverage detected