UNPKG

goodreads-bookshelf

Version:
60 lines (59 loc) 1.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Book = void 0; var Book = /** @class */ (function () { function Book(bookDto) { this._title = bookDto.title; this._author = bookDto.author; this._isbn13 = bookDto.isbn13; this._imageUrl = bookDto.imageUrl; this._link = bookDto.link; this._dateStarted = this.parseDate(bookDto.dateStarted); this._dateFinished = this.parseDate(bookDto.dateFinished); this._rating = bookDto.rating; this._shelf = bookDto.shelf; } Book.prototype.parseDate = function (input) { var parts = input.split(' '); var monthIndex = this.monthIndex(parts[1]); var day = Number(parts[2]); var year = Number(parts[5]); return new Date(year, monthIndex, day); }; Book.prototype.monthIndex = function (monthAbbr) { var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; return months.findIndex(function (a) { return a === monthAbbr; }); }; Book.prototype.title = function () { return this._title; }; Book.prototype.author = function () { return this._author; }; Book.prototype.imageUrl = function () { return this._imageUrl; }; Book.prototype.localImageUrl = function () { return this._isbn13 ? this._isbn13 + ".jpg" : ''; }; Book.prototype.link = function () { return this._link; }; Book.prototype.dateStarted = function () { return this._dateStarted; }; Book.prototype.dateFinished = function () { return this._dateFinished; }; Book.prototype.yearFinished = function () { return this._dateFinished.getFullYear(); }; Book.prototype.rating = function () { return this._rating; }; Book.prototype.shelf = function () { return this._shelf; }; return Book; }()); exports.Book = Book;