Skip to content

Commit

Permalink
derive index.js and index.d.ts from canonical list of method names
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchambers committed Mar 2, 2019
1 parent 8cf6a3a commit ee102dc
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@

Additions and modifications to the specification are best proposed in issues.
If there is support for a proposal, the next step is to submit a pull request.

When adding a type class to __README.md__, please update __names__ then run:

```console
$ npm run generate-js
$ npm run generate-ts
```
22 changes: 22 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export const equals: 'fantasy-land/equals';
export const lte: 'fantasy-land/lte';
export const compose: 'fantasy-land/compose';
export const id: 'fantasy-land/id';
export const concat: 'fantasy-land/concat';
export const empty: 'fantasy-land/empty';
export const invert: 'fantasy-land/invert';
export const filter: 'fantasy-land/filter';
export const map: 'fantasy-land/map';
export const contramap: 'fantasy-land/contramap';
export const ap: 'fantasy-land/ap';
export const of: 'fantasy-land/of';
export const alt: 'fantasy-land/alt';
export const zero: 'fantasy-land/zero';
export const reduce: 'fantasy-land/reduce';
export const traverse: 'fantasy-land/traverse';
export const chain: 'fantasy-land/chain';
export const chainRec: 'fantasy-land/chainRec';
export const extend: 'fantasy-land/extend';
export const extract: 'fantasy-land/extract';
export const bimap: 'fantasy-land/bimap';
export const promap: 'fantasy-land/promap';
22 changes: 22 additions & 0 deletions names
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
equals
lte
compose
id
concat
empty
invert
filter
map
contramap
ap
of
alt
zero
reduce
traverse
chain
chainRec
extend
extract
bimap
promap
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@
"files": [
"/LICENSE",
"/README.md",
"/index.d.ts",
"/index.js",
"/package.json"
],
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"doctest": "sanctuary-doctest",
"generate-js": "scripts/generate-js",
"generate-ts": "scripts/generate-ts",
"lint": "sanctuary-lint",
"release": "sanctuary-release",
"test": "npm run lint && sanctuary-test && npm run doctest"
Expand Down
21 changes: 21 additions & 0 deletions scripts/generate-js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euf -o pipefail

cat >index.js <<EOF
(function() {
'use strict';
var mapping = {
$(awk '{ printf (NR > 1 ? ",\n " : "") $0 ": \047fantasy-land/" $0 "\047" }' names)
};
/* istanbul ignore else */
if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = mapping;
} else {
self.FantasyLand = mapping;
}
} ());
EOF
4 changes: 4 additions & 0 deletions scripts/generate-ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -euf -o pipefail

awk '{ print "export const " $0 ": \047fantasy-land/" $0 "\047;" }' names >index.d.ts
7 changes: 7 additions & 0 deletions scripts/lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -euf -o pipefail

node_modules/.bin/sanctuary-lint "$@"

scripts/generate-js && git diff --exit-code index.js
scripts/generate-ts && git diff --exit-code index.d.ts

0 comments on commit ee102dc

Please sign in to comment.