Skip to content

Commit

Permalink
Merge pull request #34 from sanctuary-js/davidchambers/esm
Browse files Browse the repository at this point in the history
use ES modules
  • Loading branch information
davidchambers authored Oct 27, 2024
2 parents 8ebf711 + 713f5b6 commit 91705f7
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 54 deletions.
1 change: 0 additions & 1 deletion .config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
repo-owner = sanctuary-js
repo-name = sanctuary-useless
contributing-file = .github/CONTRIBUTING.md
module-type = commonjs
5 changes: 3 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"root": true,
"extends": ["./node_modules/sanctuary-style/eslint.json"],
"parserOptions": {"sourceType": "module"},
"overrides": [
{
"files": ["index.js"],
"globals": {"Deno": "readonly", "define": "readonly", "module": "readonly", "process": "readonly", "self": "readonly"}
"globals": {"Deno": "readonly", "process": "readonly"}
},
{
"files": ["test/**/*.js"],
"parserOptions": {"ecmaVersion": 2020, "sourceType": "module"}
"parserOptions": {"ecmaVersion": 2020}
}
]
}
81 changes: 35 additions & 46 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,78 +4,67 @@
//. sanctuary-useless/Useless type:
//.
//. ```javascript
//. // Useless :: Useless
//. const Useless = require ('sanctuary-useless');
//. import {Useless} from 'sanctuary-useless';
//. ```
//.
//. `Useless`, as its name suggests, has no functionality. This makes it useful
//. for testing algebraic data types which satisfy various [type classes][].
//.
//. The following assertion, in isolation, suggests that `Identity a` satisfies
//. ```javascript
//. > import Identity from 'sanctuary-identity'
//. > import Z from 'sanctuary-type-classes'
//. ```
//.
//. The following behaviour, in isolation, suggests that `Identity a` satisfies
//. [`Z.Setoid`][] _for all_ `a`:
//.
//. ```javascript
//. eq (Z.Setoid.test (Identity (0))) (true);
//. > Z.Setoid.test (Identity (0))
//. true
//. ```
//.
//. `Identity Useless`, though, does not satisfy `Z.Setoid`, indicating that
//. `a` is constrained in some way:
//.
//. ```javascript
//. eq (Z.Setoid.test (Identity (Useless))) (false);
//. eq (Z.Setoid.test (Identity (0))) (true);
//. > Z.Setoid.test (Identity (Useless))
//. false
//.
//. > Z.Setoid.test (Identity (0))
//. true
//. ```
//.
//. Conversely, one can use `Useless` to demonstrate universal quantification
//. where applicable:
//.
//. ```javascript
//. eq (Z.Functor.test (Identity (Useless))) (true);
//. > Z.Functor.test (Identity (Useless))
//. true
//. ```

(f => {

'use strict';

/* c8 ignore start */
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = f ();
} else if (typeof define === 'function' && define.amd != null) {
define ([], f);
} else {
self.sanctuaryUseless = f ();
}
/* c8 ignore stop */

}) (() => {

'use strict';

const Useless = {};

Useless['@@type'] = 'sanctuary-useless/Useless@1';
export {Useless};

if (
typeof process !== 'undefined' &&
process != null &&
process.versions != null &&
process.versions.node != null
) {
const inspect = Symbol.for ('nodejs.util.inspect.custom');
Useless[inspect] = () => 'Useless';
}
const Useless = {};

/* c8 ignore start */
if (
typeof Deno !== 'undefined' &&
Deno != null &&
typeof Deno.customInspect === 'symbol'
) Useless[Deno.customInspect] = () => 'Useless';
/* c8 ignore stop */
Useless['@@type'] = 'sanctuary-useless/Useless@1';

return Useless;
if (
typeof process !== 'undefined' &&
process != null &&
process.versions != null &&
process.versions.node != null
) {
const inspect = Symbol.for ('nodejs.util.inspect.custom');
Useless[inspect] = () => 'Useless';
}

});
/* c8 ignore start */
if (
typeof Deno !== 'undefined' &&
Deno != null &&
typeof Deno.customInspect === 'symbol'
) Useless[Deno.customInspect] = () => 'Useless';
/* c8 ignore stop */

//. [`Z.Setoid`]: v:sanctuary-js/sanctuary-type-classes#Setoid
//. [type classes]: v:sanctuary-js/sanctuary-type-classes
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@
"type": "git",
"url": "git://github.com/sanctuary-js/sanctuary-useless.git"
},
"type": "module",
"exports": {
".": "./index.js",
"./package.json": "./package.json"
},
"files": [
"/LICENSE",
"/README.md",
"/index.js",
"/package.json"
],
"engines": {
"node": ">=10.12.0"
"node": ">=16.0.0"
},
"dependencies": {},
"devDependencies": {
"sanctuary-identity": "2.1.x",
"sanctuary-scripts": "7.0.x",
"sanctuary-type-classes": "13.0.0",
"sanctuary-type-identifiers": "4.0.x"
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import test from 'oletus';
import Z from 'sanctuary-type-classes';
import type from 'sanctuary-type-identifiers';

import Useless from '../index.js';
import {Useless} from '../index.js';


test ('Useless', () => {
Expand Down
3 changes: 0 additions & 3 deletions test/package.json

This file was deleted.

0 comments on commit 91705f7

Please sign in to comment.