added example files
This commit is contained in:
35
dist/adapters/music/VinylCatalog.js
vendored
Normal file
35
dist/adapters/music/VinylCatalog.js
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"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;
|
||||
2
dist/domain/factories/IPortProvider.js
vendored
Normal file
2
dist/domain/factories/IPortProvider.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
12
dist/domain/models/Track.js
vendored
Normal file
12
dist/domain/models/Track.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var Track = /** @class */ (function () {
|
||||
function Track(id, title, artist, duration) {
|
||||
this.Id = id;
|
||||
this.Title = title;
|
||||
this.Artist = artist;
|
||||
this.Duration = duration;
|
||||
}
|
||||
return Track;
|
||||
}());
|
||||
exports.Track = Track;
|
||||
2
dist/domain/ports/IMusicRepository.js
vendored
Normal file
2
dist/domain/ports/IMusicRepository.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
24
dist/domain/services/MusicCatalogService.js
vendored
Normal file
24
dist/domain/services/MusicCatalogService.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var MusicCatalogService = /** @class */ (function () {
|
||||
function MusicCatalogService(repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
MusicCatalogService.prototype.get = function () {
|
||||
return this.repository.get();
|
||||
};
|
||||
MusicCatalogService.prototype.getById = function (id) {
|
||||
return this.repository.getById(id);
|
||||
};
|
||||
MusicCatalogService.prototype.add = function (track) {
|
||||
return this.repository.add(track);
|
||||
};
|
||||
MusicCatalogService.prototype.edit = function (id, track) {
|
||||
return this.repository.edit(id, track);
|
||||
};
|
||||
MusicCatalogService.prototype.delete = function (id) {
|
||||
return this.repository.delete(id);
|
||||
};
|
||||
return MusicCatalogService;
|
||||
}());
|
||||
exports.MusicCatalogService = MusicCatalogService;
|
||||
20
dist/view/MusicComponent.js
vendored
Normal file
20
dist/view/MusicComponent.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var MusicCatalogService_1 = require("../domain/services/MusicCatalogService");
|
||||
var VinylCatalog_1 = require("../adapters/music/VinylCatalog");
|
||||
var MusicComponent = /** @class */ (function () {
|
||||
function MusicComponent() {
|
||||
var container = {
|
||||
IMusicRepository: function () { return new VinylCatalog_1.VinylCatalog(); }
|
||||
};
|
||||
var inject = function (name) {
|
||||
if (container[name]) {
|
||||
return container[name];
|
||||
}
|
||||
throw new Error("Failed to resolve " + name);
|
||||
};
|
||||
var musicCatalogService = new MusicCatalogService_1.MusicCatalogService(inject("IMusicRepository"));
|
||||
}
|
||||
return MusicComponent;
|
||||
}());
|
||||
exports.MusicComponent = MusicComponent;
|
||||
9
dist/view/MusicComponent.spec.js
vendored
Normal file
9
dist/view/MusicComponent.spec.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var MusicComponent_1 = require("./MusicComponent");
|
||||
describe("MusicComponent", function () {
|
||||
it('should create a new MusicComponent', function (done) {
|
||||
var musicComponent = new MusicComponent_1.MusicComponent();
|
||||
done();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user