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

spreader-utils

v2.2.1

Published

A utility package for filtering and formatting name-value pairs with dynamic placeholders.

Downloads

86

Readme

Spreader Utils 📌

A lightweight, flexible utility for dynamically filtering and mapping lists of field names and values—perfect for building parameterized queries, payloads, and dynamic forms.

✨ Features

  • Smart Filtering: Automatically removes null, undefined, empty strings, arrays, and objects.
  • Dynamic Parameterization: Generates placeholders ($1, $2, etc.) for easy query building.
  • Structured Output: Returns a well-organized object ideal for database queries and template substitutions.
  • TypeScript Support: Fully compatible with TypeScript for safe and scalable development.
  • Custom Validation: Define custom logic via the isValid parameter.

📦 Installation

Install using your favorite package manager:

npm install spreader-utils
yarn add spreader-utils
pnpm add spreader-utils

🚀 Usage

Basic Example

import { spreader } from "spreader-utils";

const names = ["firstName", "lastName", "age", "email"];
const values = ["John", "Doe", null, ""];
const result = spreader(names, values, 0);

console.log(result);
/*
{
  name: "firstName, lastName",
  numberDollar: "$1, $2",
  value: ["John", "Doe"],
  objectify: { firstName: "John", lastName: "Doe" }
}
*/

Custom Validation Example

You can apply custom validation logic to filter values based on specific conditions:

const customValidator = (val: any) => typeof val === "number" && val > 0;
const result = spreader(["price", "discount"], [0, 15], 0, customValidator);
/*
{
  name: "discount",
  numberDollar: "$1",
  value: [15]
}
*/

🔧 API

spreader(names, values, lastNumber, isValid?)

Parameters

| Parameter | Type | Description | |-------------|-------------------------|----------------------------------------------------------------------------------------------| | names | string[] | Array of field names. | | values | any[] | Array of corresponding values. | | lastNumber| number | Offset used for $ placeholders. | | isValid | (val: any) => boolean | Optional custom validation function (default filters null, undefined, empty strings, etc.). |

Returns

An object:

{
  name: string;        // Comma-separated field names (e.g., "firstName, lastName")
  numberDollar: string; // Comma-separated placeholders (e.g., "$1, $2")
  value: any[];        // Array of filtered values
  objectify: {         // Object representation of key-value pairs
    [key: string]: any
  }
}

📁 Project Structure

spreader-utils/
├── src/                     # Source code directory
│   ├── examples/            # Example scripts demonstrating usage
│   │   ├── apiRequest.ts    # Handles API request operations
│   │   ├── cliArgs.ts       # Parses command-line arguments efficiently
│   │   ├── csvCleaner.ts    # Cleans and processes CSV data
│   │   ├── formSummary.ts   # Generates summaries from form input data
│   │   ├── gameInventory.ts # Manages game inventory dynamically
│   │   └── logging.ts       # Provides logging utilities
│   ├── tests/               # Unit tests for validation
│   │   └── spreader.test.ts # Test suite for `spreader` functionality
│   ├── index.ts             # Main entry point for the package
│   └── spreader.ts          # Core logic for filtering and mapping values
├── .gitignore               # Specifies ignored files in version control
├── LICENSE.md               # Defines the project's licensing terms and usage rights
├── README.md                # Project documentation and usage guide
├── package-lock.json        # Ensures consistent dependency versions
├── package.json             # Contains package metadata and dependencies
├── publish.js               # Automates package publishing process
└── tsconfig.json            # TypeScript configuration for compiling source code

🧪 Local Testing

Before publishing, ensure everything is working:

npm run build
npm pack --dry-run

📜 License

This project is licensed under the MIT License.

👤 Author

Edidiong Obodom
GitHub: @edidiong-obodom


Enjoy clean and efficient data filtering! 🚀✨