Socket
Socket
Sign inDemoInstall

@thi.ng/hiccup

Package Overview
Dependencies
Maintainers
0
Versions
254
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/hiccup - npm Package Compare versions

Comparing version 5.2.1 to 5.2.2

8

api.js

@@ -23,10 +23,10 @@ const PROC_TAGS = {

};
const tagMap = (tags) => tags.split(" ").reduce((acc, x) => (acc[x] = true, acc), {});
const SVG_TAGS = tagMap(
const __tagMap = (tags) => tags.split(" ").reduce((acc, x) => (acc[x] = true, acc), {});
const SVG_TAGS = __tagMap(
"animate animateColor animateMotion animateTransform circle clipPath color-profile defs desc discard ellipse feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence filter font foreignObject g image line linearGradient marker mask metadata mpath path pattern polygon polyline radialGradient rect set stop style svg switch symbol text textPath title tref tspan use view"
);
const VOID_TAGS = tagMap(
const VOID_TAGS = __tagMap(
"area base br col command embed hr img input keygen link meta param source stop track use wbr ?xml"
);
const NO_CLOSE_EMPTY = tagMap(
const NO_CLOSE_EMPTY = __tagMap(
"animate circle ellipse line path polygon polyline rect"

@@ -33,0 +33,0 @@ );

@@ -17,12 +17,18 @@ /**

* @example
* ```ts
* ```ts tangle:../export/merge-classes.ts
* import { mergeClasses } from "@thi.ng/hiccup";
*
* mergeClasses("foo bar", { foo: false, baz: true })
* console.log(
* mergeClasses("foo bar", { foo: false, baz: true })
* );
* // "bar baz"
*
* mergeClasses("foo", ["bar", "baz"]);
* console.log(
* mergeClasses("foo", ["bar", "baz"])
* );
* // "foo bar baz"
*
* mergeClasses("foo bar", "baz");
* console.log(
* mergeClasses("foo bar", "baz")
* );
* // "foo bar baz"

@@ -29,0 +35,0 @@ * ```

# Change Log
- **Last updated**: 2024-05-08T18:24:32Z
- **Last updated**: 2024-06-21T19:34:38Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -12,2 +12,8 @@

### [5.2.2](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@5.2.2) (2024-06-21)
#### ♻️ Refactoring
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
## [5.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/hiccup@5.2.0) (2024-04-25)

@@ -14,0 +20,0 @@

{
"name": "@thi.ng/hiccup",
"version": "5.2.1",
"version": "5.2.2",
"description": "HTML/SVG/XML serialization of nested data structures, iterables & closures",

@@ -13,3 +13,3 @@ "type": "module",

},
"homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/hiccup#readme",
"homepage": "https://thi.ng/hiccup",
"funding": [

@@ -40,13 +40,13 @@ {

"dependencies": {
"@thi.ng/api": "^8.11.2",
"@thi.ng/checks": "^3.6.4",
"@thi.ng/errors": "^2.5.7",
"@thi.ng/strings": "^3.7.33"
"@thi.ng/api": "^8.11.3",
"@thi.ng/checks": "^3.6.5",
"@thi.ng/errors": "^2.5.8",
"@thi.ng/strings": "^3.7.34"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.43.2",
"@thi.ng/atom": "^5.3.0",
"esbuild": "^0.21.1",
"@microsoft/api-extractor": "^7.47.0",
"@thi.ng/atom": "^5.3.1",
"esbuild": "^0.21.5",
"typedoc": "^0.25.13",
"typescript": "^5.4.5"
"typescript": "^5.5.2"
},

@@ -133,3 +133,3 @@ "keywords": [

},
"gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
}

@@ -6,7 +6,9 @@ /**

* @example
* ```ts
* ```ts tangle:../export/format-prefixes.ts
* import { formatPrefixes } from "@thi.ng/hiccup";
* import { foaf, xsd } from "@thi.ng/prefixes";
*
* formatPrefixes({ foaf, xsd })
* console.log(
* formatPrefixes({ foaf, xsd })
* );
* // "foaf: http://xmlns.com/foaf/0.1/ rdf: http://www.w3.org/2001/XMLSchema#"

@@ -13,0 +15,0 @@ * ```

@@ -10,3 +10,3 @@ <!-- This file is generated - DO NOT EDIT! -->

> [!NOTE]
> This is one of 192 standalone projects, maintained as part
> This is one of 193 standalone projects, maintained as part
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo

@@ -13,0 +13,0 @@ > and anti-framework.

@@ -32,14 +32,14 @@ import { deref, isDeref } from "@thi.ng/api/deref";

if (opts?.keys == null && $opts.span) $opts.keys = true;
return _serialize(tree, $opts, path);
return __serialize(tree, $opts, path);
};
const _serialize = (tree, opts, path) => tree == null ? "" : Array.isArray(tree) ? serializeElement(tree, opts, path) : isFunction(tree) ? _serialize(tree(opts.ctx), opts, path) : implementsFunction(tree, "toHiccup") ? _serialize(tree.toHiccup(opts.ctx), opts, path) : isDeref(tree) ? _serialize(tree.deref(), opts, path) : isNotStringAndIterable(tree) ? serializeIter(tree, opts, path) : (tree = __escape(String(tree), opts), opts.span) ? `<span${opts.keys ? ` key="${path.join("-")}"` : ""}>${tree}</span>` : tree;
const serializeElement = (tree, opts, path) => {
const __serialize = (tree, opts, path) => tree == null ? "" : Array.isArray(tree) ? __serializeElement(tree, opts, path) : isFunction(tree) ? __serialize(tree(opts.ctx), opts, path) : implementsFunction(tree, "toHiccup") ? __serialize(tree.toHiccup(opts.ctx), opts, path) : isDeref(tree) ? __serialize(tree.deref(), opts, path) : isNotStringAndIterable(tree) ? __serializeIter(tree, opts, path) : (tree = __escape(String(tree), opts), opts.span) ? `<span${opts.keys ? ` key="${path.join("-")}"` : ""}>${tree}</span>` : tree;
const __serializeElement = (tree, opts, path) => {
let tag = tree[0];
return !tree.length ? "" : isFunction(tag) ? _serialize(tag.apply(null, [opts.ctx, ...tree.slice(1)]), opts, path) : implementsFunction(tag, "render") ? _serialize(
return !tree.length ? "" : isFunction(tag) ? __serialize(tag.apply(null, [opts.ctx, ...tree.slice(1)]), opts, path) : implementsFunction(tag, "render") ? __serialize(
tag.render.apply(null, [opts.ctx, ...tree.slice(1)]),
opts,
path
) : tag === COMMENT ? serializeComment(tree) : tag == CDATA ? serializeCData(tree) : isString(tag) ? serializeTag(tree, opts, path) : isNotStringAndIterable(tree) ? serializeIter(tree, opts, path) : illegalArgs(`invalid tree node: ${tree}`);
) : tag === COMMENT ? __serializeComment(tree) : tag == CDATA ? __serializeCData(tree) : isString(tag) ? __serializeTag(tree, opts, path) : isNotStringAndIterable(tree) ? __serializeIter(tree, opts, path) : illegalArgs(`invalid tree node: ${tree}`);
};
const serializeTag = (tree, opts, path) => {
const __serializeTag = (tree, opts, path) => {
tree = normalize(tree);

@@ -50,10 +50,10 @@ const attribs = tree[1];

const tag = tree[0];
const body = tree[2] ? serializeBody(tag, tree[2], opts, path) : !VOID_TAGS[tag] && !NO_CLOSE_EMPTY[tag] ? `></${tag}>` : PROC_TAGS[tag] || "/>";
return `<${tag}${serializeAttribs(attribs, opts)}${body}`;
const body = tree[2] ? __serializeBody(tag, tree[2], opts, path) : !VOID_TAGS[tag] && !NO_CLOSE_EMPTY[tag] ? `></${tag}>` : PROC_TAGS[tag] || "/>";
return `<${tag}${__serializeAttribs(attribs, opts)}${body}`;
};
const serializeAttribs = (attribs, opts) => {
const __serializeAttribs = (attribs, opts) => {
let res = "";
for (let a in attribs) {
if (a.startsWith("__")) continue;
const v = serializeAttrib(attribs, a, deref(attribs[a]), opts);
const v = __serializeAttrib(attribs, a, deref(attribs[a]), opts);
v != null && (res += v);

@@ -63,10 +63,10 @@ }

};
const serializeAttrib = (attribs, a, v, opts) => {
return v == null ? null : isFunction(v) && (/^on\w+/.test(a) || (v = v(attribs)) == null) ? null : v === true ? " " + a + (opts.xml ? `=""` : "") : v === false ? null : a === "data" ? serializeDataAttribs(v, opts) : attribPair(a, v, opts);
const __serializeAttrib = (attribs, a, v, opts) => {
return v == null ? null : isFunction(v) && (/^on\w+/.test(a) || (v = v(attribs)) == null) ? null : v === true ? " " + a + (opts.xml ? `=""` : "") : v === false ? null : a === "data" ? __serializeDataAttribs(v, opts) : __attribPair(a, v, opts);
};
const attribPair = (a, v, opts) => {
const __attribPair = (a, v, opts) => {
v = a === "style" && isPlainObject(v) ? css(v) : a === "prefix" && isPlainObject(v) ? formatPrefixes(v) : isArray(v) ? v.join(ATTRIB_JOIN_DELIMS[a] || " ") : v.toString();
return v.length ? ` ${a}="${__escape(v, opts)}"` : null;
};
const serializeDataAttribs = (data, opts) => {
const __serializeDataAttribs = (data, opts) => {
let res = "";

@@ -80,3 +80,3 @@ for (let id in data) {

};
const serializeBody = (tag, body, opts, path) => {
const __serializeBody = (tag, body, opts, path) => {
if (VOID_TAGS[tag]) {

@@ -89,7 +89,7 @@ illegalArgs(`No body allowed in tag: ${tag}`);

for (let i = 0, n = body.length; i < n; i++) {
res += _serialize(body[i], opts, [...path, i]);
res += __serialize(body[i], opts, [...path, i]);
}
return res + (proc || `</${tag}>`);
};
const serializeComment = (tree) => tree.length > 2 ? `
const __serializeComment = (tree) => tree.length > 2 ? `
<!--

@@ -101,6 +101,6 @@ ${tree.slice(1).map((x) => " " + x).join("\n")}

`;
const serializeCData = (tree) => `<![CDATA[
const __serializeCData = (tree) => `<![CDATA[
${tree.slice(1).join("\n")}
]]>`;
const serializeIter = (iter, opts, path) => {
const __serializeIter = (iter, opts, path) => {
const res = [];

@@ -110,3 +110,3 @@ const p = path.slice(0, path.length - 1);

for (let i of iter) {
res.push(_serialize(i, opts, [...p, k++]));
res.push(__serialize(i, opts, [...p, k++]));
}

@@ -113,0 +113,0 @@ return res.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