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

proxy-land

v0.6.0

Published

ProxyLand is a lightweight and efficient JavaScript library designed to simplify the binding and synchronization of your UI elements with your application's state. By leveraging JavaScript's Proxy objects, ProxyLand ensures that your UI updates seamlessly

Downloads

9

Readme

ProxyLand

ProxyLand is a lightweight and efficient JavaScript library designed to simplify the binding and synchronization of your UI elements with your application's state. By leveraging JavaScript's Proxy objects, ProxyLand ensures that your UI updates seamlessly in real-time as your data changes, providing a reactive experience with minimal effort.

Features

  • Automatic UI Updates: Automatically updates your DOM elements when your data changes, keeping your UI in sync with your application state.
  • Deep Proxying: Offers deep proxy support for objects and arrays, ensuring nested data structures are also reactive.
  • Flexible Binding: Supports binding DOM elements to data properties using both direct string references and custom transformer functions for complex scenarios.
  • Minimalist API: Designed with simplicity in mind, the API is easy to use and understand, enabling rapid development with less code.

Getting Started

To get started with ProxyLand, follow these steps:

Installation

npm install proxy-land

Usage

Initialize

/* initialize with your data */
const app = new ProxyLand({
  message: 'Hello, ProxyLand!',
});

Bind DOM Elements

/* direct property binding */
app.bind('#message', 'message');

/* custom transformer function, for computed properties */
app.bind('#message', data => data.message.toUpperCase());

Bind DOM Elements with Attribute

/* set value of an attribute */
app.bind({
  selector: '#menu',
  attribute: 'style'
}, data => data.showMenu ? 'display: block' : 'display: none');

/* toggle an attribute ('null' results in the attribute not being rendered) */
app.bind({
  selector: '#menu',
  attribute: 'hidden'
}, data => data.showMenu ? null : '');

API Reference

  • bind(targetSpecifier: string | { selector: string; attribute?: string }, bindingSource: keyof T | TransformerFunc<T>): void Binds a DOM element specified by a selector or a selector-attribute combination to a data property or a custom transformer function. The targetSpecifier can either be a string representing the selector of the DOM element or an object containing both the selector and an optional attribute. The bindingSource is either the key of a property within the data being observed or a transformer function that processes the data and returns a string to be bound to the target element.
  • watch<T extends Binding>(data: T): T Watches an object or array for changes, making it reactive. This method returns a proxy of the original data, where any modifications to the data will trigger the DOM to update accordingly. It is designed to handle both objects and arrays, ensuring deep reactivity by applying proxies recursively.

Examples

Here's a simple example to demonstrate how ProxyLand can be used to bind a div element to a data property:

<div id="message"></div>
import { ProxyLand } from 'proxy-land';

const app = new ProxyLand({
  message: 'Hello, ProxyLand!'
});

app.bind('#message', 'message');

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

Don't forget to give the project a star! Thanks again!

Contact

Sjoerd Beentjes - [email protected]

Project Link: https://github.com/sjoerdbeentjes/proxy-land