Skip to content

Commit

Permalink
feat: resolve invalid typing issue, tangent now returns line
Browse files Browse the repository at this point in the history
  • Loading branch information
noramass committed Aug 13, 2022
1 parent 32675ce commit 97aecd4
Show file tree
Hide file tree
Showing 17 changed files with 567 additions and 415 deletions.
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpx --no commitlint --edit "$1"
pnpx commitlint --edit "$1"
40 changes: 40 additions & 0 deletions example/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Arc2d } from "src/arc2d";
import { Bezier2d } from "src/bezier2d";
import { CatmullRomSpline2d } from "src/catmull-rom-spline2d";
import { Catmull2d } from "src/catmull2d";
import { Line2d } from "src/line2d";
import { curveCanvas } from "example/canvas";
import { PolyCurve2d } from "src/poly-curve2d";

function init() {
curveCanvas(new Line2d({ x: 50, y: 100 }, { x: 200, y: 130 }), "Line");
Expand All @@ -15,6 +18,43 @@ function init() {
]),
"Catmull Rom Spline"
);
curveCanvas(
new Catmull2d([
{ x: 50, y: 200 },
{ x: 250, y: 50 },
{ x: 100, y: 100 },
{ x: 200, y: 200 },
{ x: 50, y: 200 },
{ x: 250, y: 50 },
{ x: 100, y: 100 },
]),
"Catmull Rom Curve"
);
curveCanvas(
Catmull2d.fromCurve(
new Bezier2d([
{ x: 50, y: 200 },
{ x: 250, y: 50 },
{ x: 250, y: 200 },
{ x: 200, y: 200 },
{ x: 200, y: 250 },
{ x: 150, y: 250 },
]),
15
),
"Catmull from Curve"
);
curveCanvas(
new Bezier2d([
{ x: 50, y: 200 },
{ x: 250, y: 50 },
{ x: 250, y: 200 },
{ x: 200, y: 200 },
{ x: 200, y: 250 },
{ x: 150, y: 250 },
]),
"Bezier"
);
}

document.addEventListener("DOMContentLoaded", init);
16 changes: 4 additions & 12 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const tsconfig = require("./tsconfig.json");
const { escapeRegExp, entries, fromPairs } = require("lodash");
const { paths } = tsconfig.compilerOptions;

const keyToRegexp = (key) => `^${escapeRegExp(key).replace("\\*", "(.*)")}$`;
const valueToPathMatcher = ([value]) =>
value.replace("*", "$1").replace("./", "<rootDir>/");
const entryMapper = ([key, value]) => [
keyToRegexp(key),
valueToPathMatcher(value),
];
const moduleNameMapper = fromPairs(entries(paths).map(entryMapper));
const { pathsToModuleNameMapper } = require("ts-jest");

module.exports = {
preset: "jest-preset-typescript",
collectCoverage: true,
collectCoverageFrom: ["src/**/*.ts", "!**/node_modules/**"],
coverageReporters: ["lcovonly"],
testRegex: ["/test/.*\\.test\\.ts$"],
moduleNameMapper,
moduleNameMapper: pathsToModuleNameMapper(tsconfig.compilerOptions.paths, {
prefix: "<rootDir>/",
}),
};
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"jest": "^28.1.0",
"jest": "^28.1.3",
"jest-preset-typescript": "^1.2.0",
"lint-staged": "^12.4.1",
"lodash": "^4.17.21",
"prettier": "^2.6.2",
"rollup": "^2.72.1",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-ts": "^2.0.7",
"rollup-plugin-ts": "^3.0.2",
"rollup-plugin-ts-paths": "^1.0.5",
"semantic-release": "^19.0.2",
"ts-jest": "^28.0.1",
"ts-jest": "^28.0.7",
"tslib": "^2.4.0",
"typescript": "^4.6.3"
"typescript": "^4.6.4"
},
"publishConfig": {
"access": "public"
Expand Down
Loading

0 comments on commit 97aecd4

Please sign in to comment.