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

@archjs/databinder

v0.0.1-beta0.0.1

Published

Databinding library

Downloads

1

Readme

DataBinder

Info

language        : TypeScript

module type  : 'commonJs'

dependencies: "@archjs/event-notifier"

description     :

A simple Typescript data-bind library that permits external predicates to intercept changes in object properties. This library uses dirty pattern and gives the user the ability to trigger changes by calling the member method 'update'.

Test coverage

Installation

npm install @archjs/databinder

package.json

{ ...
   dependencies: {
     ...
     "@archjs/databinder": "^"
     ...
}

This plugin has an install script, so when you load this module via npm it will automatically erase it's unecesary files. It uses "fs-extra" , "rimraf", "rmdir" @install.

For dev enviorment use git clone [email protected]:softem/archjs/core/databinder.git

Usage

creation

Using new DataBinder

 import { DataBinder } from "@archjs/databinder/databinder";
 ...
 /* no input data */
 var model0 = new DataBinder();
 /* basic data type as input */
 var model1 = new DataBinder( 24 );
 /* array as input */
 var model2 = new DataBinder( [24] );
 /* json object as input */
 var model3 = new DataBinder( {age:24} );

DataBinder data from nested data

When we have a nested json data object and we want each child node of the tree structure to be bindable we need to use the static method DataBinder.createRecursiveBinder( data )

 import { DataBinder } from "@archjs/databinder/databinder";
 var data  = { 
              user:{ 
                      id:24
                    , email:"[email protected]" 
              }
              , userInfo:{ 
                      age:24
                    , firstName: "John"
                    , lastName:  "Doe"
              } 
 };
 var model = DataBinder.createRecursiveBinder( data );

Bind handler to property change

   dataBinder.bind( <key:string> , <handler:Function> );

bind -> method

key -> string

handler->

function( data ){ ... } 

data ->

{ oldValue:any, newValue:any } 

example

var position:DataBinder = new DataBinder( {x:10,y:20} );
position.bind('x',function(data){ 
      var dx = (data.oldValue-data.newValue);
      console.log('moved element with dx = '+dx+'px' ); 
});
position['x'] = 21;   // dirty flag activated for 'x' key.
                   // observers are not notified!

position['x'] = 31    // dirty flag activated for 'x' key

position.update(); // observers are notified

output: moved element with dx = 21px