Skip to content
Myr

refactor(jsx): shorten use hook a bit (#2231)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* refactor(jsx): shorten use hook a bit * chore: denoify

authored by Taku Amano · committed by GitHub · parent e49c140 · Browse files · 2 files+20 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+20 added−16 removed

  • other:+20 added−16 removed

2 files+20 added−16 removed

modified:deno_dist/jsx/hooks/index.ts+10 added-8 removed
272 unmodified lines
273 throw cachedRes[1]274 }275 return cachedRes[0] as T276 }277 promise278 .then((res) => resolvedPromiseValueMap.set(promise, [res]))279 .catch((e) => resolvedPromiseValueMap.set(promise, [undefined, e]))277 promise.then(278 (res) => resolvedPromiseValueMap.set(promise, [res]),279 (e) => resolvedPromiseValueMap.set(promise, [undefined, e])280 )281282 const buildData = buildDataStack.at(-1) as [unknown, NodeObject]283 if (!buildData) {284 throw promise
2 unmodified lines
287288 const promiseArray = (node[DOM_STASH][1][STASH_USE] ||= [])289 const hookIndex = node[DOM_STASH][0]++290290 promise291 .then((res) => {291 promise.then(292 (res) => {293 promiseArray[hookIndex] = [res]293 })294 .catch((e) => {294 },295 (e) => {296 promiseArray[hookIndex] = [undefined, e]296 })297 }298 )299300 const res = promiseArray[hookIndex]301 if (res) {302 if (res.length === 2) {
24 unmodified lines
modified:src/jsx/hooks/index.ts+10 added-8 removed
272 unmodified lines
273 throw cachedRes[1]274 }275 return cachedRes[0] as T276 }277 promise278 .then((res) => resolvedPromiseValueMap.set(promise, [res]))279 .catch((e) => resolvedPromiseValueMap.set(promise, [undefined, e]))277 promise.then(278 (res) => resolvedPromiseValueMap.set(promise, [res]),279 (e) => resolvedPromiseValueMap.set(promise, [undefined, e])280 )281282 const buildData = buildDataStack.at(-1) as [unknown, NodeObject]283 if (!buildData) {284 throw promise
2 unmodified lines
287288 const promiseArray = (node[DOM_STASH][1][STASH_USE] ||= [])289 const hookIndex = node[DOM_STASH][0]++290290 promise291 .then((res) => {291 promise.then(292 (res) => {293 promiseArray[hookIndex] = [res]293 })294 .catch((e) => {294 },295 (e) => {296 promiseArray[hookIndex] = [undefined, e]296 })297 }298 )299300 const res = promiseArray[hookIndex]301 if (res) {302 if (res.length === 2) {
24 unmodified lines