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

aoy

v1.0.5

Published

Tiny JavaScript MVVM library with Virtual DOM. It has only ~600 lines of code.

Downloads

24

Readme

aoy Build Status Coverage Status NPM version MIT Licence

Tiny JavaScript MVVM library with Virtual DOM. It has only ~600 lines of code.

Install

npm:

$ npm install aoy --save

Usage

ES2015

import { init, el } from 'aoy';

//1. init aoy.
const myAoy = init();
conse store = myAoy.store;

//2. add a store to aoy instance.
store.add('firstStore',{txt: 'this is a P'});

//3. create a component.
const myP = aoy.createComponent({
                el: document.body,
                render: function(){
                    return el('p', this.firstStore.txt);
                }
            });
            
//4. component connect to a store, view will be render immediately.
myAoy.connect(myP, 'firstStore');

//5. when u update this component's store, view will be render again.
store.get('firstStore').txt = 'change view';

CommonJS

var myAoy = require('aoy').init();
var el = myAoy.el;

Browser globals

The dist folder contains aoy.js and aoy.min.js.

<script src="path/to/aoy.js"></script>
<script>
var aoy = Aoy.init();
var store = aoy.store;
var el = aoy.el;
</script>

Examples

Api

aoy.init

init function returns a aoy instance.

aoy.el(selectors, props, children])

return a Virtual DOM.

var span = el('span','this is p') // render <span>this is p</span>
var p = el('div',[ span ]) // render <p><span>this is p</span></p>
var div = el('div#mydiv.classA.classB') // render <div id="mydiv" class="classA classB"></div>

aoy.createComponent(descriptor)

descriptor is Object

descriptor.el:

it is a HTMLElement for component's parentNode.

descriptor.render:

render functon returns vnode.

var inputStore = store.get('inputStore');
var myinput = aoy.createComponent({
	inputFn: function(){
		
	},
	render: function(){
		return el('Input', {
                        oninput: this.inputFn,
                        placeholder: this.inputStore.value,
                        type: 'text' 
				});
	}
});

aoy.connect(component[,stores])

when connect function is called, Virtual DOM will be rendered immediately.

var aoy.connect(mycomponent, 'a') // mycomponent denpend on a.
var aoy.connect(mycomponent, ['a', 'b']) // mycomponent denpend on a and b.

store

aoy instance provides a store.

var aoy = Aoy.init();
var store = aoy.store;

store.add([key ,] data)

function add is used to save data. if no key, this data's key is _DEFAULT.

aoy.store.add('a',{b:1}) // a:{b:1}
aoy.store.add({b:1}) // _DEFAULT:{b:1}

store.get(key)

Return to the corresponding store's data

aoy.store.add('a',{b:1})
aoy.store.get('a') // return {b: 1}

sotre.set(newData)

update data.

aoy.store.add('a',{b:1})

aoy.store.get('a').set({a:1, b:2}) //same: aoy.store.get('a') = {a:1, b:2}

aoy.store.get('a') // return {a:1, b:2}

Note

  • support IE 9 and up + all modern browsers.
  • aoy only data-binding one-level key, if data has deep structure, suggest to cooperate immutable-js .

License

MIT