gcf-common-lib 0.8.0 → 0.10.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/index.js CHANGED
@@ -8,161 +8,93 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
11
  Object.defineProperty(exports, "__esModule", { value: true });
39
12
  exports.GcfCommon = exports.storage = exports.pubSub = void 0;
40
- var lodash_1 = require("lodash");
41
- var storage_1 = require("@google-cloud/storage");
42
- var pubsub_1 = require("@google-cloud/pubsub");
43
- var utils_1 = require("./utils");
13
+ const pubsub_1 = require("@google-cloud/pubsub");
14
+ const secret_manager_1 = require("@google-cloud/secret-manager");
15
+ const storage_1 = require("@google-cloud/storage");
16
+ const lodash_1 = require("lodash");
17
+ const utils_1 = require("./utils");
44
18
  exports.pubSub = new pubsub_1.PubSub();
45
19
  exports.storage = new storage_1.Storage();
46
- var GcfCommon = /** @class */ (function () {
47
- function GcfCommon() {
48
- }
49
- /**
50
- *
51
- * @param {!TEvent} event Event payload.
52
- * @param {!TContext} context Metadata for the event.
53
- * @param handler
54
- * @param timeout Seconds
55
- */
56
- GcfCommon.process = function (event, context, handler, timeout) {
57
- if (timeout === void 0) { timeout = 535; }
58
- return __awaiter(this, void 0, void 0, function () {
59
- var _this = this;
60
- return __generator(this, function (_a) {
61
- return [2 /*return*/, Promise.race([
62
- (0, utils_1.timeoutAfter)(timeout),
63
- handler(event, context),
64
- ])
65
- .then(function (res) { return __awaiter(_this, void 0, void 0, function () {
66
- return __generator(this, function (_a) {
67
- switch (_a.label) {
68
- case 0:
69
- // console.log('res:', res);
70
- return [4 /*yield*/, this.publish(event, context, res !== null && res !== void 0 ? res : {})];
71
- case 1:
72
- // console.log('res:', res);
73
- _a.sent();
74
- return [2 /*return*/];
75
- }
76
- });
77
- }); })
78
- .catch(function (err) { return __awaiter(_this, void 0, void 0, function () {
79
- var fname, response;
80
- var _a, _b;
81
- return __generator(this, function (_c) {
82
- switch (_c.label) {
83
- case 0:
84
- fname = (_b = (_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.K_SERVICE) !== null && _b !== void 0 ? _b : 'UNKNOWN';
85
- response = {
86
- error: {
87
- name: err.name,
88
- message: "GCF [" + fname + "]: " + err.message,
89
- stack: err.stack,
90
- },
91
- };
92
- return [4 /*yield*/, this.publish(event, context, response).catch(lodash_1.noop)];
93
- case 1:
94
- _c.sent();
95
- throw err;
96
- }
97
- });
98
- }); })];
99
- });
20
+ const secretClient = new secret_manager_1.SecretManagerServiceClient();
21
+ class GcfCommon {
22
+ static process(event, context, handler, timeout = 535) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ return Promise.race([
25
+ (0, utils_1.timeoutAfter)(timeout),
26
+ handler(event, context),
27
+ ])
28
+ .then((res) => __awaiter(this, void 0, void 0, function* () {
29
+ yield this.publish(event, context, res !== null && res !== void 0 ? res : {});
30
+ }))
31
+ .catch((err) => __awaiter(this, void 0, void 0, function* () {
32
+ var _a, _b;
33
+ const fname = (_b = (_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.K_SERVICE) !== null && _b !== void 0 ? _b : 'UNKNOWN';
34
+ const response = {
35
+ error: {
36
+ name: err.name,
37
+ message: `GCF [${fname}]: ${err.message}`,
38
+ stack: err.stack,
39
+ },
40
+ };
41
+ yield this.publish(event, context, response).catch(lodash_1.noop);
42
+ throw err;
43
+ }));
100
44
  });
101
- };
102
- GcfCommon.publish = function (event, context, json) {
103
- return __awaiter(this, void 0, void 0, function () {
104
- var topic;
105
- return __generator(this, function (_a) {
106
- switch (_a.label) {
107
- case 0: return [4 /*yield*/, this.getTopic(event, context)];
108
- case 1:
109
- topic = _a.sent();
110
- console.log('publish:', topic === null || topic === void 0 ? void 0 : topic.name, json);
111
- if (!topic) return [3 /*break*/, 3];
112
- return [4 /*yield*/, topic.publishMessage({ json: json })];
113
- case 2: return [2 /*return*/, _a.sent()];
114
- case 3: return [2 /*return*/];
115
- }
116
- });
45
+ }
46
+ static publish(event, context, json) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const topic = yield this.getTopic(event, context);
49
+ console.log('publish:', topic === null || topic === void 0 ? void 0 : topic.name, json);
50
+ if (topic)
51
+ return yield topic.publishMessage({ json });
117
52
  });
118
- };
119
- GcfCommon.getTopic = function (event, context) {
53
+ }
54
+ static getTopic(event, context) {
120
55
  var _a, _b, _c;
121
- return __awaiter(this, void 0, void 0, function () {
122
- var topicName, file, meta, topic;
123
- return __generator(this, function (_d) {
124
- switch (_d.label) {
125
- case 0:
126
- topicName = (_a = event === null || event === void 0 ? void 0 : event.metadata) === null || _a === void 0 ? void 0 : _a.topic;
127
- if (!(!topicName && ((_b = context === null || context === void 0 ? void 0 : context.resource) === null || _b === void 0 ? void 0 : _b.type) === 'storage#object')) return [3 /*break*/, 2];
128
- file = exports.storage.bucket(event.bucket).file(event.name);
129
- return [4 /*yield*/, file.getMetadata()];
130
- case 1:
131
- meta = (_d.sent())[0];
132
- topicName = (_c = meta === null || meta === void 0 ? void 0 : meta.metadata) === null || _c === void 0 ? void 0 : _c.topic;
133
- console.log('topic:', topicName);
134
- _d.label = 2;
135
- case 2:
136
- if (!!(0, lodash_1.isEmpty)(topicName)) return [3 /*break*/, 4];
137
- topic = exports.pubSub.topic(topicName);
138
- return [4 /*yield*/, topic.setMetadata({ labels: { date: topicName.split('__')[1] } })];
139
- case 3:
140
- _d.sent();
141
- return [2 /*return*/, topic];
142
- case 4: return [2 /*return*/];
143
- }
144
- });
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ let topicName = (_a = event === null || event === void 0 ? void 0 : event.metadata) === null || _a === void 0 ? void 0 : _a.topic;
58
+ if (!topicName && ((_b = context === null || context === void 0 ? void 0 : context.resource) === null || _b === void 0 ? void 0 : _b.type) === 'storage#object') {
59
+ const file = exports.storage.bucket(event.bucket).file(event.name);
60
+ const [meta] = yield file.getMetadata();
61
+ topicName = (_c = meta === null || meta === void 0 ? void 0 : meta.metadata) === null || _c === void 0 ? void 0 : _c.topic;
62
+ console.log('topic:', topicName);
63
+ }
64
+ if (topicName && !(0, lodash_1.isEmpty)(topicName)) {
65
+ const topic = exports.pubSub.topic(topicName);
66
+ yield topic.setMetadata({ labels: { date: topicName.split('__')[1] } });
67
+ return topic;
68
+ }
145
69
  });
146
- };
147
- GcfCommon.getOptions = function (event, context) {
70
+ }
71
+ static getOptions(event, context) {
148
72
  var _a, _b, _c, _d, _e;
149
- return __awaiter(this, void 0, void 0, function () {
150
- var file, meta;
151
- return __generator(this, function (_f) {
152
- switch (_f.label) {
153
- case 0:
154
- if (!((_a = event === null || event === void 0 ? void 0 : event.metadata) === null || _a === void 0 ? void 0 : _a.options)) return [3 /*break*/, 1];
155
- return [2 /*return*/, JSON.parse((_c = (_b = event === null || event === void 0 ? void 0 : event.metadata) === null || _b === void 0 ? void 0 : _b.options) !== null && _c !== void 0 ? _c : '{}')];
156
- case 1:
157
- file = exports.storage.bucket(event.bucket).file(event.name);
158
- return [4 /*yield*/, file.getMetadata()];
159
- case 2:
160
- meta = (_f.sent())[0];
161
- return [2 /*return*/, JSON.parse((_e = (_d = meta === null || meta === void 0 ? void 0 : meta.metadata) === null || _d === void 0 ? void 0 : _d.options) !== null && _e !== void 0 ? _e : '{}')];
162
- }
163
- });
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ if ((_a = event === null || event === void 0 ? void 0 : event.metadata) === null || _a === void 0 ? void 0 : _a.options) {
75
+ return JSON.parse((_c = (_b = event === null || event === void 0 ? void 0 : event.metadata) === null || _b === void 0 ? void 0 : _b.options) !== null && _c !== void 0 ? _c : '{}');
76
+ }
77
+ else {
78
+ const file = exports.storage.bucket(event.bucket).file(event.name);
79
+ const [meta] = yield file.getMetadata();
80
+ return JSON.parse((_e = (_d = meta === null || meta === void 0 ? void 0 : meta.metadata) === null || _d === void 0 ? void 0 : _d.options) !== null && _e !== void 0 ? _e : '{}');
81
+ }
82
+ });
83
+ }
84
+ static getSecret(name, version) {
85
+ var _a, _b;
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ const projectId = yield secretClient.getProjectId();
88
+ const secretName = `projects/${projectId}/secrets/${name}`;
89
+ const secretVersion = `${secretName}/versions/${version !== null && version !== void 0 ? version : 'latest'}`;
90
+ const [response] = yield secretClient.accessSecretVersion({ name: secretVersion });
91
+ return (_b = (_a = response === null || response === void 0 ? void 0 : response.payload) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.toString();
92
+ });
93
+ }
94
+ static getSecrets(names, versions) {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ return Promise.all(names.map((name, idx) => __awaiter(this, void 0, void 0, function* () { return this.getSecret(name, versions === null || versions === void 0 ? void 0 : versions[idx]); })));
164
97
  });
165
- };
166
- return GcfCommon;
167
- }());
98
+ }
99
+ }
168
100
  exports.GcfCommon = GcfCommon;
