sql-escaper
Advanced tools
+1
-0
@@ -6,2 +6,3 @@ /** | ||
| import type { Raw, SqlValue, Timezone } from './types.js'; | ||
| import { Buffer } from 'node:buffer'; | ||
| export type { Raw, SqlValue, Timezone } from './types.js'; | ||
@@ -8,0 +9,0 @@ export declare const dateToString: (date: Date, timezone: Timezone) => string; |
+3
-2
@@ -8,2 +8,3 @@ "use strict"; | ||
| exports.raw = exports.format = exports.escape = exports.arrayToList = exports.bufferToString = exports.objectToValues = exports.escapeId = exports.dateToString = void 0; | ||
| const node_buffer_1 = require("node:buffer"); | ||
| const regex = { | ||
@@ -159,3 +160,3 @@ set: /\bSET\b|\bKEY\s+UPDATE\b/i, | ||
| return (0, exports.arrayToList)(value, timezone); | ||
| if (Buffer.isBuffer(value)) | ||
| if (node_buffer_1.Buffer.isBuffer(value)) | ||
| return (0, exports.bufferToString)(value); | ||
@@ -213,3 +214,3 @@ if (hasSqlString(value)) | ||
| !Array.isArray(currentValue) && | ||
| !Buffer.isBuffer(currentValue) && | ||
| !node_buffer_1.Buffer.isBuffer(currentValue) && | ||
| !isDate(currentValue) && | ||
@@ -216,0 +217,0 @@ isRecord(currentValue)) |
+1
-0
@@ -0,1 +1,2 @@ | ||
| import { Buffer } from "node:buffer"; | ||
| const regex = { | ||
@@ -2,0 +3,0 @@ set: /\bSET\b|\bKEY\s+UPDATE\b/i, |
+1
-1
| { | ||
| "name": "sql-escaper", | ||
| "version": "0.1.1", | ||
| "version": "1.0.0", | ||
| "description": "🛡️ Faster SQL escape and format for JavaScript (Node.js, Bun, and Deno).", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
+12
-14
@@ -16,4 +16,2 @@ <h1 align="center">SQL Escaper</h1> | ||
| > 🚧 **WIP** | ||
| ```bash | ||
@@ -318,10 +316,10 @@ # Node.js | ||
| | Benchmark | sqlstring | SQL Escaper | Difference | % | | ||
| | ---------------------------------------- | --------: | ----------: | ---------------: | --------: | | ||
| | Select 100 values | 313.0 ms | 193.7 ms | **1.62x faster** | **~62%** | | ||
| | Insert 100 values | 311.9 ms | 194.1 ms | **1.61x faster** | **~61%** | | ||
| | SET with 100 values | 317.6 ms | 191.0 ms | **1.66x faster** | **~66%** | | ||
| | SET with 100 objects | 448.9 ms | 224.2 ms | **2.00x faster** | **~100%** | | ||
| | ON DUPLICATE KEY UPDATE with 100 values | 568.8 ms | 330.3 ms | **1.72x faster** | **~72%** | | ||
| | ON DUPLICATE KEY UPDATE with 100 objects | 690.3 ms | 361.1 ms | **1.91x faster** | **~91%** | | ||
| | Benchmark | sqlstring | SQL Escaper | Difference | | ||
| | ---------------------------------------- | ---------: | ----------: | ---------------: | | ||
| | Select 100 values | 460.9 ms | 242.2 ms | **1.90x faster** | | ||
| | Insert 100 values | 468.6 ms | 242.5 ms | **1.93x faster** | | ||
| | SET with 100 values | 484.2 ms | 257.0 ms | **1.88x faster** | | ||
| | SET with 100 objects | 671.6 ms | 283.2 ms | **2.37x faster** | | ||
| | ON DUPLICATE KEY UPDATE with 100 values | 894.0 ms | 459.8 ms | **1.94x faster** | | ||
| | ON DUPLICATE KEY UPDATE with 100 objects | 1,092.0 ms | 485.7 ms | **2.25x faster** | | ||
@@ -332,4 +330,4 @@ - See detailed results and how the benchmarks are run in the [**benchmark**](https://github.com/wellwelwel/sql-escaper/tree/main/benchmark) directory. | ||
| > | ||
| > Benchmarks ran on an **Apple M2 Ultra** with **64 GB RAM** using **Node.js v25.5.0**. | ||
| > Results may vary depending on hardware and runtime version. | ||
| > Benchmarks ran on [**GitHub Actions**](https://github.com/wellwelwel/sql-escaper/blob/main/.github/workflows/ci_benchmark.yml) (`ubuntu-latest`) using **Node.js LTS**. | ||
| > Results may vary depending on runner hardware and runtime version. | ||
@@ -386,3 +384,3 @@ --- | ||
| - **SQL Escaper** is adapted from [**sqlstring**](https://github.com/mysqljs/sqlstring) ([**MIT**](https://github.com/mysqljs/sqlstring/blob/master/LICENSE)), modernizing it with high performance, TypeScript support and multi-runtime compatibility. | ||
| - Special thanks to [**Douglas Wilson**](https://github.com/dougwilson) for the original **sqlstring** project. | ||
| - Special thanks to [**Douglas Wilson**](https://github.com/dougwilson) for the original **sqlstring** project and its [**contributors**](https://github.com/mysqljs/sqlstring/graphs/contributors). | ||
@@ -394,2 +392,2 @@ --- | ||
| **SQL Escaper** is under the [**MIT License**](https://github.com/wellwelwel/sql-escaper/blob/main/LICENSE).<br /> | ||
| Copyright © 2024-present [Weslley Araújo](https://github.com/wellwelwel) and **SQL Escaper** [contributors](https://github.com/wellwelwel/sql-escaper/graphs/contributors). | ||
| Copyright © 2026-present [**Weslley Araújo**](https://github.com/wellwelwel) and **SQL Escaper** [**contributors**](https://github.com/wellwelwel/sql-escaper/graphs/contributors). |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
33546
0.68%465
0.65%1
-50%389
-0.51%