parse-comcigan 0.3.0 → 1.1.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/dist/index.d.ts CHANGED
@@ -1,142 +1,3 @@
1
- export type GetTimetableOptions = {
2
- /**
3
- * 컴시간 학교 코드입니다.
4
- */
5
- "schoolCode": number;
6
- /**
7
- * 구분을 어떻게 할지 여부입니다.
8
- *
9
- * - weekday로 설정하면 시간표[교시][요일]로 과목과 선생님을 불러옵니다.
10
- * - period로 설정하면 시간표[요일][교시]로 과목과 선생님을 불러옵니다.
11
- */
12
- "criteria": "weekday" | "period";
13
- /**
14
- * 학년입니다.
15
- */
16
- "grade": number;
17
- /**
18
- * 반입니다.
19
- */
20
- "classN": number;
21
- /**
22
- * 8교시를 빼고 리턴할지 여부입니다.
23
- */
24
- "without8th"?: boolean;
25
- /**
26
- * 다음 주 시간표를 가져올지에 대한 여부입니다.
27
- */
28
- "nextWeek"?: boolean;
29
- };
30
- export interface ComciganInitializeType {
31
- /**
32
- * 이 기간동안 컴시간과 통신한 데이터가 캐시됩니다.
33
- *
34
- * 기본값은 0ms이며, 0ms일때는 캐시를 하지 않습니다.
35
- */
36
- cacheMs?: number;
37
- /**
38
- * axios에서 요청을 보내고 status가 오류 status일 때 throw할 지 여부입니다.
39
- * 만약 false일 때 요청에 status가 오류 status면 그 타입에서 빈 값을 리턴합니다.
40
- *
41
- * 기본값은 false입니다.
42
- */
43
- doNotThrow?: boolean;
44
- /**
45
- * 디버그 메시지를 파라메터로 받습니다.
46
- *
47
- * 기본값은 없습니다.
48
- */
49
- debug?: (msg: string) => any;
50
- /**
51
- * 컴시간알리미의 앱 버전입니다.
52
- *
53
- * 기본값은 2.11입니다.
54
- */
55
- appVersion?: string;
56
- }
57
- export type ComciganSearched = {
58
- /**
59
- * 학교의 지역입니다.
60
- */
61
- region: string;
62
- /**
63
- * 학교의 이름입니다.
64
- */
65
- name: string;
66
- /**
67
- * 학교의 코드입니다.
68
- */
69
- code: number;
70
- };
71
- export type ComciganTimetableObject = {
72
- /**
73
- * 과목입니다.
74
- */
75
- subject: string;
76
- /**
77
- * 교사 성명입니다.
78
- */
79
- teacher: string;
80
- /**
81
- * 만약 변경되었을때 이 값이 주어집니다.
82
- */
83
- original?: {
84
- /**
85
- * 과목입니다.
86
- */
87
- subject: string;
88
- /**
89
- * 교사 성명입니다.
90
- */
91
- teacher: string;
92
- };
93
- };
94
- export type ComciganTimetable = {
95
- /**
96
- * 컴시간알리미 앱의 최신 버전입니다.
97
- */
98
- latestVersion: string;
99
- /**
100
- * 수정일입니다.
101
- */
102
- changed: string;
103
- /**
104
- * 시간표입니다.
105
- */
106
- timetable: ComciganTimetableObject[][];
107
- };
108
- export default class Comcigan {
109
- private _options;
110
- private _cache;
111
- private mSb;
112
- private mTh;
113
- private unusable;
114
- private request;
115
- private EUC_KR_encodeURI;
116
- /**
117
- * 파서를 초기화 합니다.
118
- * @param options 파서의 옵션입니다.
119
- */
120
- constructor(options?: ComciganInitializeType);
121
- /**
122
- * 학교를 검색합니다.
123
- * 마지막 "없으면 추가 검색 하세요" 문구는 빠져서 나옵니다.
124
- * @param query 검색어
125
- * @returns 검색된 학교들
126
- */
127
- SearchSchool(query: string): Promise<ComciganSearched[]>;
128
- /**
129
- * 시간표를 가져옵니다.
130
- *
131
- * @param schoolCode
132
- * @param criteria
133
- */
134
- GetTimetable(options: GetTimetableOptions): Promise<ComciganTimetable | undefined>;
135
- /**
136
- * 학급 목록을 가져옵니다.
137
- *
138
- * @param schoolCode 학교 코드입니다.
139
- * @returns (학년)-(반) 문자열이 모인 배열
140
- */
141
- GetClassList(schoolCode: number): Promise<string[]>;
142
- }
1
+ import Comcigan from "./class.js";
2
+ export default Comcigan;
3
+ export type * from './types/index.d.ts';
package/dist/index.js CHANGED
@@ -1,219 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import axios from 'axios';
11
- import iconv from 'iconv-lite';
12
- import Cache from './cache.js';
13
- //#endregion
14
- export default class Comcigan {
15
- mSb(mm, m2) { if (m2 == 100) {
16
- return mm % m2;
17
- } return Math.floor(mm / m2); }
18
- mTh(mm, m2) { if (m2 == 100) {
19
- return Math.floor(mm / m2);
20
- } return mm % m2; }
21
- unusable(object, array) {
22
- if (object === array[0])
23
- return;
24
- return object;
25
- }
26
- request(route, doNotParse) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
29
- if (this._cache.has(route)) {
30
- (_b = (_a = this._options).debug) === null || _b === void 0 ? void 0 : _b.call(_a, `Returning cache with id registered as ${route}`);
31
- return this._cache.get(route);
32
- }
33
- (_d = (_c = this._options).debug) === null || _d === void 0 ? void 0 : _d.call(_c, `Requesting to http://comci.kr:4081/${route}`);
34
- const now = new Date();
35
- const r = yield axios.get(`http://comci.kr:4081/${route}`, Object.assign({}, (this._options.doNotThrow && { "validateStatus": () => true })));
36
- (_f = (_e = this._options).debug) === null || _f === void 0 ? void 0 : _f.call(_e, `${new Date().getTime() - now.getTime()}ms http://comci.kr:4081/${route}`);
37
- if (doNotParse) {
38
- if (this._options.cacheMs && this._options.cacheMs !== 0) {
39
- (_h = (_g = this._options).debug) === null || _h === void 0 ? void 0 : _h.call(_g, `Registered cache with id ${route}`);
40
- this._cache.register(route, r.data, this._options.cacheMs);
41
- }
42
- return r.data;
43
- }
44
- const data = JSON.parse(r.data.slice(0, r.data.indexOf("}") + 1));
45
- if (this._options.cacheMs && this._options.cacheMs !== 0) {
46
- (_k = (_j = this._options).debug) === null || _k === void 0 ? void 0 : _k.call(_j, `Registered cache with id ${route}`);
47
- this._cache.register(route, data, this._options.cacheMs);
48
- }
49
- return data;
50
- });
51
- }
52
- EUC_KR_encodeURI(str) {
53
- const buffer = iconv.encode(str, 'euc-kr');
54
- return Array.from(buffer)
55
- .map((byte) => '%' + byte.toString(16).toUpperCase().padStart(2, '0'))
56
- .join('');
57
- }
58
- /**
59
- * 파서를 초기화 합니다.
60
- * @param options 파서의 옵션입니다.
61
- */
62
- constructor(options) {
63
- this._options = {
64
- "cacheMs": 0,
65
- "doNotThrow": false,
66
- "appVersion": "2.11",
67
- };
68
- this._cache = new Cache();
69
- this._options = Object.assign(Object.assign({}, this._options), options);
70
- }
71
- /**
72
- * 학교를 검색합니다.
73
- * 마지막 "없으면 추가 검색 하세요" 문구는 빠져서 나옵니다.
74
- * @param query 검색어
75
- * @returns 검색된 학교들
76
- */
77
- SearchSchool(query) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- const r = yield this.request(`sc_${this.EUC_KR_encodeURI(query)}`);
80
- return r.학교검색.map(v => ({
81
- "region": v[1],
82
- "name": v[2],
83
- "code": v[3]
84
- })).filter(v => v.code !== 0);
85
- });
86
- }
87
- /**
88
- * 시간표를 가져옵니다.
89
- *
90
- * @param schoolCode
91
- * @param criteria
92
- */
93
- GetTimetable(options) {
94
- return __awaiter(this, void 0, void 0, function* () {
95
- var _a, _b, _c, _d, _e, _f, _g;
96
- const { schoolCode, criteria, grade, classN, without8th, nextWeek } = options;
97
- const { appVersion } = this._options;
98
- const str = `36174_${schoolCode}_${nextWeek ? 2 : 1}_4_0_3_${appVersion}`;
99
- const route = (str.substring(9) + str.substring(0, 9)).split("").reverse().join("");
100
- const data = yield this.request(`7813?${route}`, true);
101
- const [latestVersion, step1] = data.split("^");
102
- const edited = step1.substring(0, step1.indexOf("{"));
103
- const step2 = step1.slice(step1.indexOf("{"));
104
- const json = JSON.parse(step2.slice(0, step2.indexOf("}") + 1));
105
- const WEEKDAY = ["월", "화", "수", "목", "금"];
106
- const sep = (_a = json.분리) !== null && _a !== void 0 ? _a : 100;
107
- if (!json.시간표)
108
- return undefined;
109
- // 시간표[학년][반][요일][교시]
110
- const origin = json.시간표[grade][classN];
111
- const today = json.학급시간표[grade][classN];
112
- const toReturn = [];
113
- if (criteria === "period") {
114
- for (let weekday = 1; weekday < WEEKDAY.length + 1; weekday++) {
115
- const weekdayList = [];
116
- for (let period = 1; period < (without8th ? 8 : 9); period++) {
117
- const o = origin[weekday][period];
118
- const t = today[weekday][period];
119
- if (o === undefined || t === undefined) {
120
- weekdayList.push({
121
- "subject": "-",
122
- "teacher": "-"
123
- });
124
- continue;
125
- }
126
- const originSubject = json.과목명[this.mSb(o, sep) % sep];
127
- const originTeacher = json.성명[this.mTh(o, sep) % sep];
128
- if (o === t) {
129
- weekdayList.push({
130
- "subject": (_b = this.unusable(originSubject, json.과목명)) !== null && _b !== void 0 ? _b : "-",
131
- "teacher": (_c = this.unusable(originTeacher, json.성명)) !== null && _c !== void 0 ? _c : "-"
132
- });
133
- continue;
134
- }
135
- const changedSubject = json.과목명[this.mSb(t, sep) % sep];
136
- const changedTeacher = json.성명[this.mTh(t, sep) % sep];
137
- weekdayList.push({
138
- "subject": (_d = this.unusable(changedSubject, json.과목명)) !== null && _d !== void 0 ? _d : "-",
139
- "teacher": (_e = this.unusable(changedTeacher, json.성명)) !== null && _e !== void 0 ? _e : "-",
140
- "original": {
141
- "subject": (_f = this.unusable(originSubject, json.과목명)) !== null && _f !== void 0 ? _f : "-",
142
- "teacher": (_g = this.unusable(originTeacher, json.성명)) !== null && _g !== void 0 ? _g : "-",
143
- }
144
- });
145
- }
146
- toReturn.push(weekdayList);
147
- }
148
- }
149
- else {
150
- for (let period = 1; period < (without8th ? 8 : 9); period++) {
151
- const periodList = [];
152
- for (let weekday = 1; weekday < WEEKDAY.length + 1; weekday++) {
153
- const o = origin[weekday][period];
154
- const t = today[weekday][period];
155
- if (!o || !t) {
156
- periodList.push({
157
- "subject": "-",
158
- "teacher": "-"
159
- });
160
- continue;
161
- }
162
- const originSubject = json.과목명[this.mSb(o, sep) % sep];
163
- const originTeacher = json.성명[this.mTh(o, sep) % sep];
164
- if (o === t) {
165
- periodList.push({
166
- "subject": originSubject,
167
- "teacher": originTeacher
168
- });
169
- continue;
170
- }
171
- const changedSubject = json.과목명[this.mSb(t, sep) % sep];
172
- const changedTeacher = json.성명[this.mTh(t, sep) % sep];
173
- periodList.push({
174
- "subject": originSubject,
175
- "teacher": originTeacher,
176
- "original": {
177
- "subject": changedSubject,
178
- "teacher": changedTeacher
179
- }
180
- });
181
- }
182
- toReturn.push(periodList);
183
- }
184
- }
185
- return {
186
- "changed": edited,
187
- latestVersion,
188
- "timetable": toReturn
189
- };
190
- });
191
- }
192
- /**
193
- * 학급 목록을 가져옵니다.
194
- *
195
- * @param schoolCode 학교 코드입니다.
196
- * @returns (학년)-(반) 문자열이 모인 배열
197
- */
198
- GetClassList(schoolCode) {
199
- return __awaiter(this, void 0, void 0, function* () {
200
- const str = `36174_${schoolCode}_1_4_0_3_1.00`;
201
- const route = (str.substring(9) + str.substring(0, 9)).split("").reverse().join("");
202
- const data = yield this.request(`7813?${route}`, true);
203
- const step1 = data.split("^")[1];
204
- const step2 = step1.slice(step1.indexOf("{"));
205
- const json = JSON.parse(step2.slice(0, step2.indexOf("}") + 1));
206
- const rawClasses = json.학급수;
207
- if (!rawClasses)
208
- return [];
209
- const toReturn = [];
210
- for (let g = 1; g < rawClasses.length; g++) {
211
- for (let c = 1; c < rawClasses[g] + 1; c++) {
212
- toReturn.push(`${g}-${c}`);
213
- }
214
- }
215
- return toReturn;
216
- });
217
- }
218
- }
1
+ import Comcigan from "./class.js";
2
+ export default Comcigan;
219
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA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C,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;oBACzC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC/B,CAAC;YACL,CAAC;YAED,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CACJ"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,75 @@
1
+ export type ComciganSchool = {
2
+ /** 지역 */
3
+ "region": string;
4
+ /** 이름 */
5
+ "name": string;
6
+ /** 코드 */
7
+ "code": number;
8
+ };
9
+ export type ComciganSearchRaw = {
10
+ "학교검색": [number, string, string, number][];
11
+ };
12
+ export type ComciganTimetableItem = {
13
+ /** 과목 */
14
+ "subject": string;
15
+ /** 교사 */
16
+ "teacher": string;
17
+ /** 특별실 */
18
+ "classRoom"?: string;
19
+ /** 원래 시간표 */
20
+ "original"?: Omit<ComciganTimetableItem, "original" | "classRoom">;
21
+ };
22
+ export type ComciganTimetable = {
23
+ /** 총 교시 수 */
24
+ "total": number;
25
+ /** 시간표 아이템 */
26
+ "items": ComciganTimetableItem[];
27
+ }[];
28
+ export type ComciganSchoolInfo = {
29
+ /** 일과시간 */
30
+ "times": {
31
+ /** 교시 */
32
+ "number": number;
33
+ /** 시:분 */
34
+ "start": `${number}:${number}`;
35
+ }[];
36
+ /** 학년 마다 학급 수 */
37
+ "classes": number[];
38
+ /** 시간표 변경 날짜 */
39
+ "changedAt": Date;
40
+ /** 학교 코드 */
41
+ "code": number;
42
+ };
43
+ export interface ComciganRawData {
44
+ "교사수": number;
45
+ "학급수": number[];
46
+ "요일별시수": number[][];
47
+ "전일제": number[];
48
+ "버젼": string;
49
+ "동시수업수": number;
50
+ "담임": number[][];
51
+ "가상학급수": number[];
52
+ "전체학년": number[];
53
+ "특별실수": number;
54
+ "열람제한일": string;
55
+ "학기시작일자": string;
56
+ "학교명": string;
57
+ "지역명": string;
58
+ "학년도": number;
59
+ "분리": number;
60
+ "강의실": number;
61
+ "소규모학급": number;
62
+ "변경알림": number;
63
+ "시작일": string;
64
+ "일과시간": string[];
65
+ "일자자료": [number, string][];
66
+ "오늘r": number;
67
+ "자료147": any;
68
+ "자료244": string;
69
+ "자료245": any;
70
+ "자료446": string[];
71
+ "자료481": any;
72
+ "자료492": any;
73
+ "자료542": any;
74
+ "동시그룹": (number | number[])[];
75
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parse-comcigan",
3
- "version": "0.3.0",
3
+ "version": "1.1.0",
4
4
  "description": "컴시간 알리미에서 시간표를 가져오는 라이브러리입니다.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -12,16 +12,22 @@
12
12
  "build": "tsc",
13
13
  "clean": "tsc --build --clean",
14
14
  "dev": "nodemon --exec ts-node src/index.ts",
15
+ "watch": "tsc --watch",
15
16
  "test": "npm run pack && node \"test.js\""
16
17
  },
