adjusted authorship

This commit is contained in:
Christian Fraß 2020-04-04 14:33:48 +02:00
parent 5ce78cc262
commit f93c042adc
3 changed files with 24 additions and 24 deletions

View file

@ -3,7 +3,7 @@ export /*abstract */class Cache {
/** /**
* @param {string} key * @param {string} key
* @return {boolean} * @return {boolean}
* @author fenris * @author svartoyg
*/ */
/*protected */has(key) { /*protected */has(key) {
throw (new Error('not implemented')); throw (new Error('not implemented'));
@ -12,7 +12,7 @@ export /*abstract */class Cache {
/** /**
* @param {string} key * @param {string} key
* @return {any} * @return {any}
* @author fenris * @author svartoyg
*/ */
/*protected */fetch(key) { /*protected */fetch(key) {
throw (new Error('not implemented')); throw (new Error('not implemented'));
@ -21,7 +21,7 @@ export /*abstract */class Cache {
/** /**
* @param {string} key * @param {string} key
* @param {any} value * @param {any} value
* @author fenris * @author svartoyg
*/ */
/*protected */store(key, value) { /*protected */store(key, value) {
throw (new Error('not implemented')); throw (new Error('not implemented'));
@ -31,7 +31,7 @@ export /*abstract */class Cache {
* @param {string} key * @param {string} key
* @param {()=>Promise<any>} retrieve * @param {()=>Promise<any>} retrieve
* @return {Promise<any>} * @return {Promise<any>}
* @author fenris * @author svartoyg
*/ */
/*public */async get(key, retrieve) { /*public */async get(key, retrieve) {
if (this.has(key)) { if (this.has(key)) {
@ -47,32 +47,32 @@ export /*abstract */class Cache {
/** /**
* @author fenris * @author svartoyg
*/ */
class CacheNone extends Cache { class CacheNone extends Cache {
/** /**
* @author fenris * @author svartoyg
*/ */
/*public */constructor() { /*public */constructor() {
super(); super();
} }
/** /**
* @author fenris * @author svartoyg
*/ */
/*protected */has(key) { /*protected */has(key) {
return false; return false;
} }
/** /**
* @author fenris * @author svartoyg
*/ */
/*protected */fetch(key) { /*protected */fetch(key) {
throw (new Error('not possible')); throw (new Error('not possible'));
} }
/** /**
* @author fenris * @author svartoyg
*/ */
/*protected */store(key, value) { /*protected */store(key, value) {
} }
@ -80,12 +80,12 @@ class CacheNone extends Cache {
/** /**
* @author fenris * @author svartoyg
*/ */
export class CacheLocalstorage extends Cache { export class CacheLocalstorage extends Cache {
/** /**
* @param {string} [corner] for separating the cache instance from others * @param {string} [corner] for separating the cache instance from others
* @author fenris * @author svartoyg
*/ */
/*public */constructor(corner = null) { /*public */constructor(corner = null) {
super(); super();
@ -93,21 +93,21 @@ export class CacheLocalstorage extends Cache {
} }
/** /**
* @author fenris * @author svartoyg
*/ */
/*private */augmentKey(key) { /*private */augmentKey(key) {
return ((this.corner === null) ? key : (this.corner + '/' + key)); return ((this.corner === null) ? key : (this.corner + '/' + key));
} }
/** /**
* @author fenris * @author svartoyg
*/ */
/*protected */has(key) { /*protected */has(key) {
return (window.localStorage.getItem(this.augmentKey(key)) !== null); return (window.localStorage.getItem(this.augmentKey(key)) !== null);
} }
/** /**
* @author fenris * @author svartoyg
*/ */
/*protected */fetch(key) { /*protected */fetch(key) {
const valueRaw = window.localStorage.getItem(this.augmentKey(key)); const valueRaw = window.localStorage.getItem(this.augmentKey(key));
@ -116,7 +116,7 @@ export class CacheLocalstorage extends Cache {
} }
/** /**
* @author fenris * @author svartoyg
*/ */
/*protected */store(key, value) { /*protected */store(key, value) {
const valueRaw = JSON.stringify(value); const valueRaw = JSON.stringify(value);

View file

@ -3,7 +3,7 @@
* @param {string} path * @param {string} path
* @return Promise<string> * @return Promise<string>
* @todo use Util.fetch instead? * @todo use Util.fetch instead?
* @author fenris * @author svartoyg
*/ */
export async function read (path) { export async function read (path) {
return ( return (

View file

@ -7,7 +7,7 @@ import {read as fileRead} from './file';
* the relative path to the directory containing the JSON localization files * the relative path to the directory containing the JSON localization files
* *
* @var {string} * @var {string}
* @author fenris * @author svartoyg
*/ */
var _directory = 'loc'; var _directory = 'loc';
@ -16,7 +16,7 @@ var _directory = 'loc';
* the default language to use * the default language to use
* *
* @var {string} * @var {string}
* @author fenris * @author svartoyg
*/ */
var _languageDefault = null; var _languageDefault = null;
@ -25,14 +25,14 @@ var _languageDefault = null;
* the fallback language to use * the fallback language to use
* *
* @var {string} * @var {string}
* @author fenris * @author svartoyg
*/ */
var _languageFallback = null; var _languageFallback = null;
/** /**
* @var {Cache} * @var {Cache}
* @author fenris * @author svartoyg
*/ */
var _cache = null; var _cache = null;
@ -41,7 +41,7 @@ var _cache = null;
* two level map with ISO-639-1 code as first key and translation id as second key * two level map with ISO-639-1 code as first key and translation id as second key
* *
* @var {Map<string,Map<string,string>>} * @var {Map<string,Map<string,string>>}
* @author fenris * @author svartoyg
*/ */
var _data = {}; var _data = {};
@ -49,7 +49,7 @@ var _data = {};
/** /**
* @param {string} language * @param {string} language
* @return Promise<Map<string,string>> * @return Promise<Map<string,string>>
* @author fenris * @author svartoyg
*/ */
async function retrieveData (language) { async function retrieveData (language) {
const regexp = (new RegExp("^([a-z]{2})$")); const regexp = (new RegExp("^([a-z]{2})$"));
@ -77,7 +77,7 @@ async function retrieveData (language) {
/** /**
* @param {string} languageDefault * @param {string} languageDefault
* @param {string} [languageFallback] * @param {string} [languageFallback]
* @author fenris * @author svartoyg
*/ */
export async function initialize (languageDefault, languageFallback = 'en') { export async function initialize (languageDefault, languageFallback = 'en') {
_cache = new CacheLocalstorage('loc'); _cache = new CacheLocalstorage('loc');
@ -103,7 +103,7 @@ export async function initialize (languageDefault, languageFallback = 'en') {
* @param {string} key * @param {string} key
* @param {string} [languageChosen] * @param {string} [languageChosen]
* @return {string} * @return {string}
* @author fenris * @author svartoyg
*/ */
export function translate (key, languageChosen = _languageDefault) { export function translate (key, languageChosen = _languageDefault) {
let result = undefined; let result = undefined;