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

bindrjs

v1.3.2

Published

Don't mind me just re-inventing the wheel

Downloads

25

Readme

BindrJS

The lightest of libraries for good solid HTML data binding.

Why?

If you are like me and often want to spin up a quick project that uses just plain JavaScript.

  • No compilation process
  • No bundle bigger than my actual project
  • No complex setup or strict framework "rules"
  • No Virtual DOM

Just... Data... Binding... This is for you

How?

All you need to know to get this library working is:

Colon (:) before any attribute or text within a (${}) in a text node become Bind Handlers.

A Bind Handler is what Binds the Reactive Data and the HTML, expressions defined within Bind Handlers get re-evaluated ONLY when data changes that concern that Bind Handler happen

Data changes have direct effect on DOM updates thanks to native JavaScript Proxy API, which gets rid of the need for expensive dirty checking or setter functions.

Using the Proxy API along-side Bind Handlers, anytime a property is updated, all and ONLY the DOM elements that are related to that data are updated accordingly.

This library requires no configuration, or setup, just include the js bundle into your page and you are ready to start binding reactive data to your HTML

Not buying it?

This library is also built thinking about how YOU might want to scale it up to your specific needs. Chances are you DO need data reactivity, but you want it to affect your DOM in your very own specific way, with this library you can create you own HTML Bind Handlers which can interact and take full advantage of the internal data reactivity implementation.

Don't be shy and take a look at the demo: https://bindrjs.vercel.app/

How to use

// Install with npm
npm install bindrjs

JS

Include the script tag your HTML

<!-- This will make the Bind object available globally in your scripts -->
<script src="node_modules/dist/index.js"> </script>

TS

// Import the Bind class to your file
import { Bind } from 'bindrjs'
// New instance of Bind
let MainContent = new Bind({
  // Id of the element that will benefit from the Bind context
  id: 'main-content', // (Required)
  // HTML template string or path to HTML file, if provided it will replace
  // the content of the container found with the id (paths only work when running the app in a live server)
  template: '', // (Optional)
  // Reactive properties that will be provided in the template 
  bind: { // (Optional)
    // These are accessible in the template trough the "this" keyword
    text: 'Hello world!'
  }
});

// This is 100% reactive!
MainContent.bind

// You can access the properties of the Bind instance
console.log(MainContent.bind.text);
// > Hello world!

// And reassign them
MainContent.bind.text = 'Changing reactive data';
// Now any part of the template that depends on "this.text" property WILL automatically be updated accordingly

TS type safety:

You can have type safety when using TS by providing your own interface to the Bind class

interface IHomeView {
  header: string
}

let HomeBind = new Bind<IHomeView>({
  id: 'home',
  bind: {
    header: 0 // This will error out because IHomeView interface requests a string
  }
});

let bind = HomeBind.bind // The reactive bind object will follow the IHomeView interface, and provide any intellisense available from your IDE

Contribute!

Download the code

// Clone repository
git clone https://github.com/DavidMunozMartinez/bindrJS.git
// Go to directory
cd bindrjs
// Install dependencies
npm run install

Compile

npm run compile

Examples

npm run examples

This will run the examples page (https://bindrjs.vercel.app/) locally

Test

npm run test

Things that have been built using BindrJS

https://github.com/DavidMunozMartinez/files-sorter

Thanks for passing by, more things are under active development. HAPPY CODING!