Javascript 中有 Set 数据类型的库吗?
由于 Javascript 没有内置的集合数据类型,有没有人遇到过一个像样的集合库和集合操作(如并集、交集等)?
Since Javascript doesn't have a built in set datatype has anyone come across a decent library for sets and set operations like union, intersection, etc?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
immutable-js 公开了强大的设置 数据结构。
一个简单的 Node.js 示例,您可以在此处查看。
immutable-js expose a powerfull set data-structure.
A simple example for node.js, which you can see in work here.
就像已经提到的那样,现在 JS 上有 Set。根据您的目的,您可能还对 https://github.com/fsvieira/cset 感兴趣(我是它的作者),它是一个惰性集合库,具有常见的集合操作,包括笛卡尔积。
like have been mention there is now Set on JS. Depending on your purposes you also may be interested on https://github.com/fsvieira/cset (I am its author), its a lazzy set lib, with common set operation, including cartesian product.
看看 JS.Set。
它包含并集、交集、合并等方法......
Have a look at JS.Set.
It contains methods like union, intersection, merge, etc ...
如果您只想访问简单的并集、交集函数,您也可以尝试 Underscore.js' s 内置数组函数。它还提供了许多更有用的数据操作实用程序,如果您还没有,请尝试一下。
If you just want to have access to simple union, intersection functions, you could also try Underscore.js's built-in Array functions. It also provides a lot of more useful utilities for data manipulation, so try it if you haven't.
Set 现在是 ES2015 中原生的。
这适用于使用 babel 进行转译或仅在 Firefox 中进行转译。
Sets are now native in ES2015.
This works with transpiling using babel or just natively in firefox.
查看 setjs。 API 提供基本操作,并且库在设计上是不可变的。
免责声明:我是作者。
Check out setjs. The API provides basic operations and the library is immutable by design.
Disclaimer: I'm the author.