line
Control flow like a boss
Last updated 14 years ago by amccollum .
MIT · Original npm · Tarball · package.json
$ npm install line 
SYNC missed versions from official npm registry.

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.')

Current Tags

  • 0.1.8                                ...           latest (14 years ago)

12 Versions

  • 0.1.8                                ...           14 years ago
  • 0.1.7                                ...           14 years ago
  • 0.1.6                                ...           14 years ago
  • 0.1.5                                ...           14 years ago
  • 0.1.4                                ...           14 years ago
  • 0.1.3                                ...           14 years ago
  • 0.1.2                                ...           14 years ago
  • 0.1.1                                ...           15 years ago
  • 0.1.0                                ...           15 years ago
  • 0.0.3                                ...           15 years ago
  • 0.0.2                                ...           15 years ago
  • 0.0.1                                ...           15 years ago
Maintainers (1)
Downloads
Total 22
Today 0
This Week 0
This Month 13
Last Day 0
Last Week 0
Last Month 9
Dependencies (1)
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE