npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

json-transformer-funcs-one-dimension

v1.9.9

Published

One-dimensional linear collection template mapper for json-transformer-funcs

Readme

json-transformer-funcs-one-dimension

The Conveyor Belt. Takes an array of data items on the conveyor and stamps out a continuous stream of resolved JSON AST element nodes.

npm version Documentation Portal Monaco Studio v1 License: MIT Dependencies


🌐 Quick Links & Interactive Demos

| Resource / Hub | Direct Link | Description | |---|---|---| | 📦 npm Package | npm/json-transformer-funcs-one-dimension | Official npm registry distribution | | 📖 The Story (Documentation) | Online Docs Portal / docs/ | Mental model, pipeline architecture & token guides | | 🕹️ Monaco Workspaces Hub | Monaco Hub / docs/monaco/ | Directory of full-screen Monaco Editor studios | | 🚀 Modern Monaco Studio v1 | Launch Studio v1 / docs/monaco/v1/ | 50/50 Dual-Pane Studio with dynamic target container injection | | 🏗️ Architecture Guide | Architecture Deep-Dive / docs/architecture | Formal mathematical cardinality of 1D linear mapping | | 📜 Historical Versions Hub | Generations Hub (v1–v9) / docs/versions | Step-by-step evolutionary milestones across 9 versions |


📖 The Story: The Conveyor Belt

In the KeshavSoft JSON Transformer architecture, UI construction is organized by mathematical dimensionality:

┌──────────────────────────────────────┐
│  json-transformer-funcs-primitive    │ ◄── 0D (The Atom / The Mold):
│  applyTemplate(inElement, inTemplate)│     Stamps 1 data dictionary into 1 element AST.
└──────────────────┬───────────────────┘
                   │
                   ▼ delegates element-level stamping
┌──────────────────────────────────────┐
│ json-transformer-funcs-one-dimension │ ◄── 1D (The Conveyor Belt - THIS REPO):
│ (startFunc / fromCollection)         │     Places an ARRAY of data items on the belt.
│                                      │     Stamps each sequentially into sibling AST nodes
└──────────────────┬───────────────────┘     (e.g., <th> headers, <col> tags, <option> tags).
                   │
                   ▼
┌──────────────────────────────────────┐
│ json-transformer-funcs-two-dimensions│ ◄── 2D (The Grid / Matrix):
│ (Rows × Columns Cartesian space)     │     Stamps full tables (<tbody> with <tr> and <td>).
└──────────────────────────────────────┘

The Mental Model

  1. The Conveyor Line (inSource): A linear stream (array) of dynamic data dictionaries moving down the factory belt.
  2. The Stamping Die (inTemplate): The structural blueprint with ${placeholder} token slots.
  3. The Emitted Stream (output): A continuous array of resolved, immutable JSON element nodes ([ <col>, <col>, ... ] or [ <th>, <th>, ... ]).
  [ Data 1 ] ──► [ Data 2 ] ──► [ Data 3 ]   (inSource Array on Conveyor)
       │              │              │
       ▼              ▼              ▼
 ┌──────────┐   ┌──────────┐   ┌──────────┐
 │ The Mold │   │ The Mold │   │ The Mold │  (inTemplate stamped via applyTemplate)
 └──────────┘   └──────────┘   └──────────┘
       │              │              │
       ▼              ▼              ▼
  [ Node 1 ] ─── [ Node 2 ] ─── [ Node 3 ]   (Resolved Sibling AST Array)

⚙️ Two Conveyor Operational Modes

1. Uniform Conveyor (default / fromCollection)

Every item passing down the conveyor is stamped using the same identical template:

import fromCollection from "json-transformer-funcs-one-dimension";

const columns = [
  { columnName: "itemName" },
  { columnName: "baseUnit" },
  { columnName: "batches" }
];

const template = {
  tagName: "th",
  textContent: "${columnName}"
};

const headers = fromCollection(columns, template);
// Returns 3 <th> element nodes

2. Polymorphic Conveyor (loopWithIndividualTemplate)

Each item travelling on the conveyor carries its own template specification key, allowing diverse element shapes on a single conveyor pass:

import { loopWithIndividualTemplate } from "json-transformer-funcs-one-dimension";

const items = [
  { label: "Search", customMold: { tagName: "input", attributes: { placeholder: "Search..." } } },
  { label: "Submit", customMold: { tagName: "button", textContent: "Submit", attributes: { class: "btn-primary" } } }
];

const elements = loopWithIndividualTemplate(items, "customMold");
// Returns [<input>, <button>] tailored per item

📦 Installation

npm install json-transformer-funcs-one-dimension

Browser CDN (ES Module)

<script type="module">
  import fromCollection, { loopWithIndividualTemplate } from "https://keshavsoft.github.io/json-transformer-funcs-one-dimension/dist/v9/min.js";
</script>

🚀 API Signature & Contract

import fromCollection, { loopWithIndividualTemplate } from "json-transformer-funcs-one-dimension";

// Uniform mapping:
const elements = fromCollection(inSource, inTemplate);

// Polymorphic mapping:
const elements = loopWithIndividualTemplate(inSource, inTemplateKey);

Parameters

| Argument | Type | Description | | :--- | :--- | :--- | | inSource | Array<Object> | Non-empty array of plain objects to pass down the conveyor. | | inTemplate | Object | String | The element blueprint with ${placeholder} substitution slots. | | inTemplateKey | String | Property name on each element containing its individual template. |

Guarantees & Guards

  • Strict Validation: Throws if inSource is not a non-empty Array, or if items are not plain objects.
  • Pure Function: Zero side effects, complete immutability.
  • Preserves Length: output.length === inSource.length.

💡 Practical Real-World Examples

1. Table Headers (<th>)

const columns = [
  { columnName: "itemName" },
  { columnName: "baseUnit" },
  { columnName: "batches" }
];

const headers = fromCollection(columns, {
  tagName: "th",
  textContent: "${columnName}"
});

2. Colgroup Column Tags (<col>)

const columns = [
  { width: "250px" },
  { width: "120px" },
  { width: "80px" }
];

const cols = fromCollection(columns, {
  tagName: "col",
  attributes: { width: "${width}" }
});

3. Dropdown Options (<option>)

const accounts = [
  { id: "A101", label: "Cash Account" },
  { id: "A102", label: "Bank Account" }
];

const options = fromCollection(accounts, {
  tagName: "option",
  textContent: "${label}",
  attributes: { value: "${id}" }
});

🕹️ Modern Monaco Studio v1

Explore the modern Monaco Studio v1 inside docs/monaco/v1/:

  • 50/50 Dual-Pane Split: Monaco Editor on the left, live interactive DOM stage on the right.
  • Synchronized Models: Instant tab switching between base.json, columns.json, template.json, and output.json.
  • Target Container Dropdown: Dynamically inject rendered AST elements into #renderOutput or specific DOM container IDs.
  • Declarative Actions: Powered by dom-primitive-bindings and bindings.json.

🔗 The JSON Transformer Family


📄 License

MIT © KeshavSoft