/* IRC-Bot "Kvasir" Copyright (C) 2016 Fenris Wolf (fenris@folksprak.org) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ /** * @author fenris */ function alporti(strukturo : Object, ernomo : string, kompensajxo : tipo_valoro = null, eskalumado : int = 1) : tipo_valoro { if (ernomo in strukturo) { return strukturo[ernomo]; } else { switch (eskalumado) { case 0: { return kompensajxo; break; } case 1: { let mesagxo : string = "la ero kun la nomo '" + ernomo + "' ne trovigxas en la strukturo; la kompensa valoro '" + String(kompensajxo) + " eldonitos"; console.warn(mesagxo); return kompensajxo; break; } case 2: { let mesagxo : string = "la ero kun la nomo '" + ernomo + "' ne trovigxas en la strukturo"; throw (new Error(mesagxo)); // break; } default: { throw (new Error("nevalida eskalumad-nivelo '" + eskalumado + "'")); break; } } } }