Giter Site home page Giter Site logo

promised-io's Introduction

Promised-IO is a cross-platform package for asynchronous promise-based IO. Promises provide a simple robust mechanism for asynchronicity with separation of concerns by encapsulating eventual completion of an operation with side effect free callback registration separate from call invocation. Promised-IO provides cross-platform file, HTTP, and system interaction with promises for asynchronous operations.

Promised-IO also utilizes "lazy arrays" for progressively completed actions or for streaming of data. Lazy arrays provide all the standard iterative Array methods for receiving callbacks as actions are completed. Lazy arrays are utilized for progressive loading of files and HTTP responses.

Installation

Promised-IO can be installed via npm:

npm install promised-io

promise

The promise module provides the primary tools for creating new promises and interacting with promises. The promise API used by promised-io is the Promises/A proposal used by Dojo, jQuery, and other toolkits. Within promised-io, a promise is defined as any object that implements the Promises/A API, that is they provide a then() method that can take a callback. The then() methods definition is:

promise.then(fulfilledHandler, errorHandler);

Promises can originate from a variety of sources, and promised-io provides a constructor, Deferred, to create promises.

when

when = require("promised-io/promise").when;
when(promiseOrValue, fulfilledHandler, errorHandler);

You can pass a promise to the when() function and the fulfillment and error handlers will be registered for it's completion or you can pass a regular value, and the fulfillment handler will be immediately be called. The when function is a staple of working with promises because it allows you to write code that normalizes interaction with synchronous values and asynchronous promises. If you pass in a promise, a new promise for the result of execution of the callback handler will be returned. If you pass a normal value, the return value will be the value returned from the fulfilledHandler.

Deferred

deferred = require("promised-io/promise").Deferred(canceler);

The Deferred constructor is the primary mechanism for creating new promises. The Deferred object is a form of a promise with an interface for fulfilling or rejecting the promise. A Deferred object is a means for a producer to resolve a promise and it also provides a promise for consumers that are listening for the resolution of the promise. The basic usage pattern looks like:

var Deferred = require("promised-io/promise").Deferred;
function delay(ms, value){
	// create a new Deferred
	var deferred = new Deferred();
	setTimeout(function(){
		// fulfill the deferred/promise, all listeners to the promise will be notified, and
		// provided the value as the value of the promise
		deferred.resolve(value);
	}, ms);
	// return the promise that is associated with the Deferred object
	return deferred.promise;
}

The Deferred can optionally take a canceler function. This function will cause resulting promises to have a cancel() method, and if the cancel() method is called, the Deferred will be canceled and the canceler function will be called.

The Deferred object has the following methods and properties:

resolve

deferred.resolve(value);

This will fulfill the Deferred's promise with the provided value. The fulfillment listeners to the promise will be notified.

reject

deferred.reject(error);

This will reject the Deferred's promise with the provided error. The error listeners to the promise will be notified.

promise

This is the promise object associated with the Deferred instance. The promise object will not have any of the Deferred's fulfill or reject methods, and only provides an interface for listening. This can be safely provided to consumers without any chance of being modified.

cancel

deferred.cancel();

This will cancel the Deferred.

currentContext

One of the challenges with working asynchronous code is that there can be times when you wish for some contextual state information to be preserved across multiple asynchronous actions, without having to actually pass the state to each function in the asynchronous chain. Common examples of such contextual state would be tracking the current transaction or the currently logged in user. Such state information could be stored in a singleton (a module property or a global variable), but with asynchronous actions being interleaved, this is unsuitable for tracking state across asynchronous continuations of an action.

The promised-io package's promise module provides a facility for tracking state across asynchronous operations. The promise module tracks the "currentContext" global variable, and whatever value that was in the variable at the time a promise was created will be restored when that promise is fulfilled (or rejected).

all

group = require("promised-io/promise").all(arrayOfPromises);

The all() function can be passed an array of promises, or multiple promises as individual arguments, and all() will return a new promise that represents the completed values when all the promises have been fulfilled. This allows you to easily run multiple asynchronous actions, and wait for the completion ("join") of all the actions. For example:

group = all(promise1, promise2, promise3);
group.then(function(array){
	var value1 = array[0]; // result of promise1
	var value2 = array[1]; // result of promise2
	var value3 = array[2]; // result of promise3
});

first

first = require("promised-io/promise").first(arrayOfPromises);

The first() function can be passed an array of promises, or multiple promises as individual arguments, and first() will return a new promise that represents the completed value when the first promise is fulfilled. This allows you to run multiple asynchronous actions and get the first result. For example:

response = first(requestToMainSite, requestToMirrorSite1, requestToMirrorSite2);
response.then(function(response){
	// response from the first site to respond
});

seq

result = require("promised-io/promise").seq(arrayOfActionFunctions, startingValue);

The seq() function can be passed an array of functions, and seq() will execute each function in sequence, waiting for the promise returned from each one to complete before executing the next function. Each function will be called with the result of the last function (or the startingValue for the first function).

whenPromise

resultPromise = require("promised-io/promise").whenPromise(valueOrPromise, fulfillmentHandler, errorHandler);

The whenPromise() function behaves exactly like when() except that whenPromise will always return a promise, even if a non-promise value is passed in.

allKeys

group = require("promised-io/promise").allKeys(hashOfPromises);

Takes a hash of promises and returns a promise that is fulfilled once all the promises in the hash keys are fulfilled.

fs

This module provides promise-based access to the filesystem. The API of the fs module basically follows the Node File System module API. Each of the asynchronous functions in the Node's FS API is reflected with a corresponding function in the fs module that returns a promise (instead of requiring a callback argument in the initial call). For example, where Node has fs.rename(path1, path2, [callback]), with promised-io you would call it:

var fs = require("promised-io/fs");
fs.rename(path1, path2).then(function(){
	// finished renaming
});

Any callback arguments will be the same minus the error argument:

var fs = require("promised-io/fs");
fs.readdir(path).then(function(files){
	// use the result
}, function(error) {
	// Handle errors here instead
});

One function that does differ from NodeJS's fs module is the open() function.

open

var file = require("promised-io/fs").open(path, mode);

The open() function differs from simply being a promise-based version of the Node's open() function in that it immediately returns (even though the opening of the file is asynchronous) a file object that be used to read from and write to the file.

To write to the file object, we can write:

promiseForCompletion = file.write(contents, options, encoding);

To close the file object, we can write:

promiseForCompletion = file.close();

We can also use file.writeSync and file.closeSync for the synchronous versions of these functions.

The file object is also a lazy array, which means you can read from the file using standard array methods. To asynchronously read the contents of a file, you can do:

file.forEach(function(chunk){
	// called for each chunk of the file until the end of the file is reached.
});

lazy-array

The lazy-array module provides the functionality for creating and using lazy arrays, which are objects that implement the interface of the standard iterative array methods for accessing streams of data. Array methods can be called and they will be asynchronously executed as data is available. Lazy arrays are powerful way to model asynchronous streams since they can used like other JavaScript arrays.

Typically you don't need to directly use this module, rather other IO modules like the file system (fs) and HTTP (http-client) modules provide lazy arrays that you can interact with. For example, we could search through a file for the string "lazy" and stop reading once we find it using the standard some() method:

if(file.some(function(chunk){
	return chunk.toString().indexOf("lazy") > -1;
}));

Lazy arrays include the follow standard array methods, providing access to the data as the stream data becomes available:

  • forEach
  • concat

Additional iterative methods can also access data as it available and as it is requested from the returned lazy array. This means that in order for this function to be excuted, the resulting array should have a forEach (or any of the other standard methods) called on it to trigger the request for data. These methods follow this behavior:

  • filter
  • every
  • some
  • map

And also these standard methods, although these must fully fetch the stream:

  • join
  • sort
  • reverse

Also the following additional methods are available on lazy arrays:

  • toRealArray() - This will fetch all the data and return it as a real JavaScript array.
  • get(index) - This retrieves an element by index.

LazyArray

lazyArray = require("promised-io/lazy-array").LazyArray({
	some: someImplementation,
	length: arrayLength
});

This function is a constructor for creating your own lazy arrays. With this function, you don't need to implement the entire set of array methods, you can just implement the some() method and provide an array length, if it is known.

first

first = require("promised-io/lazy-array").first(lazyArray);

This function returns the first element in a lazy array.

last

last = require("promised-io/lazy-array").last(lazyArray);

This function returns the last element in a lazy array.

get

item = require("promised-io/lazy-array").get(index);

This function returns an element by index from a lazy array.

http-client

This module provides convenient promise-based access to making HTTP requests.

Promised-IO is part of the Persevere project, and therefore is licensed under the AFL or BSD license. The Persevere project is administered under the Dojo foundation, and all contributions require a Dojo CLA.

promised-io's People

Contributors

ambrusc avatar brettz9 avatar bridgear avatar calmh avatar deanlandolt avatar dstarke avatar dvv avatar ehershey avatar eldargab avatar kriszyp avatar lpatters avatar mocanu-razvan avatar msssk avatar neonstalwart avatar notslang avatar novemberborn avatar nrstott avatar rap1ds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

promised-io's Issues

Abort uploads?

If you're POSTing large binary data, the server might reject the POST with a 400 Bad Request error if the request is too large. I've been trying to figure out how to realize this from Promised-IO.

Switching body.forEach to body.every and returning true as long as writing is permitted should provide enough back-pressure to the body and finish the request. However, it looks like the response is never handled until the request is ended.

Is this something in Node? Or perhaps in JSGI (which is managing the other end of the connection)?

promise.js into /lib

module.js:338
throw err;
^

Error: Cannot find module 'promised-io/lib/promise'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (C:\Users\C1542295\Documents\NodeJS Projects\dating-website\node_modules\couchdb\lib\couchdb.js:2:20)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
26 Oct 14:58:01 - [nodemon] app crashed - waiting for file changes before starting...
^CTerminate batch job (Y/N)? y

Moving the promise.js into a /lib folder seemed to fix this issue.

Get the promise status

Hi,

I'm currently writing a promised-based cache.

However, when calling 'save' on this cache, I can't know which are the resolved promises. I have two choices :

  • Waiting to complete every promise : it would be wrong, because the cache need to be saved now, that's the purpose of the function, and because if promise are created after calling save, then they won't be saved (consistancy issue).
  • Adding a flag to the promises manually when they are fullfilled. Not very clean.

Could it be possible to add to Deferred a getter of the current status ?

fs wraps functions it shouldn't

For example, createReadStream and createWriteStream get wrapped, when they should probably be left alone (they aren't traditional callback-style functions; they immediately return streams).

Currently the code in promised-io/fs seems to be running all functions besides those ending with Sync or containing watch through convertNodeAsyncFunction. Maybe a better idea would be to check whether a function with the same name + Sync exists, and if so, wrap it, otherwise leave it alone?

Lazy Array iterator functions do not pass an index to the callback

The standard Array iterator functions like forEach() and map() take a callback function with the signature: function(element, index, array). The Lazy Array here takes a callback with the signature: function(element). I understand why the third argument doesn't necessarily make sense in this context, but it seems like the lazy array implementation should at least accept functions of the form: function(element, index).

2 problems with Reject throwing errors

  1. Unhandled errors in reject throw errors in a setTimeout making catching them impossible. It would be nice to NOT use setTimeout if exports.errorTimeout == 0.
  2. When the error is thrown, it should be wrapped in an Error() if not already instanceof Error so a stack trace can be had.

Currently, there is no way to catch a forgotten call to reject with a dontThrow parameter. The exception is caught in an unhandled exception handler but that kills my app (as it should).

Also, it would be nice if this behavior was documented.

http-client.js - client is not defined

In engines/node/http-client.js on lines 52 and 93
client.destroy();
client.end();

this cause an exception, because reference to client was never set.

Catch erros threw inside a Promise

I'm inside a large project that which uses your promised-io API.

I'm needing a method to catch exceptions not catch inside a promise, in order to get my code more robust in front of the user input. Of course, I can write a lot of try-catch code but if promise fails for example, with an error like (this promise is already resolved) the program crashes and I need to capture that exception

when I had launched an exception inside my code, the line how breaks is

promised-io/promise.js:233
throw error;
^

Could you provide me some information about catching the exceptions?

Thanks

querystring parser trims values

When parsing ?foo=%20bar%20, the whitespace around bar gets trimmed. This should be a decision outside of the querystring module.

all() in promised-io 0.3.0 cannot handle more than one rejected promise

When you try to do a all() around several promises and more than one of them get rejected, it fails with an "Error: This deferred has already been resolved". This seems to be due to the error callback being called immediately when the first rejection occurs, then again on the next rejected. It would perhaps be preferable to wait for all promises to either succeed or reject, and then call the appropriate callback? Or is there an obvious workaround/user error here? Example to reproduce:

var q = require('promised-io');

function fail(delay) {
    var d = q.defer();
    setTimeout(function () {
        d.reject(new Error('foo'));
    }, delay);
    return d.promise;
}

q.all(fail(250), fail(500)).then(function () {
    console.log("success");
}, function () {
    console.log("error");
});

Result:

% node ntest.js
error

timers.js:96
            if (!process.listeners('uncaughtException').length) throw e;
                                                                      ^
Error: This deferred has already been resolved
    at notifyAll (/Users/jb/src/zpoller/node_modules/promised-io/promise.js:164:10)
    at /Users/jb/src/zpoller/node_modules/promised-io/promise.js:229:3
    at notify (/Users/jb/src/zpoller/node_modules/promised-io/promise.js:199:22)
    at notifyAll (/Users/jb/src/zpoller/node_modules/promised-io/promise.js:179:5)
    at [object Object].<anonymous> (/Users/jb/src/zpoller/node_modules/promised-io/promise.js:229:3)
    at Object._onTimeout (/Users/jb/src/zpoller/ntest.js:6:11)
    at Timer.ontimeout (timers.js:94:19)

NPM not delivering latest code

Using NPM with a package.json, npm reports that it has installed promised-io version 0.3.3.

However, the code is not 0.3.3, as far as I can tell it's at this revision:

bc385d1

Cannot find module './engines/node/lib/http-client'

Error: Cannot find module './engines/node/lib/http-client'
at Function._resolveFilename (module.js:317:11)
at Function._load (module.js:262:25)
at require (module.js:346:19)
at Object. (/Users/tester/node_modules/promised-io/http-client.js:13:12)
at Object.define (/Users/tester/node_modules/promised-io/http-client.js:4:93)
at Object. (/Users/tester/node_modules/promised-io/http-client.js:5:1)
at Module._compile (module.js:402:26)
at Object..js (module.js:408:10)
at Module.load (module.js:334:31)
at Function._load (module.js:293:12)

Error on attempting to install promised-io from npm

When attempting to install promised-io from npm, I receive an error and the installation fails. I have noticed that if I load https://registry.npmjs.org/promised-io in my browser, it redirects to the Dojo Foundation instead of returning the expected JSON data.

The error pasted below is from running npm inside of Git Bash on Windows 7. I have seen equivalent behavior from the Windows 7 command line and in Ubuntu 12.04.

C:\Users\[me]\nodeJS>npm install promised-io
npm http GET https://registry.npmjs.org/promised-io
npm http GET https://registry.npmjs.org/promised-io
npm http GET https://registry.npmjs.org/promised-io
npm ERR! Error: 3388:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown
protocol:openssl\ssl\s23_clnt.c:683:
npm ERR!
npm ERR!     at CleartextStream._puller (tls.js:519:24)
npm ERR!     at CleartextStream.CryptoStream._pull (tls.js:453:19)
npm ERR!     at SecurePair.cycle (tls.js:744:20)
npm ERR!     at EncryptedStream.CryptoStream.write (tls.js:131:13)
npm ERR!     at Socket.ondata (stream.js:38:26)
npm ERR!     at Socket.EventEmitter.emit (events.js:88:17)
npm ERR!     at TCP.onread (net.js:397:14)
npm ERR!  [Error: 3388:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknow
n protocol:openssl\ssl\s23_clnt.c:683:
npm ERR! ]
npm ERR! You may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <[email protected]>

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program File
s (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "promised-io"
npm ERR! cwd C:\Users\[me]\nodeJS
npm ERR! node -v v0.8.1
npm ERR! npm -v 1.1.33
npm ERR! message 3388:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown
 protocol:openssl\ssl\s23_clnt.c:683:
npm ERR! message
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\[me]\nodeJS\npm-debug.log
npm ERR! not ok code 0

Error when auto-starting during server reboot

When automatically starting a node script that uses promised-io during server start with an upstart script I'm getting the following error:

node_modules/promised-io/promise.js:242
                                                throw error;
                                                      ^
Error: Command failed: 
    at ChildProcess.exithandler (child_process.js:637:15)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Socket.<anonymous> (child_process.js:956:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

When starting the script later manually, then it works just fine. So I assume that it gets loaded too early and a requirement is missing.

The start script has the following init info:

### BEGIN INIT INFO
# Provides:          mail_listener
# Required-Start:    $local_fs $remote_fs $network $syslog $named
# Required-Stop:     $local_fs $remote_fs $network $syslog $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/stop MailListener built with nodeJS
### END INIT INFO

Is there anything else I need to do?

webpack error: define cannot be used indirect (lazy-array.js)

I get this webpack error when trying to use promised-io via ES6 and babel like:

import fs from 'promised-io/fs';
...
/Users/kumar/dev/web-ext/dist/webpack:/(webpack)/buildin/amd-define.js:1
module.exports = function() { throw new Error("define cannot be used indirect"); };
                             ^
Error: define cannot be used indirect
    at Object.module.exports [as define] (/Users/kumar/dev/web-ext/dist/webpack:/(webpack)/buildin/amd-define.js:1:30)
    at Object.module.exports.module.exports (/Users/kumar/dev/web-ext/dist/webpack:/~/promised-io/lazy-array.js:2:1)
    at __webpack_require__ (/Users/kumar/dev/web-ext/dist/webpack:/webpack/bootstrap 2285ad9b75dd8ebedb0f:19:1)
...

I don't fully understand it but I guess it doesn't like how lazy-array.js is doing exports? If I put this in my webpack config the error goes away.

module: {
  noParse: /node_modules\/promised-io\/lazy-array\.js/,
}

However, I get 'cannot find module' errors after that for somewhat obvious reasons.

  • webpack: 1.12.13
  • node 4.2.3
  • promised-io: 0.3.5

node http-client: smarter request headers

In the node http-client engine, if you send a request with a headers object specified, the Host header does not get set on the request, which upsets some servers. Could this property always be added to the headers object based on the parsed url if it is missing?

Also, a User-Agent is not set by default, and I'm not sure if the node http client sets one for you or not.

Break out of a then chain

Hello is it possible to break out a then chain half way through? I tried reject it just moves on to the next then call. I also tried cancel this isn't working either. Have something like the following

security.secure(req, handleError)
.then(copyStory, handleError)
.then(getStory, handleError)
.then(getPages, handleError)
.then(storyPageCopy, handleError)

if getStory throws reject getPages still fires.

Conflict with newrelic agent

I've found that using promised-io alongside the newrelic agent raises a problem. A minimal app that shows the crash is as follows:

var newrelic = require('newrelic');
var fs = require('promised-io/fs');
fs.readdir('.');

The error produced is: TypeError: path must be a string

I reported this to newrelic; they had a look and reported the following:

"The error is due to how the promised-io library wraps functions. It uses Function.length, which is the type information of the function, to return the length of the args list. This info is not propagated to the wrapper the Node agent exposes so this causes promised-io's wrapping to fail."

It's not clear to me what mechanism is going wrong, but I thought I'd raise it here.

seq() always throws an error in case one of the promises rejects

Hi,

Since the seq() method binds new Deferred().reject as the error callback for all promises, it means that in case any promise rejects, an error will always get thrown. This is because this error callback tries to notify all it's registered error listeners, but since this is just an empty Deferred object created on the spot, it doesn't have any handlers, so the timeout will throw an error.

Hope I understood and explained it clearly :)

Thanks.

Put patr in devDependencies

I noticed in the package.json that patr is listed under dependencies. Could this be moved to devDependencies no it's not required unless you're trying to run tests?

Didn't do a pull request because I'm not sure how commonjs/nodules handle devDependencies.

Missing Promise.fulfill()

The README refers to Promise.fulfill(), but it looks like it is actually called .emitSuccess() and .fulfill() is missing.

Cannot find module 'promised-io'

Doing require('promised-io') causes the following error:

node.js:116
                throw e; // process.nextTick error, or 'error' event on first tick
                ^
Error: Cannot find module 'promised-io'
        at Function._resolveFilename (module.js:296:11)
        at Function._load (module.js:242:25)
        at require (module.js:324:19)
        at Object.<anonymous> (/usr/local/lib/node/.npm/pulverizr/0.5.1/package/lib/tasks.js:3:15)
        at Module._compile (module.js:380:26)
        at Object..js (module.js:386:10)
        at Module.load (module.js:312:31)
        at Function._load (module.js:273:12)
        at require (module.js:324:19)
        at Object.<anonymous> (/usr/local/lib/node/.npm/pulverizr/0.5.1/package/lib/job.js:6:13)

It is installed via npm install promised-io

http client bug when requesting non existing server

Using NodeJS 0.3.1,

When requesting non existing address I always get ECONNREFUSED error and it is not catched with the promise handler (it stops execution).

I think the solution is provided by:
http://rentzsch.tumblr.com/post/664884799/node-js-handling-refused-http-client-connections

The error seems to come from here 'engines/node/lib/http-client.js' line 90
req.on("error", function(error){
deferred.reject(error);
});
req.on("timeout", function(error){
deferred.reject(error);
});
req.on("close", function(error){
deferred.reject(error);
});

req should be replace with client

promise.convertNodeAsyncFunction throws error on fs.lchmod

At some point in the Node.js v10.x release cycle the behavior of conditionally available properties changed. fs.lchmod is only available on macOS.

Node.js v10.0.0:

> fs = require('fs')
> 'lchmod' in fs
false

Node.js v10.20.1

> fs = require('fs')
> 'lchmod' in fs
true
> typeof fs.lchmod
'undefined'

This breaks the conversion of async functions in fs.js since undefined is passed to convertNodeAsyncFunction:

exports[i] = convertNodeAsyncFunction(fs[i], i === "readFile");

Can't pass encoding to readFile

This code:

var fs = require('promised-io/fs');
file = fs.readFile('myfile.txt', 'utf-8');
file.then(function (content) {
  console.log(content)
});

will print out the raw stream, rather than the plain text, because the encoding is not being passed to the underlying readFile. This is because the underlying function is declared as:

fs.readFile = function(path, encoding_) {

so its length is 2, but when passing the encoding, the callback is at position 3.

version available via npm (0.2.1 or 0.2.3)

Hi Kris

Seems that the tagged release for 0.2.5 has 0.2.3 in the package.json. Funny thing is, when I look on the npm site, it says that the latest is 0.2.1 (is that an npm bug?):

http://search.npmjs.org/#/promised-io

When I install it on the command line:

mac:~/node-projects/litmus.js> npm install promised-io
[email protected] ./node_modules/promised-io

I was able to confirm that npm had installed the version it said it had (or so I thought):

mac:~/node-projects/litmus.js> grep version node_modules/promised-io/package.json 
  "version": "0.2.3",

I managed to track it down to have the same contents of the commit that was tagged as 0.2.5. Confused me for quite a while. Anyway, let me know if there's an npm bug there to be reported.

Thanks

Tom

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.