Skip to content

Commit

Permalink
2.0.1
Browse files Browse the repository at this point in the history
Switched from es-shim Object.fromEntries polyfill to local TC39 proposal polyfill
  • Loading branch information
valentine195 committed Apr 6, 2021
1 parent 6ce5ca1 commit 62209c3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-admonition",
"name": "Admonition",
"version": "2.0.0",
"version": "2.0.1",
"minAppVersion": "0.11.0",
"description": "Admonition block-styled content for Obsidian.md",
"author": "Jeremy Valentine",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-admonition",
"version": "2.0.0",
"version": "2.0.1",
"description": "Admonition block-styled content for Obsidian.md",
"main": "main.js",
"scripts": {
Expand Down
36 changes: 28 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,34 @@ import {
Plugin
} from "obsidian";

import fromEntries from "object.fromentries/index";
if (!Object.fromEntries) {
//incorrect @types definition
//I tested that this correctly shims without error
//@ts-expect-error
fromEntries.shim();
}
Object.fromEntries =
Object.fromEntries ||
/** Polyfill taken from https://github.com/tc39/proposal-object-from-entries/blob/master/polyfill.js */
function <T = any>(
entries: Iterable<readonly [PropertyKey, T]>
): { [k: string]: T } {
const obj = {};

for (const pair of entries) {
if (Object(pair) !== pair) {
throw new TypeError(
"iterable for fromEntries should yield objects"
);
}
// Consistency with Map: contract is that entry has "0" and "1" keys, not
// that it is an array or iterable.
const { "0": key, "1": val } = pair;

Object.defineProperty(obj, key, {
configurable: true,
enumerable: true,
writable: true,
value: val
});
}

return obj;
};

import "./main.css";

Expand Down Expand Up @@ -58,7 +79,6 @@ export default class ObsidianAdmonition extends Plugin {
this.postprocessor.bind(this, type)
)
);

}
postprocessor(
type: string,
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"0.2.3": "0.11.0",
"1.0.1": "0.11.0",
"2.0.0": "0.11.0"
"2.0.1": "0.11.0"
}

0 comments on commit 62209c3

Please sign in to comment.