pref: allow anonymous function in asswmbly.

This commit is contained in:
Rintim 2024-03-17 22:56:41 +08:00
parent 618b6d653a
commit 1ef8238a00
No known key found for this signature in database
GPG Key ID: BE9E1EA615BACFCF
1 changed files with 5 additions and 2 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)
}