MCPcopy Index your code
hub / github.com/formatjs/formatjs / collectSegments

Function collectSegments

packages/intl-segmenter/scripts/benchmark.ts:31–40  ·  view source on GitHub ↗
(iterator: SegmentIterator)

Source from the content-addressed store, hash-verified

29}
30
31const collectSegments = (iterator: SegmentIterator) => {
32 let r
33 const collected = []
34 let i = iterator[Symbol.iterator]()
35 while (!(r = i.next()).done) {
36 // ar.push(r.value);
37 collected.push({segment: r.value?.segment})
38 }
39 return collected
40}
41
42async function run() {
43 const bench = new Bench({time: 1000})

Callers 1

runFunction · 0.85

Calls 1

nextMethod · 0.80

Tested by

no test coverage detected