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

jflow-framework

v1.1.0

Published

jFlow Framework, is a model framework for node.js and in the browser. It provides a common component structure for maintainable and reusable code with asynchronous flow control.

Downloads

17

Readme

jFlow Framework, is a model framework for node.js and in the browser. It provides a common component structure for maintainable and reusable code with asynchronous flow control. Some key features include:

  • Any number of asynchronous functions can be grouped / organised without the need for callbacks.
  • A flow-enabled function can simplify asynchronous routines and be easily reusable.
  • Components contain a reusable structure provided in traditional object oriented programming such as static, public and private members.
  • Extendable component structures (inheritance).
  • Each component instance returns a unique object, i.e there is no need to use the "new" keyword.

For node.js

For Browser, download here and copy jflow-framework.js to your server's desired path

For node.js

require("jflow-framework");

For the browser, in the HTML header or body footer:

<script src="..pathto/jflow-framework.js"></script>

By default, the jFlow instance is global

jflow.pause( this,
	
	function( flow ){
		console.log("I'm first");		
		//  start a wait event
		flow.wait();
		//  asynchronous call
		setTimeout(function(){
			console.log("I'm second");
			//  account for the wait event
			flow.continue();
		}, 200);
	},
	
	function( flow ) {
		console.log("I'm third");
	}
);		

The console will write:

I'm first

I'm second

I'm third

//  define a component
var Foo = function(jflow) {
   
   //  define private variable
   var cantTouchThis = true;
   
    //  component definition
    return {
		// runs when component is initalized
		init: function( value ){
            // assign public property [value] of given instance
            this.value = value;

            console.log( "i ran when initalized, i was passed a value of ["+value+"]");
        },
		
		//  component method
        do : function() {
            console.log("I have a value of ["+this.value+"]");
        }
    };
};

//  create static properties
// Static definition
Foo.Static = function(jflow) {
	////		object containing the properties you want to assign as static
	return{
		//  Static member
		iamStatic: function(){
			console.log("no instance, just Static");
		}
	};
};


// add component to the framework
jflow.addComponent("Foo", Foo);

//  run this when jFlow framework is ready
jflow.ready( function( jflow ){
	
	//  create instance
	var foo = jflow.Foo( "bar" );  
		
	//  console writes : `i ran when initalized, i was passed a value of [bar]`
	
	foo.do();
	
	//  console writes : `I have a value of [bar]`
	
	// this "Foo" is the installed component, not the instance "foo"
	jflow.Foo.iamStatic();
	
	//  console writes : `no instance, just Static`
	
	console.log( foo.cantTouchThis );
	
	//  console writes : undefined

});