New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

bedazzlejs

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bedazzlejs

Progressively decorate your objects with composable functions.

latest
Source
npmnpm
Version
1.0.28
Version published
Maintainers
1
Created
Source

📦 BedazzleJS

npm version

A tiny functional way to decorate objects with composable behaviors.

TL;DR

BedazzleJS lets you progressively add methods and properties to objects using pure functions — no classes, no heavy frameworks.

What is BedazzleJS?

BedazzleJS is a tiny library (less than 1KB) that helps you compose objects from multiple behaviors without needing class hierarchies, mutation, or complexity.

Instead of rigid blueprints (like classes), you add behaviors one step at a time with small, reusable functions.

Why BedazzleJS?

  • ✅ No class inheritance mess
  • ✅ No framework lock-in
  • ✅ Predictable, pure functions
  • ✅ Easy to extend, compose, and test
  • ✅ Perfect for plugins, middleware, or micro-frameworks

Installation

npm install bedazzlejs

or

pnpm add bedazzlejs

Usage

import { bedazzle } from 'bedazzlejs';

const withWheels = obj => ({
  roll: () => console.log(`Rolling with ${obj.wheels} wheels!`)
});

const withHorn = obj => ({
  honk: () => console.log('Beep beep!')
});

const vehicle = bedazzle({ wheels: 4 }, withWheels, withHorn);

vehicle.roll(); // Rolling with 4 wheels!
vehicle.honk(); // Beep beep!

You can easily add more decorators without changing the original object structure.

API

bedazzle(state, ...fns)

ParameterTypeDescription
stateObjectThe base object to decorate
...fnsFunction[]Functions that receive the object and return partial objects to merge

Each function gets the current object and can return new properties, methods, or even call next() to continue decorating recursively.

Real-World Ideas

  • Add "plugins" dynamically to a system
  • Compose UI components without classes
  • Create flexible middleware chains
  • Design small, testable interfaces
  • Create evolving APIs or objects at runtime

How is this Different?

ClassesFactory FunctionsBedazzleJS
ExtendabilityMedium (inheritance)Medium (closures)High (pure functions)
TestabilityMediumHighVery High
ComplexityHigher over timeModerateVery Low

BedazzleJS gives you the freedom of factories with the simplicity of pure functions.

License

MIT © Brad Mehder

Contributing

Pull requests, issues, and ideas are welcome!

  • Fork the repo
  • Create a feature branch
  • Submit a pull request 🚀

Keywords

decorator

FAQs

Package last updated on 30 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts