From eb03b3a341f3c8152db4ee2ee99b85cffb27796e Mon Sep 17 00:00:00 2001 From: sanine-a Date: Tue, 1 Aug 2023 17:40:53 -0500 Subject: add util.js --- src/util.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/util.js (limited to 'src/util.js') diff --git a/src/util.js b/src/util.js new file mode 100644 index 0000000..9f52551 --- /dev/null +++ b/src/util.js @@ -0,0 +1,10 @@ +'use strict'; + + +export function create(obj, proto=Object.prototype) { + const props = Object.keys(obj) + .map((key) => [ key, { value: obj[key], enumerable: true } ]) + .reduce((acc, [ key, value ]) => ({ ...acc, [key]: value }), {}); + + return Object.create(proto, props); +}; -- cgit v1.2.1