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 🙏

© 2024 – Pkg Stats / Ryan Hefner

blipdom

v1.0.0

Published

A lightweight JavaScript library for reactivity, statefulness, and DOM rendering.

Downloads

79

Readme

blipDOM, an ultra-lightweight reactive JavaScript library

This is a lightweight JavaScript library for reactivity, state management, and DOM rendering. It’s designed to be simple and easy to understand.

Table of Contents

Installation

Install via npm:

npm install blip-dom

Features

  • Reactivity: Automatically updates the DOM when state changes.
  • Stateful: Allows for reactive state management using proxies.
  • DOM Rendering: Renders only the necessary DOM elements.

Usage

Here's a basic usage example to get you started:

import { createReactiveState, render } from "my-framework";

// Define an initial reactive state
const state = createReactiveState({ count: 0 });

// Define a template function for rendering the state
const template = (state) => `<div>Count: ${state.count}</div>`;

// Render the template with the current state to an HTML element
render(document.getElementById("app"), template, state);

In this example:

  1. createReactiveState initializes a reactive state.
  2. render binds the state to an HTML element, updating the DOM whenever the state changes.

API Documentation

createReactiveState(initialState)

Creates a reactive state object. Changes to this object will automatically trigger updates in any components or DOM elements using this state.

  • Parameters:

    • initialState (Object): An object containing initial state properties.
  • Returns: A reactive version of initialState.

  • Example:

    const state = createReactiveState({ count: 0 });
    state.count = 1; // This will automatically trigger an update in the UI.

render(targetElement, templateFunction, state)

Renders a DOM element based on the provided state and template function. Automatically re-renders when the state changes.

  • Parameters:

    • targetElement (HTMLElement): The HTML element to render into.
    • templateFunction (Function): A function that takes state as a parameter and returns an HTML string.
    • state (Object): The reactive state object to be rendered.
  • Example:

    render(document.getElementById("app"), template, state);

Example Usage

See examples/example.html for a sample setup.

Contributing

Contributions are welcome! To get started:

  1. Fork this repository.
  2. Create a new branch for your feature (git checkout -b feature-branch).
  3. Commit your changes (git commit -m "Add new feature").
  4. Push to the branch (git push origin feature-branch).
  5. Open a pull request.

Please follow the code of conduct and include tests where applicable.

License

This library is licensed under the MIT License. See the LICENSE file for details.