Brandon Benvie
f9014438c7
util: use getOwnPropertyDescripter
Change formatProperty in util.js to use Object.getOwnPropertyDescriptor
instead of __lookup[GS]etter__.
Use the cached value from the descriptor to reduce number of property
lookups from 3 to 1.
Fallback to standard lookup if the descriptor is empty. This doesn't
ever happen with normal JS objects (this function is called only when
the key exists) but apparently does with Node's custom ENV interface.
Fixes : #2109 .
13 years ago
Ben Noordhuis
97900776bb
util: add internal function _deprecationWarning()
13 years ago
Nathan Rajlich
b204006105
util: ensure that the .inspect function isn't the one being executed
Fixes #2225 .
13 years ago
E. Azer Koçulu
1cb6fe47fc
util: remove the line requiring events
13 years ago
Ryan Dahl
74f39041d4
dont use blue for numbers in util.inspect
13 years ago
Nathan Rajlich
ebefe77bc0
More bulletproof `util.inspect()` function.
Use the *real* versions of the Date and RegExp functions, from the
prototype. This defends against code like:
var d = new Date()
d.toUTCString = null
util.inspect(d)
// TypeError: toUTCString is not a function
Fixes #1944 .
13 years ago
Nathan Rajlich
2dbb470ea1
Don't use `instanceof` in lib/util.js "is" checks.
While using `instanceof`, these functions could easily be faked with something
like: Object.create(Date.prototype)
So let's just not use it at all. A little slower, but these functions are only
used in the REPL / for debugging so it's OK.
Fixes #1941 .
Fixes #1942 .
13 years ago
Nathan Rajlich
b8f3e18a5d
Export the type checking functions from `util.js`.
As per discussion at:
http://groups.google.com/group/nodejs-dev/browse_thread/thread/b08970166e4670cf
13 years ago
Ryan Dahl
239b3d62de
Remove resume and pause events
Too complex; unnecessary.
13 years ago
Ryan Dahl
d77ce4b998
Fixes #1860 . Remove process.writeError
Breaks a few tests in "make test-message"
13 years ago
Ryan Dahl
cdf5d91fe5
Remove tty_legacy
13 years ago
Colton Baker
87286cc737
Fixed a lot of jslint errors.
Fixes #1831
13 years ago
Nathan Rajlich
0c91a835ff
util: isRegExp() should not call toString() on its argument
An overloaded toString() method may have side effects
so don't call it for a simple type check.
Back-port of 54b409d
to the v0.4 branch.
13 years ago
Ryan Dahl
8c87250816
Do not load readline from util.inspect
This causes all modules using console.log() to load readline which seems
unnecessary.
13 years ago
koichik
389e2a07e6
util: Fix inspection for Error
Fixes #1634 .
13 years ago
koichik
6139459d45
util: Fix inspection for sparse array
Fixes #1651 .
13 years ago
koichik
98b64422bb
util: Divide inspect() into some subroutines
13 years ago
Nathan Rajlich
44574bc39b
util: improve util.isDate() function
The old implementation was fragile. i.e. node-time is an example of a user-land
module that exports an extended Date object (with a few added functions on it's
own Date object's prototype). In that case, the old check fails.
13 years ago
Nathan Rajlich
54b409d650
util: isRegExp() should not call toString() on its argument
An overloaded toString() method may have side effects
so don't call it for a simple type check.
13 years ago
koichik
d439c092c2
Improve util.format() compatibility with browser.
Fixes #1434 .
13 years ago
koichik
d3d8f1b972
Add %% escape to util.format()
Fixes #1273 .
13 years ago
Ben Noordhuis
874260b40f
util: add sprintf-like format() function
Fixes #1407 .
13 years ago
koichik
d38fac2230
Fixes #1260
RegExp object is no longer Function.
http://code.google.com/p/v8/issues/detail?id=617
14 years ago
Ryan Dahl
d1eba2b18b
Revert "Fixes #1260"
Due to downgrade of V8.
This reverts commit 3e2abd12d3
.
14 years ago
koichik
3e2abd12d3
Fixes #1260
RegExp object is no longer Function.
http://code.google.com/p/v8/issues/detail?id=617
14 years ago
Ryan Dahl
1ba2c32135
Massage util.inherits for perf increase
14 years ago
isaacs
4d64f36338
Closes GH-310 Format slashes properly
14 years ago
Ryan Dahl
55048cdf79
Update copyright headers
14 years ago
Devin Torres
8c6a7b5de4
Use more color in the repl, loosely inspired by TextMate's SunBurst theme
14 years ago
Ryan Dahl
558e5ba2b0
lint util.js and src/node.js
14 years ago
Ryan Dahl
dd53ceebe4
lint
14 years ago
Tim Cooijmans
d4b726a1a6
fix utils.inspect's detection of circular structures
14 years ago
Micheil Smith
e38eb0c5a4
Soft migration of sys -> util, Removal of deprecated utils module.
14 years ago
Ryan Dahl
f23eb282c0
Fix style
14 years ago
Ryan Dahl
39b9043bef
Use readline.columns in sys.inspect when possible
Though, this should probably be an option to sys.inspect and be set by REPL.
14 years ago
Ryan Dahl
d164989e3f
Commas last in sys.inspect
Ugly? Yes. More readable by first time users? Yes.
14 years ago
Joshaven Potter
3d4e4d8909
syntax fixes to pass jslint
14 years ago
Jorge Chamorro Bieling
fc334b3a97
sys.js: --needless Object.keys() --needless .map() in a single patch
14 years ago
Jorge Chamorro Bieling
8e246acd0e
sys.js: sys.inspect: show function names
14 years ago
Ryan Dahl
f08985c193
Handle writeStream errors in sys.pump
14 years ago
Trent Mick
1d961a6630
add ANSI coloring option to sys.inspect and, by default, to the repl
14 years ago
Russell Haering
37b6e10684
Pass an error to the sys.pump callback if one occurs
- Add test case for pumping from unreadable stream.
- Document the sys.pump error handling behavior
14 years ago
isaacs
e55c486801
Missing 'var' in sys.inspect (Found by Oleg Slobodskoi)
14 years ago
Herbert Vojčík
5dc2b93311
Fix sys.inspect for regex in different context.
14 years ago
Mikeal Rogers
16cb45103f
Adds "pause" and "resume" events to pump and it's readable argument.
15 years ago
Dmitry Baranovskiy
d3f04933f1
sys.inherts to shadow constructor property from enumerability
thanks to ES5 features in V8 it is quite easily possible.
15 years ago
Mikeal Rogers
f62979da6b
Add sys.pump
15 years ago
Ben Lowery
f3cd7bbe77
Coerce each argument to a String before attempting to print it via sys.print
15 years ago
Ryan Dahl
d62b0f442a
Fix style in sys.js
15 years ago
isaacs
3c7873bd3f
Use duck-typing as well as instanceof in sys.inspect
This makes it so that inspecting objects from other contexts works as expected.
15 years ago