aprog 2.1.4 → 2.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aprog",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "Допоміжна JavaScript-бібліотека для проєктів",
5
5
  "main": "index.js",
6
6
  "exports": {
package/src/general.js CHANGED
@@ -98,7 +98,7 @@ const isHtmlElement = (value) => {
98
98
  });
99
99
  };
100
100
 
101
- export const isEmpty = (variable): boolean => {
101
+ export const isEmpty = (variable) => {
102
102
  if (variable === undefined || variable === null) {
103
103
  return true;
104
104
  }
@@ -1261,7 +1261,7 @@ export const td = (attributes = {}) => {
1261
1261
  return td;
1262
1262
  };
1263
1263
 
1264
- export const img = (attributes: Record<string, any> = {}): HTMLImageElement => {
1264
+ export const img = (attributes = {}) => {
1265
1265
  let img = document.createElement("img");
1266
1266
  img.alt = "img...";
1267
1267
  if (attributes) {
@@ -1350,21 +1350,21 @@ export const apFetch = async (url, params = {}) => {
1350
1350
  return [data, error, isLoading];
1351
1351
  };
1352
1352
 
1353
- export const scrollToTop = (): void => {
1353
+ export const scrollToTop = () => {
1354
1354
  window.scrollTo({
1355
1355
  top: 0,
1356
1356
  behavior: "smooth",
1357
1357
  });
1358
1358
  };
1359
1359
 
1360
- export const scrollToBottom = (): void => {
1360
+ export const scrollToBottom = () => {
1361
1361
  window.scrollTo({
1362
1362
  top: document.documentElement.scrollHeight,
1363
1363
  behavior: "smooth",
1364
1364
  });
1365
1365
  };
1366
1366
 
1367
- export const _get = (name: string, defaulting: any = null): string|number|null => {
1367
+ export const _get = (name, defaulting = null) => {
1368
1368
  let url = new URL(window.location.href);
1369
1369
  let searchParams = new URLSearchParams(url.search);
1370
1370
  if (searchParams.has(name)) {
@@ -1375,7 +1375,7 @@ export const _get = (name: string, defaulting: any = null): string|number|null =
1375
1375
  return defaulting;
1376
1376
  };
1377
1377
 
1378
- export const _getAll = (): Record<string, string> => {
1378
+ export const _getAll = () => {
1379
1379
  let url = new URL(window.location.href);
1380
1380
  let searchParams = new URLSearchParams(url.search);
1381
1381
  let params = {};
@@ -1385,7 +1385,7 @@ export const _getAll = (): Record<string, string> => {
1385
1385
  return params;
1386
1386
  };
1387
1387
 
1388
- export const GUID = (): string => {
1388
+ export const GUID = () => {
1389
1389
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (char) {
1390
1390
  const random = Math.random() * 16 | 0;
1391
1391
  const value = char === 'x' ? random : (random & 0x3 | 0x8);
package/src/pages.js CHANGED
@@ -6,7 +6,7 @@ export const uniquePage = ({
6
6
  callbackTrue = () => {},
7
7
  callbackFalse = () => {},
8
8
  timer = 60000 // таймер 1 хвилина
9
- }): void => {
9
+ }) => {
10
10
  const setSession = () => {
11
11
  // Якщо немає ні сесії, ні лс, то додаємо
12
12
  if (!session.check(key) && !storage.check(key)) {
package/src/storage.js CHANGED
@@ -7,7 +7,7 @@ export const cookie = {
7
7
  * @param {any|null} defaulting
8
8
  * @returns {string|null}
9
9
  */
10
- get(name: string, defaulting: any = null): string|null {
10
+ get(name, defaulting = null) {
11
11
  const cookies = document.cookie.split('; ');
12
12
  for (let cookie of cookies) {
13
13
  const index = cookie.indexOf('=');
@@ -27,7 +27,7 @@ export const cookie = {
27
27
  * --- Отримати всі cookie ---
28
28
  * @return {{}}
29
29
  */
30
- getAll(): Record<string, string> {
30
+ getAll() {
31
31
  return document.cookie.split('; ').reduce((acc, cookie) => {
32
32
  const [key, ...val] = cookie.split('=');
33
33
  acc[key] = decodeURIComponent(val.join('='));
@@ -41,7 +41,7 @@ export const cookie = {
41
41
  * @param {string} value
42
42
  * @param {number} days
43
43
  */
44
- set(name: string, value: string, days: number = 7): void {
44
+ set(name, value, days = 7) {
45
45
  let expires = "";
46
46
  if (days) {
47
47
  const date = new Date();
@@ -56,7 +56,7 @@ export const cookie = {
56
56
  * Видалити cookie
57
57
  * @param {string} name
58
58
  */
59
- delete(name: string): void {
59
+ delete(name) {
60
60
  document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
61
61
  }
62
62
  };
@@ -71,7 +71,7 @@ export const storage = {
71
71
  * @param {any|null} defaulting
72
72
  * @return {any|null}
73
73
  */
74
- get(key: string, defaulting: any = null): any|null {
74
+ get(key, defaulting = null) {
75
75
  try {
76
76
  const item = localStorage.getItem(key);
77
77
  return item ? JSON.parse(item) : defaulting;
@@ -86,7 +86,7 @@ export const storage = {
86
86
  * @param {string} key
87
87
  * @param {any} data
88
88
  */
89
- set(key: string, data: any): void {
89
+ set(key, data) {
90
90
  localStorage.setItem(key, JSON.stringify(data));
91
91
  },
92
92
 
@@ -95,7 +95,7 @@ export const storage = {
95
95
  * @param {string} key
96
96
  * @return {boolean}
97
97
  */
98
- check(key: string): boolean {
98
+ check(key) {
99
99
  return !isEmpty(localStorage.getItem(key));
100
100
  },
101
101
 
@@ -103,7 +103,7 @@ export const storage = {
103
103
  * --- Видалити елемент зі сховища ---
104
104
  * @param {string} key
105
105
  */
106
- delete(key: string): void {
106
+ delete(key) {
107
107
  localStorage.removeItem(key);
108
108
  }
109
109
  };
@@ -118,7 +118,7 @@ export const session = {
118
118
  * @param {any|null} defaulting
119
119
  * @return {any|null}
120
120
  */
121
- get(key: string, defaulting: any = null): any|null {
121
+ get(key, defaulting = null) {
122
122
  try {
123
123
  const item = sessionStorage.getItem(key);
124
124
  return item ? JSON.parse(item) : defaulting;
@@ -133,7 +133,7 @@ export const session = {
133
133
  * @param {string} key
134
134
  * @param {any} data
135
135
  */
136
- set(key: string, data: any): void {
136
+ set(key, data) {
137
137
  sessionStorage.setItem(key, JSON.stringify(data));
138
138
  },
139
139
 
@@ -142,7 +142,7 @@ export const session = {
142
142
  * @param {string} key
143
143
  * @return {boolean}
144
144
  */
145
- check(key: string): boolean {
145
+ check(key) {
146
146
  return !isEmpty(sessionStorage.getItem(key));
147
147
  },
148
148
 
@@ -150,7 +150,7 @@ export const session = {
150
150
  * --- Видалити елемент з сесії ---
151
151
  * @param {string} key
152
152
  */
153
- delete(key: string): void {
153
+ delete(key) {
154
154
  sessionStorage.removeItem(key);
155
155
  }
156
156
  };
@@ -161,7 +161,7 @@ export const session = {
161
161
  * @param {boolean} create
162
162
  * @return {string}
163
163
  */
164
- export const cacheKey = (name: string, create: boolean = true): string => {
164
+ export const cacheKey = (name, create = true) => {
165
165
  let key = cookie.get(`_key_${name}`);
166
166
 
167
167
  if (!create) return key;
@@ -180,9 +180,9 @@ export const cacheKey = (name: string, create: boolean = true): string => {
180
180
  * @param content
181
181
  * @param filename
182
182
  */
183
- export const downloadFile = (content: string | Blob | Uint8Array, filename = "file.txt"): void => {
183
+ export const downloadFile = (content, filename = "file.txt") => {
184
184
  /** Мапа: розширення -> MIME-тип */
185
- const extensionToMime: Record<string, string> = {
185
+ const extensionToMime = {
186
186
  "txt": "text/plain",
187
187
  "json": "application/json",
188
188
  "xml": "text/xml",