1 | import nodejsCustomInspectSymbol from './nodejsCustomInspectSymbol';
|
2 | /**
|
3 | * The `defineToJSON()` function defines toJSON() and inspect() prototype
|
4 | * methods, if no function provided they become aliases for toString().
|
5 | */
|
6 |
|
7 | export default function defineToJSON(classObject) {
|
8 | var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : classObject.prototype.toString;
|
9 | classObject.prototype.toJSON = fn;
|
10 | classObject.prototype.inspect = fn;
|
11 |
|
12 | if (nodejsCustomInspectSymbol) {
|
13 | classObject.prototype[nodejsCustomInspectSymbol] = fn;
|
14 | }
|
15 | }
|