Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions bench/isNumericString.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { bench } from 'vitest';

import { isNumericString } from '../src/predicate/isNumericString.js';

const numberValue = Number.MAX_SAFE_INTEGER;
const bigIntValue = BigInt(Number.MAX_VALUE) + BigInt(Number.MAX_VALUE);
const stringValue = String(numberValue);
const bigIntStringValue = String(bigIntValue);

bench('isNumericString() - number', () => {
isNumericString(numberValue);
});

bench('isNumericString() - bigint', () => {
isNumericString(bigIntValue);
});

bench('isNumericString() - stringified number', () => {
isNumericString(stringValue);
});

bench('isNumericString() - stringified bigint', () => {
isNumericString(bigIntStringValue);
});
29 changes: 29 additions & 0 deletions bench/isNumericValue.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { bench } from 'vitest';

import { isNumericValue } from '../src/predicate/isNumericValue.js';

const simpleNumber = 123.456;
const maxSafeInt = Number.MAX_SAFE_INTEGER;
const bigIntValue = BigInt(Number.MAX_VALUE) + BigInt(Number.MAX_VALUE);
const stringifiedMaxInt = String(maxSafeInt);
const stringifiedBigInt = String(bigIntValue);

bench('isNumericValue() - simple decimal numbers', () => {
isNumericValue(simpleNumber);
});

bench('isNumericValue() - Number.MAX_SAFE_INTEGER', () => {
isNumericValue(maxSafeInt);
});

bench('isNumericValue() - bigint', () => {
isNumericValue(bigIntValue);
});

bench('isNumericValue() - stringified Number.MAX_SAFE_INTEGER', () => {
isNumericValue(stringifiedMaxInt);
});

bench('isNumericValue() - stringified BigInt', () => {
isNumericValue(stringifiedBigInt);
});
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"url": "https://github.com/webdeveric/utils/issues"
},
"homepage": "https://github.com/webdeveric/utils/#readme",
"packageManager": "[email protected].4+sha512.da3d715bfd22a9a105e6e8088cfc7826699332ded60c423b14ec613a185f1602206702ff0fe4c438cb15c979081ce4cb02568e364b15174503a63c7a8e2a5f6c",
"packageManager": "[email protected].5+sha512.cdf928fca20832cd59ec53826492b7dc25dc524d4370b6b4adbf65803d32efaa6c1c88147c0ae4e8d579a6c9eec715757b50d4fa35eea179d868eada4ed043af",
"scripts": {
"clean": "rimraf ./dist/",
"prebuild": "pnpm clean",
Expand All @@ -87,7 +87,7 @@
"devDependencies": {
"@commitlint/config-conventional": "^19.8.0",
"@commitlint/types": "^19.8.0",
"@types/node": "^22.13.10",
"@types/node": "^22.13.11",
"@vitest/coverage-v8": "^3.0.9",
"@webdeveric/eslint-config-ts": "^0.11.0",
"@webdeveric/prettier-config": "^0.3.0",
Expand Down
Loading