musicbrainz-api
Advanced tools
Comparing version 0.18.2 to 0.19.0
export * from './coverartarchive-api.js'; | ||
export * from './musicbrainz-api.js'; | ||
/** | ||
* CommonJS (only) function to load `musicbrainz-api` ESM module | ||
*/ | ||
export declare function loadMusicBrainzApi(): Promise<typeof import('musicbrainz-api')>; |
{ | ||
"name": "musicbrainz-api", | ||
"version": "0.18.2", | ||
"version": "0.19.0", | ||
"description": "MusicBrainz API client for reading and submitting metadata", | ||
"exports": "./lib/index.js", | ||
"exports": { | ||
"import": "./lib/index.js", | ||
"require": "./lib/default.cjs" | ||
}, | ||
"types": "lib/index.d.ts", | ||
"files": [ | ||
"lib/**/*.js", | ||
"lib/**/*.d.ts" | ||
"lib/**/*.d.ts", | ||
"lib/default.cjs" | ||
], | ||
@@ -11,0 +15,0 @@ "type": "module", |
@@ -14,4 +14,6 @@ [![Node.js CI](https://github.com/Borewit/musicbrainz-api/actions/workflows/nodejs-ci.yml/badge.svg)](https://github.com/Borewit/musicbrainz-api/actions/workflows/nodejs-ci.yml) | ||
A MusicBrainz-API-client for reading and submitting metadata | ||
A MusicBrainz-API-client for reading and submitting metadata. | ||
<img src="doc/musicbrainz-api-logo.png" width="40%" style="center"></img> | ||
## Features | ||
@@ -28,2 +30,5 @@ - **Access Metadata**: Retrieve detailed metadata from the [MusicBrainz database](https://musicbrainz.org/). | ||
> [!NOTE] | ||
> See also [CommonJS backward compatibility](#commonjs-backward-compatibility) | ||
### Requirements | ||
@@ -71,2 +76,5 @@ - Node.js: Requires [Node.js version 16](https://nodejs.org/en/about/previous-releases) or higher. | ||
> [!NOTE] | ||
> See also [CommonJS backward compatibility](#commonjs-backward-compatibility) | ||
### Configuration Options | ||
@@ -469,1 +477,27 @@ | ||
## CommonJS backward compatibility | ||
For legacy CommonJS projects needing to load the `music-metadata` ESM module, you can use the `loadMusicMetadata` function: | ||
```js | ||
const { loadMusicBrainzApi } = require('musicbrainz-api'); | ||
(async () => { | ||
// Dynamically loads the ESM module in a CommonJS project | ||
const {MusicBrainzApi} = await loadMusicBrainzApi(); | ||
const mbApi = new MusicBrainzApi({ | ||
appName: 'my-app', | ||
appVersion: '0.1.0', | ||
appContactInfo: 'user@mail.org', | ||
}); | ||
const releaseList = await mbApi.search('release', {query: {barcode: 602537479870}}); | ||
for(const release of releaseList.releases) { | ||
console.log(release.title); | ||
} | ||
})(); | ||
``` | ||
> [!NOTE] | ||
> The `loadMusicMetadata` function is experimental. |
71338
23
1470
500