Skip to content

Commit

Permalink
docs: fix old example output for converting to best unit
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahsnider committed Oct 27, 2024
1 parent 1a4eac6 commit 934d592
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ convert(20n, "hours").to("minutes");

// Format to the best unit automatically
convert(5500, "meters").to("best");
// -> { quantity: 5.5, unit: 'km', toString: () => '5.5km' }
// -> { quantity: 5.5, unit: 'km', toString: () => '5.5 km' }

// You can also do length, data, volume, mass, temperature, and more
convert(5, "kilometers").to("nautical miles");
Expand Down Expand Up @@ -76,16 +76,16 @@ const { convert } = require("convert");

// Convert into the best unit
const duration = convert(36, "h").to("best");
// -> { quantity: 1.5, unit: 'd', toString: () => '1.5d' }
// -> { quantity: 1.5, unit: 'd', toString: () => '1.5 d' }

// The toString() method means you can automatically cast the object to a string without any issues
"duration is " + duration;
// -> duration is 1.5d

// You can also specify to use a specific kind of units (metric or imperial, metric is default)
convert(3.5, "km").to("best"); // -> { quantity: 3.5, unit: 'km', toString: () => '3.5km' }
convert(3.5, "km").to("best", "metric"); // -> { quantity: 3.5, unit: 'km', toString: () => '3.5km' }
convert(3.5, "km").to("best", "imperial"); // -> { quantity: 2.17, unit: 'mi', toString: () => '3.5mi' }
convert(3.5, "km").to("best"); // -> { quantity: 3.5, unit: 'km', toString: () => '3.5 km' }
convert(3.5, "km").to("best", "metric"); // -> { quantity: 3.5, unit: 'km', toString: () => '3.5 km' }
convert(3.5, "km").to("best", "imperial"); // -> { quantity: 2.17, unit: 'mi', toString: () => '3.5 mi' }
```

### `ms` shorthand
Expand Down

0 comments on commit 934d592

Please sign in to comment.