Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

adder

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adder

interpolating adder

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by100%
Maintainers
2
Weekly downloads
 
Created
Source

Adder will create an array of steps at regular intervals.

var adder = require('adder');

// basic use: adder(start, end, steps)
var steps = adder(10, 100, 10);
steps == [ 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ]

// figures it out if the numbers are too small
var steps = adder(1, 2.5, 6);
steps == [ 1, 1.3, 1.6, 1.9, 2.2, 2.5 ]

// When the numbers are not too small, choose your rounding: adder(start, end, steps, decimalPlaces)
var steps = adder(0, 6.52, 6, 3);
steps == [ 0, 1.304, 2.608 , 3.912, 5.216, 6.52 ]

// When decimalPlaces is set to 0 we won't round at all.
var adder(0, 5, 4, 0);
steps == [ 0, 1.6666666666666667, 3.3333333333333335, 5 ]

// works in reverse and with negative numbers
var steps = adder(10, -10, 5);
steps == [ 10, 5, 0, -5, -10 ]

Entire file is under 10 lines of code.

fire

MIT license.

Keywords

FAQs

Package last updated on 01 May 2014

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