Skip to content

Commit

Permalink
Merge branch 'master' of github.com:poolifier/tatami
Browse files Browse the repository at this point in the history
  • Loading branch information
jerome-benoit committed Oct 18, 2024
2 parents ab1753f + d6dd610 commit 151a133
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/release-please/manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.8.6"
".": "0.8.7"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.7](https://github.com/poolifier/tatami-ng/compare/0.8.6...0.8.7) (2024-10-18)


### 🐞 Bug Fixes

* handle corner case promise like benchmark function ([ad9c3be](https://github.com/poolifier/tatami-ng/commit/ad9c3becc72359b8b89330fc324eef61040b84ba))
* promise like rejection without catch handling ([57de829](https://github.com/poolifier/tatami-ng/commit/57de82906b809f4949ba0e300a98409aa0c7a756))

## [0.8.6](https://github.com/poolifier/tatami-ng/compare/0.8.5...0.8.6) (2024-10-17)


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Bun versions >= 1.x are supported.
<script type="module">
import {
...
} from 'https://cdn.jsdelivr.net/npm/[email protected].6/dist/browser/index.js'
} from 'https://cdn.jsdelivr.net/npm/[email protected].7/dist/browser/index.js'
</script>
```

Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"organizeImports": {
"enabled": true
},
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion jsr.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://jsr.io/schema/config-file.v1.json",
"name": "@poolifier/tatami-ng",
"version": "0.8.6",
"version": "0.8.7",
"exports": "./src/index.js",
"publish": {
"include": [
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"name": "tatami-ng",
"type": "module",
"license": "MIT",
"version": "0.8.6",
"packageManager": "[email protected].30",
"version": "0.8.7",
"packageManager": "[email protected].31",
"bin": {
"tatami": "cli.js"
},
Expand Down Expand Up @@ -51,13 +51,13 @@
"peowly": "^1.3.2"
},
"devDependencies": {
"@biomejs/biome": "^1.9.3",
"@biomejs/biome": "^1.9.4",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@types/bun": "^1.1.11",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"npm-run-all2": "^6.2.3",
"npm-run-all2": "^6.2.4",
"prettier": "^3.3.3"
},
"peerDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions src/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import {
import { runtime } from './runtime.js'
import { now } from './time.js'
import {
isAsyncFnResource,
isAsyncFunction,
isFunction,
isFunctionAsyncResource,
isObject,
} from './utils.js'

Expand Down Expand Up @@ -175,7 +175,7 @@ export function bench(name, fn = undefined, opts = {}) {
samples: opts.samples ?? defaultSamples,
warmup: opts.warmup ?? true,
baseline: false,
async: isAsyncFnResource(fn),
async: isFunctionAsyncResource(fn),
})
}

Expand Down Expand Up @@ -215,7 +215,7 @@ export function baseline(name, fn = undefined, opts = {}) {
samples: opts.samples ?? defaultSamples,
warmup: opts.warmup ?? true,
baseline: true,
async: isAsyncFnResource(fn),
async: isFunctionAsyncResource(fn),
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { now } from './time.js'
import {
AsyncFunction,
checkDividend,
isAsyncFnResource,
isAsyncFunction,
isFunction,
isFunctionAsyncResource,
isObject,
} from './utils.js'

Expand Down Expand Up @@ -204,7 +204,7 @@ export async function measure(fn, opts = {}) {
`expected boolean as 'async' option, got ${opts.async.constructor.name}`
)

opts.async = opts.async ?? isAsyncFnResource(fn)
opts.async = opts.async ?? isFunctionAsyncResource(fn)
opts.time = opts.time ?? defaultTime
opts.samples = opts.samples ?? defaultSamples
opts.warmup =
Expand Down
8 changes: 6 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const isAsyncFunction = fn => {
* @param {Function} fn the function to check
* @returns {Boolean} true if the function is an async function or returns a promise
*/
export const isAsyncFnResource = fn => {
export const isFunctionAsyncResource = fn => {
if (fn == null) {
return false
}
Expand All @@ -49,7 +49,11 @@ export const isAsyncFnResource = fn => {
const promiseLike = isPromiseLike(fnCall)
if (promiseLike) {
// silence promise rejection
fnCall.then(() => {}).catch(() => {})
try {
fnCall.then(() => {})?.catch(() => {})
} catch {
// ignore
}
}
return promiseLike
} catch {
Expand Down

0 comments on commit 151a133

Please sign in to comment.