Commit Graph

114 Commits

Author SHA1 Message Date
Felix Geisendörfer
bfd3144861 Make unhandled Promise errors throw an exception
A promise will throw an exception unless an error handler is attached in the
same "tick" that the error is emitted. This is to avoid silent promise
failures.
2010-01-19 14:29:57 -08:00
Felix Geisendörfer
f64371fccb Support late callback binding for Promises
Listeners attached with addCallback / addErrback will now be executed
right away if the promise has already fired.
2010-01-19 14:29:49 -08:00
Felix Geisendörfer
d9dc2e0709 Fixed misnamed Promise property 2010-01-19 14:29:44 -08:00
Felix Geisendörfer
f2274840a9 Removed Promise.cancel()
The current implementation was bad and nobody is using it. Has a chance
of getting re-implemented by somebody who has an actual need for it.
2010-01-19 14:29:38 -08:00
Micheil Smith
6e3d12f617 Allow optional params to setTimeout, setInterval 2010-01-18 10:41:03 -08:00
Ryan Dahl
8abeffa9ea Add process.nextTick()
This is a replacement for the common hack:

  setTimeout(cb, 0);

It's much more efficient.
2010-01-18 10:32:36 -08:00
Joseph Pecoraro
fd183bdb07 Fixed typo in comments. 2010-01-18 09:11:02 -08:00
Ryan Dahl
70293a43c9 API: Move Promise and EventEmitter into 'events' module 2010-01-15 12:46:08 -08:00
Ryan Dahl
8e6dd52683 Hack to display more useful SyntaxError exceptions.
For some reason v8 doesn't include the frame with the syntax error in the
stack trace - so have to special case it.
2010-01-15 10:45:04 -08:00
isaacs
b21056d63a Rename path.filename() to path.basename()
Also make normalizeArray a bit more proper wrt handling dots when keepBlanks
is enabled. Fix indentation.
2010-01-09 00:26:49 -08:00
Benjamin Thomas
73266cb486 Added extname function to path module that returns the extension. 2010-01-08 22:28:27 -08:00
Charles Lehner
caf22c8e0a Fixed clearTimeout to check if timer is a Timer 2010-01-04 22:18:06 -08:00
isaacs
7342fecaec Improve path module slightly:
1. Provide a switch to tell it to not remove empty path parts when
   normalizing.
2. Correct the handling of some edge cases when you have lots of dots and
   empty bits, such as paths like "././/./..//." and so on.
2010-01-04 11:36:52 -08:00
Ryan Dahl
359d0170ab Better error message on bad ARGV[1] 2009-12-29 20:31:56 +01:00
Ryan Dahl
64fe9fb85d fix whitespace 2009-12-22 23:11:54 +01:00
Jonas Pfenniger
e6c5ac4f73 posix.cat not using call() correctly
'this' will point to "arguments" and the arguments of the callback itself
will not be set.
2009-12-22 18:01:13 +01:00
Ryan Dahl
120492e5c2 export path.normalizeArray for the uri module 2009-12-22 17:50:23 +01:00
isaacs
4dcdfaf929 Fix require("../blah") issues
Added some more tests, and refactored the uri and path modules to use the
same normalization logic, so that nothing is relying on flaky regexps.

http://groups.google.com/group/nodejs/browse_thread/thread/34779f8c10098c5e
http://groups.google.com/group/nodejs/browse_thread/thread/1aa0146b92582679#msg_9822c03998cb4064
2009-12-22 17:22:12 +01:00
isaacs
0ea2f9e04b Remove two debug statements that are a bit much. 2009-12-19 00:14:50 +01:00
isaacs
6301f18e62 Bugfix: child modules get wrong id with "index.js"
Fix for bug brought up by nua in irc, where child modules get the wrong id
when loaded from a parent module with an id of index.js or index.addon.
2009-12-19 00:14:10 +01:00
isaacs
c2454a0d06 Inadvertently introduced a bug in how single-dot path parts are handled. 2009-12-19 00:13:20 +01:00
isaacs
3b8e47755a Bugfix: require("../foo")
If you have a circular require chain in which one or more of the modules are
referenced with a ".." relative path, like require("../foo"), node blows up.
This patch un-blows-up that case.  There still seem to be issues with
circularity, but this solves one of the more obnoxious ones.
2009-12-19 00:12:38 +01:00
Ryan Dahl
bfa36136da require() should throw error if module does.
Reported by Kris Zyp
http://groups.google.com/group/nodejs/browse_thread/thread/1feab0309bd5402b
2009-12-18 23:58:04 +01:00
visionmedia
f3b0cefd0b Replaced several Array.prototype.slice.call() calls with Array.prototype.unshift.call()
Acts in pretty much the same manor just a bit more elegant
2009-12-18 18:42:20 +01:00
Joshaven Potter
7873639f55 syntax fixes in src/node.js 2009-12-18 16:21:21 +01:00
Ryan Dahl
dbb1a267d7 Fix ARGV[0] weirdness 2009-12-08 06:54:26 +01:00
Johan Dahlberg
9599d2d0e9 Added superCtor to ctor.super_ instead superCtor.prototype.
This way let's us do deep comparison between object instances.

I have a suggestion for the sys.inherits function. Today it's impossible to
deep comparison between instance and class.

Take this snippet for example:

function ClassA() {}
function ClassB() {}

sys.inherits(ClassB, ClassA);

var instance = new ClassB();

The instance variable inherits from ClassA but we can't check it (which is
useful sometimes). You can compare the instance against ClassB
(instance.constructor == ClassB) but we can't compare it deeper
(instance.constructor.super == ClassA). The committed change simply assign
super to the super constructor instead of the super prototype.

I can't see any problem with this fix. You can still get the super constructor
by calling super_.prototype.
2009-12-08 06:19:12 +01:00
Ryan Dahl
71680f512c Give default encodings for posix.read and posix.write 2009-12-07 18:13:45 +01:00
Felix Geisendörfer
876b6d2183 Make process.mixin copy over undefined values
This is not a bug in process.mixin, but I think it is undesirable
behavior. Right now process.mixin will not copy over keys with undefined
values. To me that is an unexpected filtering that should not happen
unless specifically called for.
2009-12-06 19:21:20 +01:00
Felix Geisendörfer
f080de5380 Two bug fixes for process.mixin
Bug #1 occurred when trying to use process.mixin on a function and
produced a fatal exception.

Bug #2 occurred when trying to do a deep merge with an object containing
one or more objects with a nodeType property. In those cases the deep
copy for this part of the object was not performed and a shallow one was
performed instead.

Both of these bugs were artifacts of the jQuery.extend port.
2009-12-06 19:21:06 +01:00
Ryan Dahl
4d818f1fd3 Implement promises entirely in JS 2009-12-06 11:36:22 +01:00
Ryan Dahl
3414eab2f3 Refactor node_file.cc to not use Promises.
At the same time implement synchronous wrappers of the POSIX functions.
These will be undocumented until we settle on an API. Works like this

    // returns promise as before
    posix.mkdir("test").addCallback(function () {
      sys.puts("done");
    });

    // returns undefined, executed synchronously.
    posix.mkdirSync("test");
    sys.puts("done");

This refactoring is a step towards allowing promises to be implemented
purely in javascript.
2009-12-06 10:50:03 +01:00
Ryan Dahl
dc093ef833 Add process.loop() process.unloop()!!!
Move the event loop calls into javascript.
Makes life so much easier.
2009-11-23 00:59:39 +01:00
Friedemann Altrock
2d54d664ff Promises should not be able to be canceled more than once. 2009-11-22 19:18:24 +01:00
Ryan Dahl
8195e0f723 Fix default value for persistent in watchFile() 2009-11-17 23:07:31 +01:00
Ryan Dahl
6de2173d7c Add options to process.watchFile() 2009-11-17 22:35:47 +01:00
Ryan Dahl
8d2f9e83a4 Add process.watchFile() process.unwatchFile()
This is an interface to libev's ev_stat watcher.
2009-11-17 14:07:48 +01:00
Felix Geisendörfer
2b252acea4 Implement process "uncaughtException" event
This event can be used to overwrite the default exception mechanism which
reports the exception and kills the node process.

See google group post:
http://groups.google.com/group/nodejs/browse_thread/thread/9721dc3a2638446f
2009-11-14 23:46:37 +01:00
fwg
bd6c08a984 Add EventEmitter.removeListener 2009-11-13 17:12:41 +01:00
Felix Geisendörfer
bb8f0725da Bugfix, Promise.timeout() blocked the event loop
Promise.timeout() was blocking the event loop from shutting down while it
was waiting for an internal timer to fire. This timer is now cleared when
it is no longer needed, causing the event loop to shut down as fast as
possible.
2009-11-12 12:45:06 +01:00
Felix Geisendörfer
1026ffea40 Proper deprecation message for process.inherits 2009-11-11 17:38:45 +01:00
Ryan Dahl
42dd629c16 deprecation error for process.inherits() 2009-11-07 16:27:18 +01:00
Ryan Dahl
1020efb6f7 Create require.main, remove process.cat() 2009-11-07 14:57:49 +01:00
Ryan Dahl
43121c15be API: rename process.inherits to sys.inherits 2009-11-07 14:45:39 +01:00
Ryan Dahl
d737a060c8 Combine all compiled javascript files into src/node.js 2009-11-07 14:37:22 +01:00
Ryan Dahl
c6bd0e56cb Fix regexp in file extension checking 2009-11-04 12:39:08 +01:00
Felix Geisendörfer
43d651daef The return of relative module loading 2009-11-02 21:26:55 +01:00
Felix Geisendörfer
7069bee982 The return of absolute Module loading 2009-11-02 21:20:44 +01:00
Felix Geisendörfer
8fd472b9a1 The return of remote module loading 2009-11-01 15:39:49 +01:00
Ryan Dahl
9bd2717e74 require.paths aliased as process.path 2009-11-01 09:30:01 +01:00