Skip to content

Commit

Permalink
Large TypeScript refactor #3097
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Jul 27, 2024
1 parent 1c7cd0e commit 17a065c
Show file tree
Hide file tree
Showing 65 changed files with 1,612 additions and 262 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"type": "module",
"main": "src/Eleventy.js",
"types": "types/types.d.ts",
"exports": {
"import": "./src/Eleventy.js",
"require": "./src/EleventyCommonJs.cjs"
Expand Down Expand Up @@ -47,7 +48,8 @@
"test:node": "node --test test_node/tests.js",
"jsdoc": "rm -rf jsdoc && npx jsdoc src/* -r -d jsdoc",
"format": "prettier . --write",
"check": "eslint src",
"check-ts": "tsc",
"check-es": "eslint src",
"lint-staged": "lint-staged",
"coverage": "npx c8 ava && npx c8 report --reporter=json-summary && cp coverage/coverage-summary.json docs/_data/coverage.json && node cmd.cjs --config=docs/eleventy.coverage.js",
"prepare": "husky"
Expand Down Expand Up @@ -86,6 +88,7 @@
"@eslint/js": "^9.7.0",
"@iarna/toml": "^2.2.5",
"@mdx-js/node-loader": "^3.0.1",
"@types/node": "^20.14.12",
"@vue/server-renderer": "^3.4.31",
"@zachleat/noop": "^1.0.3",
"ava": "^6.1.3",
Expand All @@ -106,6 +109,7 @@
"rimraf": "^6.0.1",
"sass": "^1.77.8",
"tsx": "^4.16.2",
"typescript": "^5.5.4",
"vue": "^3.4.31",
"zod": "^3.23.8",
"zod-validation-error": "^3.3.0"
Expand Down
17 changes: 10 additions & 7 deletions src/Benchmark/Benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ import { performance } from "node:perf_hooks";

class Benchmark {
constructor() {
this.reset();
// TypeScript slop
this.timeSpent = 0;
this.timesCalled = 0;
this.beforeTimers = [];
}

reset() {
this.timeSpent = 0;
this.timesCalled = 0;
this.beforeTimers = [];
}

getNewTimestamp() {
Expand All @@ -12,12 +21,6 @@ class Benchmark {
return new Date().getTime();
}

reset() {
this.timeSpent = 0;
this.timesCalled = 0;
this.beforeTimers = [];
}

incrementCount() {
this.timesCalled++;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Benchmark/BenchmarkGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BenchmarkGroup {
this.benchmarks = {};
// Warning: aggregate benchmarks automatically default to false via BenchmarkManager->getBenchmarkGroup
this.isVerbose = true;
this.logger = new ConsoleLogger(this.isVerbose);
this.logger = new ConsoleLogger();
this.minimumThresholdMs = 50;
this.minimumThresholdPercent = 8;
}
Expand All @@ -33,6 +33,7 @@ class BenchmarkGroup {

let fn = function (...args) {
benchmark.before();
// @ts-expect-error
let ret = callback.call(this, ...args);
benchmark.after();
return ret;
Expand Down
Loading

0 comments on commit 17a065c

Please sign in to comment.