Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/durationjs/src/duration.ts>matchUnit

Get the formated time duration
Latest
function matchUnit
import { matchUnit } from "https://deno.land/x/durationjs@v4.1.1/src/duration.ts";

Match a unit in a string. Like "1kg", "3L", etc.

Parameters

str: string

String to match from

t: string

Unit to look for. Doesn't support aliases.

Returns

number

value Value of the unit matched