node-firebird 1.1.6 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ function doError(obj, callback) {
2
+ if (callback)
3
+ callback(obj)
4
+ }
5
+
6
+ function isError(obj) {
7
+ return Boolean(
8
+ obj != null && typeof obj === "object" && !Array.isArray(obj) && obj.status
9
+ );
10
+ }
11
+
12
+ function doCallback(obj, callback) {
13
+
14
+ if (!callback)
15
+ return;
16
+
17
+ if (obj instanceof Error) {
18
+ callback(obj);
19
+ return;
20
+ }
21
+
22
+ if (isError(obj)) {
23
+ var error = new Error(obj.message);
24
+ var status = obj.status && obj.status.length && obj.status[0] || {};
25
+ error.gdscode = status.gdscode; // main error gds code
26
+ error.gdsparams = status.params; // parameters (constraint name, table, etc.)
27
+ callback(error);
28
+ return;
29
+ }
30
+
31
+ callback(undefined, obj);
32
+
33
+ }
34
+
35
+ module.exports = {
36
+ doError,
37
+ doCallback
38
+ }
package/lib/index.d.ts CHANGED
@@ -39,6 +39,7 @@ declare module 'node-firebird' {
39
39
  sequentially(query: string, params: any[], rowCallback: SequentialCallback, callback: SimpleCallback, asArray?: boolean): Database;
40
40
  drop(callback: SimpleCallback): void;
41
41
  escape(value: any): string;
42
+ attachEvent(callback: any): this;
42
43
  }
43
44
 
44
45
  export interface Transaction {