Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
streaming html templates
like hyperstream, but faster. it does not support all hyperstream features.
currently unsupported:
npm install hstream
var hyperstream = require('hstream')
hyperstream({
'div > .x[attr="value"]': fs.createReadStream('./xyz.html')
})
hyperstream(updates)
Create a through stream that applies updates
. updates
is an object with CSS
selectors for keys. Values can be different types depending on what sort of
update you want to do.
Selectors support the most common CSS features, like matching tag names, classes, IDs, attributes. Pseudo selectors are not supported, but PRs are welcome.
Pass a stream or string to replace the matching element's contents with some
HTML. Pass an object to set attributes on the matching element or do some
special operations. When passing an object, you can use keys prefixed with _
for the following special operations:
_html
- Replace the matching element's contents with some HTML_prependHtml
- Prepend some HTML to the matching element_appendHtml
- Append some HTML to the matching elementAll properties accept streams and strings.
hstream({
'#a': someReadableStream(), // replace content with a stream
'#b': 'a string value', // replace content with a string
// prepend and append some html
'#c': { _prependHtml: 'here comes the <b>content</b>: ', _appendHtml: ' …that\'s all folks!' },
// replace content with a stream and set an attribute `attr="value"`
'#d': { _html: someReadableStream(), 'attr': 'value' },
// set an attribute `data-whatever` to a streamed value
'#e': { 'data-whatever': someReadableStream() }
})
Run npm run bench
.
NANOBENCH version 2
> node bench/hyperstream.js
# hyperstream single
ok ~5.38 s (5 s + 381237046 ns)
# hyperstream many
ok ~5.67 s (5 s + 673399368 ns)
# hyperstream small file
ok ~946 ms (0 s + 946487806 ns)
# hstream single
ok ~1.16 s (1 s + 159528184 ns)
# hstream many
ok ~951 ms (0 s + 951094352 ns)
# hstream small file
ok ~70 ms (0 s + 70058016 ns)
all benchmarks completed
ok ~14 s (14 s + 181804772 ns)
1.0.1
FAQs
streaming html templates
The npm package hstream receives a total of 140 weekly downloads. As such, hstream popularity was classified as not popular.
We found that hstream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.