es-promise-polyfill

1.3.0 • Public • Published

es6-promise-polyfill

es6-promise-polyfill

umd模块规范,支持node,浏览器或者直接引用js使用PromisePolyfill全局变量。

安装

npm install --save es-promise-polyfill
# or
yarn add es-promise-polyfill

使用

  • es module
import Promise from 'es-promise-polyfill'

// 跟es6语法使用方法一样
new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve(true);
  }, 1000);
}).then(res => {
  console.log(res);
});
  • commonJS
const Promise = require('es-promise-polyfill');

// 跟es6语法使用方法一样
new Promise((resolve, reject) => {
  setTimeout(() => {
    resolve(true);
  }, 1000);
}).then(res => {
  console.log(res);
});
  • 非模块化环境

下载lib/index.min.js,然后在script标签引用。

<script src="your path to save index.min.js"></script>
// 使用全局变量 PromisePolyfill,然后跟es6语法使用方法一样
new PromisePolyfill((resolve, reject) => {
  setTimeout(() => {
    resolve(true);
  }, 1000);
}).then(res => {
  console.log(res);
});

/es-promise-polyfill/

    Package Sidebar

    Install

    npm i es-promise-polyfill

    Weekly Downloads

    2

    Version

    1.3.0

    License

    ISC

    Unpacked Size

    11 kB

    Total Files

    5

    Last publish

    Collaborators

    • jerry_cheung