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

format-quantity

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

format-quantity - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

dist/format-quantity.test.d.ts

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## 0.6.0 (2019-08-31)
- Added ability to produce unicode vulgar fractions (pass `true` as the second argument)
## 0.5.0 (2019-08-24)

@@ -2,0 +6,0 @@

26

dist/format-quantity.cjs.js

@@ -36,18 +36,18 @@ 'use strict';

if (closeEnough(dDecimal, 0.33)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2153' : '1/3');
return "" + sFloorFinal + (useVulgarFractions ? '⅓' : '1/3');
}
else if (closeEnough(dDecimal, 0.66)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2154' : '2/3');
return "" + sFloorFinal + (useVulgarFractions ? '⅔' : '2/3');
}
else if (closeEnough(dDecimal, 0.2)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2155' : '1/5');
return "" + sFloorFinal + (useVulgarFractions ? '⅕' : '1/5');
}
else if (closeEnough(dDecimal, 0.4)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2156' : '2/5');
return "" + sFloorFinal + (useVulgarFractions ? '⅖' : '2/5');
}
else if (closeEnough(dDecimal, 0.6)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2157' : '3/5');
return "" + sFloorFinal + (useVulgarFractions ? '⅗' : '3/5');
}
else if (closeEnough(dDecimal, 0.8)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2158' : '4/5');
return "" + sFloorFinal + (useVulgarFractions ? '⅘' : '4/5');
}

@@ -57,15 +57,15 @@ else {

case 0.125:
return "" + sFloorFinal + (useVulgarFractions ? '\u215B' : '1/8');
return "" + sFloorFinal + (useVulgarFractions ? '⅛' : '1/8');
case 0.25:
return "" + sFloorFinal + (useVulgarFractions ? '\u00BC' : '1/4');
return "" + sFloorFinal + (useVulgarFractions ? '¼' : '1/4');
case 0.375:
return "" + sFloorFinal + (useVulgarFractions ? '\u215C' : '3/8');
return "" + sFloorFinal + (useVulgarFractions ? '⅜' : '3/8');
case 0.5:
return "" + sFloorFinal + (useVulgarFractions ? '\u00BD' : '1/2');
return "" + sFloorFinal + (useVulgarFractions ? '½' : '1/2');
case 0.625:
return "" + sFloorFinal + (useVulgarFractions ? '\u215D' : '5/8');
return "" + sFloorFinal + (useVulgarFractions ? '⅝' : '5/8');
case 0.75:
return "" + sFloorFinal + (useVulgarFractions ? '\u00BE' : '3/4');
return "" + sFloorFinal + (useVulgarFractions ? '¾' : '3/4');
case 0.875:
return "" + sFloorFinal + (useVulgarFractions ? '\u215E' : '7/8');
return "" + sFloorFinal + (useVulgarFractions ? '⅞' : '7/8');
}

@@ -72,0 +72,0 @@ }

@@ -7,3 +7,3 @@ /**

*/
declare function formatQuantity(qty: string | number, useVulgarFractions?: boolean): string;
declare function formatQuantity(qty: string | number, useVulgarFractions?: boolean): string | null;
export default formatQuantity;

