aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/scripts/generate-classes.ts
diff options
context:
space:
mode:
authorGravatar zhiyuan <32867472+zhiyuang@users.noreply.github.com> 2022-10-09 13:36:33 +0800
committerGravatar GitHub <noreply@github.com> 2022-10-08 22:36:33 -0700
commit36ec06493e5649374a98d1b4068cd8d89d0a9bf6 (patch)
tree4bc5cd69948aca9e634ae83afe6b7d6ea3b2ca40 /src/bun.js/scripts/generate-classes.ts
parent6068ad15d4d7a4c3f2a81e554c18a0c13a3174e5 (diff)
downloadbun-36ec06493e5649374a98d1b4068cd8d89d0a9bf6.tar.gz
bun-36ec06493e5649374a98d1b4068cd8d89d0a9bf6.tar.zst
bun-36ec06493e5649374a98d1b4068cd8d89d0a9bf6.zip
Fix fetch response redirected (#1303)
* fix: sync codegen * fix: generate class script * fix: sync codegen * fix: add response redirected property
Diffstat (limited to 'src/bun.js/scripts/generate-classes.ts')
-rw-r--r--src/bun.js/scripts/generate-classes.ts24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/bun.js/scripts/generate-classes.ts b/src/bun.js/scripts/generate-classes.ts
index 55627bcc4..13e1780f4 100644
--- a/src/bun.js/scripts/generate-classes.ts
+++ b/src/bun.js/scripts/generate-classes.ts
@@ -35,7 +35,7 @@ function constructorName(typeName) {
return `JS${typeName}Constructor`;
}
-function appendSymbols(to, symbolName, prop) {
+function appendSymbols(to: Map<string, string>, symbolName: (name: string) => string, prop) {
var { defaultValue, getter, setter, accesosr, fn } = prop;
if (accesosr) {
@@ -43,16 +43,16 @@ function appendSymbols(to, symbolName, prop) {
setter = accesosr.setter;
}
- if (getter) {
- to.push([getter, symbolName(getter)]);
+ if (getter && !to.get(getter)) {
+ to.set(getter, symbolName(getter));
}
- if (setter) {
- to.push([setter, symbolName(setter)]);
+ if (setter && !to.get(setter)) {
+ to.set(setter, symbolName(setter));
}
- if (fn) {
- to.push([fn, symbolName(fn)]);
+ if (fn && !to.get(fn)) {
+ to.set(fn, symbolName(fn));
}
}
function propRow(
@@ -929,18 +929,18 @@ function generateZig(
estimatedSize,
} = {} as ClassDefinition
) {
- const exports: [string, string][] = [];
+ const exports = new Map<string, string>();
if (construct) {
- exports.push([`constructor`, classSymbolName(typeName, "construct")]);
+ exports.set(`constructor`, classSymbolName(typeName, "construct"));
}
if (finalize) {
- exports.push([`finalize`, classSymbolName(typeName, "finalize")]);
+ exports.set(`finalize`, classSymbolName(typeName, "finalize"));
}
if (estimatedSize) {
- exports.push([`estimatedSize`, symbolName(typeName, "estimatedSize")]);
+ exports.set(`estimatedSize`, symbolName(typeName, "estimatedSize"));
}
Object.values(klass).map((a) =>
@@ -1108,7 +1108,7 @@ pub const ${className(typeName)} = struct {
comptime {
${typeCheck()}
if (!JSC.is_bindgen) {
-${exports
+${[...exports]
.sort(([a], [b]) => a.localeCompare(b))
.map(
([internalName, externalName]) =>