package/index.ts CHANGED
@@ -1,6 +1,7 @@
1
- import {isEmpty, noop} from 'lodash';
2
- import {File, Storage} from "@google-cloud/storage";
3
1
  import {PubSub} from "@google-cloud/pubsub";
2
+ import {SecretManagerServiceClient} from "@google-cloud/secret-manager";
3
+ import {File, Storage} from "@google-cloud/storage";
4
+ import {isEmpty, noop} from 'lodash';
4
5
  import {timeoutAfter} from "./utils";
5
6
 
6
7
  export type TEvent = {
@@ -39,12 +40,13 @@ export type TResponse = {
39
40
  error?: {
40
41
  name: string,
41
42
  message: string,
42
- stack: string,
43
+ stack?: string,
43
44
  }
44
45
  }
45
46
 
46
47
  export const pubSub = new PubSub();
47
48
  export const storage = new Storage();
49
+ const secretClient = new SecretManagerServiceClient();
48
50
 
49
51
  export class GcfCommon {
50
52
 
@@ -102,7 +104,7 @@ export class GcfCommon {
102
104
  console.log('topic:', topicName);
103
105
  }
104
106
 
105
- if (!isEmpty(topicName)) {
107
+ if (topicName && !isEmpty(topicName)) {
106
108
  const topic = pubSub.topic(topicName);
107
109
  await topic.setMetadata({labels: {date: topicName.split('__')[1]}});
108
110
  return topic;
@@ -118,4 +120,16 @@ export class GcfCommon {
118
120
  return JSON.parse(meta?.metadata?.options ?? '{}');
119
121
  }
120
122
  }
123
+
124
+ static async getSecret(name: string, version?: string) {
125
+ const projectId = await secretClient.getProjectId();
126
+ const secretName = `projects/${projectId}/secrets/${name}`;
127
+ const secretVersion = `${secretName}/versions/${version ?? 'latest'}`;
128
+ const [response] = await secretClient.accessSecretVersion({name: secretVersion});
129
+ return response?.payload?.data?.toString();
130
+ }
131
+
132
+ static async getSecrets(names: string[], versions?: string[]) {
133
+ return Promise.all(names.map(async (name, idx) => this.getSecret(name, versions?.[idx])));
134
+ }
121
135
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gcf-common-lib",
3
3
  "description": "",
4
- "version": "0.8.0",
4
+ "version": "0.10.0",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "branches": [
@@ -17,11 +17,13 @@
17
17
  "url": "https://github.com/TopTechnologies/gcf-common.git"
18
18
  },
19
19
  "dependencies": {
20
- "@google-cloud/pubsub": "^2.18.4",
21
- "@google-cloud/storage": "^5.17.0",
20
+ "@google-cloud/pubsub": "^2.18.5",
21
+ "@google-cloud/secret-manager": "^3.10.1",
22
+ "@google-cloud/storage": "^5.18.0",
22
23
  "lodash": "^4.17.21"
23
24
  },
24
25
  "devDependencies": {
26
+ "@tsconfig/node14": "^1.0.1",
25
27
  "@types/lodash": "^4.14.178"
26
28
  },
27
29
  "keywords": [],
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "http://json.schemastore.org/tsconfig",
3
+ "extends": "@tsconfig/node14/tsconfig.json",
4
+ "compilerOptions": {
5
+ "allowJs": false,
6
+ "removeComments": true,
7
+ "esModuleInterop": true,
8
+ "allowSyntheticDefaultImports": true,
9
+ "isolatedModules": false,
10
+ "emitDecoratorMetadata": true,
11
+ "experimentalDecorators": true,
12
+ "module": "commonjs",
13
+ "moduleResolution": "node",
14
+ "target": "ES6",
15
+ "typeRoots": [
16
+ "node_modules/@types"
17
+ ],
18
+ "lib": [
19
+ "ES2018",
20
+ "ES2019",
21
+ "ES2020",
22
+ "ES2021",
23
+ "ESNext"
24
+ ],
25
+ "types": [],
26
+ "plugins": []
27
+ },
28
+ "exclude": [
29
+ "node_modules/**",
30
+ "**/*.d.ts"
31
+ ]
32
+ }
package/utils.js CHANGED
@@ -8,107 +8,50 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
11
  Object.defineProperty(exports, "__esModule", { value: true });
39
12
  exports.A1ToColNum = exports.A1ToIndex = exports.colNumToA1 = exports.indexToA1 = exports.timeoutAfter = void 0;
40
- /**
41
- *
42
- * @param seconds Google function timeout limit (max: 9 min)
43
- */
44
- function timeoutAfter(seconds) {
45
- if (seconds === void 0) { seconds = 540; }
46
- return __awaiter(this, void 0, void 0, function () {
47
- return __generator(this, function (_a) {
48
- return [2 /*return*/, new Promise(function (resolve, reject) {
49
- setTimeout(function () {
50
- reject(new Error(seconds + " seconds timeout exceeded"));
51
- }, seconds * 1000);
52
- })];
13
+ function timeoutAfter(seconds = 540) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ return new Promise((resolve, reject) => {
16
+ setTimeout(() => {
17
+ reject(new Error(`${seconds} seconds timeout exceeded`));
18
+ }, seconds * 1000);
53
19
  });
54
20
  });
55
21
  }
56
22
  exports.timeoutAfter = timeoutAfter;
57
- //
58
23
  function indexToA1(idx) {
59
- return __awaiter(this, void 0, void 0, function () {
60
- return __generator(this, function (_a) {
61
- return [2 /*return*/, this.colNumToA1(idx + 1)];
62
- });
63
- });
24
+ return colNumToA1(idx + 1);
64
25
  }
65
26
  exports.indexToA1 = indexToA1;
66
27
  function colNumToA1(columnNumber) {
67
- return __awaiter(this, void 0, void 0, function () {
68
- var chars, charIdxArr, rem;
69
- return __generator(this, function (_a) {
70
- chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
71
- charIdxArr = [];
72
- while (columnNumber > 0) {
73
- rem = columnNumber % chars.length;
74
- // If remainder is 0, then a
75
- // 'Z' must be there in output
76
- if (rem === 0) {
77
- charIdxArr.push(chars.length - 1);
78
- columnNumber = Math.floor(columnNumber / chars.length) - 1;
79
- }
80
- else { // If remainder is non-zero
81
- charIdxArr.push(rem - 1);
82
- columnNumber = Math.floor(columnNumber / chars.length);
83
- }
84
- }
85
- // Reverse the string and print result
86
- return [2 /*return*/, charIdxArr.reverse().map(function (n) { return chars[n]; }).join('')];
87
- });
88
- });
28
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
29
+ const charIdxArr = [];
30
+ while (columnNumber > 0) {
31
+ const rem = columnNumber % chars.length;
32
+ if (rem === 0) {
33
+ charIdxArr.push(chars.length - 1);
34
+ columnNumber = Math.floor(columnNumber / chars.length) - 1;
35
+ }
36
+ else {
37
+ charIdxArr.push(rem - 1);
38
+ columnNumber = Math.floor(columnNumber / chars.length);
39
+ }
40
+ }
41
+ return charIdxArr.reverse().map((n) => chars[n]).join('');
89
42
  }
90
43
  exports.colNumToA1 = colNumToA1;
91
44
  function A1ToIndex(value) {
92
- return __awaiter(this, void 0, void 0, function () {
93
- return __generator(this, function (_a) {
94
- return [2 /*return*/, this.A1ToColNum(value) - 1];
95
- });
96
- });
45
+ return A1ToColNum(value) - 1;
97
46
  }
98
47
  exports.A1ToIndex = A1ToIndex;
99
48
  function A1ToColNum(value) {
100
- return __awaiter(this, void 0, void 0, function () {
101
- var chars, result, i;
102
- return __generator(this, function (_a) {
103
- chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
104
- result = 0;
105
- // tslint:disable-next-line:prefer-for-of
106
- for (i = 0; i < value.length; i++) {
107
- result *= chars.length;
108
- result += chars.indexOf(value[i]) + 1;
109
- }
110
- return [2 /*return*/, result];
111
- });
112
- });
49
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
50
+ let result = 0;
51
+ for (let i = 0; i < value.length; i++) {
52
+ result *= chars.length;
53
+ result += chars.indexOf(value[i]) + 1;
54
+ }
55
+ return result;
113
56
  }
114
57
  exports.A1ToColNum = A1ToColNum;
package/utils.ts CHANGED
@@ -12,11 +12,11 @@ export async function timeoutAfter(seconds: number = 540) {
12
12
 
13
13
  //
14
14
 
15
- export async function indexToA1(idx: number) {
16
- return this.colNumToA1(idx + 1);
15
+ export function indexToA1(idx: number) {
16
+ return colNumToA1(idx + 1);
17
17
  }
18
18
 
19
- export async function colNumToA1(columnNumber: number) {
19
+ export function colNumToA1(columnNumber: number) {
20
20
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
21
21
 
22
22
  // To store result (Excel column name)
@@ -41,11 +41,11 @@ export async function colNumToA1(columnNumber: number) {
41
41
  return charIdxArr.reverse().map((n) => chars[n]).join('');
42
42
  }
43
43
 
44
- export async function A1ToIndex(value: string) {
45
- return this.A1ToColNum(value) - 1;
44
+ export function A1ToIndex(value: string) {
45
+ return A1ToColNum(value) - 1;
46
46
  }
47
47
 
48
- export async function A1ToColNum(value: string) {
48
+ export function A1ToColNum(value: string) {
49
49
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
50
50
  let result = 0;
51
51
  // tslint:disable-next-line:prefer-for-of