# @tonaljs/duration-value

> Musical duration values

Latest version **4.9.0** (published 2024-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tonaljs/duration-value
pnpm add @tonaljs/duration-value
yarn add @tonaljs/duration-value
bun add @tonaljs/duration-value
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.9.0 |
| Published | 2024-07-23 |
| First published | 2020-03-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | danigb@gmail.com |
| Maintainers | danigb |
| Keywords | duration-value, music, theory |

## Links

- npm: https://www.npmjs.com/package/@tonaljs/duration-value
- npm.io page: https://npm.io/package/@tonaljs/duration-value

## Recent versions

- 4.9.0 (latest) — 2024-07-23
- 4.8.1 — 2024-01-04
- 4.8.0 — 2022-11-29
- 4.7.3 — 2022-11-29
- 4.7.2 — 2022-11-29
- 4.7.1 — 2022-11-29
- 4.7.0 — 2022-11-28
- 4.6.10 — 2022-11-18
- 4.6.2 — 2021-07-12
- 4.5.1 — 2020-11-05
- 4.5.0 — 2020-11-04
- 3.6.3 — 2020-05-04
- 3.6.2 — 2020-04-27
- 3.6.1 — 2020-04-27
- 3.6.0 — 2020-03-15

## README

# @tonaljs/duration-value ![tonal](https://img.shields.io/badge/@tonaljs-duration_value-yellow.svg?style=flat-square) [![npm version](https://img.shields.io/npm/v/@tonaljs/duration-value.svg?style=flat-square)](https://www.npmjs.com/package/@tonaljs/duration-value)

> Functions to parse and manipulate time duration values

## Usage

ES6:

```js
import { DurationValue } from "tonal";
```

node:

```js
const { DurationValue } = require("tonal");
```

single module:

```js
import DurationValue from "@tonaljs/duration-value";
```

## API

#### `DurationValue.names() => string[]`

Return all duration names

```js
DurationValue.names(); // => ["large", "duplex longa", ...]
```

#### `DurationValue.shorthands() => string[]`

Return all duration value shorthands

```js
DurationValue.shorthands(); // => ["dl", "l", "d", "w", "h", "q", "e", "s", "t", "sf", "h", "th"]
```

#### `DurationValue.get(name: string) // => object`

Get a duration value object from name:

```js
DurationValue.get("quarter"); // =>
// {
//   empty: false,
//   name: 'q',
//   value: 0.25,
//   fraction: [ 1, 4 ],
//   shorthand: 'q',
//   dots: '',
//   names: [ 'quarter', 'crotchet' ]
// }
```

The name accepts an arbitrary number of dots:

```js
DurationValue.get("quarter.."); // =>
// {
//   empty: false,
//   name: 'q..',
//   value: 0.4375,
//   fraction: [ 7, 16 ],
//   shorthand: 'q',
//   dots: '..',
//   names: [ 'quarter', 'crotchet' ]
// }
```

Short names are accepted:

```js
DurationValue.get("q") == DurationValue.get("quarter");
DurationValue.get("q.") == DurationValue.get("quarter.");
DurationValue.get("q..") == DurationValue.get("quarter..");
```

Some aliases (`value` and `fraction`) are provided:

```js
DurationValue.value("q.."); // => 0.4375
DurationValue.fraction("q.."); // => [ 7, 16 ]
```

## References

- https://en.wikipedia.org/wiki/Note_value

---
_Source: https://npm.io/package/@tonaljs/duration-value · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
