pgsql-deparser 13.6.2 → 13.7.0

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.
package/main/index.js CHANGED
@@ -1,19 +1,10 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- Object.defineProperty(exports, "Deparser", {
9
- enumerable: true,
10
- get: function get() {
11
- return _deparser["default"];
12
- }
13
- });
14
- exports.deparse = void 0;
15
-
16
- var _deparser = _interopRequireDefault(require("./deparser"));
17
-
18
- var deparse = _deparser["default"].deparse;
19
- exports.deparse = deparse;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Deparser = exports.deparse = void 0;
7
+ const deparser_1 = __importDefault(require("./deparser"));
8
+ exports.Deparser = deparser_1.default;
9
+ const deparse = deparser_1.default.deparse;
10
+ exports.deparse = deparse;
@@ -1,117 +1,97 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.cleanTreeWithStmt = exports.cleanTree = exports.transform = exports.cleanLines = void 0;
9
-
10
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
-
12
2
  /* eslint-disable no-restricted-syntax */
13
- var cleanLines = function cleanLines(sql) {
14
- return sql.split('\n').map(function (l) {
15
- return l.trim();
16
- }).filter(function (a) {
17
- return a;
18
- }).join('\n');
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.cleanTreeWithStmt = exports.cleanTree = exports.transform = exports.cleanLines = void 0;
5
+ const cleanLines = (sql) => {
6
+ return sql
7
+ .split('\n')
8
+ .map((l) => l.trim())
9
+ .filter((a) => a)
10
+ .join('\n');
19
11
  };
20
-
21
12
  exports.cleanLines = cleanLines;
22
-
23
- var transform = function transform(obj, props) {
24
- var copy = null; // Handle the 3 simple types, and null or undefined
25
-
26
- if (obj == null || (0, _typeof2["default"])(obj) !== 'object') {
27
- return obj;
28
- } // Handle Date
29
-
30
-
31
- if (obj instanceof Date) {
32
- copy = new Date();
33
- copy.setTime(obj.getTime());
34
- return copy;
35
- } // Handle Array
36
-
37
-
38
- if (obj instanceof Array) {
39
- copy = [];
40
-
41
- for (var i = 0, len = obj.length; i < len; i++) {
42
- copy[i] = transform(obj[i], props);
13
+ const transform = (obj, props) => {
14
+ let copy = null;
15
+ // Handle the 3 simple types, and null or undefined
16
+ if (obj == null || typeof obj !== 'object') {
17
+ return obj;
43
18
  }
44
-
45
- return copy;
46
- } // Handle Object
47
-
48
-
49
- if (obj instanceof Object || (0, _typeof2["default"])(obj) === 'object') {
50
- copy = {};
51
-
52
- for (var attr in obj) {
53
- if (obj.hasOwnProperty(attr)) {
54
- if (props.hasOwnProperty(attr)) {
55
- if (typeof props[attr] === 'function') {
56
- copy[attr] = props[attr](obj[attr]);
57
- } else if (props[attr].hasOwnProperty(obj[attr])) {
58
- copy[attr] = props[attr][obj[attr]];
59
- } else {
60
- copy[attr] = transform(obj[attr], props);
61
- }
62
- } else {
63
- copy[attr] = transform(obj[attr], props);
19
+ // Handle Date
20
+ if (obj instanceof Date) {
21
+ copy = new Date();
22
+ copy.setTime(obj.getTime());
23
+ return copy;
24
+ }
25
+ // Handle Array
26
+ if (obj instanceof Array) {
27
+ copy = [];
28
+ for (let i = 0, len = obj.length; i < len; i++) {
29
+ copy[i] = (0, exports.transform)(obj[i], props);
64
30
  }
65
- } else {
66
- copy[attr] = transform(obj[attr], props);
67
- }
31
+ return copy;
68
32
  }
69
-
70
- return copy;
71
- }
72
-
73
- throw new Error("Unable to copy obj! Its type isn't supported.");
33
+ // Handle Object
34
+ if (obj instanceof Object || typeof obj === 'object') {
35
+ copy = {};
36
+ for (const attr in obj) {
37
+ if (obj.hasOwnProperty(attr)) {
38
+ if (props.hasOwnProperty(attr)) {
39
+ if (typeof props[attr] === 'function') {
40
+ copy[attr] = props[attr](obj[attr]);
41
+ }
42
+ else if (props[attr].hasOwnProperty(obj[attr])) {
43
+ copy[attr] = props[attr][obj[attr]];
44
+ }
45
+ else {
46
+ copy[attr] = (0, exports.transform)(obj[attr], props);
47
+ }
48
+ }
49
+ else {
50
+ copy[attr] = (0, exports.transform)(obj[attr], props);
51
+ }
52
+ }
53
+ else {
54
+ copy[attr] = (0, exports.transform)(obj[attr], props);
55
+ }
56
+ }
57
+ return copy;
58
+ }
59
+ throw new Error("Unable to copy obj! Its type isn't supported.");
74
60
  };
75
-
76
61
  exports.transform = transform;
77
-
78
- var noop = function noop() {
79
- return undefined;
80
- };
81
-
82
- var cleanTree = function cleanTree(tree) {
83
- return transform(tree, {
84
- stmt_len: noop,
85
- stmt_location: noop,
86
- location: noop,
87
- DefElem: function DefElem(obj) {
88
- if (obj.defname === 'as') {
89
- if (Array.isArray(obj.arg) && obj.arg.length) {
90
- // function
91
- obj.arg[0].String.str = obj.arg[0].String.str.trim();
92
- } else if (obj.arg.List && obj.arg.List.items) {
93
- // function
94
- obj.arg.List.items[0].String.str = obj.arg.List.items[0].String.str.trim();
95
- } else {
96
- // do stmt
97
- obj.arg.String.str = obj.arg.String.str.trim();
62
+ const noop = () => undefined;
63
+ const cleanTree = (tree) => {
64
+ return (0, exports.transform)(tree, {
65
+ stmt_len: noop,
66
+ stmt_location: noop,
67
+ location: noop,
68
+ DefElem: (obj) => {
69
+ if (obj.defname === 'as') {
70
+ if (Array.isArray(obj.arg) && obj.arg.length) {
71
+ // function
72
+ obj.arg[0].String.str = obj.arg[0].String.str.trim();
73
+ }
74
+ else if (obj.arg.List && obj.arg.List.items) {
75
+ // function
76
+ obj.arg.List.items[0].String.str = obj.arg.List.items[0].String.str.trim();
77
+ }
78
+ else {
79
+ // do stmt
80
+ obj.arg.String.str = obj.arg.String.str.trim();
81
+ }
82
+ return (0, exports.cleanTree)(obj);
83
+ }
84
+ else {
85
+ return (0, exports.cleanTree)(obj);
86
+ }
98
87
  }
99
-
100
- return cleanTree(obj);
101
- } else {
102
- return cleanTree(obj);
103
- }
104
- }
105
- });
88
+ });
106
89
  };
107
-
108
90
  exports.cleanTree = cleanTree;
109
-
110
- var cleanTreeWithStmt = function cleanTreeWithStmt(tree) {
111
- return transform(tree, {
112
- stmt_location: noop,
113
- location: noop
114
- });
91
+ const cleanTreeWithStmt = (tree) => {
92
+ return (0, exports.transform)(tree, {
93
+ stmt_location: noop,
94
+ location: noop
95
+ });
115
96
  };
116
-
117
- exports.cleanTreeWithStmt = cleanTreeWithStmt;
97
+ exports.cleanTreeWithStmt = cleanTreeWithStmt;