mirror of
https://github.com/samsonjs/batteries.git
synced 2026-03-25 09:15:46 +00:00
add extendNative() to repr extension
This commit is contained in:
parent
930225c297
commit
7ec9d3f296
1 changed files with 5 additions and 1 deletions
|
|
@ -4,6 +4,10 @@
|
|||
// readable string representations of values
|
||||
exports.repr = repr;
|
||||
|
||||
exports.extendNative = function() {
|
||||
global.repr = repr;
|
||||
};
|
||||
|
||||
function repr(x) {
|
||||
if (x !== null && x !== undefined && typeof x.repr === 'function') return x.repr();
|
||||
|
||||
|
|
@ -43,4 +47,4 @@ function repr(x) {
|
|||
}
|
||||
|
||||
throw new Error("don't know how to represent " + x);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue