diff options
author | sanine-a <sanine.not@pm.me> | 2023-08-01 17:40:53 -0500 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2023-08-01 17:40:53 -0500 |
commit | eb03b3a341f3c8152db4ee2ee99b85cffb27796e (patch) | |
tree | b617069542b540cc9083f8481c881fc6a3819e52 /src/util.js | |
parent | 6aae1f6fb4cf289ecf5ed318b34c0e7df62bbf83 (diff) |
add util.js
Diffstat (limited to 'src/util.js')
-rw-r--r-- | src/util.js | 10 |
1 files changed, 10 insertions, 0 deletions
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);
+};
|