cgatno / measuring-cup

A quick and simple tool to convert cooking measurements like ounces, cups and tablespoons right in your code! 📏🥛
https://www.npmjs.com/package/measuring-cup
MIT License
10 stars 2 forks source link

Metric <-> imperial conversions? #4

Open danielbachhuber opened 5 years ago

danielbachhuber commented 5 years ago

👋 I work for WP Tasty and we're thinking about using this library in our plugin, Tasty Recipes.

Have you considered offering imperial -> metric conversions (and back again)? Would you be open to some pull requests for this?

cgatno commented 5 years ago

Hey Daniel, great to meet you! That would be awesome; I'm definitely open to directing some more time and energy to maintaining this project if it were to be distributed in a scenario like that. (In fact, I'll go in and update the dev dependencies now to get rid of GitHub's security warnings.)

I think imperial <-> metric conversions would be a great addition that would fit well with the existing API. Would you be willing to kick start the work for that? I'd be more than happy to look over some PRs for that feature.

Thanks!

danielbachhuber commented 5 years ago

That would be awesome; I'm definitely open to directing some more time and energy to maintaining this project if it were to be distributed in a scenario like that.

Sweet :)

(In fact, I'll go in and update the dev dependencies now to get rid of GitHub's security warnings.)

Thanks!

I think imperial <-> metric conversions would be a great addition that would fit well with the existing API. Would you be willing to kick start the work for that? I'd be more than happy to look over some PRs for that feature.

Yep, more than happy to. We're not moving on it immediately, so I'll loop back around when we plan to start.

danielbachhuber commented 5 years ago

To share a bit more context, this is from our internal Asana:

This one is rather complicated. I think what people want is something like "1 cup flour => 128 g flour." The problem with this is that different ingredients have such different weights that without a library that contains nearly every ingredient amount it's pretty much impossible.

We need to do a bit more user research before we know which direction to head on this.

cgatno commented 5 years ago

@danielbachhuber thanks for the additional info, that definitely sheds some light on the issue. It sounds like you're looking to convert between volume (e.g. cups) and mass (e.g. grams).

I've run into this issue quite a bit when brewing coffee, for example. The most precise brewing instructions specify a coffee amount in grams, but most people are more familiar with using tablespoons to measure out coffee. It's impossible to directly interconvert between the two, because it depends on the density of that particular coffee.

Anyway, I think this can be split up into two separate issues:

  1. Conversion between imperial and metric units of the same physical property. This means volume <-> volume and mass <-> mass, for example. This would mean adding methods like toMilliliters() to the library.
  2. Conversion between physical properties for common cooking ingredients. This would allow for volume <-> mass conversions. This is the tougher problem, but I think it could be addressed by creating a table of densities for common items like flour, coffee, sugar, etc.

By being smart about the densities stored, I think the second item can be accomplished without adding much weight to the library at all.

danielbachhuber commented 5 years ago

Cool :) We'll follow up when we dive into this project. Thanks!

marcus-hiles commented 5 years ago

Great tool @cgatno, keep the good work 👍 . Lets connect and do great stuffs https://marcus-hiles.com/

codingedgar commented 5 years ago
  1. Conversion between imperial and metric units of the same physical property. This means volume <-> volume and mass <-> mass, for example. This would mean adding methods like toMilliliters() to the library.
  2. Conversion between physical properties for common cooking ingredients. This would allow for volume <-> mass conversions. This is the tougher problem, but I think it could be addressed by creating a table of densities for common items like flour, coffee, sugar, etc.

Hi! great library, I think both of this use cases present themself frequently with recipes.

For the second point maybe a complement like Moment timezone, could store all the transformations density of common ingredient, and some way to add explicit densities would be great.