@@ -34,18 +34,18 @@ /**

if (closeEnough(dDecimal, 0.33)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2153' : '1/3');
return "" + sFloorFinal + (useVulgarFractions ? '⅓' : '1/3');
}
else if (closeEnough(dDecimal, 0.66)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2154' : '2/3');
return "" + sFloorFinal + (useVulgarFractions ? '⅔' : '2/3');
}
else if (closeEnough(dDecimal, 0.2)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2155' : '1/5');
return "" + sFloorFinal + (useVulgarFractions ? '⅕' : '1/5');
}
else if (closeEnough(dDecimal, 0.4)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2156' : '2/5');
return "" + sFloorFinal + (useVulgarFractions ? '⅖' : '2/5');
}
else if (closeEnough(dDecimal, 0.6)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2157' : '3/5');
return "" + sFloorFinal + (useVulgarFractions ? '⅗' : '3/5');
}
else if (closeEnough(dDecimal, 0.8)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2158' : '4/5');
return "" + sFloorFinal + (useVulgarFractions ? '⅘' : '4/5');
}

@@ -55,15 +55,15 @@ else {

case 0.125:
return "" + sFloorFinal + (useVulgarFractions ? '\u215B' : '1/8');
return "" + sFloorFinal + (useVulgarFractions ? '⅛' : '1/8');
case 0.25:
return "" + sFloorFinal + (useVulgarFractions ? '\u00BC' : '1/4');
return "" + sFloorFinal + (useVulgarFractions ? '¼' : '1/4');
case 0.375:
return "" + sFloorFinal + (useVulgarFractions ? '\u215C' : '3/8');
return "" + sFloorFinal + (useVulgarFractions ? '⅜' : '3/8');
case 0.5:
return "" + sFloorFinal + (useVulgarFractions ? '\u00BD' : '1/2');
return "" + sFloorFinal + (useVulgarFractions ? '½' : '1/2');
case 0.625:
return "" + sFloorFinal + (useVulgarFractions ? '\u215D' : '5/8');
return "" + sFloorFinal + (useVulgarFractions ? '⅝' : '5/8');
case 0.75:
return "" + sFloorFinal + (useVulgarFractions ? '\u00BE' : '3/4');
return "" + sFloorFinal + (useVulgarFractions ? '¾' : '3/4');
case 0.875:
return "" + sFloorFinal + (useVulgarFractions ? '\u215E' : '7/8');
return "" + sFloorFinal + (useVulgarFractions ? '⅞' : '7/8');
}

@@ -70,0 +70,0 @@ }

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.formatQuantity = factory());
}(this, function () { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.formatQuantity = factory());
}(this, (function () { 'use strict';

@@ -40,18 +40,18 @@ /**

if (closeEnough(dDecimal, 0.33)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2153' : '1/3');
return "" + sFloorFinal + (useVulgarFractions ? '⅓' : '1/3');
}
else if (closeEnough(dDecimal, 0.66)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2154' : '2/3');
return "" + sFloorFinal + (useVulgarFractions ? '⅔' : '2/3');
}
else if (closeEnough(dDecimal, 0.2)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2155' : '1/5');
return "" + sFloorFinal + (useVulgarFractions ? '⅕' : '1/5');
}
else if (closeEnough(dDecimal, 0.4)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2156' : '2/5');
return "" + sFloorFinal + (useVulgarFractions ? '⅖' : '2/5');
}
else if (closeEnough(dDecimal, 0.6)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2157' : '3/5');
return "" + sFloorFinal + (useVulgarFractions ? '⅗' : '3/5');
}
else if (closeEnough(dDecimal, 0.8)) {
return "" + sFloorFinal + (useVulgarFractions ? '\u2158' : '4/5');
return "" + sFloorFinal + (useVulgarFractions ? '⅘' : '4/5');
}

@@ -61,15 +61,15 @@ else {

case 0.125:
return "" + sFloorFinal + (useVulgarFractions ? '\u215B' : '1/8');
return "" + sFloorFinal + (useVulgarFractions ? '⅛' : '1/8');
case 0.25:
return "" + sFloorFinal + (useVulgarFractions ? '\u00BC' : '1/4');
return "" + sFloorFinal + (useVulgarFractions ? '¼' : '1/4');
case 0.375:
return "" + sFloorFinal + (useVulgarFractions ? '\u215C' : '3/8');
return "" + sFloorFinal + (useVulgarFractions ? '⅜' : '3/8');
case 0.5:
return "" + sFloorFinal + (useVulgarFractions ? '\u00BD' : '1/2');
return "" + sFloorFinal + (useVulgarFractions ? '½' : '1/2');
case 0.625:
return "" + sFloorFinal + (useVulgarFractions ? '\u215D' : '5/8');
return "" + sFloorFinal + (useVulgarFractions ? '⅝' : '5/8');
case 0.75:
return "" + sFloorFinal + (useVulgarFractions ? '\u00BE' : '3/4');
return "" + sFloorFinal + (useVulgarFractions ? '¾' : '3/4');
case 0.875:
return "" + sFloorFinal + (useVulgarFractions ? '\u215E' : '7/8');
return "" + sFloorFinal + (useVulgarFractions ? '⅞' : '7/8');
}

@@ -82,2 +82,2 @@ }

}));
})));
{
"name": "format-quantity",
"version": "0.6.0",
"version": "0.6.1",
"description": "Format a number as an integer plus fraction, as seen in recipe ingredient lists",

@@ -19,3 +19,5 @@ "repository": {

"dev": "rollup -c -w",
"test": "jest"
"pretty-print": "npx prettier --write ./src/**/*",
"publish:npm": "np",
"test": "jest --coverage"
},

@@ -40,9 +42,11 @@ "keywords": [

"@babel/preset-typescript": "^7.3.3",
"@types/jest": "^24.0.18",
"babel-jest": "^24.9.0",
"jest": "^24.9.0",
"rollup": "^1.20.0",
"rollup-plugin-typescript2": "^0.23.0",
"typescript": "^3.5.3"
"@types/jest": "^26.0.15",
"babel-jest": "^26.0.1",
"jest": "^26.0.1",
"np": "^7.0.0",
"prettier": "2.2.1",
"rollup": "^2.13.1",
"rollup-plugin-typescript2": "^0.29.0",
"typescript": "^4.0.5"
}
}
# format-quantity
[![npm version](https://badge.fury.io/js/format-quantity.svg)](//npmjs.com/package/format-quantity)
[![Travis (.org)](https://img.shields.io/travis/jakeboone02/format-quantity)](https://travis-ci.org/jakeboone02/format-quantity)
![workflow status](https://github.com/jakeboone02/format-quantity/workflows/Continuous%20Integration/badge.svg)
[![codecov.io](https://codecov.io/github/jakeboone02/format-quantity/coverage.svg?branch=master)](https://codecov.io/github/jakeboone02/format-quantity?branch=master)

@@ -6,0 +6,0 @@ [![downloads](https://img.shields.io/npm/dm/format-quantity.svg)](http://npm-stat.com/charts.html?package=format-quantity&from=2015-08-01)

Sorry, the diff of this file is not supported yet

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