Skip to content

Commit 34e15ef

Browse files
isJsonObject script migration
1 parent e0dbc6d commit 34e15ef

6 files changed

Lines changed: 19 additions & 10 deletions

File tree

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
"lodash": "^4.17.21",
2323
"pg": "^8.16.3",
2424
"sqlite": "^5.1.1",
25-
"sqlite3": "^5.1.7",
26-
"tiny-essentials": "^1.24.2"
25+
"sqlite3": "^5.1.7"
2726
},
2827
"keywords": [
2928
"sql",
@@ -72,6 +71,7 @@
7271
"@rollup/plugin-typescript": "^12.1.4",
7372
"@types/http-errors": "^2.0.5",
7473
"@types/node": "^24.0.10",
74+
"tiny-essentials": "^1.24.2",
7575
"babel-preset-es2015": "^6.24.1",
7676
"http-errors": "^2.0.0",
7777
"node-polyfill-webpack-plugin": "^4.1.0",

src/PuddySqlInstance.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { open, Database } from 'sqlite';
22
import { EventEmitter } from 'events';
3-
import { isJsonObject } from 'tiny-essentials';
43

5-
import { validatePostgresParams } from './Utils.mjs';
4+
import { isJsonObject, validatePostgresParams } from './Utils.mjs';
65
import { pg, sqlite3 } from './Modules.mjs';
76
import PuddySqlEngine from './PuddySqlEngine.mjs';
87
import PuddySqlQuery from './PuddySqlQuery.mjs';

src/PuddySqlQuery.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { isJsonObject } from 'tiny-essentials';
21
import { pg } from './Modules.mjs';
32
import PuddySqlEngine from './PuddySqlEngine.mjs';
43
import PuddySqlTags from './PuddySqlTags.mjs';
4+
import { isJsonObject } from './Utils.mjs';
55

66
/**
77
* Defines the schema structure used to create or modify SQL tables programmatically.

src/PuddySqlTags.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _ from 'lodash';
2-
import { isJsonObject } from 'tiny-essentials';
2+
import { isJsonObject } from './Utils.mjs';
33

44
/** @typedef {{ title: string; parser?: (value: string) => string }} SpecialQuery */
55
/** @typedef {import('./PuddySqlQuery.mjs').Pcache} Pcache */

src/Utils.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* Validates if the provided value is a non-null object.
3+
* @param {unknown} value - The value to evaluate.
4+
* @returns {value is Record<string | number | symbol, unknown>} True if the value is a type of object and specifically not null.
5+
*/
6+
export function isJsonObject(value) {
7+
return value !== null && !Array.isArray(value) && typeof value === 'object';
8+
}
9+
110
/**
211
* Converts PostgreSQL-style SQL placeholders ($1, $2, ...) to MySQL-style placeholders (?).
312
* Maintains full compatibility with repeated and unordered params.

0 commit comments

Comments
 (0)