Skip to content

Commit

Permalink
feat: merge high-order functions into regular functions
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed Oct 14, 2024
1 parent c5ad329 commit dd905bd
Show file tree
Hide file tree
Showing 117 changed files with 369 additions and 366 deletions.
16 changes: 1 addition & 15 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
}
},
{
"files": ["src/functions"],
"files": ["src/math.ts"],
"rules": {
"functional/functional-parameters": [
"error",
Expand All @@ -59,20 +59,6 @@
]
}
},
{
"files": ["src/functions-ho"],
"rules": {
"functional/functional-parameters": [
"error",
{
"allowRestParameter": false,
"enforceParameterCount": {
"count": "exactlyOne"
}
}
]
}
},
{
"files": ["**/*.test.ts"],
"plugins": ["vitest"],
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@ This library is split into several submodules.
- `uom-types`\
Defines the core types of this library. You'll only need to use if if you are defining your own custom types.

- `uom-types/functions`\
- `uom-types/math`\
Defines runtime mathematical functions that are type-aware of this library's types.

- `uom-types/functions/higher-order`\
Defines runtime higher order mathematical functions that are type-aware of this library's types.

- `uom-types/units`\
Defines common units.\
Note: does not currently define any imperial types.
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Typesafe units with no runtime overhead.
Example:

```ts
import { mul } from "uom-types/functions";
import { mul } from "uom-types/math";
import {
type Metre,
type Length,
Expand Down Expand Up @@ -55,7 +55,7 @@ Example of defining and using a custom `Health` unit:

```ts
import { type Unit } from "uom-types";
import { mul, sub } from "uom-types/functions";
import { mul, sub } from "uom-types/math";
import { type Second } from "uom-types/units";

type Health = Unit<{ HP: 1 }>;
Expand Down
3 changes: 1 addition & 2 deletions knip.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"$schema": "https://unpkg.com/knip@next/schema.json",
"entry": [
"src/index.ts!",
"src/functions/index.ts!",
"src/functions-ho/index.ts!",
"src/math.ts!",
"src/units/index.ts!",
"src/units/converters/index.ts!",
"tests/**/*.test.ts",
Expand Down
18 changes: 5 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,13 @@
"require": "./dist/index.d.cts"
}
},
"./functions": {
"./math": {
"types": {
"import": "./dist/functions.d.mts",
"require": "./dist/functions.d.cts"
"import": "./dist/math.d.mts",
"require": "./dist/math.d.cts"
},
"import": "./dist/functions.mjs",
"require": "./dist/functions.cjs"
},
"./functions/higher-order": {
"types": {
"import": "./dist/functions-higher-order.d.mts",
"require": "./dist/functions-higher-order.d.cts"
},
"import": "./dist/functions-higher-order.mjs",
"require": "./dist/functions-higher-order.cjs"
"import": "./dist/math.mjs",
"require": "./dist/math.cjs"
},
"./units": {
"types": {
Expand Down
6 changes: 2 additions & 4 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ const common = {
const runtimes = {
...common,
input: {
functions: "./src/functions/index.ts",
"functions-higher-order": "./src/functions-ho/index.ts",
math: "./src/math.ts",
"units-converters": "./src/units/converters/index.ts",
},
output: formats.map((format) => {
Expand Down Expand Up @@ -76,8 +75,7 @@ const types = {
...common,
input: {
index: "./src/index.ts",
functions: "./src/functions/index.ts",
"functions-higher-order": "./src/functions-ho/index.ts",
math: "./src/math.ts",
units: "./src/units/index.ts",
"units-converters": "./src/units/converters/index.ts",
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function generateSiUnitPrefixesFile() {
}

function generateSiUnitPrefixesConvertionFile() {

Check warning on line 84 in scripts/generate-files.ts

View workflow job for this annotation

GitHub Actions / lint_js

Missing JSDoc comment
const imports = `import { type UnknownUnit, type UnitConversionRate } from "#uom-types";\nimport { mul, div } from "#uom-types/functions";\n\n`;
const imports = `import { type UnknownUnit, type UnitConversionRate } from "#uom-types";\nimport { mul, div } from "#uom-types/math";\n\n`;
const main = [...exponents.values()]
.map((exponent) => {
const name = scalar10ToName.get(exponent);
Expand Down
181 changes: 0 additions & 181 deletions src/functions-ho/index.ts

This file was deleted.

Loading

0 comments on commit dd905bd

Please sign in to comment.