Skip to content

Commit

Permalink
add utils.artistsToMarkdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Luna-devv committed Jan 18, 2024
1 parent 0e9a691 commit 8d692cd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"oauth2",
"music"
],
"version": "0.1.8",
"version": "0.1.9",
"main": "dist/src/lib/index.js",
"types": "dist/src/lib/index.d.js",
"files": [
Expand Down
3 changes: 2 additions & 1 deletion src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ export class Lunify {

export * from './managers';
export * from './structures';
export * from './Constants';
export * from './Constants';
export * as utils from './utils';
14 changes: 14 additions & 0 deletions src/lib/utils/artistsToMarkdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { PartialArtist } from '../structures';

export const aristsToMarkdown = (artists: PartialArtist[], max?: number) => {
const arr = artists.map((artist) => `[${artist.name}](<https://open.spotify.com/artist/${artist.id}>)`);

if (max && arr.length > max) {
const shownArists = arr.slice(0, max).join(', ');
const remainingCount = Math.max(0, arr.length - max);

return `${shownArists} & ${remainingCount} more`;
}

return arr.join(', ');
};
1 change: 1 addition & 0 deletions src/lib/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './artistsToMarkdown';

0 comments on commit 8d692cd

Please sign in to comment.