changelog-guru
Version:
Git changelog generator
37 lines (36 loc) • 2.04 kB
JavaScript
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var _Author_priority;
import Entity, { Priority } from './Entity.js';
const DEFAULT_AVATAR_SIZE = 40;
const PRIORITY_INCREASE_STEP = 1;
const URL_SIZE_PARAMETER_NAME = 's';
class Author extends Entity {
constructor({ login, url, avatar }) {
super(`@${login}`);
_Author_priority.set(this, Priority.Low);
const avatarUrl = new URL(avatar);
avatarUrl.searchParams.delete(URL_SIZE_PARAMETER_NAME);
avatarUrl.searchParams.append(URL_SIZE_PARAMETER_NAME, `${DEFAULT_AVATAR_SIZE}`);
this.url = url;
this.login = login;
this.avatar = `${avatarUrl}`;
}
get priority() {
return __classPrivateFieldGet(this, _Author_priority, "f");
}
contribute(value = PRIORITY_INCREASE_STEP) {
__classPrivateFieldSet(this, _Author_priority, __classPrivateFieldGet(this, _Author_priority, "f") + Math.max(0, value), "f");
}
}
_Author_priority = new WeakMap();
export default Author;