├── .all-contributorsrc
├── .eslintrc
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ └── docs.yml
├── .gitignore
├── .npmignore
├── .prettierrc
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
├── docs
├── .nojekyll
├── CNAME
├── assets
│ ├── custom.css
│ ├── highlight.css
│ ├── icons.js
│ ├── icons.svg
│ ├── main.js
│ ├── material-style.css
│ ├── navigation.js
│ ├── search.js
│ └── style.css
├── classes
│ └── Jsoning.html
├── enums
│ ├── Events.html
│ └── MathOps.html
├── index.html
├── interfaces
│ ├── JSONValueArray.html
│ └── JSONValueRecord.html
├── modules.html
├── sitemap.xml
└── types
│ ├── JSONValue.html
│ └── JsoningOptions.html
├── media
├── jsoning-square.png
├── jsoning-square.svg
├── jsoning.png
├── jsoning.svg
└── typedoc_css.css
├── package-lock.json
├── package.json
├── src
└── index.ts
├── tests
└── test.js
├── tsconfig.json
└── typedoc.json
/.all-contributorsrc:
--------------------------------------------------------------------------------
1 | {
2 | "projectName": "jsoning",
3 | "projectOwner": "khalby786",
4 | "repoType": "github",
5 | "repoHost": "https://github.com",
6 | "files": [
7 | "README.md"
8 | ],
9 | "imageSize": 100,
10 | "commit": true,
11 | "commitConvention": "angular",
12 | "contributors": [
13 | {
14 | "login": "khalby786",
15 | "name": "Khaleel Gibran",
16 | "avatar_url": "https://avatars.githubusercontent.com/u/38468163?v=4",
17 | "profile": "https://github.com/khalby786",
18 | "contributions": [
19 | "code",
20 | "doc",
21 | "design",
22 | "infra",
23 | "test",
24 | "tutorial"
25 | ]
26 | },
27 | {
28 | "login": "aboutDavid",
29 | "name": "David",
30 | "avatar_url": "https://avatars.githubusercontent.com/u/62346025?v=4",
31 | "profile": "https://aboutdavid.me/",
32 | "contributions": [
33 | "doc"
34 | ]
35 | },
36 | {
37 | "login": "Jonyk56",
38 | "name": "Jonyk56",
39 | "avatar_url": "https://avatars.githubusercontent.com/u/44901605?v=4",
40 | "profile": "https://github.com/Jonyk56",
41 | "contributions": [
42 | "code"
43 | ]
44 | },
45 | {
46 | "login": "ayntee",
47 | "name": "ayntee",
48 | "avatar_url": "https://avatars.githubusercontent.com/u/34645569?v=4",
49 | "profile": "https://github.com/ayntee",
50 | "contributions": [
51 | "code"
52 | ]
53 | },
54 | {
55 | "login": "oadpoaw",
56 | "name": "undefine",
57 | "avatar_url": "https://avatars.githubusercontent.com/u/46276781?v=4",
58 | "profile": "https://xetha-bot.me/",
59 | "contributions": [
60 | "code",
61 | "bug",
62 | "security"
63 | ]
64 | },
65 | {
66 | "login": "adi-g15",
67 | "name": "Aditya Gupta",
68 | "avatar_url": "https://avatars.githubusercontent.com/u/37269665?v=4",
69 | "profile": "https://github.com/adi-g15",
70 | "contributions": [
71 | "code"
72 | ]
73 | },
74 | {
75 | "login": "manmal",
76 | "name": "Manuel Maly",
77 | "avatar_url": "https://avatars.githubusercontent.com/u/142797?v=4",
78 | "profile": "http://www.creativepragmatics.com",
79 | "contributions": [
80 | "code",
81 | "bug"
82 | ]
83 | },
84 | {
85 | "login": "wh0",
86 | "name": "wh0",
87 | "avatar_url": "https://avatars.githubusercontent.com/u/382796?v=4",
88 | "profile": "https://wh0.github.io/",
89 | "contributions": [
90 | "code"
91 | ]
92 | },
93 | {
94 | "login": "akpi816218",
95 | "name": "akpi816218",
96 | "avatar_url": "https://avatars.githubusercontent.com/u/111009970?v=4",
97 | "profile": "https://akpi.is-a.dev/",
98 | "contributions": [
99 | "code",
100 | "doc",
101 | "example",
102 | "maintenance",
103 | "test",
104 | "tool"
105 | ]
106 | }
107 | ],
108 | "contributorsPerLine": 7,
109 | "skipCi": true
110 | }
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
3 | "parser": "@typescript-eslint/parser",
4 | "parserOptions": {
5 | "ecmaVersion": "latest",
6 | "sourceType": "module"
7 | },
8 | "plugins": ["@typescript-eslint"],
9 | "root": true,
10 | "env": {
11 | "es6": true,
12 | "node": true
13 | },
14 | "rules": {
15 | "@typescript-eslint/no-unused-vars": "error",
16 | "camelcase": "error",
17 | "capitalized-comments": "off",
18 | "comma-dangle": "error",
19 | "eol-last": "error",
20 | "func-call-spacing": "error",
21 | "getter-return": "error",
22 | "indent": "off",
23 | "new-parens": "error",
24 | "no-alert": "error",
25 | "no-console": "error",
26 | "no-const-assign": "error",
27 | "no-debugger": "error",
28 | "no-delete-var": "error",
29 | "no-dupe-args": "error",
30 | "no-dupe-keys": "error",
31 | "no-duplicate-case": "error",
32 | "no-duplicate-imports": "error",
33 | "no-eq-null": "error",
34 | "no-eval": "error",
35 | "no-fallthrough": "error",
36 | "no-implied-eval": "error",
37 | "no-invalid-regexp": "error",
38 | "no-invalid-this": "error",
39 | "no-irregular-whitespace": "error",
40 | "no-lonely-if": "error",
41 | "no-multi-str": "error",
42 | "no-param-reassign": "error",
43 | "no-redeclare": "error",
44 | "no-self-assign": "error",
45 | "no-self-compare": "error",
46 | "no-trailing-spaces": "error",
47 | "no-unneeded-ternary": "error",
48 | "no-unreachable": "error",
49 | "no-unused-expressions": "error",
50 | "no-unused-vars": "off",
51 | "no-var": "error",
52 | "no-with": "error",
53 | "object-curly-newline": "error",
54 | "prefer-arrow-callback": "error",
55 | "prefer-const": "error",
56 | "prefer-promise-reject-errors": "error",
57 | "prefer-template": "error",
58 | "semi-spacing": "error",
59 | "strict": "error",
60 | "use-isnan": "error"
61 | }
62 | }
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug
6 | assignees: khalby786
7 |
8 | ---
9 |
10 | ## Describe the bug
11 | A clear and concise description of what the bug is.
12 |
13 | ## Reproducible code sample (if applicable)
14 |
15 | ```javascript
16 | // place the code here
17 | ```
18 |
19 | ## Expected behavior
20 | A clear and concise description of what you expected to happen.
21 |
22 | ## Further details
23 | - Jsoning version:
24 | - Node.js version:
25 | - Operating system:
26 |
27 | ## Additional context
28 | If applicable, add any other context about the problem here.
29 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/workflows/docs.yml:
--------------------------------------------------------------------------------
1 | name: Generate documentation
2 |
3 | on:
4 | push:
5 | branches: [ $default-branch ]
6 | pull_request:
7 | branches: [ $default-branch ]
8 |
9 | jobs:
10 | build:
11 |
12 | runs-on: ubuntu-latest
13 |
14 | strategy:
15 | matrix:
16 | node-version: [12.x]
17 |
18 | steps:
19 | - uses: actions/checkout@v2
20 | - name: Generate documentation using TypeDoc
21 | uses: actions/setup-node@v1
22 | with:
23 | node-version: '12.x'
24 | - run: npm install
25 | - run: npm run gendocs
26 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .nyc_output
3 | coverage
4 | dist
5 | *.test.json
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | docs
2 | src
3 | tests
4 | docma.js
5 | tsconfig.json
6 | scripts
7 | .github
8 | .all-contributorsrc
9 | .eslintrc
10 | .gitignore
11 | .prettierrc
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "trailingComma": "none",
3 | "tabWidth": 2,
4 | "semi": true,
5 | "singleQuote": false,
6 | "useTabs": false,
7 | "arrowParens": "avoid"
8 | }
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at khalby786@gmail.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | When contributing to this repository, please first discuss the change you wish to make via issue,
4 | email, or any other method with the owners of this repository before making a change.
5 |
6 | Please note we have a code of conduct, please follow it in all your interactions with the project.
7 |
8 | ## Pull Request Process
9 |
10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11 | build.
12 | 2. Update the README.md with details of changes to the interface, this includes new environment
13 | variables, exposed ports, useful file locations and container parameters.
14 | 3. Increase the version numbers in `package.json`, any examples files and the README.md to the new version that this
15 | Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16 |
17 | ## Code of Conduct
18 |
19 | ### Our Pledge
20 |
21 | In the interest of fostering an open and welcoming environment, we as
22 | contributors and maintainers pledge to making participation in our project and
23 | our community a harassment-free experience for everyone, regardless of age, body
24 | size, disability, ethnicity, gender identity and expression, level of experience,
25 | nationality, personal appearance, race, religion, or sexual identity and
26 | orientation.
27 |
28 | ### Our Standards
29 |
30 | Examples of behavior that contributes to creating a positive environment
31 | include:
32 |
33 | * Using welcoming and inclusive language
34 | * Being respectful of differing viewpoints and experiences
35 | * Gracefully accepting constructive criticism
36 | * Focusing on what is best for the community
37 | * Showing empathy towards other community members
38 |
39 | Examples of unacceptable behavior by participants include:
40 |
41 | * The use of sexualized language or imagery and unwelcome sexual attention or
42 | advances
43 | * Trolling, insulting/derogatory comments, and personal or political attacks
44 | * Public or private harassment
45 | * Publishing others' private information, such as a physical or electronic
46 | address, without explicit permission
47 | * Other conduct which could reasonably be considered inappropriate in a
48 | professional setting
49 |
50 | ### Our Responsibilities
51 |
52 | Project maintainers are responsible for clarifying the standards of acceptable
53 | behavior and are expected to take appropriate and fair corrective action in
54 | response to any instances of unacceptable behavior.
55 |
56 | Project maintainers have the right and responsibility to remove, edit, or
57 | reject comments, commits, code, wiki edits, issues, and other contributions
58 | that are not aligned to this Code of Conduct, or to ban temporarily or
59 | permanently any contributor for other behaviors that they deem inappropriate,
60 | threatening, offensive, or harmful.
61 |
62 | ### Scope
63 |
64 | This Code of Conduct applies both within project spaces and in public spaces
65 | when an individual is representing the project or its community. Examples of
66 | representing a project or community include using an official project e-mail
67 | address, posting via an official social media account, or acting as an appointed
68 | representative at an online or offline event. Representation of a project may be
69 | further defined and clarified by project maintainers.
70 |
71 | ### Enforcement
72 |
73 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
74 | reported by contacting the project owner at [khalby786@gmail.com](mailto:khalby786@gmail.com). All
75 | complaints will be reviewed and investigated and will result in a response that
76 | is deemed necessary and appropriate to the circumstances. The project owner is
77 | obligated to maintain confidentiality with regard to the reporter of an incident.
78 | Further details of specific enforcement policies may be posted separately.
79 |
80 | Project maintainers who do not follow or enforce the Code of Conduct in good
81 | faith may face temporary or permanent repercussions as determined by other
82 | members of the project's leadership.
83 |
84 | ### Attribution
85 |
86 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
87 | available at [http://contributor-covenant.org/version/1/4][version]
88 |
89 | [homepage]: http://contributor-covenant.org
90 | [version]: http://contributor-covenant.org/version/1/4/
91 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Khaleel Gibran
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
21 |
22 | ---
23 |
24 | Jsoning is a simplified wrapper for Node.js that lets you write and read data to and from JSON files. It's designed to be beginner-friendly and easy to use, with a simple API that makes it easy to get started with. It's perfect for small projects, prototyping, and learning how to work with databases.
25 |
26 |
27 | ## Features
28 |
29 | - Use existing JSON files to read and write key-value pairs
30 | - EventEmitters to listen to changes in the database
31 | - Atomic file writing to prevent data corruption
32 | - Easier to use than a toaster
33 | - TypeScript support for all the fixed-type addicts out there
34 |
35 | ## Install
36 |
37 | **Node.js v16.x or greater is required for this package to work.**
38 |
39 | ```bash
40 | npm i jsoning
41 |
42 | # pnpm if you're feeling fast
43 | pnpm i jsoning
44 |
45 | # yarn if you're feeling fancy
46 | yarn add jsoning
47 | ```
48 |
49 | View the full documentation [here](https://jsoning.js.org/).
50 |
51 | ## Basic Usage
52 |
53 | ```ts
54 | import { Jsoning, MathOps } from 'jsoning';
55 | const db = new Jsoning('database.json');
56 |
57 | // Set some values with a key
58 | await db.set('birthday', '07-aug');
59 | await db.set('age', '13');
60 |
61 | // Push stuff to an array for a particular key
62 | await db.push('transformers', 'optimus prime');
63 | await db.push('transformers', 'bumblebee');
64 | await db.push('transformers', 'iron hide');
65 |
66 | // Get the value of a key
67 | console.log(await db.get('transformers')); // [ 'optimus prime', 'bumblebee', 'iron hide' ]
68 |
69 | // Get all the values
70 | console.log(await db.all()); // { Record of the whole database contents }
71 |
72 | // does such a value exist?
73 | console.log(await db.has('value2')); // false
74 |
75 | // My age keeps changing, so I'm deleting it
76 | console.log(await db.delete('age')); // true
77 |
78 | // I got $100 for my birthday
79 | await db.set('money', 100);
80 |
81 | // and someone gave me $200 more
82 | await db.math('money', MathOps.Add, 200);
83 |
84 | // Just wanna make sure how much money I got
85 | console.log(await db.get('money')); // 300
86 |
87 | // RIP iron hide, he died
88 | await db.remove('transformers', 'iron hide');
89 |
90 | // I'm getting bored, so I'm clearing the whole database
91 | await db.clear();
92 | ```
93 |
94 | ## Contributing
95 |
96 | Please see `CONTRIBUTING.md` for more details on contributing!
97 |
98 | ### Contributors
99 |
100 |
101 | [](#contributors-)
102 |
103 |
104 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
105 |
106 |
107 |
108 |
109 |
MathOps
160 |