dphelper 1.9.19 → 1.9.20

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/docs/index.md DELETED
@@ -1,315 +0,0 @@
1
- # dpHelper
2
-
3
- ![dpHelper](https://raw.githubusercontent.com/passariello/container/refs/heads/main/dphelper/assets/images/banner.svg)
4
-
5
- **Manager | DevTools** by [Dario Passariello](https://dario.passariello.ca) (c)
6
-
7
- [![version](https://img.shields.io/npm/v/dphelper.svg)](https://npmjs.org/package/dphelper)
8
- [![downloads](https://img.shields.io/npm/dm/dphelper.svg)](https://npmjs.org/package/dphelper)
9
- ![TypeScript](https://img.shields.io/badge/TypeScript-006b98?logo=TypeScript&logoColor=white)
10
-
11
- ![dphelper](https://img.shields.io/badge/dphelper-npm-green?logo=dphelper&logoColor=white)
12
- ![browser extension](https://img.shields.io/badge/browser%20extension-beta-orange.svg)
13
-
14
- [![GitBook](https://img.shields.io/static/v1?message=Documented%20on%20GitBook&logo=gitbook&logoColor=ffffff&label=%20&labelColor=5c5c5c&color=3F89A1)](https://a51.gitbook.io/dphelper)
15
-
16
- <!--
17
- [![dphelper](https://snyk.io/advisor/npm-package/dphelper/badge.svg)](https://snyk.io/advisor/npm-package/dphelper)
18
- [![Socket Badge](https://socket.dev/api/badge/npm/package/dphelper)](https://socket.dev/npm/package/dphelper)
19
- -->
20
-
21
- ## About
22
-
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
-
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
-
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
-
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
-
31
- ### 1. Example in React
32
-
33
- ```js
34
- import { useEffect } from 'react';
35
- import 'dphelper';
36
-
37
- function App() {
38
- // Store a value in the state
39
- state.test = 'Hello, World!';
40
-
41
- // Use the stored value in a React component
42
- useEffect(() => {
43
- console.log("You can recall from all pages: " + state.test); // Output: "Hello, World!"
44
- }, []);
45
-
46
- return (
47
- <div>
48
- <h1>{state.test}</h1>
49
- </div>
50
- );
51
- }
52
-
53
- export default App;
54
- ```
55
-
56
- ## Live Demo
57
-
58
- [https://tests.a51.dev/](https://tests.a51.dev/)
59
-
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
-
62
- * HTML
63
- * React
64
- * Vue
65
- * And any other frontend library
66
-
67
- ## Documentation
68
-
69
- You can see:
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)
75
-
76
- You can see more tutorials, information, and examples about **dpHelper** [clicking here](https://a51.gitbook.io/dphelper).
77
-
78
- ## Usage
79
-
80
- Install dpHelper.
81
-
82
- ```shell
83
- npm i dphelper --save-dev
84
- ```
85
-
86
- or update:
87
-
88
- ```shell
89
- npm i dphelper@latest --save-dev
90
- ```
91
-
92
- Use it in the main root file (and only there):
93
-
94
- ```js
95
- import "dphelper";
96
- ```
97
-
98
- or
99
-
100
- ```js
101
- require("dphelper");
102
- ```
103
-
104
- ## Install for EJS or Other Types of Projects (like HTML)
105
-
106
- Note: You don't need to use npm install in this case, or you will get an error.
107
-
108
- ```html
109
- <script src="https://cdn.jsdelivr.net/npm/dphelper"></script>
110
- ```
111
-
112
- ## The Best Way To Use State
113
-
114
- ### Using the "state" Function
115
-
116
- You can use the state function to store and reuse data throughout your application. Similar to other state managers, you can save state information in JSON format and access it easily in various contexts, including React useEffect and/or dispatch.
117
-
118
- For example, you can store a value like this: _state.test = 'I am ready'_ and then retrieve it later using state.test.
119
-
120
- _example:_
121
-
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**.
123
-
124
- ```js
125
- // Set a state
126
- state.test = "I am ready" *
127
-
128
- // Get the state
129
- state.test *
130
-
131
- // List all states
132
- state.list // or just "state" to see the proxy
133
-
134
- // Lock a state from edit (Only for Objects or Array)
135
- state.test.lock() *
136
-
137
- // Remove a state
138
- state.remove("test")
139
-
140
- // Remove all states
141
- state.removeAll()
142
-
143
- *["test" is only an example]
144
-
145
- ```
146
-
147
- ### Observer for States
148
-
149
- **Note**: _Observer works only with states. Stores are excluded at the moment._
150
-
151
- If you want to run a function every time a state changes, you can use:
152
-
153
- ```js
154
- /**
155
- * Observer is a non-cumulative listener,
156
- * triggered from customEvent / dispatch from state
157
- * @parameters
158
- * [ state | store, function ]
159
- */
160
- observer( "state.test", () => alert("Test Changes to: " + state.test) )
161
- |__________| |___________________________________________|
162
- State: string Function
163
-
164
- PS: you need to use the name of state | store as string
165
- ```
166
-
167
- You can use it everywhere. Works like "useState" in React but with more flexibility (use one observer for each state!).
168
-
169
- ### Example
170
-
171
- ```js
172
- import 'dphelper';
173
-
174
- // Use the observer to log the changing state value
175
- observer(
176
- 'state.count',
177
- () => console.log("State changed: ", state.count)
178
- );
179
-
180
- // Store a value in the state that changes every 5 seconds
181
- setInterval(() => state.count = Date.now(), 5000);
182
- ```
183
-
184
- #### Another Simple Example
185
-
186
- ```js
187
- import 'dphelper';
188
-
189
- // Set a state
190
- state.myData = 'Hello, world!';
191
-
192
- // Retrieve the state
193
- console.log(state.myData); // Output: Hello, world!
194
-
195
- // Observe state changes
196
- observer('myData', () => {
197
- console.log('myData has changed to:', state.myData);
198
- });
199
-
200
- // Change the state
201
- state.myData = 'New value';
202
- ```
203
-
204
- ## The Best Way To Use Store 🫙
205
-
206
- ### Persistent Storage with dpHelper
207
-
208
- When using dpHelper for permanent storage, you should use the **store**, which stores data persistently across sessions.
209
-
210
- #### Important Security Note
211
-
212
- 1. **Use store for persistent storage:** If you want to store data permanently, use store to ensure it is saved in localStorage.
213
-
214
- 2. **Remove data when necessary:** To maintain security, remove stored data when it is no longer needed, such as during logout.
215
-
216
- 3. **Remove all stored data:** Use store.removeAll() to securely remove all stored data from your application.
217
-
218
- ```js
219
- // Set a store:
220
- store.set("test", { test: "test" })
221
-
222
- // Get a store:
223
- store.get("test") // Output: { test: "test" }
224
-
225
- // Remove a store:
226
- store.remove("test") // Output: "ok"
227
-
228
- // Remove all stores:
229
- store.removeAll() // Output: "ok"
230
- ```
231
-
232
- ### 2. Example in React
233
-
234
- ```js
235
- import { useEffect } from 'react';
236
- import 'dphelper';
237
-
238
- function App() {
239
-
240
- // Store a value in the store (persistent storage)
241
- store.set(
242
- 'user',
243
- {
244
- name: 'John Doe',
245
- age: 30
246
- }
247
- );
248
-
249
- // Use the stored value in a React component
250
- useEffect(
251
- () => {
252
- console.log(store.get("user")); // Output: { name: "John Doe", age: 30 }
253
- $("#name").text(store.get("user").name)
254
- }, []
255
- );
256
-
257
- // Remove all stored data if necessary
258
- // store.removeAll();
259
-
260
- return (
261
- <div>
262
- <h1 id="name">...</h1>
263
- </div>
264
- );
265
- }
266
-
267
- export default App;
268
- ```
269
-
270
- ## Console It
271
-
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).
273
-
274
- ## Browser Extension (Chrome/Edge) ♥️
275
-
276
- ![browser extension](https://img.shields.io/badge/browser%20extension-beta-orange.svg)
277
-
278
- ![dphelper Banner](https://raw.githubusercontent.com/passariello/container/refs/heads/main/dphelper/assets/images/banner.png)
279
-
280
- ![dphelper Banner](https://raw.githubusercontent.com/passariello/container/refs/heads/main/dphelper/assets/images/screenshot.png)
281
-
282
- Chrome: [Download from Google Web Store](https://chrome.google.com/webstore/detail/dphelper-manager-dev-tool/oppppldaoknfddeikfloonnialijngbk)
283
-
284
- Edge: [Download from Microsoft Addons](https://microsoftedge.microsoft.com/addons/detail/dphelper-manager-dev-to/kphabkbdpaljlfagldhojilhfammepnk)
285
-
286
- PS: **dpHelper** is compatible with all Chromium-based browsers like **Edge or Brave**!
287
-
288
- ## dpHelper Browser Extension
289
-
290
- The dpHelper browser extension allows you to manage your application's dpHelper NPM. Key features include:
291
-
292
- 1. Simplified API operations: Easily manage and manipulate data with dpHelper's collection of scripts.
293
- 2. Real-time monitoring: Track memory usage and localStorage to optimize your application's performance.
294
- 3. Stay up-to-date: Receive updates and tips to improve your daily workflow.
295
- 4. Easy installation: Simply import 'dphelper' in your project index to get started.
296
- 5. Global accessibility: All scripts are available globally and can be accessed from anywhere in your application.
297
-
298
- ## Check
299
-
300
- [Socket.dev](https://socket.dev/npm/package/dphelper)
301
-
302
- [Snyk.io](https://security.snyk.io/package/npm/dphelper)
303
-
304
- ## License
305
-
306
- [MIT - https://en.wikipedia.org/wiki/MIT_License](https://en.wikipedia.org/wiki/MIT_License)
307
-
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)
312
-
313
- ---
314
-
315
- Dario Passariello - <dariopassariello@gmail.com>, All rights reserved - Copyright (c) 2019 - 2024
@@ -1,67 +0,0 @@
1
- # Observer
2
-
3
- ## Overview
4
-
5
- This document provides a comprehensive list of all available observer functions in the `dphelper` library along with their descriptions and examples.
6
-
7
- ## Functions
8
-
9
- ### observer([state.name], [function])
10
-
11
- - **Description:** Sets up an observer to monitor state changes and trigger a callback.
12
- - **Parameters:**
13
- - `stateName` (string): The name of the state to monitor.
14
- - `callBack` (Function): The callback function to run when the state changes.
15
- - `option` (object): Additional options for the observer.
16
- - **Example:**
17
-
18
- ```javascript
19
- observer('state.test', (newValue) => {
20
- console.log('State changed:', newValue);
21
- });
22
- ```
23
-
24
- ### observer([state.name])
25
-
26
- - **Description:** Recall the observer previously generated.
27
- - **Returns:** Console log with a note
28
- - **Example:**
29
-
30
- ```javascript
31
- observer('state.test');
32
- ```
33
-
34
- ### observer.list
35
-
36
- - **Description:** See the list of all your observer (eventListener) actually installed.
37
- - **Returns:** The list of all installed observers.
38
- - **Example:**
39
-
40
- ```javascript
41
- observer.list;
42
- ```
43
-
44
- ### remove
45
-
46
- - **Description:** Remove an observer.
47
- - **Parameters:**
48
- - `name` (string): The name of the observer to remove.
49
- - **Example:**
50
-
51
- ```javascript
52
- observer.remove('state.test');
53
- ```
54
-
55
- ### removeAll
56
-
57
- - **Description:** Remove all observers.
58
- - **Returns:** void
59
- - **Example:**
60
-
61
- ```javascript
62
- observer.removeAll();
63
- ```
64
-
65
- ## License
66
-
67
- This project is licensed under the MIT License.
@@ -1,67 +0,0 @@
1
- # dpHelper State
2
-
3
- ## Overview
4
-
5
- This document provides a comprehensive list of all available state functions in the `dphelper` library along with their descriptions and examples.
6
-
7
- ## Functions
8
-
9
- ### state.[state.name] ex: _state.test_
10
-
11
- - **Description:** Set and get state values.
12
- - **Example:**
13
-
14
- ```javascript
15
- // To set a state value
16
- state.name = 'value';
17
-
18
- // To get a state value
19
- const value = state.name;
20
- ```
21
-
22
- ### state.list
23
-
24
- - **Description:** Show all states out of proxy.
25
- - **Example:**
26
-
27
- ```javascript
28
- state.list;
29
- ```
30
-
31
- ### state.remove([state.name])
32
-
33
- - **Description:** Remove a state.
34
- - **Parameters:**
35
- - `name` (string): The name of the state to remove.
36
- - **Example:**
37
-
38
- ```javascript
39
- state.remove('stateName');
40
- ```
41
-
42
- ### state.name.lock()
43
-
44
- - **Description:** Lock a state (only for types: Array, Object).
45
- - **Example:**
46
-
47
- ```javascript
48
- state.name = {test:"test"}
49
- state.name.lock();
50
- "Now you can't add more data or remove it"
51
- ```
52
-
53
- ### state.removeAll()
54
-
55
- - **Description:** Remove all states.
56
- - **Example:**
57
-
58
- ```javascript
59
- state.name = {test:"test"}
60
- state.removeAll();
61
- "Now you can't see state.name (all states are removed)"
62
- "Use for Log-out / Sign-out operation"
63
- ```
64
-
65
- ## License
66
-
67
- This project is licensed under the MIT License.
@@ -1,78 +0,0 @@
1
- # dpHelper Store
2
-
3
- ## Overview
4
-
5
- This document provides a comprehensive list of all available store functions in the `dphelper` library along with their descriptions and examples.
6
-
7
- ## Functions
8
-
9
- ### store.get([store.name])
10
-
11
- - **Description:** Retrieve an item from local storage.
12
- - **Parameters:**
13
- - `name` (string): The name of the item to retrieve.
14
- - **Example:**
15
-
16
- ```javascript
17
- const value = store.get('itemName');
18
- console.log(value);
19
- ```
20
-
21
- ### store.set([name, value])
22
-
23
- - **Description:** Set an item in local storage.
24
- - **Parameters:**
25
- - `name` (string): The name of the item to set.
26
- - `value` (any): The value of the item to set.
27
- - **Example:**
28
-
29
- ```javascript
30
- store.set('itemName', value);
31
- ```
32
-
33
- ### store.remove([store.name])
34
-
35
- - **Description:** Delete an item from local storage.
36
- - **Parameters:**
37
- - `name` (string): The name of the item to delete.
38
- - **Example:**
39
-
40
- ```javascript
41
- store.remove('itemName');
42
- ```
43
-
44
- ### store.removeAll()
45
-
46
- - **Description:** Remove all items from local storage.
47
- - **Parameters:** None
48
- - **Example:**
49
-
50
- ```javascript
51
- store.removeAll();
52
- ```
53
-
54
- ### store.quota()
55
-
56
- - **Description:** Estimate the storage quota and usage.
57
- - **Parameters:** None
58
- - **Example:**
59
-
60
- ```javascript
61
- const quota = store.quota();
62
- console.log(quota);
63
- ```
64
-
65
- ### store.size()
66
-
67
- - **Description:** Calculate the total size of all items in local storage.
68
- - **Parameters:** None
69
- - **Example:**
70
-
71
- ```javascript
72
- const totalSize = store.size();
73
- console.log(totalSize);
74
- ```
75
-
76
- ## License
77
-
78
- This project is licensed under the MIT License.