npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

plate-calculator

v1.0.6

Published

Calculates how many weight plates to put on a barbell to get a specific weight with the weights you have available

Downloads

18

Readme

#plate-calculator A library that calculates how many plates you need to put on a barbell to reach a target weight. It can take into account the weights that you actually own.

Useable from client or server side.

Installation

NPM

npm install plate-calculator --save-dev

Browser

Run npm run build and copy the plate-calculator.js file from the dist directory. Place it wherever you like in your application and include it like normal.

Usage

Regardless how you include the script to your app, you'll end up with a plateCalculator object with a calculate function.

The function takes two parameters: plateCalculator.calculate(weight : Number, options : Object);

Weight should be the weight you want to put on the bar.

Options are passed in a second parameter. They have the following defaults:

{
	set : weightSets.pounds,
	barbellWeight : 45,
	weightLimits : {},
	addedPlates : [],
}

set : Array

An array of plate sizes. Defaults to standard pound plates. Setting this variable will override the list of plates entirely.

returnClosest : Boolean = true

By default the calculator will return the closest weight that is possible with the given set. For instance, if you put in 46 pounds it will calculate to 45 if you don't have .5 pound plates.

If you set this to false, the calculator will throw an error instead when matching the entered weight is impossible.

barbellWeight : Number

The weight of the barbell you're using. Standard olympic barbell (45 pounds) is assumed, but you can change it if you're using a non standard bar (such as a curl bar)

weightLimits : Object

An object that tells the system what plates you have available.

This is an object in the shape { 45:2, 35:0} where the plate weight is the key and the quantity that you have available is the value. In the given case, you have two 45 pound plates and 0 35 pound plates.

Note: Null is assumed to be infinite, but 0 is treated as 0. Don't get them confused!gst

addedPlates : Array

Any plates that you own that aren't part of the standard set. For instance, if you own half pound plates: addedPlates : [.5]

The calculate function returns an object in the following shape:

{"plates":[{"plateWeight":45,"qty":4}],"closestWeight":225}

Node

const plateCalculator = require('plate-calculator');

Browser

If you've included plate-calculator as a script, then you can run plateCalculator.calculate() as a global function.

React / ES6

import plateCalculator from 'plate-calculator';

Examples

Better usageexamples will be live at a later date. For now you can run npm start and a webpack server will launch a very (very) simple demo.