Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert to old fashioned javascript from the 1940s
- Loading branch information
Showing
1 changed file
with
10 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
const error = key => new Error(`Object does not contain ${key}`) | ||
module.exports = object => new Proxy(object, { | ||
get: (object, key) => { | ||
if (key in object) { | ||
return object[key] | ||
} else { | ||
throw error(key) | ||
module.exports = function (object) { | ||
return new Proxy(object, { | ||
get: function (object, key) { | ||
if (key in object) { | ||
return object[key] | ||
} else { | ||
throw new Error('Object does not contain ' + key) | ||
} | ||
} | ||
} | ||
}) | ||
}) | ||
} |