Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mini-van-plate

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mini-van-plate - npm Package Compare versions

Comparing version 0.4.2 to 0.5.0-perf.0

2

package.json
{
"name": "mini-van-plate",
"version": "0.4.2",
"version": "0.5.0-perf.0",
"description": "A minimalist template engine for DOM generation and manipulation, working for both client-side and server-side rendering",

@@ -5,0 +5,0 @@ "files": [

@@ -47,15 +47,19 @@ /// <reference types="./van-plate.d.ts" />

const elementProto = {
renderToBuf(buf) {
buf.push(`<${this.name}${this.propsStr}>`)
if (noChild[this.name]) return
for (const c of this.children) {
const plainC = plainValue(c)
protoOf(plainC) === elementProto ? plainC.renderToBuf(buf) : buf.push(escape(plainC.toString()))
}
buf.push(`</${this.name}>`)
},
render() {
return noChild[this.name] ?
`<${this.name}${this.propsStr}>` :
`<${this.name}${this.propsStr}>${this.childrenStrs.join("")}</${this.name}>`
}
const buf = []
this.renderToBuf(buf)
return buf.join("")
},
}
const toStr = children => children.map(
c => {
const plainC = plainValue(c)
return protoOf(plainC) === elementProto ? plainC.render() : escape(plainC.toString())
}).join("")
const tags = new Proxy((name, ...args) => {

@@ -70,10 +74,8 @@ const [props, ...children] = protoOf(args[0] ?? 0) === objProto ? args : [{}, ...args]

}).join("")
const flattenedChildren = children.flat(Infinity).filter(c => c != null)
return {__proto__: elementProto, name, propsStr,
childrenStrs: flattenedChildren.length > 0 ? [toStr(flattenedChildren)] : []}
children: children.flat(Infinity).filter(c => c != null)}
}, { get: (tag, name) => tag.bind(null, name) })
const add = (dom, ...children) => {
children = children.flat(Infinity).filter(c => c != null)
if (children.length > 0) dom.childrenStrs.push(toStr(children))
dom.children.push(...children.flat(Infinity).filter(c => c != null))
return dom

@@ -85,3 +87,7 @@ }

val, oldVal: val, derive: f => state(f()),
html: (...args) => "<!DOCTYPE html>" + tags.html(...args).render()
html: (...args) => {
const buf = ["<!DOCTYPE html>"]
tags.html(...args).renderToBuf(buf)
return buf.join("")
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc