From 82998fa79fe773b7f96032c3111bcc9eafdd1fbc Mon Sep 17 00:00:00 2001 From: Justin Stayton Date: Wed, 19 Aug 2026 13:45:56 -0400 Subject: [PATCH] Replace is dependency with native code --- AGENTS.md | 2 +- package-lock.json | 10 ---------- package.json | 1 - src/adapters/base.js | 4 +--- src/orchestrators/base.js | 4 +--- src/parsers/filter.js | 7 ++++--- src/parsers/page.js | 7 ++++--- src/parsers/sort.js | 6 ++---- src/schema.js | 4 +--- 9 files changed, 14 insertions(+), 31 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 5d1361a..bccc6e7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -20,7 +20,7 @@ code in this repository. release). CI runs `npm run lint` then `npm test -- --ci --coverage --runInBand` against -Node 20.x, 22.x, and 24.x. The package targets `node >= 20` and is CommonJS +Node 22.x, 24.x, and 26.x. The package targets `node >= 22` and is CommonJS (`require` / `module.exports`). ## Architecture diff --git a/package-lock.json b/package-lock.json index e9eaee7..c4caeca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "version": "0.22.0", "license": "MIT", "dependencies": { - "is": "^3.3.2", "joi": "^18.2.4" }, "devDependencies": { @@ -4516,15 +4515,6 @@ "node": ">= 12" } }, - "node_modules/is": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/is/-/is-3.3.2.tgz", - "integrity": "sha512-a2xr4E3s1PjDS8ORcGgXpWx6V+liNs+O3JRD2mb9aeugD7rtkkZ0zgLdYgw0tWsKhsdiezGYptSiMlVazCBTuQ==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, "node_modules/is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", diff --git a/package.json b/package.json index e4e73da..880fc4a 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,6 @@ "test": "jest" }, "dependencies": { - "is": "^3.3.2", "joi": "^18.2.4" }, "devDependencies": { diff --git a/src/adapters/base.js b/src/adapters/base.js index eb148ff..1161868 100644 --- a/src/adapters/base.js +++ b/src/adapters/base.js @@ -1,5 +1,3 @@ -const is = require('is') - const AdapterValidator = require('../validators/adapter') const NotImplementedError = require('../errors/not_implemented') @@ -41,7 +39,7 @@ class BaseAdapter { const operatorMethod = `filter:${operator}` - if (is.fn(this[operatorMethod])) { + if (typeof this[operatorMethod] === 'function') { return this[operatorMethod](builder, filter) } diff --git a/src/orchestrators/base.js b/src/orchestrators/base.js index 547e8e7..3f25a64 100644 --- a/src/orchestrators/base.js +++ b/src/orchestrators/base.js @@ -1,5 +1,3 @@ -const is = require('is') - const cache = require('../services/cache_function') const NotImplementedError = require('../errors/not_implemented') const ValidationError = require('../errors/validation') @@ -58,7 +56,7 @@ class BaseOrchestrator { const args = [this.querier.builder, values] this.querier.builder = - querierMethod && is.fn(this.querier[querierMethod]) + querierMethod && typeof this.querier[querierMethod] === 'function' ? this.querier[querierMethod](...args) : this.querier.adapter[this.queryKey](...args) diff --git a/src/parsers/filter.js b/src/parsers/filter.js index 7aae13d..310d325 100644 --- a/src/parsers/filter.js +++ b/src/parsers/filter.js @@ -1,5 +1,3 @@ -const is = require('is') - const BaseParser = require('./base') const flattenMap = require('../services/flatten_map') @@ -95,7 +93,10 @@ class FilterParser extends BaseParser { const filters = [] for (const [name, value] of entries) { - if (is.object(value)) { + // `Object.prototype.toString` is used instead of `typeof` so that arrays, + // `null`, and exotic objects (like `Date`) are treated as filter values + // rather than operator objects. + if (Object.prototype.toString.call(value) === '[object Object]') { filters.push(...this.parseObject(name, value)) } else { filters.push(this.parseNonObject(name, value)) diff --git a/src/parsers/page.js b/src/parsers/page.js index 82952ea..0d389cd 100644 --- a/src/parsers/page.js +++ b/src/parsers/page.js @@ -1,5 +1,3 @@ -const is = require('is') - const BaseParser = require('./base') const flattenMap = require('../services/flatten_map') @@ -60,7 +58,10 @@ class PageParser extends BaseParser { if (!this.query) { page = this.defaults - } else if (is.number(this.query) || is.string(this.query)) { + } else if ( + typeof this.query === 'number' || + typeof this.query === 'string' + ) { page = this.parseNumber() } else { page = this.parseObject() diff --git a/src/parsers/sort.js b/src/parsers/sort.js index 57c3a02..4cf61fa 100644 --- a/src/parsers/sort.js +++ b/src/parsers/sort.js @@ -1,5 +1,3 @@ -const is = require('is') - const BaseParser = require('./base') const flattenMap = require('../services/flatten_map') @@ -89,9 +87,9 @@ class SortParser extends BaseParser { const sorts = [] - if (is.string(this.query)) { + if (typeof this.query === 'string') { sorts.push(this.parseString(this.query)) - } else if (is.array(this.query)) { + } else if (Array.isArray(this.query)) { sorts.push(...this.parseArray(this.query)) } else { sorts.push(...this.parseObject(this.query)) diff --git a/src/schema.js b/src/schema.js index 4f08cb0..edc542b 100644 --- a/src/schema.js +++ b/src/schema.js @@ -1,5 +1,3 @@ -const is = require('is') - class Schema { constructor() { this.filters = new Map() @@ -33,7 +31,7 @@ class Schema { } page(isEnabledOrOptions = true) { - if (is.bool(isEnabledOrOptions)) { + if (typeof isEnabledOrOptions === 'boolean') { this.pageOptions = { isEnabled: isEnabledOrOptions } } else { this.pageOptions = {