New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@andersaloof/next-step

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@andersaloof/next-step

Steps an integer by a specified amount (+ or -), within a range from 0 to max, wrapping when the new value exceeds the range.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

nextStep Build Status

Steps an integer by a specified amount (+ or -), within a range from 0 to max, wrapping when the new value exceeds the range.

Install

$ npm install @andersaloof/next-step

Why?

Having made similar logic in a dozen of slideshows/galleries over the years, handling previous and next buttons to increase/decrease a current index, it was time to move it out to a separate module.

Usage

nextStep(current, max, value)

Example code

const nextStep = require('@andersaloof/next-step');

const nextValue = nextStep(1, 5, 2); // Increase current value 1 by 2, returns 3;
const anotherValue = nextStep(1, 5, -3); // Decrease current value 1 by -3, with a max value of 5, returns 4;

License

MIT. See LICENSE.md for details.

Keywords

FAQs

Package last updated on 17 Aug 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc