@sagb_24/mytimerjs

1.4.4 • Public • Published

MyTimerJS

Screenshot (31) In this project a timer was developed using Javascript; This in order to be able to easily implement this element in future projects. And in turn, learn to publish open source projects in NPM.

Installation

Use the JavaScript package manager npm or yarn to install.

npm install @sagb_24/mytimerjs 
or
yarn add @sagb_24/mytimerjs

Getting started

  1. Set an id in the container where the timer will be displayed.
<div id="timerJS">00:00:00</div>
  1. Put the type "module" in the link of your external JavaScript file.
<script type="module" src="./index.js"></script>
  1. Don't forget to run your code from a local server.

In your JavaScript file

  • Import the "Timer" class using a relative path to your main JavaScript file.
  • Then you must instantiate the class passing it as a parameter the id of the container that you set in the HTML and the format you want to use.
  • Finally we will call the basic functions of the timer.
import Timer from "../node_modules/@sagb_24/mytimerjs/dist/mytimer.min.js";

const init = new Timer({
  // USE HTML ELEMENT ID
  idContainer: 'timerJS',  
  // THE TYPE OF TIMER TO USE IS INDICATED
  // HOURS:MINUTES:SECONDS | 00:00:00
  // MINUTES:SECONDS | 00:00
  timerFormat: '00:00:00' 
});

init.start(); // METHOD THAT START THE TIMER
init.pause() // METHOD THAT PAUSES THE TIMER
init.stop(); // METHOD THAT STOPS THE TIMER
init.getCurrentTime(); // METHOD THAT RETURNS LAST STORED VALUE OF THE TIMER

Sample project

  • In the following link you can access the demo site 🔮 where you can use the basic functions of myTimerJS.
  • You can also clone the demo repository and check the initial configuration.

Readme

Keywords

Package Sidebar

Install

npm i @sagb_24/mytimerjs

Weekly Downloads

0

Version

1.4.4

License

MIT

Unpacked Size

7.75 kB

Total Files

6

Last publish

Collaborators

  • sagb_24