lockmethod

0.0.6 • Public • Published

lock method for node.js

Install

npm install lockmethod

Example

var lockmethod  =  require('lockmethod');

	var time = 3000;	

	var obj = { changeState  :  lockmethod(
		function(state,cb){
			setTimeout(function(){
				cb(state+time)		
			},time)	
			time -= 300;
		}
	)
	}

	obj.changeState('a',function(r){console.log(r);});
	obj.changeState('b',function(r){console.log(r);});
	obj.changeState('c',function(r){console.log(r);});

	result is >>>  

		a2700
		b2400
		c2100
		

	IF:	

	var obj = { changeState  :  
		function(state,cb){
			setTimeout(function(){
				cb(state+time)		
			},time)	
			time -= 300;
		}
	}

	Then result is >>>

		c2100
		b2100
		a2100

Readme

Keywords

none

Package Sidebar

Install

npm i lockmethod

Weekly Downloads

2

Version

0.0.6

License

MIT

Last publish

Collaborators

  • brighthas