const MamiCompat = (path, handler) => { if(typeof path !== 'string') throw 'path must be a string'; if(typeof handler !== 'object') throw 'handler must be a property definition'; path = path.split('.'); const final = path.pop(); if(final === undefined) throw 'invalid path'; let current = window; for(const part of path) { if(!(part in current)) current[part] = {}; current = current[part]; } if(!(final in current)) Object.defineProperty(current, final, handler); };