8000 GitHub - amccollum/line · GitHub
[go: up one dir, main page]

Skip to content
amccollumPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

25 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

line

Line is flow control designed to work with CoffeeScript.

Here's an example:

Line = require('line').Line

data2 = null

l = new Line
	error: (err) -> console.log('Oh no! One of the callbacks had an error:', err)
		
	-> fs.readdir 'my_dir', @wait()
    
	(files) ->
		# Callback results can be named, or observed
	    fs.readFile "my_dir/#{files[0]}", 'utf8', @wait('data1')
	    fs.readFile "my_dir/#{files[1]}", 'utf8', @wait (data) -> data2 = data
	    fs.stat "my_dir/#{files[2]}", @wait()

	# By default, the result of the last wait() call will be passed on
	(stats) ->
	    console.log('Contents of the first file:', @results.data1)
	    console.log('Contents of the second file:', data2)
	    console.log('Result of fs.stat for the third file:', stats)
    
    # If there is no wait() call, the callback will complete immediately

# Blocks can also be added later
l.add -> console.log('All the tasks completed without errors.')

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

0