Liking cljdoc? Tell your friends :D
All platforms.

com.vadelabs.toon.encode.keys

Key manipulation utilities for TOON encoding.

Provides functions to collapse nested single-key objects into dotted paths.

Key manipulation utilities for TOON encoding.

Provides functions to collapse nested single-key objects into dotted paths.
raw docstring

collapseclj/s

(collapse key value siblings options)
(collapse key value siblings options root-literal-keys path-prefix)

Collapses a key-value pair into a dotted path, or returns nil if collapsing not possible.

Collapsing traverses nested objects with single keys, merging them into a dotted path. It stops when:

  • A non-single-key object is encountered
  • An array is encountered
  • A primitive value is reached
  • The flatten depth limit is reached
  • Any segment fails safe mode validation

Safe mode requirements:

  • key-collapsing must be :safe
  • Every segment must be a valid identifier (no dots, no special chars)
  • The collapsed key must not collide with existing sibling keys
  • The collapsed key must not collide with root-level literal dotted keys

Parameters:

  • key: The starting key to collapse
  • value: The value associated with the key
  • siblings: Vector of all sibling keys at this level (for collision detection)
  • options: Map with :key-collapsing and :flatten-depth
  • root-literal-keys: Optional set of dotted keys that exist at root level
  • path-prefix: Optional string prefix for building absolute path

Returns: Map with :collapsed-key, :remainder, :leaf-value, :segment-count if collapsing is possible, nil otherwise

Collapses a key-value pair into a dotted path, or returns nil if collapsing not possible.

Collapsing traverses nested objects with single keys, merging them into a dotted path.
It stops when:
- A non-single-key object is encountered
- An array is encountered
- A primitive value is reached
- The flatten depth limit is reached
- Any segment fails safe mode validation

Safe mode requirements:
- key-collapsing must be :safe
- Every segment must be a valid identifier (no dots, no special chars)
- The collapsed key must not collide with existing sibling keys
- The collapsed key must not collide with root-level literal dotted keys

Parameters:
  - key: The starting key to collapse
  - value: The value associated with the key
  - siblings: Vector of all sibling keys at this level (for collision detection)
  - options: Map with :key-collapsing and :flatten-depth
  - root-literal-keys: Optional set of dotted keys that exist at root level
  - path-prefix: Optional string prefix for building absolute path

Returns:
  Map with :collapsed-key, :remainder, :leaf-value, :segment-count if collapsing is possible,
  nil otherwise
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close