Skip to content
This repository was archived by the owner on Jun 23, 2019. It is now read-only.

Improved file structure

Latest
Compare
Choose a tag to compare
@motss motss released this 16 Mar 02:59
· 24 commits to master since this release

The module can be used in either Web of Node depends on your usage. This release tackles this particular use case so that users do not have to worry much which file should be used and the module system will help you in this regard (hopefully).

Web

The file has been renamed to match the name of the module for web usage:

/dist/browser.js -> /dist/async-poll.js

ES Modules

<script type="module">
  import { asyncPoll } from 'https://unpkg.com/async-poll@latest/dist/async-poll.js'; 

  asyncPoll(...).then(console.log).catch(console.error);
</script>

IIFE

<script src="https://unpkg.com/async-poll@latest/dist/async-poll.iife.js"><script>
<script>
  const { asyncPoll } = window.AsyncPoll;
  asyncPoll(...).then(console.log).catch(console.error);
</script>

Node.js

TypeScript or ES Modules

import { asyncPoll } from 'async-poll'; /** This reads content from `index.mjs` */

asyncPoll(...).then(console.log).catch(console.error);

CommonJS

const { asyncPoll } = require('async-poll'); /** This reads content from `index.js` */

asyncPoll(...).then(console.log).catch(console.error);