Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Serby committed Feb 20, 2012
0 parents commit a309b6d
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Node.js with Express and Stlyus
public/css/*.css
public/css/main/*.css
public/css/admin/*.css
/.monitor

# Eclipse
/.project
/.settings
/.buildpath

# Windows
Thumbs.db

# Vim
.*.sw[a-z]
*.un~i
tags

# OsX
.DS_Store
Icon?
._*
.Spotlight-V100
.Trashes

# nodejs npm modules
/node_modules

# node-cluster
/pids
*.sock

# ZSH Cake plugin cache
/.cake_task_cache
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: node_js
node_js:
- 0.4
- 0.6
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
test:
@./node_modules/.bin/mocha \
-r should \
-R spec

lint-changed:
@jshint `git status --porcelain | sed -e "s/^...//g"`

lint:
@jshint lib test

.PHONY: test lint lint-changed
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# jangle

[![build status](https://secure.travis-ci.org/serby/jangle.png)](http://travis-ci.org/serby/jangle)

## Installation

npm install jangle

## Usage

## Credits
[Paul Serby](https://github.com/serby/)

## Licence
Licenced under the [New BSD License](http://opensource.org/licenses/bsd-license.php)
56 changes: 56 additions & 0 deletions lib/jangle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
var async = require('async');

module.exports.chain = function () {
var
responseArgs,
errored = false,
links = [],
detectFn;

var self = {
link: function() {
var
args = Array.prototype.slice.call(arguments),
fn = args.shift();

links.push(function(callback) {
args.push(callback);
fn.apply(fn, args);
});

return self;
},
detect: function(fn) {
detectFn = function(error) {
if (error || fn.apply(fn, arguments)) {
responseArgs = Array.prototype.slice.call(arguments);
}
};
return self;
},
error: function(fn) {
var error = [responseArgs ? responseArgs.shift() : null];
if (error[0]) {
fn.apply(fn, error);
errored = true;
}
return self;
},
run: function(fn) {
async.forEachSeries(links, function(linkFn, done) {

linkFn.bind(linkFn, function() {
detectFn.apply(detectFn, arguments);
done();
})();

}, function() {
if (!errored) {
fn.apply(fn, responseArgs);
}
});
}
};

return self;
};
21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"author": "Paul Serby <paul@serby.net>",
"name": "jangle",
"description": "",
"version": "0.0.1",
"repository": {
"type": "git",
"url": "git@github.com:serby/jangle"
},
"main": "lib/jangle.js",
"scripts": {
"test": "mocha -r should -R List "
},
"engines": {
"node": ">0.4.0"
},
"dependencies": {
"async": "~0.1"
},
"devDependencies": {}
}

0 comments on commit a309b6d

Please sign in to comment.