{"id":18645159,"url":"https://github.com/danigb/interval-parser","last_synced_at":"2025-04-11T12:31:17.497Z","repository":{"id":32274962,"uuid":"35849616","full_name":"danigb/interval-parser","owner":"danigb","description":"Music interval parser for javascript","archived":false,"fork":false,"pushed_at":"2016-06-14T09:30:17.000Z","size":22,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T13:46:30.436Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danigb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-19T00:22:16.000Z","updated_at":"2021-05-17T16:42:58.000Z","dependencies_parsed_at":"2022-09-12T21:52:28.663Z","dependency_job_id":null,"html_url":"https://github.com/danigb/interval-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Finterval-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Finterval-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Finterval-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danigb%2Finterval-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danigb","download_url":"https://codeload.github.com/danigb/interval-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248401954,"owners_count":21097328,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T06:14:52.968Z","updated_at":"2025-04-11T12:31:17.222Z","avatar_url":"https://github.com/danigb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# interval-parser [![npm](https://img.shields.io/npm/v/interval-parser.svg?style=flat-square)](https://www.npmjs.com/package/interval-parser)\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) [![license](https://img.shields.io/npm/l/interval-parser.svg?style=flat-square)](https://www.npmjs.com/package/interval-parser)\n\nParses music intervals in shorthand notation:\n\n```js\nvar parser = require('interval-parser')\nparser.parse('P4')\n// =\u003e { num: 4, q: 'P', dir: 1, simple: 4, type: 'P', alt: 0, oct: 0, semitones: 5 }\n\n// accepts reverse shorthand notation\nparser.parse('6m')\n// =\u003e { num: 6, q: 'm', dir: 1, simple: 6, type: 'M', alt: -1, oct: 0, semitones: 8 }\n```\n\nIf you only need a property, you can use a function with the property name:\n\n```js\nparser.semitones('6m') // =\u003e 8\nparser.simple('9M') // =\u003e 2\n```\n\n#### Interval string format\n\nIt accepts two different interval string formats:\n\n- In standard shorthand notation: `quality+[dir]+num`. Examples: 'P8', 'M-3'\n- In reverse shorthand notation: `[dur]+num+quality`. Examples: '8P', '-3M'\n\n## API\n\n### `parse(str)`\n\nParse a string with an interval in [shorthand notation](https://en.wikipedia.org/wiki/Interval_(music)#Shorthand_notation)\nand returns an object with interval properties\n\n#### Parameters\n\n* `str` **`String`** the string with the interval\n\n\n#### Examples\n\n```js\nvar parser = require('interval-parser')\nparser.parse('P4')\n// =\u003e { num: 4, q: 'P', dir: 1, simple: 4, type: 'P', alt: 0, oct: 0, semitones: 5 }\n// accepts reverse shorthand notation\nparser.parse('6m')\n// =\u003e { num: 6, q: 'm', dir: 1, simple: 6, type: 'M', alt: -1, oct: 0, semitones: 8 }\n```\n\nReturns an object with interval properties or null if not valid interval string:\n\n- `num`: the interval number\n- `q`: the interval quality string (M is major, m is minor, P is perfect...)\n- `simple`: the simplified number (from 1 to 7)\n- `dir`: the interval direction (1 ascending, -1 descending)\n- `type`: the interval type (P is perfectable, M is majorable)\n- `alt`: the alteration, a numeric representation of the quality\n- `oct`: the number of octaves the interval spans. 0 for simple intervals.\n- `semitones`: the size of the interval in semitones\n\n### Helper functions\n\nFor each property of the interval there's a function with the same name that returns only that property:\n\n```js\nparser.num('9m') // =\u003e 9\nparser.q('9m') // =\u003e 'm'\nparser.simple('9m') // =\u003e 2\nparser.dir('9m') // =\u003e 1\nparser.type('9m') // =\u003e 'M'\nparser.alt('9m') // =\u003e -1\nparser.oct('9m') // =\u003e 1\nparser.semitones('9m') // =\u003e 13\n```\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanigb%2Finterval-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanigb%2Finterval-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanigb%2Finterval-parser/lists"}