1.0.2 • Published 6 years ago

dxmp-common v1.0.2

Weekly downloads
2
License
WTFPL
Repository
github
Last release
6 years ago

dxmp-common

Provides a set of common interfaces and utilities for dxmp.

Installation

npm install --save dxmp-common

All members are named exports and can be imported via destructuring:

import { Dictionary, createPerma } from 'dxmp-common';

Interfaces

Dictionary

A common interface to type a hash map. The hash key is always a string.

import { Dictionary } from 'dxmp-common';
const hashOfNumbers: Dictionary<number>;

IAlbum

PropertyTypeDescription
idnumberThe database ID of the album
titlestringAlbum title
wallpaperbooleanWhether the album has wallpaper. If so, the filename will be the {perma-slug}-album-wallpaper.jpg (see createPerma)
artbooleanWhether the album has album art. If so, the filename will be the {perma-slug}-album-art.jpg (see createPerma)

ISong

PropertyTypeDescription
idnumberThe database ID of the song
titlestringSong title
albumIdnumberThe ID of the album that the song belongs to
artistId?numberThe ID of the song's artist
filenamestringThe name of the song's MP3 file
durationnumberThe length of the song in seconds
track?numberThe song's on disc track number
disc?numberThe song's disc number within a series
createdAtnumberThe Unix timestamp the song was uploaded
addedBy?numberThe ID of the user that added the song

ITracking

PropertyTypeDescription
songIdnumberThe ID of the song tracked
userIdnumberThe ID of the user that triggered the tracking
typeTrackingTypeThe type of event being tracked
createdAtThe Unix timestamp when the tracking event occurred

Enums

AlbumImageType

NameDescription
ARTAlbum art
WALLPAPERAlbum wallpaper

TrackingType

NameDescription
STARTThe user started playing a song
FINISHThe user finished listening to a song
SKIPThe user skipped a song

Methods

createPerma(text: string): string

Takes a string and returns a dxmpv2 compatible perma slug.

isNumeric(val: any): boolean

Takes a value and returns whether that value is numeric. Works on both integers and floating values.

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago