Skip to content
/ lock Public

Lock method according to options, is huskies framework's middle.

License

Notifications You must be signed in to change notification settings

huskies/lock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lock

Lock method according to options, is huskies framework's middle.

Install for component

Install with component(1):

$ component install brighthas/lock

Install

npm install huskies-lock

Example

if no use huskies-lock.

function test(name,time,cb){
    setTimeout(function(){
        cb(name + "-leo");
    },time);
}

// for call wrap
for(var i=0;i<10;i++){
    test("name"+i,1000-i*10,function(n){
        console.log(n)
    })
}
Result
name9-leo
name8-leo
name7-leo
name6-leo
name5-leo
name4-leo
name3-leo
name2-leo
name1-leo
name0-leo

if use huskies-lock.

var hus = require("huskies"),
    lock = require("huskies-lock");
    
function test(name,time,cb){
    setTimeout(function(){
        cb(name + "-leo");
    },time);
}

var wrap = hus(test).use(lock);

// for call wrap
for(var i=0;i<10;i++){
    wrap("name"+i,1000-i*10,function(n){
        console.log(n)
    })
}
Result
name0-leo
name1-leo
name2-leo
name3-leo
name4-leo
name5-leo
name6-leo
name7-leo
name8-leo
name9-leo

License

MIT

About

Lock method according to options, is huskies framework's middle.

Resources

License

Stars

Watchers

Forks

Packages

No packages published