babel如何实施Set / Map polyfills [英] How does babel implement Set / Map polyfills

查看:1096
本文介绍了babel如何实施Set / Map polyfills的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题与巴别塔的Set / Map,弱集/弱地图polyfills的计算复杂性有关? Afaik没有ES5语言功能允许直接实现Set / Map,因此可能会发生Set / Map可能使用引擎框架下的数组结构来实现对象引用的查找,这将产生O(N)查找性能。所以问题是:

My question is related to computational complexity of Set / Map, Weak Set / Weak Map polyfills by Babel? Afaik there are no ES5 language features allowing to implement Set / Map directly, and so it might happen that Set / Map might use Array structure under the hood to implement lookup by object reference which would yield to O(N) lookup performance. And so the question is:

Set / Map查找操作的计算复杂度是多少?

What is the computational complexity of Set / Map lookup operations?

谢谢提前!

推荐答案

Babel使用core-js作为其polyfill,从 GitHub repo

Babel uses core-js for its polyfill, from the GitHub repo:


核心-js在大多数情况下使用本地集合,只需修复方法/
构造函数(如果需要),并且在旧环境中使用快速
polyfill (O(1)lookup) / p>

core-js uses native collections in most case, just fixes methods / constructor, if it's required, and in old environment uses fast polyfill (O(1) lookup).

(Emphasis mine)

您对确切的查找感兴趣,它位于这个文件。它不是由数组支持。

And if you're interested in the exact lookup, it's in this file. It's not backed by an array.

这篇关于babel如何实施Set / Map polyfills的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