Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F12654213
test.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
907 B
Referenced Files
None
Subscribers
None
test.ts
View Options
import
{
Readable
}
from
"stream"
;
import
{
Templatable
,
tempstream
}
from
"."
;
import
{
Slot
}
from
"./slot"
;
import
streamToString
from
"./tostring"
;
const
name
=
new
Slot
(
"noname"
);
const
world
=
Promise
.
resolve
([
"Wo"
,
"rld"
]);
// a test
function
html
(
strings
:
TemplateStringsArray
,
...
params
:
Templatable
[]
)
:
Readable
{
const
title
=
new
Slot
(
"Default page title"
);
setTimeout
(()
=>
title
.
set
(
"Changed page title"
),
3000
);
console
.
error
(
"try playing around with the above timeout. Weird things happen when you go to e.g. 3000"
);
// process.exit(1);
return
tempstream
/* HTML */
`<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>
${
title
}
</title>
</head>
<body>
${
tempstream
(
strings
,
...
params
)
}
</body> `
;
}
const
result
=
html
`hello
${
world
}
, and
${
name
}
`
;
streamToString
(
result
).
then
(
console
.
log
);
// template`hello ${world}, and ${name}`.pipe(process.stdout);
File Metadata
Details
Attached
Mime Type
text/html
Expires
Fri, Nov 28, 14:49 (6 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1066134
Default Alt Text
test.ts (907 B)
Attached To
Mode
rSTREAM tempstream
Attached
Detach File
Event Timeline
Log In to Comment