Merge pull request #1104 from nofficalfs/Dev-Feat-HookTension

pref: allow anonymous function in asswmbly.
This commit is contained in:
Spmario233 2024-03-18 23:09:44 +08:00 committed by GitHub
commit d219f5a451
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 5 deletions

View File

@ -59,9 +59,12 @@ export class NonameAssembly extends Array {
name = content.name
}
if (typeof content !== "function") throw new Error("you can't add a non-function to assembly.")
if (typeof name !== "string" || name.length === 0) throw new Error("you can't add a anonymous function to assembly.")
// if (typeof name !== "string" || name.length === 0) throw new Error("you can't add a anonymous function to assembly.")
if (!this.has(name)) {
if (typeof name !== "string" || name.length === 0) {
Array.prototype.add.call(this, content)
}
else if (!this.has(name)) {
this.#record.set(name, this.length)
Array.prototype.push.call(this, content)
}
@ -119,7 +122,7 @@ export class NonameAssembly extends Array {
}
}
export const defaultAssemblys = {
export const defaultHookcompatition = {
checkBegin: new NonameAssembly("checkBegin"),
checkCard: new NonameAssembly("checkCard"),
checkTarget: new NonameAssembly("checkTarget"),
@ -132,3 +135,7 @@ export const defaultAssemblys = {
uncheckButton: new NonameAssembly("uncheckButton"),
uncheckEnd: new NonameAssembly("uncheckEnd")
}
export const defaultAssemblys = {
...defaultHookcompatition
}

View File

@ -1,11 +1,11 @@
import { NonameHook } from "./hook.js"
import { defaultAssemblys } from "../assembly/index.js"
import { defaultHookcompatition } from "../assembly/index.js"
export const defaultHooks = {
addGroup: new NonameHook("addGroup"),
addNature: new NonameHook("addNature"),
...defaultAssemblys
...defaultHookcompatition
}
export {