热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Immutable.js2.3.0发布,不可变数据集合

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

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

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

迭代器!

所有序列,包括 concrete collections (Map, Vector, Set) 和 lazy Sequences (mapped, filtered) 都可以被迭代。

API:

values() returns an iterator object where each call to next() provides the next value.

keys() returns an iterator object where each call to next() provides the next key.

entries() returns an iterator object where each call to next() provides the next entry as a [key, value] tuple.

示例:

var myMap = Immutable.Map([['A', 1], ['B', 2], ['C', 3]]);
var entries = myMap.entries();
entries.next() // { value: ['A', 1], done: false }
entries.next() // { value: ['B', 2], done: false }
entries.next() // { value: ['C', 3], done: false }
entries.next() // { value: undefined, done: true }

所有的序列通过 @@iteratorSymbol.iterator 方法都可以进行迭代,所以可以在 ES6 中使用。

新特性

  • interpose()

  • Sequence documentation is easier to follow now that methods are categorized and alphabetized.

  • A number of lazy sequence optimizations. For example, seq.flip().reverse().flip() becomes seq.reverse().

  • Optimizations that allow get() and has() to be O(1) on lazy sequences.

Bugs 修复

  • Equality checking via Immutable.is or seq.equals() could throw or incorrectly return false.

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

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


推荐阅读
author-avatar
陌北从南_221
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有