npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tb-app/polyfill

v0.1.1

Published

提供一些最新特性的polyfill

Downloads

5

Readme

@tb-app/polyfill

简介

小程序引擎中禁止访问 globalThis、global ,因此无法直接使用 babel-polyfill(babel-polyfill 访问了 global 对象)。

开发者使用新的 JavaScript 特性时,需要关心新特性的兼容性。如果必须使用新特性,需要自己提供内置对象的 polyfill。

Polyfill :用于实现浏览器或其他 JavaScript 引擎不支持的原生 API 的代码

为了能够在小程序中使用最新版本的特性,我从 core-js 源码中拷贝了一些目前小程序中可能存在兼容性问题的 API 的 polyfill 实现。

我对这些代码进行了修改,使之能够兼容小程序引擎。并且,删除了这些 polyfill 中对 ie8 或 es3 的兼容代码。修改过的代码,仍然能够百分百通过 core-js 的单元测试(我对 core-js 的单元测试也拷贝了一份)。

为什么自己不实现 polyfill?

要实现符合 ESMA 规范 的 polyfill,需要注重很多细节,要很熟悉 ESMA 规范,实现难度比较大。因此,我选择了十分成熟的 库, core-js。

小程序支持哪些新的特性

小程序对 ES6 扩展内置对象支持情况

ios8 已经不需要考虑了,因为手机端千牛要求的最低版本是 Ios9.因此,表中所列出的 API, 你都可以直接使用(Reflect,Proxy 还需要小心使用)。

安装

npm i @tb-app/polyfill --save

使用

import '@tb-app/polyfill';

注意:一定要在 app.js 的最顶层中 引入 @tb-app/polyfill

引入 @tb-app/polyfill 后,如果用户的小程序引擎中没有对应的 api, 会自动提供 polyfill 版本。

目前提供了以下 API 的 polyfill