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

koa-polyfill-io

v1.1.2

Published

koa middleware for polyfill service

Downloads

5

Readme

Koa-polyfill-io

This is a Koa middleware based on polyfill.io, which can't be stable visited in mainland & causing request timeout. therefore I create this;

本项目是基于polyfill.io 进行封装的一个Koa 中间件,由于polyfill.io 在国内访问不稳定,会出现请求过久的问题,因此为方便使用,封装了此中间件。

Install

npm install koa-polyfill-io

Usage

const koa = require('koa');
const polyfillMiddleWare = require('koa-polyfill-io');
const koaRouter = require('koa-router');
const conditional = require('koa-conditional-get');
const etag = require('koa-etag');

const app = new koa();
// in order to cache request
app.use(conditional());
app.use(etag());
const router = koaRouter();

router.get('/polyfill.min.js', polyfillMiddleWare); // use in min size
router.get('/polyfill.js', polyfillMiddleWare); // use in normal size
app.use(router.routes());
app.listen(8080);

Description

It will minimize code when request with min.js

And it's support follow queries:

  • flags

    you can use props below & sperate with %7C (|), like flags=gated%7Calways;

    • gated: to identity each polyfill, it will polyfill only if native Api is not supported

    • always: include all polyfill function, no matter the browser that current request from is needed

  • features

    all features available can be seen in polyfill list & api

  • compression

    compression bundle with gzip (gzip compress), br (brotli compress) & identity (no compress)

  • ua

    you can define user-agent yourself, if it's not provied, than the user-agent header will be used alternatively

当请求以min.js 结尾时会压缩代码

可使用以下参数:

  • flags

    以下属性值可使用%7C(即|) 分隔使用, 如flags=gated%7Calways

    gated: 对每个polyfill 进行特性检测,即仅在原生Api 不支持的情况下进行 polyfill

    always: 包含所有polyfill 方法,无论当前请求的浏览器是否需要

  • callback

    当polyfill 文件加载完成后执行的回调函数

  • features

    参考可用的polyfill 列表及对应包含的api

  • compression

    压缩方式,可选为gzipbr 或者 identity

  • ua

    你可以自定义 user agent ,如果不定义,则使用header 中的user-agent