working example
This commit is contained in:
35
dist/adapters/music/VinylCatalog.js
vendored
35
dist/adapters/music/VinylCatalog.js
vendored
@@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Track_1 = require("../../domain/models/Track");
|
||||
var VinylCatalog = /** @class */ (function () {
|
||||
function VinylCatalog() {
|
||||
this.vinylList = new Array(new Track_1.Track(1, "DNA.", "Kendrick Lamar", 340), new Track_1.Track(2, "Come Down", "Anderson Paak.", 430), new Track_1.Track(3, "DNA.", "Kendrick Lamar", 340), new Track_1.Track(4, "DNA.", "Kendrick Lamar", 340), new Track_1.Track(5, "DNA.", "Kendrick Lamar", 340));
|
||||
}
|
||||
VinylCatalog.prototype.get = function () {
|
||||
return this.vinylList;
|
||||
};
|
||||
VinylCatalog.prototype.getById = function (id) {
|
||||
return this.vinylList.filter(function (track) { return track.Id == id; }).pop();
|
||||
};
|
||||
VinylCatalog.prototype.add = function (track) {
|
||||
return this.vinylList.push(track);
|
||||
};
|
||||
VinylCatalog.prototype.edit = function (id, track) {
|
||||
var existingTrack = this.getById(id);
|
||||
existingTrack.Artist = track.Artist;
|
||||
existingTrack.Title = track.Title;
|
||||
existingTrack.Duration = track.Duration;
|
||||
return existingTrack;
|
||||
};
|
||||
VinylCatalog.prototype.delete = function (id) {
|
||||
var track = this.getById(id);
|
||||
if (track) {
|
||||
var targetIndex = this.vinylList.indexOf(track);
|
||||
if (targetIndex < -1)
|
||||
return null;
|
||||
return this.vinylList.splice(targetIndex, 1)[0];
|
||||
}
|
||||
};
|
||||
return VinylCatalog;
|
||||
}());
|
||||
exports.VinylCatalog = VinylCatalog;
|
||||
Reference in New Issue
Block a user