Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make sure that sanctuary-def will run without "util" module #301

Closed

Conversation

dotnetCarpenter
Copy link

Fix so sanctuary-def can be used in CommonJS enviroments that does
not have the util module, such as scrimba.com.

Here is an example with sanctuary-def 0.22.0:
https://scrimba.com/scrim/cQGBN6cM

The def test "returns a function with "inspect" and "@@show" methods"
fails with the default util object but I guess you already know
that.

This will hopefully fix issue #300 but I guess the only way to know for sure is to publish and test it out on scrimba.com.

Fix so sanctuary-def can be used in CommonJS enviroments that does
not have the `util` module, such as scrimba.com.

Here is an example with sanctuary-def 0.22.0:
https://scrimba.com/scrim/cQGBN6cM

The def test "returns a function with "inspect" and "@@show" methods"
fails with the default `util` object but I guess you already know
that.
@dotnetCarpenter
Copy link
Author

Closing in favour of:

    wrapped.toString = always0 (typeSignature (typeInfo));

    // Node.js
    if (
      typeof process === 'object' &&
      process != null &&
      process.versions != null &&
      process.versions.node != null
    ) wrapped[Symbol.for('nodejs.util.inspect.custom')] = wrapped.toString;

    // Deno
    if (
      typeof Deno !== 'undefined' &&
      Deno != null &&
      typeof Deno.customInspect === 'symbol'
    ) wrapped[Deno.customInspect] = wrapped.toString;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant