aprog 1.3.7 → 1.3.8

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/README.md CHANGED
@@ -148,7 +148,7 @@ onInput: (event) => {
148
148
  - *encrypt(str), decrypt(encryptedStr)*
149
149
 
150
150
  - *div, span, button, a, img, meta, label, input, select, option, options, form, hr, textarea, table, caption, thead, tbody, tr, th, td, pre*
151
- - *_get, GUID, apState, cookie, date, pause, apFetch, chars, elementToObject, copyText, scrollToTop, scrollToBottom, firstKey, checkArrays, ucfirst, deepEqual, nodeListToObject*
151
+ - *_get, GUID, apState, date, pause, apFetch, chars, elementToObject, copyText, scrollToTop, scrollToBottom, firstKey, checkArrays, ucfirst, deepEqual, nodeListToObject*
152
152
  - *isEmpty, isNull, isFloat, isNumeric, isObject, isArray, isNumber, isString, isPromise, isNull, isFloat, isNumeric, isObject*
153
153
 
154
154
  - *router({ routes, main, "Page Not Found" })*
@@ -157,6 +157,8 @@ onInput: (event) => {
157
157
 
158
158
  - *mathInput(event.target)*
159
159
 
160
+ - *cookie, storage*
161
+
160
162
  ### Info
161
163
 
162
164
  - Додано безплатний чат із Gemini
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export {
2
2
  div, span, button, a, img, meta, label, input, select, option, options, form, hr, textarea,
3
- table, caption, thead, tbody, tr, th, td, pre, _get, GUID, isEmpty, apState, cookie, date, pause, apFetch,
3
+ table, caption, thead, tbody, tr, th, td, pre, _get, GUID, isEmpty, apState, date, pause, apFetch,
4
4
  chars, isNull, isFloat, isNumeric, isObject, elementToObject, copyText, scrollToTop, scrollToBottom,
5
5
  firstKey, isArray, checkArrays, isNumber, isString, isPromise, ucfirst, deepEqual, nodeListToObject
6
6
  } from './src/aprog.js';
@@ -9,4 +9,5 @@ export { redirect, reload } from './src/redirect.js';
9
9
  export { router, navigateTo } from './src/router.js';
10
10
  export { encrypt, decrypt } from './src/shifrator.js';
11
11
  export { gemini } from './src/OpenAI.js';
12
- export { mathInput } from './src/math.js';
12
+ export { mathInput } from './src/math.js';
13
+ export { cookie, storage } from './src/storage.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aprog",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "description": "Допоміжна бібліотека js",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/aprog.js CHANGED
@@ -1324,33 +1324,6 @@ export const GUID = () => {
1324
1324
  });
1325
1325
  }
1326
1326
 
1327
- export const cookie = {
1328
- get(name) {
1329
- const cookies = document.cookie.split('; ');
1330
- for (let cookie of cookies) {
1331
- let [key, value] = cookie.split('=');
1332
- if (key === name) {
1333
- return decodeURIComponent(value);
1334
- }
1335
- }
1336
- return null;
1337
- },
1338
-
1339
- set(name, value, days = 7) {
1340
- let expires = "";
1341
- if (days) {
1342
- let date = new Date();
1343
- date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
1344
- expires = "; expires=" + date.toUTCString();
1345
- }
1346
- document.cookie = name + "=" + encodeURIComponent(value) + expires + "; path=/";
1347
- },
1348
-
1349
- delete(name) {
1350
- document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
1351
- }
1352
- };
1353
-
1354
1327
  export const checkArrays = (arr1, arr2, checkAll = false) => {
1355
1328
  const set1 = new Set(arr1);
1356
1329
  if (checkAll) {
package/src/storage.js ADDED
@@ -0,0 +1,40 @@
1
+ export const cookie = {
2
+ get(name) {
3
+ const cookies = document.cookie.split('; ');
4
+ for (let cookie of cookies) {
5
+ let [key, value] = cookie.split('=');
6
+ if (key === name) {
7
+ return decodeURIComponent(value);
8
+ }
9
+ }
10
+ return null;
11
+ },
12
+
13
+ set(name, value, days = 7) {
14
+ let expires = "";
15
+ if (days) {
16
+ let date = new Date();
17
+ date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
18
+ expires = "; expires=" + date.toUTCString();
19
+ }
20
+ document.cookie = name + "=" + encodeURIComponent(value) + expires + "; path=/";
21
+ },
22
+
23
+ delete(name) {
24
+ document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
25
+ }
26
+ };
27
+
28
+ export const storage = {
29
+ get(key, defaulting = null) {
30
+ return JSON.parse(localStorage.getItem(key)) || defaulting;
31
+ },
32
+
33
+ set(key, data) {
34
+ localStorage.setItem(key, JSON.stringify(data));
35
+ },
36
+
37
+ delete(key) {
38
+ localStorage.removeItem(key);
39
+ }
40
+ };