Skip to content
Merged
9 changes: 9 additions & 0 deletions bench/isIterable.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { bench } from 'vitest';

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

const data: unknown[] = [];

bench('isIterable()', () => {
isIterable(data);
});
28 changes: 28 additions & 0 deletions bench/isPromiseLike.bench.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { bench } from 'vitest';

import { isFunction } from '../src/predicate/isFunction.js';
import { isObjectWith } from '../src/predicate/isObjectWith.js';
import { isPromiseLike } from '../src/predicate/isPromiseLike.js';

function isPromiseLike2<T>(input: unknown): input is PromiseLike<T> {
return isObjectWith(input, 'then') && isFunction(input.then) && input.then.length === 2;
}

const resolvedPromise = Promise.resolve();

const promiseLikeObject = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
then(_onfulfilled: unknown, _onrejected: unknown): void {
// noop
},
};

bench('isPromiseLike()', () => {
isPromiseLike(resolvedPromise);
isPromiseLike(promiseLikeObject);
});

bench('isPromiseLike2()', () => {
isPromiseLike2(resolvedPromise);
isPromiseLike2(promiseLikeObject);
});
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"require": "./dist/cjs/index.js",
"import": "./dist/mjs/index.js"
},
"./predicate-factory": {
"types": "./dist/types/predicate-factory/index.d.ts",
"require": "./dist/cjs/predicate-factory/index.js",
"import": "./dist/mjs/predicate-factory/index.js"
"./predicate/factory": {
"types": "./dist/types/predicate/factory/index.d.ts",
"require": "./dist/cjs/predicate/factory/index.js",
"import": "./dist/mjs/predicate/factory/index.js"
},
"./predicate": {
"types": "./dist/types/predicate/index.d.ts",
Expand Down Expand Up @@ -72,7 +72,7 @@
"prebuild": "pnpm clean",
"build": "tsc --build tsconfig.cjs.json tsconfig.mjs.json --force",
"postbuild": "echo '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json && echo '{\"type\":\"module\"}' > ./dist/mjs/package.json && pnpm validate",
"typecheck": "tsc --build --verbose --noEmit",
"typecheck": "tsc --build tsconfig.mjs.json tsconfig.test.json --verbose --noEmit",
"lint": "eslint ./*.{js,cjs,mjs,ts,cts,mts} ./src/ ./bench/ ./test/ --ext .ts,.mjs,.cjs",
"bench": "vitest bench",
"test": "vitest --typecheck",
Expand All @@ -97,7 +97,7 @@
"cspell": "^8.17.5",
"eslint": "^8.57.1",
"eslint-config-prettier": "^10.1.1",
"eslint-import-resolver-typescript": "^3.8.7",
"eslint-import-resolver-typescript": "^3.9.1",
"eslint-plugin-import": "^2.31.0",
"husky": "^9.1.7",
"jsdom": "^26.0.0",
Expand Down
Loading