Skip to content

AlexcastroDev/castroclock-documentation

Repository files navigation

Greetings

Hello there

👋 Hey there, I'm Alexandro castro, brazilian 🇧🇷 , but now living in Portugal 🇵🇹

I Love Open Source, FrontEnd and Mobile Development Project

👨‍💻 All of my projects are available at https://github.com/alexcastrodev

📝 I regularly write articles on https://alexandrocastro.dev.br

📄 Know about my experiences https://www.linkedin.com/in/alexandro-c-oliveira/




Quick Start

If you want to use npm, you can use this command.

npm i castroclock

Maybe you want to use yarn.

yarn add castroclock

How to use

This package does not have any dependencies. Therefore, you are free to design what you want.

imports

Import this module

import CastroClock from 'castroclock-js'

Typescript support

To have a typescript support, you should import

import { CastroClockType } from 'castroclock/types'

Examples

Project code:

https://github.com/AlexcastroDev/chronometer-react

Preview: https://chronometer.vercel.app/

Tests

All calls and exceptions are covered by Jest

Documentation

start

This method returns instance of Timer, and start chronometer

Exemple:

CastroClock.start()

pause

This method returns instance of Timer, and pause chronometer

CastroClock.pause()

continue

This method is a void, and resume chronometer

CastroClock.continue()

lap

This method returns an array of stops (object), that contains: start_at (unix), ends_at (unix) and a string called period that returns 00:00:04

If start and wait 4 seconds

CastroClock.lap()

reset

This method returns instance of Timer, and reset chronometer status

const logger = () => {
    console.log("I'm here")
}
CastroClock.onChange(logger)

onChange

This method recieve a () => void that is called when [one of them] pause, reset, lap, continue are called.

CastroClock.reset()

currentTime

This getter returns an object, that contains: hours (Number), minutes (Number), seconds (Number)

currentTimeString

This getter returns a string that returns 00:00:04

If start and wait 4 seconds

periodTime

Period time: When you call CastroClock.start() untill Call this getter.

This getter returns an object, that contains: hours (Number), minutes (Number), seconds (Number)

periodTimeString

This getter returns a string that returns 00:30:00

If you start, wait about 30 minutes and call this getter or your laps time is about 30 minutes and call this getter.

Timer

This getter returns a Proxy Handler

_instance: {
        startInstance: Number | null,
        stopInstance: Number | null,
    },
    stopwatch: {
        startTime: Number | null,
        stopTime: Number | null,
    },
    stops: [
        {
            start_at: Number | null,
            ends_at: Number | null,
            period: string | null,
        }
    ],
    onChange: Function

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published