Skip to content

Commit

Permalink
s/node_fn/nodefn/g
Browse files Browse the repository at this point in the history
  • Loading branch information
renato-zannon committed Jan 19, 2013
1 parent 1126562 commit 23da4a4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
18 changes: 9 additions & 9 deletions node/function.js
Expand Up @@ -36,13 +36,13 @@ define(['../when'], function(when) {
* }
* }
*
* var node_fn = require("when/node/function");
* var nodefn = require("when/node/function");
*
* // Logs '15'
* node_fn.apply(onlySmallNumbers, [5]).then(console.log, console.error);
* nodefn.apply(onlySmallNumbers, [5]).then(console.log, console.error);
*
* // Logs 'Calculation failed'
* node_fn.apply(onlySmallNumbers, [15]).then(console.log, console.error);
* nodefn.apply(onlySmallNumbers, [15]).then(console.log, console.error);
*
* @param {function} func node-style function that will be called
* @param {Array} [args] array of arguments to func
Expand Down Expand Up @@ -80,10 +80,10 @@ define(['../when'], function(when) {
* }
*
* // Logs '5'
* node_fn.call(sumSmallNumbers, 2, 3).then(console.log, console.error);
* nodefn.call(sumSmallNumbers, 2, 3).then(console.log, console.error);
*
* // Logs 'Calculation failed'
* node_fn.call(sumSmallNumbers, 5, 10).then(console.log, console.error);
* nodefn.call(sumSmallNumbers, 5, 10).then(console.log, console.error);
*
* @param {function} func node-style function that will be called
* @param {...*} [args] arguments that will be forwarded to the function
Expand All @@ -104,9 +104,9 @@ define(['../when'], function(when) {
* is resolved with the callback's second argument.
*
* @example
* var fs = require("fs"), node_fn = require("when/node/function");
* var fs = require("fs"), nodefn = require("when/node/function");
*
* var promiseRead = node_fn.bind(fs.readFile);
* var promiseRead = nodefn.bind(fs.readFile);
*
* // The promise is resolved with the contents of the file if everything
* // goes ok
Expand Down Expand Up @@ -141,10 +141,10 @@ define(['../when'], function(when) {
* }
* }
*
* var when = require('when'), node_fn = require('when/node/function');
* var when = require('when'), nodefn = require('when/node/function');
*
* var deferred = when.defer();
* callbackTakingFunction(node_fn.createCallback(deferred.resolver));
* callbackTakingFunction(nodefn.createCallback(deferred.resolver));
*
* deferred.then(function(interestingValue) {
* // Use interestingValue
Expand Down
42 changes: 21 additions & 21 deletions test/node/function.js
@@ -1,4 +1,4 @@
(function(buster, node_fn, when) {
(function(buster, nodefn, when) {
var assert = buster.assert;
var fail = buster.fail;

Expand All @@ -10,7 +10,7 @@ function assertIsPromise(something) {
buster.testCase('when/node/function', {
'apply': {
'should return promise': function() {
var result = node_fn.apply(function() {});
var result = nodefn.apply(function() {});
assertIsPromise(result);
},

Expand All @@ -20,7 +20,7 @@ buster.testCase('when/node/function', {
cb(null, 10);
}

var promise = node_fn.apply(async);
var promise = nodefn.apply(async);
promise.then(function(value) {
assert.equals(value, 10);
}, fail).always(done);
Expand All @@ -32,7 +32,7 @@ buster.testCase('when/node/function', {
cb(error);
}

var promise = node_fn.apply(async);
var promise = nodefn.apply(async);
promise.then(fail, function(reason) {
assert.same(reason, error);
}).always(done);
Expand All @@ -43,7 +43,7 @@ buster.testCase('when/node/function', {
cb(null, 10, 20, 30);
}

var promise = node_fn.apply(async);
var promise = nodefn.apply(async);
promise.then(function(values) {
assert.equals(values, [10, 20, 30]);
}).always(done);
Expand All @@ -55,7 +55,7 @@ buster.testCase('when/node/function', {
cb(null, x + y);
}

var promise = node_fn.apply(async, [10, 20]);
var promise = nodefn.apply(async, [10, 20]);
promise.then(function(value) {
assert.equals(value, 30);
}).always(done);
Expand All @@ -64,7 +64,7 @@ buster.testCase('when/node/function', {

'call': {
'should return promise': function() {
var result = node_fn.call(function() {});
var result = nodefn.call(function() {});
assertIsPromise(result);
},

Expand All @@ -74,7 +74,7 @@ buster.testCase('when/node/function', {
cb(null, 10);
}

var promise = node_fn.call(async);
var promise = nodefn.call(async);
promise.then(function(value) {
assert.equals(value, 10);
}, fail).always(done);
Expand All @@ -86,7 +86,7 @@ buster.testCase('when/node/function', {
cb(error);
}

var promise = node_fn.call(async);
var promise = nodefn.call(async);
promise.then(fail, function(reason) {
assert.same(reason, error);
}).always(done);
Expand All @@ -97,7 +97,7 @@ buster.testCase('when/node/function', {
cb(null, 10, 20, 30);
}

var promise = node_fn.call(async);
var promise = nodefn.call(async);
promise.then(function(values) {
assert.equals(values, [10, 20, 30]);
}).always(done);
Expand All @@ -109,7 +109,7 @@ buster.testCase('when/node/function', {
cb(null, x + y);
}

var promise = node_fn.call(async, 10, 20);
var promise = nodefn.call(async, 10, 20);
promise.then(function(value) {
assert.equals(value, 30);
}).always(done);
Expand All @@ -118,17 +118,17 @@ buster.testCase('when/node/function', {

'bind': {
'should return a function': function() {
assert.isFunction(node_fn.bind(function() {}));
assert.isFunction(nodefn.bind(function() {}));
},

'the returned function': {
'should return a promise': function() {
var result = node_fn.bind(function() {});
var result = nodefn.bind(function() {});
assertIsPromise(result());
},

'should resolve the promise with the callback value': function(done) {
var result = node_fn.bind(function(callback) {
var result = nodefn.bind(function(callback) {
callback(null, 10);
});

Expand All @@ -140,7 +140,7 @@ buster.testCase('when/node/function', {

'should reject the promise with the error argument': function(done) {
var error = new Error();
var result = node_fn.bind(function(callback) {
var result = nodefn.bind(function(callback) {
callback(error);
});

Expand All @@ -151,7 +151,7 @@ buster.testCase('when/node/function', {
},

'should resolve the promise to an array for mult-args': function(done) {
var result = node_fn.bind(function(callback) {
var result = nodefn.bind(function(callback) {
callback(null, 10, 20, 30);
});

Expand All @@ -166,7 +166,7 @@ buster.testCase('when/node/function', {
callback(null, x + y);
}

var curried = node_fn.bind(fancySum, 5);
var curried = nodefn.bind(fancySum, 5);

curried(10).then(function(value) {
assert.equals(value, 15);
Expand All @@ -176,14 +176,14 @@ buster.testCase('when/node/function', {

'createCallback': {
'should return a function': function() {
var result = node_fn.createCallback();
var result = nodefn.createCallback();
assert.isFunction(result);
},

'the returned function': {
'should resolve the resolver when called without errors': function(done) {
var deferred = when.defer();
var callback = node_fn.createCallback(deferred.resolver);
var callback = nodefn.createCallback(deferred.resolver);

callback(null, 10);

Expand All @@ -194,7 +194,7 @@ buster.testCase('when/node/function', {

'should reject the resolver when called with errors': function(done) {
var deferred = when.defer();
var callback = node_fn.createCallback(deferred.resolver);
var callback = nodefn.createCallback(deferred.resolver);

var error = new Error();

Expand All @@ -207,7 +207,7 @@ buster.testCase('when/node/function', {

'should pass multiple arguments as an array': function(done) {
var deferred = when.defer();
var callback = node_fn.createCallback(deferred.resolver);
var callback = nodefn.createCallback(deferred.resolver);

callback(null, 10, 20, 30);

Expand Down

1 comment on commit 23da4a4

@briancavalier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Please sign in to comment.