MCPcopy Create free account
hub / github.com/denoland/std / createIndentCache

Function createIndentCache

xml/stringify.ts:80–86  ·  view source on GitHub ↗

* Creates a memoized indent getter to avoid recomputing indent.repeat(depth).

(
  indent: string | undefined,
)

Source from the content-addressed store, hash-verified

78 * Creates a memoized indent getter to avoid recomputing indent.repeat(depth).
79 */
80function createIndentCache(
81 indent: string | undefined,
82): (depth: number) => string {
83 if (indent === undefined) return () => "";
84 const cache: string[] = [""];
85 return (depth: number): string => (cache[depth] ??= indent.repeat(depth));
86}
87
88/**
89 * Serializes an XML element and its children to a string.

Callers 1

serializeElementFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected