当前位置

网站首页> 程序设计 > 程序资讯 > 软件更新资讯 > 浏览文章

Immutable.js 2.2.1 发布,不可变数据集合

作者:小梦 来源: 网络 时间: 2024-06-19 阅读:

第29期OSC源创会#南京#开始报名,AngularJS、Netty 等

Immutable.js 2.2.1 发布,此版本现已提供下载,更新内容如下:

新特性:

  • groupBy and countBy now return Sequence instead of Map.

Bug 修复

  • Fix issue where seq.flip().reverse() can result in incorrect value.

在 2.2.1 发布前两个小时还发布了 Immutable.js 2.2.0 版本,更新内容如下:

新特性

  • mapEntries() works like map and mapKeys, but accepts and returns [key, value] tuples, enabling mapping both keys and values simultaniously.

  • toKeyedSeq() converts an IndexedSequence into a Sequence where the indices are treated as keys. This is a lazy operation.

  • The whole IndexedSequence API has been reworked to remove the third maintainIndices argument from many methods. Using maintainIndices resulted in a sparse IndexedSequence, which no longer made sense in the context of dense IndexedSequences.

示例:

// Old: [0,,2,,4,,6,,8,,]Range(0,10).filter(isEven, null, true) // New: { 0: 0, 2: 2, 4: 4, 6: 6, 8: 8 }Range(0,10).toKeyedSeq().filter(isEven)

Bug 修复:

  • Returning false from forEach() often resulted in an incorrect length iterated. Clarified the documentation describing this behavior and corrected any bad behavior.

  • Fixed some documentation which referenced sparse behavior.

  • Fixed some issues when using reverse() and take() or skip() in concert that resulted in incorrect indices.

  • Fixed incorrect behavior when take() or skip() are given negative values.

  • Fixed issue where iteration of valueSeq() didn't provide the correct collection as a third argument.

  • Fixed issue where flatten() and concat() behavior diverged.

Immutable 是 Facebook 开发的不可变数据集合。不可变数据一旦创建就不能被修改,是的应用开发更简单,允许使用函数式编程技术,比如惰性评估。Immutable JS 提供一个惰性 Sequence,允许高效的队列方法链,类似 mapfilter ,不用创建中间代表。

immutable 通过惰性队列和哈希映射提供 Sequence, Range, Repeat, Map, OrderedMap, Set 和一个稀疏 Vector

热点阅读

网友最爱