Socket
Socket
Sign inDemoInstall

count-slowly

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    count-slowly

Make numbers go up or down, one at a time


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
15.1 kB
Created
Weekly downloads
 

Changelog

Source

1.0.0

Added

  • factory function
  • .set method
  • .onUpdate method
  • .update method
  • .hurry method
  • .stop method

Readme

Source

count-slowly

  • Usage

Usage

const countSlowly = require('count-slowly');

const cs = countSlowly({ stepDuration: 100 });

// Set the initial value
cs.set(1);
// Handle values between your final value
cs.onUpdate((tempValue) => {
  // Handle the temp value
});

// Update value when needed
cs.update(100);

// Skip directly to the new value. Calls onUpdate callback with final value then stops.
cs.hurry();

// Stops the onUpdate callbacks without skipping to new value.
cs.stop();

factory function

Rely on the .update() method to determine the values.

const cs = countSlowly();

Set the starting value straight-away.

const cs = countSlowly({}, 50);

Set a default duration to stay on each step

const cs = countSlowly({ stepDuration: 100 });

Set the default length of time to arrive at the new count

const cs = countSlowly({ totalDuration: 2000 });

.set()

Set an initial integer value. This will call the .onUpdate() callback once if it has been set.

cs.set(1);

.onUpdate()

Set the callback from each integer between the old value and the new value.

cs.onUpdate((tempValue) => {
  console.log(`Called with ${tempValue}`);
});

.update()

Set a new value. This will call the .onUpdate() callback for each integer between the old integer and the new integer according to either the factory function's stepDuration or totalDuration value.

cs.update(100);

Set a new value, calling the .onUpdate() callback every 50ms regardless of the factory function's stepDuration or totalDuration value.

cs.update(100, {
  overrideStepDuration: 50,
});

Set a new value, calling the .onUpdate() callback as often as needed in order to invoke the callback with 100 after 1200ms regardless of the factory function's stepDuration or totalDuration value.

cs.update(100, {
  overrideTotalDuration: 1200,
});

.hurry()

Skip directly to the new value. Calls the .onUpdate() callback with final value then stops.

cs.hurry();

.stop()

Stop the .onUpdate() callbacks without skipping to the new value.

cs.stop();

Examples

FAQs

Last updated on 12 Nov 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc