首页 时政热点 科技头条 智能AI 安全攻防 数码硬件 开发者生态 汽车 游戏 社会热点 开源推荐 医疗健康 归档 标签 关于

GitHub热门项目: polyfill-library

摘要

GitHub项目:polyfill-library 仓库地址:https://github。com/polyfillpolyfill/polyfill-library Stars:674 | 作者:polyfillpolyfill 项目描述:NodeJS module to create polyfill bundles tailored to individual user-agents。

the polyfill opts param features
2026-06-30 1 阅读 约9分钟阅读 GitHub Trending
分享:
字号:
GitHub项目:polyfill-library 仓库地址:https://github.com/polyfillpolyfill/polyfill-library Stars:674 | 作者:polyfillpolyfill 项目描述:NodeJS module to create polyfill bundles tailored to individual user-agents. ================================================== README 内容: # Polyfill-library · [![license][license-badge]][license] [![PRs Welcome][pull-requests-badge]][contributing-guide] > NodeJS module to create polyfill bundles tailored to individual user-agents ## Install ```bash npm install polyfill-library --save ``` ## Usage ```javascript const polyfillLibrary = require('polyfill-library'); const polyfillBundle = polyfillLibrary.getPolyfillString({ uaString: 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)', minify: true, features: { 'es6': { flags: ['gated'] } } }).then(function(bundleString) { console.log(bundleString); }); ``` ## API ### `polyfillLibrary.listAllPolyfills()` Get a list of all the polyfills which exist within the collection of polyfill sources. Returns a Promise which resolves with an array of all the polyfills within the collection. ### `polyfillLibrary.describePolyfill(featureName)` Get the metadata for a specific polyfill within the collection of polyfill sources. - `@param {String} featureName` - The name of a polyfill whose metadata should be returned. Returns a Promise which resolves with the metadata or with `undefined` if no metadata exists for the polyfill. ### `polyfillLibrary.getOptions(opts = {})` Create an options object for use with `getPolyfills` or `getPolyfillString`. - `@param {object} opts` - Valid keys are uaString, minify, unknown, excludes, rum and features. - `@param {Boolean} [opts.minify=true]` - Whether to return the minified or raw implementation of the polyfills. - `@param {'ignore'|'polyfill'} [opts.unknown='polyfill']` - Whether to return all polyfills or no polyfills if the user-agent is unknown or unsupported. - `@param {Object} [opts.features={}]` - Which features should be returned if the user-agent does not support them natively. - `@param {Array} [opts.excludes=[]]` - Which features should be excluded from the returned object. - `@param {String} [opts.uaString='']` - The user-agent string to check each feature against. - `@param {Boolean} [opts.rum=false]` - Whether to include a script that reports anonymous usage data in the polyfill bundle. Returns an object which has merged `opts` with the defaults option values. ### `polyfillLibrary.getPolyfills(opts)` Given a set of features that should be polyfilled in 'opts.features' (with flags i.e. `{: {flags:Set[]}, ...}`), determine which have a configuration valid for the given opts.uaString, and return a promise of set of canonical (unaliased) features (with flags) and polyfills. - `@param {object} opts` - Valid keys are uaString, minify, unknown, excludes, rum and features. - `@param {Boolean} [opts.minify=true]` - Whether to return the minified or raw implementation of the pol
这篇文章对您有帮助吗?

订阅66必读

每日精选科技资讯,直达你的邮箱