wasm-rquickjs-cli 0.5.3

Tool for wrapping JavaScript modules as WebAssembly components using the QuickJS engine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import assert from 'assert';
import mysql from 'mysql2';

export const run = () => {
  const escapedValue = mysql.escape("O'Reilly");
  assert.strictEqual(escapedValue, "'O\\'Reilly'");

  const escapedIdentifier = mysql.escapeId('users.profile');
  assert.strictEqual(escapedIdentifier, '`users`.`profile`');

  const formatted = mysql.format(
    'SELECT ? AS value, ? AS text, ? AS generated',
    [7, "D'Angelo", mysql.raw('NOW()')],
  );
  assert.strictEqual(formatted, "SELECT 7 AS value, 'D\\'Angelo' AS text, NOW() AS generated");

  return 'PASS: mysql2 escaping and SQL formatting helpers work';
};