首页 > 其他 > 详细

[Compose] 19. Leapfrogging types with Traversable

时间:2016-12-21 21:34:01      阅读:212      评论:0      收藏:0      [点我收藏+]

We use the traversable instance on List to reimplement Promise.all() type functionality.

 

For example we want to conver:

[Task] => Task([])

Conver array of Task, into Task of array value.

 

To do that we can use traverse.

const fs = require(fs)
const Task = require(data.task)
const futurize = require(futurize).futurize(Task)
const { List } = require(immutable-ext)

const readFile = futurize(fs.readFile)

const files = List([box.js, config.json])

files.traverse(Task.of, fn => readFile(fn, utf-8))
.fork(console.error, console.log)

 

[Compose] 19. Leapfrogging types with Traversable

原文:http://www.cnblogs.com/Answer1215/p/6208930.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!