【文件属性】:
文件名称:iterators.ts:Typescript中的:couch_and_lamp:Rustical迭代器
文件大小:17KB
文件格式:ZIP
更新时间:2021-02-12 18:26:27
typescript functional lazy iterators TypeScript
Typescript中的惰性迭代器
JavaScript迭代器很烂...
const it = Iter . fromArray ( [ 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' , 'i' , 'j' , 'k' , 'l' ] )
. enumerate ( )
. map ( ( [ k , v ] ) => [ k , v . toUpperCase ( ) ] )
. filter ( ( [ k , v ] ) => k % 2 == 0 )
. map ( ( [ , v ] ) => v )
const collected = it . take ( 3 )
. intoArray ( ) ; // -> [ 'A', 'C', 'E']
const collected2 = it
【文件预览】:
iterators.ts-master
----.gitignore(37B)
----package.json(626B)
----src()
--------index.ts(10KB)
----tsconfig.json(980B)
----examples()
--------simple.ts(543B)
----README.md(424B)
----renovate.json(41B)
----test()
--------iterator.spec.ts(9KB)
----yarn.lock(26KB)