Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

加入 minimal working example #45

Open
graphemecluster opened this issue Nov 3, 2024 · 0 comments
Open

加入 minimal working example #45

graphemecluster opened this issue Nov 3, 2024 · 0 comments

Comments

@graphemecluster
Copy link
Member

graphemecluster commented Nov 3, 2024

#10 (comment)
對應 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant