David Chan
b3e4fc6a48
util: Format negative zero as '-0'
Format negative zero as '-0' instead of as '0', as it does not behave
identically to positive zero. ((-0).toString() still returns '0' as
required by ES5 9.8.1.2).
Fixes joyent/node#6548 .
Closes joyent/node#6550 .
11 years ago
Rod Vagg
684dd28a6c
util: format as Error if instanceof Error
11 years ago
Timothy J Fontaine
546ae2eef9
util: pass opts to custom inspect functions
Objects with custom inpsect functions should get the options that were
passed to `util.inspect()`
fixes #5822
fixes #6098
12 years ago
Trevor Norris
50cee6ecab
util: isObject should always return boolean
Fix small bug where isObject would return the original object instead of
true.
12 years ago
Trevor Norris
d66d840e3b
util: fix isPrimitive check
Previous check failed for the edge case Object.create(null). This uses
the current v8 code for the check.
12 years ago
Trevor Norris
3158ffb6ef
util: add isPrimitive check
12 years ago
isaacs
22c68fdc1d
src: Replace macros with util functions
12 years ago
Ben Noordhuis
2cd7adc7f4
util: don't throw on circular %j input to format()
Don't throw an exception when the argument to %j is an object that
contains circular references, it's not helpful. Catch the exception
and return the string '[Circular]'.
12 years ago
Ben Noordhuis
0330bdf519
lib: macro-ify type checks
Increases the grep factor. Makes it easier to harmonize type checks
across the code base.
12 years ago
Wyatt Preul
5fcd6e4038
util: removed duplicated isArray check
12 years ago
Ben Noordhuis
0161ec87af
src, lib: deduplicate errnoException
12 years ago
isaacs
896b2aa707
util: Add debuglog, deprecate console lookalikes
12 years ago
Nick Sullivan
8db693a87e
util: make util.log handle non strings like console.log
util.log will fail on input that does not support .toString(). Have it
use console.log() instead. Includes tests for hairy data types.
Fixes #5349 .
12 years ago
Marcin Kostrzewa
1f55704718
util: fix util.inspect() line width calculation
Have the formatter filter out vt100 color codes when calculating the
line width. Stops it from unnecessarily splitting strings over multiple
lines.
Fixes #5039 .
12 years ago
Nathan Rajlich
66280de133
util: custom `inspect()` method may return an Object
This is more like how `JSON.stringify()` works.
Closes #2711 .
12 years ago
isaacs
5038f40185
node: Add --throw-deprecation
Extremely handy when tracking down a flood of recursive nextTick warnings.
12 years ago
Ryunosuke SATO
27a91387ae
util: fix deprecation message in `util.pump`
12 years ago
isaacs
8509073458
lint
12 years ago
Nathan Rajlich
4eb5399bb2
util: add a "customInspect" option to `util.inspect()`
For disabling calling the custom `inspect()` function when defined on an object
that is being inspected.
12 years ago
Nathan Rajlich
07774e6b95
util: make `inspect()` accept an "options" argument
Consolidates all the formatting options into an "options" object argument.
This is so that we don't have to be constantly remembering the order of
the arguments and so that we can add more formatting options easily.
Closes #4085 .
12 years ago
Nathan Rajlich
fb383a0ad0
util: make util.inspect() work when "hasOwnProperty" is overwritten
12 years ago
Ben Noordhuis
3219616f43
util: mark util.pump() as deprecated
13 years ago
Pavel Lang
ff14007573
Enable color customization of `util.inspect`
This is rewrite of #3701 and #3603 before.
This patch introduce `util.inspect.styles`
and `util.inspect.colors` objects, which enables customization
of color sequences.
13 years ago
Jonas Westerlund
c7bc4cacde
Use unicode escape sequences instead of octal
The latter is illegal in strict mode.
13 years ago
Ben Noordhuis
6531f187d8
util: speed up formatting of large arrays/objects
Don't .indexOf() into the keys array. V8 is smart but not so smart that it
knows how to turn the linear scan into a O(1) lookup.
Fixes #3562 .
13 years ago
isaacs
5b39929d47
Add --no-deprecation and --trace-deprecation flags
13 years ago
Ben Noordhuis
928d28a7b3
util: make _extend() more robust
Add a better 'is object?' check, the old one let values like true slip through.
13 years ago
Alex Kocharin
e85927119c
util: handle non-string return value in .inspect()
13 years ago
ssuda
578ba76e6c
util: fix util.format() formatting of %%
13 years ago
Maciej Małecki
c6c6f98f1c
util: add `util._extend` for extending objects
There were 2 duplicates with such functionality in `cluster` and
`child_process` modules which were replaced by this function.
13 years ago
Luke Gallagher
8d3c46daa8
util: fix typo in lib/util.js
13 years ago
Brandon Benvie
5403a8ce4c
core: add `NativeModule.prototype.deprecate`
Formalize and cleanup handling of deprecated core methods.
13 years ago
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
Fedor Indutny
03e689fae4
Revert "util: always display a warning for module in debug mode"
This reverts commit df62005ece
.
13 years ago
Maciej Małecki
df62005ece
util: always display a warning for module in debug mode
13 years ago
Avi Flax
ee0a7b928b
util: output Dates with Date.toString not Date.toUTCString
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
E. Azer Koçulu
e258169666
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.
14 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