Skip to content

Commit

Permalink
Merge pull request #34 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 335e502 + 9fdb5dd commit bee536d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 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
39 changes: 19 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,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.sanctuaryDescending = f (util,
self.sanctuaryShow,
self.sanctuaryDescending = f (self.sanctuaryShow,
self.sanctuaryTypeClasses);
}

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

'use strict';

Expand Down Expand Up @@ -73,17 +68,21 @@
/* eslint-enable key-spacing */
};

{
const {custom} = util.inspect; // added in Node.js v6.6.0
/* istanbul ignore else */
if (typeof custom === 'symbol') {
prototype[custom] = Descending$prototype$show;
}
/* istanbul ignore if */
if (typeof Deno !== 'undefined') {
if (Deno != null && typeof Deno.customInspect === 'symbol') {
prototype[Deno.customInspect] = Descending$prototype$show;
}
/* istanbul ignore else */
if (
typeof process !== 'undefined' &&
process != null &&
process.versions != null &&
process.versions.node != null
) {
prototype[
Symbol.for ('nodejs.util.inspect.custom') // added in Node.js v10.12.0
] = Descending$prototype$show;
}
/* istanbul ignore if */
if (typeof Deno !== 'undefined') {
if (Deno != null && typeof Deno.customInspect === 'symbol') {
prototype[Deno.customInspect] = Descending$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 bee536d

Please sign in to comment.