"use strict" ; export class DefaultDict { constructor ( defaultInit ) { return new Proxy ( { } , { get : ( target , name ) => name in target ? target [ name ] : ( target [ name ] = typeof defaultInit === 'function' ? new defaultInit ( ) . valueOf ( ) : defaultInit ) } ) ; } } export default class Utilities { /**
     * note that this returns true if obj evaluates to false.
     * (For example, of obj is null)
     */ static isEmpty ( obj ) { if ( ! obj ) return true ; return Object . keys ( obj ) . length === 0 ; } param object param key static flattenNestedObject < T > ( object , key ) { const objects = [ ] ; while ( object != null ) { objects . push ( object ) ; object = object [ key ] ; } return objects ; } param object param key static flattenNestedObjectWithMultipleKeys < T > ( object , keys ) { const objects = [ ] ; while ( object != null ) { objects . push ( object ) ; let innerObject ; for ( let index = 0 ; index < keys . length ; index ++ ) { innerObject = object [ keys [ index ] ] ; if ( innerObject ) break ; } object = innerObject ; } return objects ; } static sleep ( ms ) { return new Promise ( resolve => { setTimeout ( resolve , ms ) ; } ) ; } /**
     * returns trimmed last line (split by \n)
     */ static getLastLine ( input ) { return input . slice ( input . lastIndexOf ( '\n' ) ) . trim ( ) ; } param string static escapeHtml ( input ) { if ( input == null ) return null ; return input . replace ( /[&<>"'`=\/]/g , function ( s ) { return Utilities . entityMap [ s ] ; } ) ; } private static entityMap = { '"' : "&quot;" , "&" : "&amp;" , "'" : "&#39;" , "/" : "&#x2F;" , "<" : "&lt;" , "=" : "&#x3D;" , ">" : "&gt;" , "`" : "&#x60;" , } ; }