18
+ "exports": {
19
+ "types": "./src/types/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ },
17
22
  "devDependencies": {
18
- "@types/node": "^22.15.30",
19
- "nodemon": "^3.1.9",
23
+ "@types/node": "^22.19.20",
24
+ "nodemon": "^3.1.14",
20
25
  "ts-node": "^10.9.2",
21
- "typescript": "^5.8.3"
26
+ "typescript": "^5.9.3"
22
27
  },
23
28
  "dependencies": {
24
- "axios": "^1.8.4",
29
+ "axios": "^1.17.0",
30
+ "dayjs": "^1.11.21",
25
31
  "iconv-lite": "^0.6.3"
26
32
  },
27
33
  "repository": {
package/test.ts ADDED
@@ -0,0 +1,11 @@
1
+ import Comcigan, { ComciganSchool } from '.';
2
+
3
+ (async () => {
4
+ // 컴시간 인스턴스 생성
5
+ const comci = new Comcigan(41896);
6
+
7
+
8
+
9
+ // 시간표 조회
10
+ console.log(await comci.schoolInfo());
11
+ })();
package/tsconfig.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "outDir": "dist",
3
+ "outDir": "./dist",
4
+ "rootDir": "./src",
4
5
  "target": "ES6",
5
- "module": "ESNext",
6
6
  "lib": [
7
7
  "ES6",
8
8
  "DOM"
9
9
  ],
10
- "moduleResolution": "Node",
10
+ "moduleResolution": "node16",
11
+ "module": "node16",
11
12
  "esModuleInterop": true,
12
13
  "declaration": true,
13
14
  "strict": true,
package/dist/cache.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export default class Cache {
2
- private _cacheStorage;
3
- register(id: string, data: any, duration: number): void;
4
- delete(id: string): void;
5
- clear(): void;
6
- has(id: string): boolean;
7
- get(id: string): any;
8
- }
package/dist/cache.js DELETED
@@ -1,32 +0,0 @@
1
- export default class Cache {
2
- constructor() {
3
- this._cacheStorage = {};
4
- }
5
- register(id, data, duration) {
6
- this._cacheStorage[id] = {
7
- "timeout": setTimeout(() => {
8
- delete this._cacheStorage[id];
9
- }, duration),
10
- "data": data
11
- };
12
- }
13
- delete(id) {
14
- clearTimeout(this._cacheStorage[id].timeout);
15
- delete this._cacheStorage[id];
16
- }
17
- clear() {
18
- const caches = Object.keys(this._cacheStorage);
19
- for (let cache of caches) {
20
- clearTimeout(this._cacheStorage[cache].timeout);
21
- delete this._cacheStorage[cache];
22
- }
23
- }
24
- has(id) {
25
- return Boolean(this._cacheStorage[id]);
26
- }
27
- get(id) {
28
- var _a;
29
- return (_a = this._cacheStorage[id]) === null || _a === void 0 ? void 0 : _a.data;
30
- }
31
- }
32
- //# sourceMappingURL=cache.js.map
package/dist/cache.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,KAAK;IAA1B;QACY,kBAAa,GAGhB,EAAE,CAAC;IA2BZ,CAAC;IAzBU,QAAQ,CAAC,EAAU,EAAE,IAAS,EAAE,QAAgB;QACnD,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG;YACrB,SAAS,EAAE,UAAU,CAAC,GAAG,EAAE;gBACvB,OAAO,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;YAClC,CAAC,EAAE,QAAQ,CAAC;YACZ,MAAM,EAAE,IAAI;SACf,CAAC;IACN,CAAC;IACM,MAAM,CAAC,EAAU;QACpB,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAClC,CAAC;IACM,KAAK;QACR,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC/C,KAAK,IAAI,KAAK,IAAI,MAAM,EAAE,CAAC;YACvB,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC;YAChD,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;IACL,CAAC;IACM,GAAG,CAAC,EAAU;QACjB,OAAO,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC;IACM,GAAG,CAAC,EAAU;;QACjB,OAAO,MAAA,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,0CAAE,IAAI,CAAC;IACxC,CAAC;CACJ"}
package/src/cache.ts DELETED
@@ -1,32 +0,0 @@
1
- export default class Cache {
2
- private _cacheStorage: Collection<{
3
- "timeout": NodeJS.Timeout;
4
- "data": any;
5
- }> = {};
6
-
7
- public register(id: string, data: any, duration: number) {
8
- this._cacheStorage[id] = {
9
- "timeout": setTimeout(() => {
10
- delete this._cacheStorage[id];
11
- }, duration),
12
- "data": data
13
- };
14
- }
15
- public delete(id: string) {
16
- clearTimeout(this._cacheStorage[id].timeout);
17
- delete this._cacheStorage[id];
18
- }
19
- public clear() {
20
- const caches = Object.keys(this._cacheStorage);
21
- for (let cache of caches) {
22
- clearTimeout(this._cacheStorage[cache].timeout);
23
- delete this._cacheStorage[cache];
24
- }
25
- }
26
- public has(id: string) {
27
- return Boolean(this._cacheStorage[id]);
28
- }
29
- public get(id: string) {
30
- return this._cacheStorage[id]?.data;
31
- }
32
- }