New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pimeys/connection-string

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pimeys/connection-string - npm Package Compare versions

Comparing version 0.1.10 to 0.1.11

77

connection_string.d.ts
/* tslint:disable */
/* eslint-disable */
/**
* A version of `JdbcString` to be used from web-assembly.
*/
export class AdoNetString {
free(): void;
/**
* A constructor to create a new `AdoNet`, used from JavaScript with
* `new AdoNet("server=tcp:localhost,1433")`.
* @param {string} s
*/
constructor(s: string);
/**
* Get a parameter from the connection's key-value pairs
* @param {string} key
* @returns {string | undefined}
*/
get(key: string): string | undefined;
/**
* Set a parameter value to the connection's key-value pairs. If replacing
* a pre-existing value, returns the old value.
* @param {string} key
* @param {string} value
* @returns {string | undefined}
*/
set(key: string, value: string): string | undefined;
}
/**
* A version of `JdbcString` to be used from web-assembly.
*/
export class JdbcString {
free(): void;
/**
* A constructor to create a new `JdbcInstance`, used from JavaScript with
* `new JdbcString("sqlserver://...")`.
* @param {string} s
*/
constructor(s: string);
/**
* Access the connection sub-protocol
* @returns {string}
*/
sub_protocol(): string;
/**
* Access the connection server name
* @returns {string | undefined}
*/
server_name(): string | undefined;
/**
* Access the connection's instance name
* @returns {string | undefined}
*/
instance_name(): string | undefined;
/**
* Access the connection's port
* @returns {number | undefined}
*/
port(): number | undefined;
/**
* Get a parameter from the connection's key-value pairs
* @param {string} key
* @returns {string | undefined}
*/
get(key: string): string | undefined;
/**
* Set a parameter value to the connection's key-value pairs. If replacing
* a pre-existing value, returns the old value.
* @param {string} key
* @param {string} value
* @returns {string | undefined}
*/
set(key: string, value: string): string | undefined;
/**
* Get a string representation of the `JdbcString`.
* @returns {string}
*/
to_string(): string;
}
let imports = {};
imports['__wbindgen_placeholder__'] = module.exports;
let wasm;
const { TextDecoder, TextEncoder } = require(String.raw`util`);
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
let cachegetUint8Memory0 = null;
function getUint8Memory0() {
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachegetUint8Memory0;
}
function getStringFromWasm0(ptr, len) {
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
}
const heap = new Array(32).fill(undefined);
heap.push(undefined, null, true, false);
let heap_next = heap.length;
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx];
heap[idx] = obj;
return idx;
}
function getObject(idx) { return heap[idx]; }
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getObject(idx);
dropObject(idx);
return ret;
}
let WASM_VECTOR_LEN = 0;
let cachedTextEncoder = new TextEncoder('utf-8');
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
? function (arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
}
: function (arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
});
function passStringToWasm0(arg, malloc, realloc) {
if (realloc === undefined) {
const buf = cachedTextEncoder.encode(arg);
const ptr = malloc(buf.length);
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
WASM_VECTOR_LEN = buf.length;
return ptr;
}
let len = arg.length;
let ptr = malloc(len);
const mem = getUint8Memory0();
let offset = 0;
for (; offset < len; offset++) {
const code = arg.charCodeAt(offset);
if (code > 0x7F) break;
mem[ptr + offset] = code;
}
if (offset !== len) {
if (offset !== 0) {
arg = arg.slice(offset);
}
ptr = realloc(ptr, len, len = offset + arg.length * 3);
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
const ret = encodeString(arg, view);
offset += ret.written;
}
WASM_VECTOR_LEN = offset;
return ptr;
}
let cachegetInt32Memory0 = null;
function getInt32Memory0() {
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
}
return cachegetInt32Memory0;
}
/**
* A version of `JdbcString` to be used from web-assembly.
*/
class AdoNetString {
static __wrap(ptr) {
const obj = Object.create(AdoNetString.prototype);
obj.ptr = ptr;
return obj;
}
free() {
const ptr = this.ptr;
this.ptr = 0;
wasm.__wbg_adonetstring_free(ptr);
}
/**
* A constructor to create a new `AdoNet`, used from JavaScript with
* `new AdoNet("server=tcp:localhost,1433")`.
* @param {string} s
*/
constructor(s) {
var ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ret = wasm.adonetstring_new(ptr0, len0);
return AdoNetString.__wrap(ret);
}
/**
* Get a parameter from the connection's key-value pairs
* @param {string} key
* @returns {string | undefined}
*/
get(key) {
try {
const retptr = wasm.__wbindgen_export_2.value - 16;
wasm.__wbindgen_export_2.value = retptr;
var ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
wasm.adonetstring_get(retptr, this.ptr, ptr0, len0);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
let v1;
if (r0 !== 0) {
v1 = getStringFromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
}
return v1;
} finally {
wasm.__wbindgen_export_2.value += 16;
}
}
/**
* Set a parameter value to the connection's key-value pairs. If replacing
* a pre-existing value, returns the old value.
* @param {string} key
* @param {string} value
* @returns {string | undefined}
*/
set(key, value) {
try {
const retptr = wasm.__wbindgen_export_2.value - 16;
wasm.__wbindgen_export_2.value = retptr;
var ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
wasm.adonetstring_set(retptr, this.ptr, ptr0, len0, ptr1, len1);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
let v2;
if (r0 !== 0) {
v2 = getStringFromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
}
return v2;
} finally {
wasm.__wbindgen_export_2.value += 16;
}
}
}
module.exports.AdoNetString = AdoNetString;
/**
* A version of `JdbcString` to be used from web-assembly.
*/
class JdbcString {
static __wrap(ptr) {
const obj = Object.create(JdbcString.prototype);
obj.ptr = ptr;
return obj;
}
free() {
const ptr = this.ptr;
this.ptr = 0;
wasm.__wbg_jdbcstring_free(ptr);
}
/**
* A constructor to create a new `JdbcInstance`, used from JavaScript with
* `new JdbcString("sqlserver://...")`.
* @param {string} s
*/
constructor(s) {
var ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ret = wasm.jdbcstring_new(ptr0, len0);
return JdbcString.__wrap(ret);
}
/**
* Access the connection sub-protocol
* @returns {string}
*/
sub_protocol() {
try {
const retptr = wasm.__wbindgen_export_2.value - 16;
wasm.__wbindgen_export_2.value = retptr;
wasm.jdbcstring_sub_protocol(retptr, this.ptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_export_2.value += 16;
wasm.__wbindgen_free(r0, r1);
}
}
/**
* Access the connection server name
* @returns {string | undefined}
*/
server_name() {
try {
const retptr = wasm.__wbindgen_export_2.value - 16;
wasm.__wbindgen_export_2.value = retptr;
wasm.jdbcstring_server_name(retptr, this.ptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
let v0;
if (r0 !== 0) {
v0 = getStringFromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
}
return v0;
} finally {
wasm.__wbindgen_export_2.value += 16;
}
}
/**
* Access the connection's instance name
* @returns {string | undefined}
*/
instance_name() {
try {
const retptr = wasm.__wbindgen_export_2.value - 16;
wasm.__wbindgen_export_2.value = retptr;
wasm.jdbcstring_instance_name(retptr, this.ptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
let v0;
if (r0 !== 0) {
v0 = getStringFromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
}
return v0;
} finally {
wasm.__wbindgen_export_2.value += 16;
}
}
/**
* Access the connection's port
* @returns {number | undefined}
*/
port() {
var ret = wasm.jdbcstring_port(this.ptr);
return ret === 0xFFFFFF ? undefined : ret;
}
/**
* Get a parameter from the connection's key-value pairs
* @param {string} key
* @returns {string | undefined}
*/
get(key) {
try {
const retptr = wasm.__wbindgen_export_2.value - 16;
wasm.__wbindgen_export_2.value = retptr;
var ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
wasm.jdbcstring_get(retptr, this.ptr, ptr0, len0);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
let v1;
if (r0 !== 0) {
v1 = getStringFromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
}
return v1;
} finally {
wasm.__wbindgen_export_2.value += 16;
}
}
/**
* Set a parameter value to the connection's key-value pairs. If replacing
* a pre-existing value, returns the old value.
* @param {string} key
* @param {string} value
* @returns {string | undefined}
*/
set(key, value) {
try {
const retptr = wasm.__wbindgen_export_2.value - 16;
wasm.__wbindgen_export_2.value = retptr;
var ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len0 = WASM_VECTOR_LEN;
var ptr1 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
var len1 = WASM_VECTOR_LEN;
wasm.jdbcstring_set(retptr, this.ptr, ptr0, len0, ptr1, len1);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
let v2;
if (r0 !== 0) {
v2 = getStringFromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
}
return v2;
} finally {
wasm.__wbindgen_export_2.value += 16;
}
}
/**
* Get a string representation of the `JdbcString`.
* @returns {string}
*/
to_string() {
try {
const retptr = wasm.__wbindgen_export_2.value - 16;
wasm.__wbindgen_export_2.value = retptr;
wasm.jdbcstring_to_string(retptr, this.ptr);
var r0 = getInt32Memory0()[retptr / 4 + 0];
var r1 = getInt32Memory0()[retptr / 4 + 1];
return getStringFromWasm0(r0, r1);
} finally {
wasm.__wbindgen_export_2.value += 16;
wasm.__wbindgen_free(r0, r1);
}
}
}
module.exports.JdbcString = JdbcString;
module.exports.__wbindgen_string_new = function(arg0, arg1) {
var ret = getStringFromWasm0(arg0, arg1);
return addHeapObject(ret);
};
module.exports.__wbindgen_throw = function(arg0, arg1) {
throw new Error(getStringFromWasm0(arg0, arg1));
};
module.exports.__wbindgen_rethrow = function(arg0) {
throw takeObject(arg0);
};
const path = require('path').join(__dirname, 'connection_string_bg.wasm');

@@ -378,0 +5,0 @@ const bytes = require('fs').readFileSync(path);

2

package.json

@@ -8,3 +8,3 @@ {

"description": "Connection string parsing in Rust (and WebAssembly)",
"version": "0.1.10",
"version": "0.1.11",
"license": "MIT OR Apache-2.0",

@@ -11,0 +11,0 @@ "repository": {

@@ -44,3 +44,3 @@ <h1 align="center">connection-string</h1>

## Installation
## Installation for Rust
```sh

@@ -50,2 +50,36 @@ $ cargo add connection-string

## Usage for JavaScript
The crate is available in npm as `@pimeys/connection-string`. Usage patters try
to follow the Rust version as close as possible. Please see the [Rust
docs](https://docs.rs/connection-string) for more information.
JDBC:
``` javascript
const j = new JdbcString("jdbc:sqlserver://localhost\\INSTANCE:1433;database=master;user=SA;password={my_password;123}");
console.log(j.server_name()); // "localhost"
console.log(j.port()); // 1433
console.log(j.instance_name()); // "INSTANCE"
console.log(j.get("database")); // "master"
console.log(j.get("password")); // "my_password;123" (see escaping)
console.log(j.set("password", "a;;new;;password")); // "my_password;123" (returns the old value, if available)
// "jdbc:sqlserver://localhost\INSTANCE:1433;user=SA;database=master;password=a{;;}new{;;}password"
console.log(j.to_string())
```
ADO.net:
``` javascript
const a = new AdoNetString("server=tcp:localhost,1433;user=SA;password=a{;;}new{;;}password");
console.log(a.get("password")); // a;;new;;password
console.log(a.set("user", "john")); // "SA" (returns the old value, if available)
// "server=tcp:localhost,1433;user=john;password=a{;;}new{;;}password"
console.log(j.to_string())
```
## Safety

@@ -52,0 +86,0 @@ This crate uses ``#![deny(unsafe_code)]`` to ensure everything is implemented in

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc