Skip to content

Commit

Permalink
useful set function
Browse files Browse the repository at this point in the history
  • Loading branch information
brekk committed Jan 23, 2024
1 parent 3087b4c commit d5e7676
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/cabal/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ['monoculture'],
}
5 changes: 5 additions & 0 deletions packages/cabal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# cabal

![dependencies via madge](./graph.svg)

Useful tooling for Sets
9 changes: 9 additions & 0 deletions packages/cabal/cabal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { curry } from 'ramda'

export const hasOrAdd = curry(function _hasOrAdd(set, x) {
const had = set.has(x)
if (!had) {
set.add(x)
}
return had
})
4 changes: 4 additions & 0 deletions packages/cabal/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const config = require('../../shared/jest-config/jest.config')
module.exports = {
...config,
}
34 changes: 34 additions & 0 deletions packages/cabal/package-scripts.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const PKG = require('./package.json')
const sd = (script, description = '') =>
!!description ? { script, description } : { script }

module.exports = {
scripts: {
autotest: {
...sd(
'nps -c ./package-scripts.cjs autotest.rebuild test',
'rebuild and test autotests'
),
rebuild: sd(
`drgen -i ${['./cabal.js'].join(
' '
)} -o autotests --processor doctor-general-jest`,
'generate tests with `doctor-general`!'
),
},
clean: sd('rm -r dist', 'clean the build!'),
lint: sd('eslint --fix .', 'lint!'),
test: {
...sd('jest --coverage --verbose', 'test!'),
silent: sd(
'jest --silent --reporters=jest-silent-reporter --coverageReporters=none',
'test, quietly.'
),
ci: sd(
'jest --ci --json --coverage --testLocationInResults --outputFile=ci-report.json',
'test for CI!'
),
watch: sd('jest --watch', 'test with watch-mode!'),
},
},
}
38 changes: 38 additions & 0 deletions packages/cabal/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "cabal",
"version": "0.0.1",
"description": "tooling for Sets 🍽️",
"main": "cabal.js",
"type": "module",
"repository": "brekk/monoculture",
"author": "brekk",
"license": "ISC",
"private": true,
"exports": {
".": "./cabal.js"
},
"dependencies": {
"envtrace": "0.0.2",
"fluture": "14.0.0",
"ramda": "0.29.1"
},
"devDependencies": {
"@testing-library/jest-dom": "6.1.5",
"dotenv-cli": "7.3.0",
"eslint-config-monoculture": "workspace:shared/eslint-config-monoculture",
"jest": "29.7.0",
"jest-config": "workspace:shared/jest-config",
"nps": "^5.10.0"
},
"scripts": {
"nps": "dotenv -- nps -c ./package-scripts.cjs",
"autotest": "dotenv -- nps -c ./package-scripts.cjs autotest",
"autotest:rebuild": "dotenv -- nps -c ./package-scripts.cjs autotest.rebuild",
"clean": "dotenv -- nps -c ./package-scripts.cjs clean",
"lint": "dotenv -- nps -c ./package-scripts.cjs lint",
"test": "dotenv -- nps -c ./package-scripts.cjs test",
"test:ci": "dotenv -- nps -c ./package-scripts.cjs test.ci",
"test:silent": "dotenv -- nps -c ./package-scripts.cjs test.silent",
"test:watch": "dotenv -- nps -c ./package-scripts.cjs test.watch"
}
}

0 comments on commit d5e7676

Please sign in to comment.