dphelper 1.8.148 → 1.9.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/CODEOWNERS +1 -0
- package/README.md +31 -29
- package/docs/index.md +31 -29
- package/documents/TOOLS.md +4 -4
- package/index.js +1 -1
- package/package.json +7 -6
package/CODEOWNERS
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @passariello
|
package/README.md
CHANGED
|
@@ -18,19 +18,19 @@
|
|
|
18
18
|
[](https://socket.dev/npm/package/dphelper)
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
-
## About
|
|
21
|
+
## About
|
|
22
22
|
|
|
23
23
|
dpHelper is a precise and complete collection of 190+ tools ready to use in all web/SaaS applications. State and Store Management are now easy, accessible everywhere in your application, including Ajax or React apps, without the need for extra files.
|
|
24
24
|
|
|
25
|
-
1.
|
|
25
|
+
1. **Single Source of Truth**: The application's entire state is held within a single object in one store, ensuring consistent and accessible state management throughout the app.
|
|
26
26
|
|
|
27
|
-
2.
|
|
27
|
+
2. **State is flexible**: State changes are facilitated exclusively through actions. These actions, which are straightforward JavaScript objects, delineate what has occurred. This methodology ensures that state changes remain predictable.
|
|
28
28
|
|
|
29
|
-
3.
|
|
29
|
+
3. **Changes are made with proxy handle function**: To define state changes, dpHelper employs pure functions as intermediaries. These functions accept the current state as input and produce a new state as output, ensuring predictability and ease of testing in the system.
|
|
30
30
|
|
|
31
|
-
### Example in React
|
|
31
|
+
### 1. Example in React
|
|
32
32
|
|
|
33
|
-
```
|
|
33
|
+
```js
|
|
34
34
|
import { useEffect } from 'react';
|
|
35
35
|
import 'dphelper';
|
|
36
36
|
|
|
@@ -58,6 +58,7 @@ export default App;
|
|
|
58
58
|
[https://tests.a51.dev/](https://tests.a51.dev/)
|
|
59
59
|
|
|
60
60
|
You can see an HTML version where dpHelper and LayerPro work together seamlessly. dpHelper is compatible with a variety of frontend libraries, including:
|
|
61
|
+
|
|
61
62
|
* HTML
|
|
62
63
|
* React
|
|
63
64
|
* Vue
|
|
@@ -66,10 +67,11 @@ You can see an HTML version where dpHelper and LayerPro work together seamlessly
|
|
|
66
67
|
## Documentation
|
|
67
68
|
|
|
68
69
|
You can see:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
|
|
71
|
+
* [State](https://a51.gitbook.io/dphelper/general/state)
|
|
72
|
+
* [Store](https://a51.gitbook.io/dphelper/general/store)
|
|
73
|
+
* [Observer](https://a51.gitbook.io/dphelper/general/observer)
|
|
74
|
+
* [List of functions](https://a51.gitbook.io/dphelper/general/tools)
|
|
73
75
|
|
|
74
76
|
You can see more tutorials, information, and examples about **dpHelper** [clicking here](https://a51.gitbook.io/dphelper).
|
|
75
77
|
|
|
@@ -89,13 +91,13 @@ npm i dphelper@latest --save-dev
|
|
|
89
91
|
|
|
90
92
|
Use it in the main root file (and only there):
|
|
91
93
|
|
|
92
|
-
```
|
|
94
|
+
```js
|
|
93
95
|
import "dphelper";
|
|
94
96
|
```
|
|
95
97
|
|
|
96
98
|
or
|
|
97
99
|
|
|
98
|
-
```
|
|
100
|
+
```js
|
|
99
101
|
require("dphelper");
|
|
100
102
|
```
|
|
101
103
|
|
|
@@ -107,7 +109,7 @@ Note: You don't need to use npm install in this case, or you will get an error.
|
|
|
107
109
|
<script src="https://cdn.jsdelivr.net/npm/dphelper"></script>
|
|
108
110
|
```
|
|
109
111
|
|
|
110
|
-
## The Best Way To Use State
|
|
112
|
+
## The Best Way To Use State
|
|
111
113
|
|
|
112
114
|
### Using the "state" Function
|
|
113
115
|
|
|
@@ -119,7 +121,7 @@ _example:_
|
|
|
119
121
|
|
|
120
122
|
You can use the browser's devtools console and type " **state.test = 'I am ready'** ". Every time you want to use '**test**' values, you need just recall **state.test**.
|
|
121
123
|
|
|
122
|
-
```
|
|
124
|
+
```js
|
|
123
125
|
// Set a state
|
|
124
126
|
state.test = "I am ready" *
|
|
125
127
|
|
|
@@ -142,13 +144,13 @@ state.removeAll()
|
|
|
142
144
|
|
|
143
145
|
```
|
|
144
146
|
|
|
145
|
-
### Observer
|
|
147
|
+
### Observer for States
|
|
146
148
|
|
|
147
149
|
**Note**: _Observer works only with states. Stores are excluded at the moment._
|
|
148
150
|
|
|
149
151
|
If you want to run a function every time a state changes, you can use:
|
|
150
152
|
|
|
151
|
-
```
|
|
153
|
+
```js
|
|
152
154
|
/**
|
|
153
155
|
* Observer is a non-cumulative listener,
|
|
154
156
|
* triggered from customEvent / dispatch from state
|
|
@@ -164,9 +166,9 @@ PS: you need to use the name of state | store as string
|
|
|
164
166
|
|
|
165
167
|
You can use it everywhere. Works like "useState" in React but with more flexibility (use one observer for each state!).
|
|
166
168
|
|
|
167
|
-
### Example
|
|
169
|
+
### Example
|
|
168
170
|
|
|
169
|
-
```
|
|
171
|
+
```js
|
|
170
172
|
import 'dphelper';
|
|
171
173
|
|
|
172
174
|
// Use the observer to log the changing state value
|
|
@@ -179,9 +181,9 @@ observer(
|
|
|
179
181
|
setInterval(() => state.count = Date.now(), 5000);
|
|
180
182
|
```
|
|
181
183
|
|
|
182
|
-
#### Another Simple Example
|
|
184
|
+
#### Another Simple Example
|
|
183
185
|
|
|
184
|
-
```
|
|
186
|
+
```js
|
|
185
187
|
import 'dphelper';
|
|
186
188
|
|
|
187
189
|
// Set a state
|
|
@@ -213,7 +215,7 @@ When using dpHelper for permanent storage, you should use the **store**, which s
|
|
|
213
215
|
|
|
214
216
|
3. **Remove all stored data:** Use store.removeAll() to securely remove all stored data from your application.
|
|
215
217
|
|
|
216
|
-
```
|
|
218
|
+
```js
|
|
217
219
|
// Set a store:
|
|
218
220
|
store.set("test", { test: "test" })
|
|
219
221
|
|
|
@@ -227,9 +229,9 @@ store.remove("test") // Output: "ok"
|
|
|
227
229
|
store.removeAll() // Output: "ok"
|
|
228
230
|
```
|
|
229
231
|
|
|
230
|
-
### Example in React
|
|
232
|
+
### 2. Example in React
|
|
231
233
|
|
|
232
|
-
```
|
|
234
|
+
```js
|
|
233
235
|
import { useEffect } from 'react';
|
|
234
236
|
import 'dphelper';
|
|
235
237
|
|
|
@@ -265,7 +267,7 @@ function App() {
|
|
|
265
267
|
export default App;
|
|
266
268
|
```
|
|
267
269
|
|
|
268
|
-
## Console It
|
|
270
|
+
## Console It
|
|
269
271
|
|
|
270
272
|
Type **dphelper** in the devtool console of your browser to have a look at all available tools that you can use! You can call these from everywhere without import (just one time in the main/root page).
|
|
271
273
|
|
|
@@ -303,11 +305,11 @@ The dpHelper browser extension allows you to manage your application's dpHelper
|
|
|
303
305
|
|
|
304
306
|
[MIT - https://en.wikipedia.org/wiki/MIT_License](https://en.wikipedia.org/wiki/MIT_License)
|
|
305
307
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
308
|
+
* [LICENSE](https://a51.gitbook.io/dphelper/documents/license)
|
|
309
|
+
* [CODE OF CONDUCT](https://a51.gitbook.io/dphelper/documents/code_of_conduct)
|
|
310
|
+
* [SECURITY](https://a51.gitbook.io/dphelper/documents/security)
|
|
311
|
+
* [CONTRIBUTING](https://a51.gitbook.io/dphelper/documents/contributing)
|
|
310
312
|
|
|
311
313
|
---
|
|
312
314
|
|
|
313
|
-
Dario Passariello - dariopassariello@gmail.com
|
|
315
|
+
Dario Passariello - <dariopassariello@gmail.com>, All rights reserved - Copyright (c) 2019 - 2024
|
package/docs/index.md
CHANGED
|
@@ -18,19 +18,19 @@
|
|
|
18
18
|
[](https://socket.dev/npm/package/dphelper)
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
-
## About
|
|
21
|
+
## About
|
|
22
22
|
|
|
23
23
|
dpHelper is a precise and complete collection of 190+ tools ready to use in all web/SaaS applications. State and Store Management are now easy, accessible everywhere in your application, including Ajax or React apps, without the need for extra files.
|
|
24
24
|
|
|
25
|
-
1.
|
|
25
|
+
1. **Single Source of Truth**: The application's entire state is held within a single object in one store, ensuring consistent and accessible state management throughout the app.
|
|
26
26
|
|
|
27
|
-
2.
|
|
27
|
+
2. **State is flexible**: State changes are facilitated exclusively through actions. These actions, which are straightforward JavaScript objects, delineate what has occurred. This methodology ensures that state changes remain predictable.
|
|
28
28
|
|
|
29
|
-
3.
|
|
29
|
+
3. **Changes are made with proxy handle function**: To define state changes, dpHelper employs pure functions as intermediaries. These functions accept the current state as input and produce a new state as output, ensuring predictability and ease of testing in the system.
|
|
30
30
|
|
|
31
|
-
### Example in React
|
|
31
|
+
### 1. Example in React
|
|
32
32
|
|
|
33
|
-
```
|
|
33
|
+
```js
|
|
34
34
|
import { useEffect } from 'react';
|
|
35
35
|
import 'dphelper';
|
|
36
36
|
|
|
@@ -58,6 +58,7 @@ export default App;
|
|
|
58
58
|
[https://tests.a51.dev/](https://tests.a51.dev/)
|
|
59
59
|
|
|
60
60
|
You can see an HTML version where dpHelper and LayerPro work together seamlessly. dpHelper is compatible with a variety of frontend libraries, including:
|
|
61
|
+
|
|
61
62
|
* HTML
|
|
62
63
|
* React
|
|
63
64
|
* Vue
|
|
@@ -66,10 +67,11 @@ You can see an HTML version where dpHelper and LayerPro work together seamlessly
|
|
|
66
67
|
## Documentation
|
|
67
68
|
|
|
68
69
|
You can see:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
|
|
71
|
+
* [State](https://a51.gitbook.io/dphelper/general/state)
|
|
72
|
+
* [Store](https://a51.gitbook.io/dphelper/general/store)
|
|
73
|
+
* [Observer](https://a51.gitbook.io/dphelper/general/observer)
|
|
74
|
+
* [List of functions](https://a51.gitbook.io/dphelper/general/tools)
|
|
73
75
|
|
|
74
76
|
You can see more tutorials, information, and examples about **dpHelper** [clicking here](https://a51.gitbook.io/dphelper).
|
|
75
77
|
|
|
@@ -89,13 +91,13 @@ npm i dphelper@latest --save-dev
|
|
|
89
91
|
|
|
90
92
|
Use it in the main root file (and only there):
|
|
91
93
|
|
|
92
|
-
```
|
|
94
|
+
```js
|
|
93
95
|
import "dphelper";
|
|
94
96
|
```
|
|
95
97
|
|
|
96
98
|
or
|
|
97
99
|
|
|
98
|
-
```
|
|
100
|
+
```js
|
|
99
101
|
require("dphelper");
|
|
100
102
|
```
|
|
101
103
|
|
|
@@ -107,7 +109,7 @@ Note: You don't need to use npm install in this case, or you will get an error.
|
|
|
107
109
|
<script src="https://cdn.jsdelivr.net/npm/dphelper"></script>
|
|
108
110
|
```
|
|
109
111
|
|
|
110
|
-
## The Best Way To Use State
|
|
112
|
+
## The Best Way To Use State
|
|
111
113
|
|
|
112
114
|
### Using the "state" Function
|
|
113
115
|
|
|
@@ -119,7 +121,7 @@ _example:_
|
|
|
119
121
|
|
|
120
122
|
You can use the browser's devtools console and type " **state.test = 'I am ready'** ". Every time you want to use '**test**' values, you need just recall **state.test**.
|
|
121
123
|
|
|
122
|
-
```
|
|
124
|
+
```js
|
|
123
125
|
// Set a state
|
|
124
126
|
state.test = "I am ready" *
|
|
125
127
|
|
|
@@ -142,13 +144,13 @@ state.removeAll()
|
|
|
142
144
|
|
|
143
145
|
```
|
|
144
146
|
|
|
145
|
-
### Observer
|
|
147
|
+
### Observer for States
|
|
146
148
|
|
|
147
149
|
**Note**: _Observer works only with states. Stores are excluded at the moment._
|
|
148
150
|
|
|
149
151
|
If you want to run a function every time a state changes, you can use:
|
|
150
152
|
|
|
151
|
-
```
|
|
153
|
+
```js
|
|
152
154
|
/**
|
|
153
155
|
* Observer is a non-cumulative listener,
|
|
154
156
|
* triggered from customEvent / dispatch from state
|
|
@@ -164,9 +166,9 @@ PS: you need to use the name of state | store as string
|
|
|
164
166
|
|
|
165
167
|
You can use it everywhere. Works like "useState" in React but with more flexibility (use one observer for each state!).
|
|
166
168
|
|
|
167
|
-
### Example
|
|
169
|
+
### Example
|
|
168
170
|
|
|
169
|
-
```
|
|
171
|
+
```js
|
|
170
172
|
import 'dphelper';
|
|
171
173
|
|
|
172
174
|
// Use the observer to log the changing state value
|
|
@@ -179,9 +181,9 @@ observer(
|
|
|
179
181
|
setInterval(() => state.count = Date.now(), 5000);
|
|
180
182
|
```
|
|
181
183
|
|
|
182
|
-
#### Another Simple Example
|
|
184
|
+
#### Another Simple Example
|
|
183
185
|
|
|
184
|
-
```
|
|
186
|
+
```js
|
|
185
187
|
import 'dphelper';
|
|
186
188
|
|
|
187
189
|
// Set a state
|
|
@@ -213,7 +215,7 @@ When using dpHelper for permanent storage, you should use the **store**, which s
|
|
|
213
215
|
|
|
214
216
|
3. **Remove all stored data:** Use store.removeAll() to securely remove all stored data from your application.
|
|
215
217
|
|
|
216
|
-
```
|
|
218
|
+
```js
|
|
217
219
|
// Set a store:
|
|
218
220
|
store.set("test", { test: "test" })
|
|
219
221
|
|
|
@@ -227,9 +229,9 @@ store.remove("test") // Output: "ok"
|
|
|
227
229
|
store.removeAll() // Output: "ok"
|
|
228
230
|
```
|
|
229
231
|
|
|
230
|
-
### Example in React
|
|
232
|
+
### 2. Example in React
|
|
231
233
|
|
|
232
|
-
```
|
|
234
|
+
```js
|
|
233
235
|
import { useEffect } from 'react';
|
|
234
236
|
import 'dphelper';
|
|
235
237
|
|
|
@@ -265,7 +267,7 @@ function App() {
|
|
|
265
267
|
export default App;
|
|
266
268
|
```
|
|
267
269
|
|
|
268
|
-
## Console It
|
|
270
|
+
## Console It
|
|
269
271
|
|
|
270
272
|
Type **dphelper** in the devtool console of your browser to have a look at all available tools that you can use! You can call these from everywhere without import (just one time in the main/root page).
|
|
271
273
|
|
|
@@ -303,11 +305,11 @@ The dpHelper browser extension allows you to manage your application's dpHelper
|
|
|
303
305
|
|
|
304
306
|
[MIT - https://en.wikipedia.org/wiki/MIT_License](https://en.wikipedia.org/wiki/MIT_License)
|
|
305
307
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
308
|
+
* [LICENSE](https://a51.gitbook.io/dphelper/documents/license)
|
|
309
|
+
* [CODE OF CONDUCT](https://a51.gitbook.io/dphelper/documents/code_of_conduct)
|
|
310
|
+
* [SECURITY](https://a51.gitbook.io/dphelper/documents/security)
|
|
311
|
+
* [CONTRIBUTING](https://a51.gitbook.io/dphelper/documents/contributing)
|
|
310
312
|
|
|
311
313
|
---
|
|
312
314
|
|
|
313
|
-
Dario Passariello - dariopassariello@gmail.com
|
|
315
|
+
Dario Passariello - <dariopassariello@gmail.com>, All rights reserved - Copyright (c) 2019 - 2024
|
package/documents/TOOLS.md
CHANGED
|
@@ -512,13 +512,13 @@ This document provides a comprehensive list of all available functions in the `d
|
|
|
512
512
|
<br> Calculates the percentage of time elapsed.
|
|
513
513
|
|
|
514
514
|
### Tools
|
|
515
|
-
- `dphelper.
|
|
515
|
+
- `dphelper.dev.getip()`
|
|
516
516
|
<br> Gets the IP address.
|
|
517
|
-
- `dphelper.
|
|
517
|
+
- `dphelper.dev.byteSize(bytes)`
|
|
518
518
|
<br> Converts bytes to a human-readable format.
|
|
519
|
-
- `dphelper.
|
|
519
|
+
- `dphelper.dev.zIndex()`
|
|
520
520
|
<br> Gets the z-index.
|
|
521
|
-
- `dphelper.
|
|
521
|
+
- `dphelper.dev.zeroToFalse(value)`
|
|
522
522
|
<br> Converts zero to false.
|
|
523
523
|
|
|
524
524
|
### Translators
|