Skip to content

Commit

Permalink
Merge pull request #46 from sanctuary-js/davidchambers/no-util
Browse files Browse the repository at this point in the history
use global symbol to customize string representations in Node.js REPL
  • Loading branch information
davidchambers authored Oct 20, 2021
2 parents 33b144a + 1a53d8a commit 8ab915d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
{
"files": ["index.js"],
"globals": {"Deno": false},
"globals": {"Deno": false, "process": false},
"rules": {
"multiline-comment-style": ["off"]
}
Expand Down
45 changes: 23 additions & 22 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,18 @@

'use strict';

const util = {inspect: {}};

/* istanbul ignore else */
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = f (require ('util'),
require ('sanctuary-show'),
module.exports = f (require ('sanctuary-show'),
require ('sanctuary-type-classes'));
} else if (typeof define === 'function' && define.amd != null) {
define (['sanctuary-show', 'sanctuary-type-classes'],
(show, Z) => f (util, show, Z));
define (['sanctuary-show', 'sanctuary-type-classes'], f);
} else {
self.sanctuaryMaybe = f (util,
self.sanctuaryShow,
self.sanctuaryMaybe = f (self.sanctuaryShow,
self.sanctuaryTypeClasses);
}

}) ((util, show, Z) => {
}) ((show, Z) => {

'use strict';

Expand Down Expand Up @@ -90,19 +85,25 @@
/* eslint-enable key-spacing */
};

{
const {custom} = util.inspect; // added in Node.js v6.6.0
/* istanbul ignore else */
if (typeof custom === 'symbol') {
Nothing$prototype[custom] = Nothing$prototype$show;
Just$prototype[custom] = Just$prototype$show;
}
/* istanbul ignore if */
if (typeof Deno !== 'undefined') {
if (Deno != null && typeof Deno.customInspect === 'symbol') {
Nothing$prototype[Deno.customInspect] = Nothing$prototype$show;
Just$prototype[Deno.customInspect] = Just$prototype$show;
}
/* istanbul ignore else */
if (
typeof process !== 'undefined' &&
process != null &&
process.versions != null &&
process.versions.node != null
) {
Nothing$prototype[
Symbol.for ('nodejs.util.inspect.custom') // added in Node.js v10.12.0
] = Nothing$prototype$show;
Just$prototype[
Symbol.for ('nodejs.util.inspect.custom') // added in Node.js v10.12.0
] = Just$prototype$show;
}
/* istanbul ignore if */
if (typeof Deno !== 'undefined') {
if (Deno != null && typeof Deno.customInspect === 'symbol') {
Nothing$prototype[Deno.customInspect] = Nothing$prototype$show;
Just$prototype[Deno.customInspect] = Just$prototype$show;
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"/package.json"
],
"engines": {
"node": ">=6.6.0"
"node": ">=10.12.0"
},
"dependencies": {
"sanctuary-show": "2.0.0",
Expand Down

0 comments on commit 8ab915d

Please sign in to comment.