tshet-uinh-autoderiver icon indicating copy to clipboard operation
tshet-uinh-autoderiver copied to clipboard

加入 minimal working example

Open graphemecluster opened this issue 1 year ago • 0 comments

https://github.com/nk2028/tshet-uinh-autoderiver/issues/10#issuecomment-1117890697 對應 TshetUinh.js v0.15 可改成

if (!音韻地位) {
  const 地位 = TshetUinh.音韻地位.from描述("幫三C凡入");
  const 屬性 =
    Object.getOwnPropertyNames(地位).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(地位)))
      .filter(prop => typeof 地位[prop] !== "function");
  return [
    ["音韻屬性", ["屬於", ...屬性, "屬於"]],
    ["表達式", 選項.音韻屬性 === "屬於" ? "冬韻 平聲" : null],
  ];
}
if (選項.音韻屬性 === "屬於") {
  const result = 音韻地位.屬於(選項.表達式);
  return ({ b, fg }) => fg(result ? "green" : "red")`${result ? b`+` : "−"}`;
}
return 音韻地位[選項.音韻屬性];

if (!音韻地位) return [
  ["音韻屬性", ["屬於",
    ...Object.getOwnPropertyNames(TshetUinh.音韻地位.from描述("幫三C凡入")),
    ...Object.entries(Object.getOwnPropertyDescriptors(TshetUinh.音韻地位.prototype))
      .flatMap(([key, descriptor]) => "get" in descriptor ? [key] : []),
    "屬於",
  ]],
  ["表達式", 選項.音韻屬性 === "屬於" ? "冬韻 平聲" : null],
];
if (選項.音韻屬性 === "屬於") {
  const result = 音韻地位.屬於(選項.表達式);
  return ({ b, fg }) => fg(result ? "green" : "red")`${result ? b`+` : "−"}`;
}
return 音韻地位[選項.音韻屬性];

哪個比較好? (我認為這樣 minimal 的應該直接放在「新增空白方案」下面,不適合放 tshet-uinh-examples,纔在這裏開 issue)

graphemecluster avatar Nov 03 '24 12:11 graphemecluster