diff --git a/index.js b/index.js index fa8ac54..b38edda 100644 --- a/index.js +++ b/index.js @@ -210,6 +210,16 @@ var slice = Array.prototype.slice; var hasOwnProperty = Object.prototype.hasOwnProperty; + var inspect = (function() { + /* istanbul ignore else */ + if (typeof module === 'object' && typeof module.exports === 'object') { + var util = require ('util'); + /* istanbul ignore else */ + if (typeof util.inspect.custom === 'symbol') return util.inspect.custom; + } + return 'inspect'; + } ()); + // Left :: a -> Either a b var Left = Either.Left; @@ -2539,7 +2549,7 @@ } : wrapNext ({}, [], 0); - wrapped.inspect = wrapped.toString = always0 (typeSignature (typeInfo)); + wrapped[inspect] = wrapped.toString = always0 (typeSignature (typeInfo)); return wrapped; } diff --git a/test/index.js b/test/index.js index 74986d5..0ca61e5 100644 --- a/test/index.js +++ b/test/index.js @@ -1,5 +1,6 @@ 'use strict'; +const util = require ('util'); const vm = require ('vm'); const {Left, Right} = require ('sanctuary-either'); @@ -238,7 +239,7 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Function for ([$.Number, $.Number, $.Number]) (x => y => x + y); - eq (add.inspect ()) ('add :: Number -> Number -> Number'); + eq (util.inspect (add)) ('add :: Number -> Number -> Number'); eq (show (add)) ('add :: Number -> Number -> Number'); eq (show ($0)) ('$0 :: () -> Array a');