JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q34268F
  • License MIT

Typical stopwatch JavaScript library

Package Exports

  • @zzinpan/stopwatch.js
  • @zzinpan/stopwatch.js/dist/umd/Stopwatch.min.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@zzinpan/stopwatch.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Stopwatch.js

build test documentation publish pages-build-deployment

Stopwatch.js is a JavaScript-based stopwatch library.
Lightweight, easy to use,
Available in browsers, ESM, CJS, AMD, and UMD.


Installation

Note: Please enter a value of {version} in the import path.


Browser

<script type="javascript" src="https://cdn.jsdelivr.net/npm/@zzinpan/stopwatch.js@{version}/dist/iife/Stopwatch.min.js"></script>

Browser - ECMAScript Module

<script type="module">
import Stopwatch from "https://cdn.jsdelivr.net/npm/@zzinpan/stopwatch.js@{version}/dist/esm/Stopwatch.min.js";

// ...
</script>

Node.js

# Installation
npm install @zzinpan/stopwatch.js
const Stopwatch = require( "@zzinpan/stopwatch.js" );

// ...

getting started

<script type="module">

import Stopwatch from "Stopwatch.js";

// create api
const stopwatch = new Stopwatch();

// add events
stopwatch.on( "update", ( time ) => console.log( time ) );
stopwatch.on( "alarm", ( time ) => alert( time ) );

// set alarm
stopwatch.setAlarm( 5000, Stopwatch.AlarmType.ABSOLUTE );

// start
stopwatch.start();

</script>

Sample - browser


https://zzinpan.github.io/Stopwatch.js/sample/img/thumbnail.png


The same features are implemented in IIFE, ESM, AMD, and UMD respectively.

  • start: click the right button
  • stop: click the right button ( toggle )
  • pause: click the left button ( during the start )
  • setAlarm: drag the small hand
  • stopAlarm: click the stopwatch

https://zzinpan.github.io/Stopwatch.js/sample/index.html
https://zzinpan.github.io/Stopwatch.js/sample/index-esm.html
https://zzinpan.github.io/Stopwatch.js/sample/index-amd.html
https://zzinpan.github.io/Stopwatch.js/sample/index-umd.html


document

https://zzinpan.github.io/Stopwatch.js/docs/