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

@tiaod/weapp-polyfill

v1.1.3

Published

Browser API polyfill for Weapp

Downloads

3

Readme

weapp-polyfill npm

Polyfills for w3c API on top of Weapp API, including:

  • XMLHttpRequest
  • FormData
  • WebSocket
  • localStorage

Why

微信小程序设计了一系列 IO 相关的 API,但社区中现存的模块绝大部分使用的是 w3c 标准的 API。本项目通过 polyfill 这些 w3c API 允许开发者在不修改第三方模块代码的情况下直接在小程序中使用这些模块。

Usage

npm i weapp-polyfill -D

如果你的应用或 SDK 使用打包工具(打包成一个文件后再导入微信开发工具使用),你可以在程序入口的最开始 auto polyfill 所有 API

require('weapp-polyfill/auto-polyfill');

即可在整个项目中直接使用浏览器 API。See a realworld demo

weapp-polyfill pacakge 本身 export 了以下对象:

const {
  XMLHttpRequest,·
  FormData,
  WebSocket,
  localStorage,
  polyfill,
} = requrie('weapp-polyfill');

不支持不使用打包工具直接在微信开发工具使用。

Caveats

由于微信 API 的限制,polyfill 的 API 有以下限制:

XMLHttpRequest

  • Response Headers 无法获得,getResponseHeade('content-type') 始终返回 'application/json',其他 key 始终返回 ''
  • 不支持上传进度
  • 不支持 abort
  • 不会出现HEADERS_RECEIVEDLOADING 状态

FormData

  • Blob 被定义为一个拥有 uri 属性的对象,uri 的值为通过微信 API 得到的本地临时文件路径:{ uri: 'tempFilePath' }
  • 如果一个 FormData append 了多个 blob,只有第一个会被发送

WebSocket

  • 不支持 subprotocal
  • 不支持二进制帧