dphelper 1.9.20 → 1.9.23
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/CHANGELOG.md +12 -0
- package/CITATION.cff +43 -0
- package/CODEOWNERS +1 -0
- package/CODE_OF_CONDUCT.md +110 -0
- package/CONTRIBUTING.md +110 -0
- package/FUNDING.yml +16 -0
- package/HISTORY.md +1 -0
- package/SECURITY.md +3 -0
- package/SUMMARY.md +22 -0
- package/docs/_config.yml +1 -0
- package/docs/index.md +315 -0
- package/documents/OBSERVER.md +67 -0
- package/documents/STATE.md +67 -0
- package/documents/STORE.md +78 -0
- package/documents/TOOLS.md +614 -0
- package/index.d.ts +21 -0
- package/index.js +1 -0
- package/package.json +4 -11
- package/types/cache.d.ts +27 -0
- package/types/dphelper.d.ts +572 -0
- package/types/idb.d.ts +21 -0
- package/types/jquery.d.ts +20 -0
- package/types/memorio.d.ts +21 -0
- package/types/observer.d.ts +47 -0
- package/types/session.d.ts +67 -0
- package/types/state.d.ts +71 -0
- package/types/store.d.ts +91 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
New minor (feature) releases of this app/software are released every six months and
|
|
6
|
+
patch (bugfix) releases are released every month. More information on the
|
|
7
|
+
release cycle: see package.json
|
|
8
|
+
|
|
9
|
+
## Previous
|
|
10
|
+
|
|
11
|
+
Please see the git history for the details of previous versions.
|
|
12
|
+
You can see HISTORY.md for all information.
|
package/CITATION.cff
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# This CITATION.cff file was generated with cffinit.
|
|
2
|
+
# Visit https://bit.ly/cffinit to generate yours today!
|
|
3
|
+
|
|
4
|
+
cff-version: 1.2.0
|
|
5
|
+
title: dpHelper
|
|
6
|
+
message: dphelper devtools | tools, store and state management for developers by Dario Passariello
|
|
7
|
+
type: software
|
|
8
|
+
authors:
|
|
9
|
+
- given-names: "Dario "
|
|
10
|
+
family-names: Passariello
|
|
11
|
+
email: dariopassariello@gmail.com
|
|
12
|
+
abstract: >-
|
|
13
|
+
dpHelper is a precise and complete collection of 190+
|
|
14
|
+
tools ready to use in all web/SaaS applications. State and
|
|
15
|
+
Store Management are now easy, accessible
|
|
16
|
+
everywhere in your application, including Ajax or React
|
|
17
|
+
apps, without the need for extra files.
|
|
18
|
+
keywords:
|
|
19
|
+
- dphelper
|
|
20
|
+
- development
|
|
21
|
+
- toolset
|
|
22
|
+
- state
|
|
23
|
+
- store
|
|
24
|
+
- observer
|
|
25
|
+
- helper
|
|
26
|
+
- utils
|
|
27
|
+
- tools
|
|
28
|
+
- uuid
|
|
29
|
+
- random
|
|
30
|
+
- window
|
|
31
|
+
- easy
|
|
32
|
+
- pro
|
|
33
|
+
- powerful
|
|
34
|
+
- status
|
|
35
|
+
- dp helper
|
|
36
|
+
- local
|
|
37
|
+
- storage
|
|
38
|
+
- indexeddb
|
|
39
|
+
- idb
|
|
40
|
+
- devtool
|
|
41
|
+
- dario
|
|
42
|
+
- passariello
|
|
43
|
+
license: MIT
|
package/CODEOWNERS
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @passariello
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Code of Conduct - dphelper
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
## Our Pledge
|
|
6
|
+
|
|
7
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
8
|
+
contributors and maintainers pledge to make participation in our project and
|
|
9
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
10
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
|
11
|
+
level of experience, education, socio-economic status, nationality, personal
|
|
12
|
+
appearance, race, religion, or sexual identity and orientation.
|
|
13
|
+
|
|
14
|
+
## Our Standards
|
|
15
|
+
|
|
16
|
+
Examples of behaviour that contributes to a positive environment for our
|
|
17
|
+
community include:
|
|
18
|
+
|
|
19
|
+
* Demonstrating empathy and kindness toward other people
|
|
20
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
21
|
+
* Giving and gracefully accepting constructive feedback
|
|
22
|
+
* Accepting responsibility and apologising to those affected by our mistakes,
|
|
23
|
+
and learning from the experience
|
|
24
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
25
|
+
overall community
|
|
26
|
+
|
|
27
|
+
Examples of unacceptable behaviour include:
|
|
28
|
+
|
|
29
|
+
* The use of sexualised language or imagery, and sexual attention or advances
|
|
30
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
31
|
+
* Public or private harassment
|
|
32
|
+
* Publishing others' private information, such as a physical or email
|
|
33
|
+
address, without their explicit permission
|
|
34
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
35
|
+
professional setting
|
|
36
|
+
|
|
37
|
+
## Our Responsibilities
|
|
38
|
+
|
|
39
|
+
Project maintainers are responsible for clarifying and enforcing our standards of
|
|
40
|
+
acceptable behaviour and will take appropriate and fair corrective action in
|
|
41
|
+
response to any behaviour that they deem inappropriate,
|
|
42
|
+
threatening, offensive, or harmful.
|
|
43
|
+
|
|
44
|
+
Project maintainers have the right and responsibility to remove, edit, or reject
|
|
45
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
46
|
+
not aligned to this Code of Conduct, and will
|
|
47
|
+
communicate reasons for moderation decisions when appropriate.
|
|
48
|
+
|
|
49
|
+
## Scope
|
|
50
|
+
|
|
51
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
52
|
+
an individual is officially representing the community in public spaces.
|
|
53
|
+
Examples of representing our community include using an official e-mail address,
|
|
54
|
+
posting via an official social media account, or acting as an appointed
|
|
55
|
+
representative at an online or offline event.
|
|
56
|
+
|
|
57
|
+
## Enforcement
|
|
58
|
+
|
|
59
|
+
Instances of abusive, harassing, or otherwise unacceptable behaviour may be
|
|
60
|
+
reported to the community leaders responsible for enforcement at <dariopassariello@gmail.com>.
|
|
61
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
62
|
+
|
|
63
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
64
|
+
reporter of any incident.
|
|
65
|
+
|
|
66
|
+
## Enforcement Guidelines
|
|
67
|
+
|
|
68
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
69
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
70
|
+
|
|
71
|
+
### 1. Correction
|
|
72
|
+
|
|
73
|
+
**Community Impact**: Use of inappropriate language or other behaviour deemed
|
|
74
|
+
unprofessional or unwelcome in the community.
|
|
75
|
+
|
|
76
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
77
|
+
clarity around the nature of the violation and an explanation of why the
|
|
78
|
+
behaviour was inappropriate. A public apology may be requested.
|
|
79
|
+
|
|
80
|
+
### 2. Warning
|
|
81
|
+
|
|
82
|
+
**Community Impact**: A violation through a single incident or series
|
|
83
|
+
of actions.
|
|
84
|
+
|
|
85
|
+
**Consequence**: A warning with consequences for continued behaviour. No
|
|
86
|
+
interaction with the people involved, including unsolicited interaction with
|
|
87
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
88
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
89
|
+
like social media. Violating these terms may lead to a temporary or
|
|
90
|
+
permanent ban.
|
|
91
|
+
|
|
92
|
+
### 3. Temporary Ban
|
|
93
|
+
|
|
94
|
+
**Community Impact**: A serious violation of community standards, including
|
|
95
|
+
sustained inappropriate behaviour.
|
|
96
|
+
|
|
97
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
98
|
+
communication with the community for a specified period of time. No public or
|
|
99
|
+
private interaction with the people involved, including unsolicited interaction
|
|
100
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
101
|
+
Violating these terms may lead to a permanent ban.
|
|
102
|
+
|
|
103
|
+
### 4. Permanent Ban
|
|
104
|
+
|
|
105
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
106
|
+
standards, including sustained inappropriate behaviour, harassment of an
|
|
107
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
108
|
+
|
|
109
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
110
|
+
the community.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
First off, thanks for taking the time to contribute! ❤️
|
|
6
|
+
|
|
7
|
+
All types of contributions are encouraged and valued. See the [Table of Contents](contributing.md#table-of-contents) for different ways to help and details about how this project handles them. Please make sure to read the relevant section before making your contribution. It will make it a lot easier for us maintainers and smooth out the experience for all involved. The community looks forward to your contributions. 🎉
|
|
8
|
+
|
|
9
|
+
> And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about:
|
|
10
|
+
>
|
|
11
|
+
> * Star the project
|
|
12
|
+
> * Tweet about it
|
|
13
|
+
> * Refer this project in your project's readme
|
|
14
|
+
> * Mention the project at local meetups and tell your friends/colleagues
|
|
15
|
+
|
|
16
|
+
## Table of Contents
|
|
17
|
+
|
|
18
|
+
* [Code of Conduct](contributing.md#code-of-conduct)
|
|
19
|
+
* [I Have a Question](contributing.md#i-have-a-question)
|
|
20
|
+
* [I Want To Contribute](contributing.md#i-want-to-contribute)
|
|
21
|
+
* [Reporting Bugs](contributing.md#reporting-bugs)
|
|
22
|
+
* [Suggesting Enhancements](contributing.md#suggesting-enhancements)
|
|
23
|
+
* [Your First Code Contribution](contributing.md#your-first-code-contribution)
|
|
24
|
+
* [Improving The Documentation](contributing.md#improving-the-documentation)
|
|
25
|
+
* [Styleguides](contributing.md#styleguides)
|
|
26
|
+
* [Commit Messages](contributing.md#commit-messages)
|
|
27
|
+
* [Join The Project Team](contributing.md#join-the-project-team)
|
|
28
|
+
|
|
29
|
+
## Code of Conduct
|
|
30
|
+
|
|
31
|
+
This project and everyone participating in it is governed by the [dphelper Code of Conduct](https://github.com/a51-dev/a51.dphelper.public/blob/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [dariopassariello@gmail.com](mailto:dariopassariello@gmail.com).
|
|
32
|
+
|
|
33
|
+
## I Have a Question
|
|
34
|
+
|
|
35
|
+
> If you want to ask a question, we assume that you have read the available [Documentation](https://a51.gitbook.io/dphelper/).
|
|
36
|
+
|
|
37
|
+
Before you ask a question, it is best to search for existing [Issues](https://github.com/a51-dev/a51.dphelper.public/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.
|
|
38
|
+
|
|
39
|
+
If you then still feel the need to ask a question and need clarification, we recommend the following:
|
|
40
|
+
|
|
41
|
+
* Open an [Issue](https://github.com/a51-dev/a51.dphelper.public/issues/new).
|
|
42
|
+
* Provide as much context as you can about what you're running into.
|
|
43
|
+
* Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant.
|
|
44
|
+
|
|
45
|
+
We will then take care of the issue as soon as possible.
|
|
46
|
+
|
|
47
|
+
## I Want To Contribute
|
|
48
|
+
|
|
49
|
+
> #### Legal Notice
|
|
50
|
+
>
|
|
51
|
+
> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project licence.
|
|
52
|
+
|
|
53
|
+
### Reporting Bugs
|
|
54
|
+
|
|
55
|
+
#### Before Submitting a Bug Report
|
|
56
|
+
|
|
57
|
+
A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.
|
|
58
|
+
|
|
59
|
+
* Make sure that you are using the latest version.
|
|
60
|
+
* Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://a51.gitbook.io/dphelper/). If you are looking for support, you might want to check [this section](contributing.md#i-have-a-question)).
|
|
61
|
+
* To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/a51-dev/a51.dphelper.public/issues?q=label%3Abug).
|
|
62
|
+
* Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
|
|
63
|
+
* Collect information about the bug:
|
|
64
|
+
* Stack trace (Traceback)
|
|
65
|
+
* OS, Platform and Version (Windows, Linux, macOS, x86, ARM)
|
|
66
|
+
* Version of the interpreter, compiler, SDK, runtime environment, package manager, depending on what seems relevant.
|
|
67
|
+
* Possibly your input and the output
|
|
68
|
+
* Can you reliably reproduce the issue? And can you also reproduce it with older versions?
|
|
69
|
+
|
|
70
|
+
#### How Do I Submit a Good Bug Report?
|
|
71
|
+
|
|
72
|
+
> You must never report security related issues, vulnerabilities or bugs including sensitive information to the issue tracker, or elsewhere in public. Instead sensitive bugs must be sent by email to [dariopassariello@gmail.com](mailto:dariopassariello@gmail.com).
|
|
73
|
+
|
|
74
|
+
We use GitHub issues to track bugs and errors. If you run into an issue with the project:
|
|
75
|
+
|
|
76
|
+
* Open an [Issue](https://github.com/a51-dev/a51.dphelper.public/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
|
|
77
|
+
* Explain the behavior you would expect and the actual behavior.
|
|
78
|
+
* Please provide as much context as possible and describe the _reproduction steps_ that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
|
|
79
|
+
* Provide the information you collected in the previous section.
|
|
80
|
+
|
|
81
|
+
Once it's filed:
|
|
82
|
+
|
|
83
|
+
* The project team will label the issue accordingly.
|
|
84
|
+
* A team member will try to reproduce the issue with your provided steps. If there are no reproduction steps or no obvious way to reproduce the issue, the team will ask you for those steps and mark the issue as `needs-repro`. Bugs with the `needs-repro` tag will not be addressed until they are reproduced.
|
|
85
|
+
* If the team is able to reproduce the issue, it will be marked `needs-fix`, as well as possibly other tags (such as `critical`), and the issue will be left to be [implemented by someone](contributing.md#your-first-code-contribution).
|
|
86
|
+
|
|
87
|
+
### Suggesting Enhancements
|
|
88
|
+
|
|
89
|
+
This section guides you through submitting an enhancement suggestion for dphelper, **including completely new features and minor improvements to existing functionality**. Following these guidelines will help maintainers and the community to understand your suggestion and find related suggestions.
|
|
90
|
+
|
|
91
|
+
#### Before Submitting an Enhancement
|
|
92
|
+
|
|
93
|
+
* Make sure that you are using the latest version.
|
|
94
|
+
* Read the [documentation](https://a51.gitbook.io/dphelper/) carefully and find out if the functionality is already covered, maybe by an individual configuration.
|
|
95
|
+
* Perform a [search](https://github.com/a51-dev/a51.dphelper.public/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
|
|
96
|
+
* Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
|
|
97
|
+
|
|
98
|
+
#### How Do I Submit a Good Enhancement Suggestion?
|
|
99
|
+
|
|
100
|
+
Enhancement suggestions are tracked as [GitHub issues](https://github.com/a51-dev/a51.dphelper.public/issues).
|
|
101
|
+
|
|
102
|
+
* Use a **clear and descriptive title** for the issue to identify the suggestion.
|
|
103
|
+
* Provide a **step-by-step description of the suggested enhancement** in as many details as possible.
|
|
104
|
+
* **Describe the current behavior** and **explain which behavior you expected to see instead** and why. At this point you can also tell which alternatives do not work for you.
|
|
105
|
+
* You may want to **include screenshots or screen recordings** which help you demonstrate the steps or point out the part which the suggestion is related to. You can use [screentogif](https://www.screentogif.com/) to record GIFs on macOS and Windows, and the built-in [screen recorder in GNOME](https://help.gnome.org/users/gnome-help/stable/screen-shot-record.html.en) or [SimpleScreenRecorder](https://github.com/MaartenBaert/ssr) on Linux.
|
|
106
|
+
* **Explain why this enhancement would be useful** to most boilerplate users. You may also want to point out the other projects that solved it better and which could serve as inspiration.
|
|
107
|
+
|
|
108
|
+
## Join The Project Team
|
|
109
|
+
|
|
110
|
+
Please send email to dariopassariello@gmail.com
|
package/FUNDING.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# These are supported funding model platforms
|
|
2
|
+
|
|
3
|
+
github: passariello
|
|
4
|
+
patreon: passariello
|
|
5
|
+
open_collective: # Replace with a single Open Collective username
|
|
6
|
+
ko_fi: passariello
|
|
7
|
+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
9
|
+
liberapay: passariello
|
|
10
|
+
issuehunt: passariello
|
|
11
|
+
otechie: # Replace with a single Otechie username
|
|
12
|
+
custom:
|
|
13
|
+
[
|
|
14
|
+
"https://dario.passariello.ca",
|
|
15
|
+
"https://www.indiegogo.com/individuals/28513718",
|
|
16
|
+
]
|
package/HISTORY.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
none
|
package/SECURITY.md
ADDED
package/SUMMARY.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Table of contents
|
|
2
|
+
|
|
3
|
+
* [dpHelper](README.md)
|
|
4
|
+
|
|
5
|
+
## General
|
|
6
|
+
|
|
7
|
+
* [State](/documents/STATE.md)
|
|
8
|
+
* [Observer](/documents/OBSERVER.md)
|
|
9
|
+
* [Store](/documents/STORE.md)
|
|
10
|
+
* [All Functions](/documents/TOOLS.md)
|
|
11
|
+
|
|
12
|
+
## documents
|
|
13
|
+
|
|
14
|
+
* [License](LICENSE.md)
|
|
15
|
+
* [Contributing](CONTRIBUTING.md)
|
|
16
|
+
* [Code of Conduct](CODE_OF_CONDUCT.md)
|
|
17
|
+
* [Security](SECURITY.md)
|
|
18
|
+
|
|
19
|
+
## changes
|
|
20
|
+
|
|
21
|
+
* [Changelog](CAHNGELOG.md)
|
|
22
|
+
* [History](HISTORY.md)
|
package/docs/_config.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
theme: jekyll-theme-modernist
|
package/docs/index.md
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
# dpHelper
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
**Manager | DevTools** by [Dario Passariello](https://dario.passariello.ca) (c)
|
|
6
|
+
|
|
7
|
+
[](https://npmjs.org/package/dphelper)
|
|
8
|
+
[](https://npmjs.org/package/dphelper)
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
[](https://a51.gitbook.io/dphelper)
|
|
15
|
+
|
|
16
|
+
<!--
|
|
17
|
+
[](https://snyk.io/advisor/npm-package/dphelper)
|
|
18
|
+
[](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
|
+

|
|
277
|
+
|
|
278
|
+

|
|
279
|
+
|
|
280
|
+

|
|
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
|