-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
25,165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"extends": ["google"], | ||
"overrides": [], | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"plugins": [], | ||
"rules": { | ||
"object-curly-spacing": "off", | ||
"indent": "off", | ||
"require-jsdoc": "off", | ||
"max-len": "off", | ||
"operator-linebreak": "off", | ||
"no-invalid-this": "off", | ||
"new-cap": "off", | ||
"space-before-function-paren": "off" | ||
}, | ||
"settings": { | ||
"react": { | ||
"version": "detect" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
node_modules | ||
.pnp | ||
.pnp.js | ||
package-lock.json | ||
|
||
# testing | ||
coverage | ||
|
||
# next.js | ||
.next/ | ||
out/ | ||
|
||
# production | ||
build | ||
production | ||
public/uploads/**/ | ||
libs | ||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# vercel | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
node_modules | ||
.storybook | ||
example | ||
src | ||
libs | ||
*.tgz | ||
.gitignore | ||
rollup.config.js | ||
.vscode | ||
.eslintrc.json | ||
.prettierrc | ||
.eslintignore | ||
.prettierignore | ||
package-lock.json | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"singleQuote": true, | ||
"printWidth": 80, | ||
"proseWrap": "always", | ||
"tabWidth": 4, | ||
"useTabs": false, | ||
"trailingComma": "all", | ||
"bracketSpacing": true, | ||
"semi": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"_comment": "The authentication module can be proceed in two ways. Using combination of username and password or token. The project.json which contains two of them at once is invalid.", | ||
"project": "<your-key-here>", | ||
"sonarURL": "<your-sonar-url>", | ||
"auth": { | ||
"username": "<sonar-username>", | ||
"password": "<sonar-password>" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/xml-to-json-chunk-processor/.vscode/settings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.cursorBlinking": "blink", | ||
"editor.cursorStyle": "line", | ||
"editor.fontFamily": "'Operator Mono', 'SF Mono', Menlo, Operator Mono, Monaco, 'Courier New', monospace", | ||
"editor.fontSize": 10, | ||
"editor.fontWeight": "500", | ||
"editor.letterSpacing": 0, | ||
"editor.lineHeight": 20, | ||
"editor.lineNumbers": "on", | ||
"editor.insertSpaces": false, | ||
"editor.tabSize": 4, | ||
"editor.detectIndentation": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# XML to JSON Chunk Processor | ||
|
||
`xml-to-json-chunk-processor` is a Node.js module that provides an efficient way to read large XML files, split them into smaller chunks based on specified XML tags, and convert these chunks to JSON format. | ||
|
||
## Features | ||
|
||
- **Split Large XML Files:** Split large XML files into smaller chunks based on custom XML tags. | ||
- **Convert XML to JSON:** Convert XML chunks to JSON format. | ||
- **Customizable Chunk Size:** Define the number of chunks to be processed at a time. | ||
- **Tag Validation:** Validate the existence of opening and closing tags in the XML file before processing. | ||
|
||
## Installation | ||
|
||
You can install this package via npm: | ||
|
||
```bash | ||
npm install xml-to-json-chunk-processor | ||
``` | ||
|
||
## Usage | ||
|
||
Here's a basic example of how to use the package: | ||
|
||
```javascript | ||
const xmltoJson = require('xml-to-json-chunk-processor'); | ||
|
||
const params = { | ||
xmlUrl: 'path/to/your/largefile.xml', | ||
openingTag: '<YourOpeningTag>', | ||
closingTag: '</YourClosingTag>', | ||
chunkSize: 2500, // Optional, default is 2500 | ||
callback: (data) => { | ||
console.log('Processed data:', data); | ||
} | ||
}; | ||
|
||
xmltoJson(params) | ||
.then(() => { | ||
console.log('XML Processing Completed'); | ||
}) | ||
.catch((error) => { | ||
console.error('Error:', error); | ||
}); | ||
``` | ||
|
||
### Methods | ||
|
||
### `xmltoJson(params)` | ||
|
||
Splits the XML file into chunks, converts each chunk to JSON, and passes the JSON data to the provided callback function. | ||
|
||
### Parameters | ||
|
||
| Parameter | Type |Description | | ||
|------------------|----------|-----------------------------------------------------------------------------------------------| | ||
| `xmlUrl` | string | The path to the XML file to be processed. | | ||
| `openingTag` | string | The opening tag to look for in the XML file, e.g., `<item>`. | | ||
| `closingTag` | string | The closing tag to look for in the XML file, e.g., `</item>`. | | ||
| `chunkSize` | number | (Optional) The number of XML elements per chunk. Default is 2500. | | ||
| `callback` | function | A callback function that receives the processed JSON data for each chunk. | | ||
|
||
### XML Example | ||
|
||
Given an XML file like this: | ||
|
||
```xml | ||
<root> | ||
<item> | ||
<name>Item 1</name> | ||
<value>Value 1</value> | ||
</item> | ||
<item> | ||
<name>Item 2</name> | ||
<value>Value 2</value> | ||
</item> | ||
<!-- More items --> | ||
</root> | ||
``` | ||
|
||
You can process it with: | ||
|
||
```javascript | ||
const params = { | ||
xmlUrl: 'path/to/your/largefile.xml', | ||
openingTag: '<item>', | ||
closingTag: '</item>', | ||
callback: (data) => { | ||
console.log('Processed item:', data); | ||
} | ||
}; | ||
``` | ||
|
||
### Contributing | ||
|
||
If you find any issues or have suggestions for improvement, feel free to open an issue or submit a pull request on [GitHub](https://github.com/mernjs/create-mern-app/issues). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const { xmltoJson } = require(".."); | ||
|
||
const params = { | ||
xmlUrl: `${__dirname}/sample1.xml`, | ||
openingTag: '<PubmedArticle>', | ||
closingTag: '</PubmedArticle>', | ||
callback: (data) => { | ||
console.log('Processed Data:', data); | ||
} | ||
} | ||
|
||
xmltoJson(params) | ||
.then(() => { | ||
console.log('XML processing completed successfully!'); | ||
}) | ||
.catch((error) => { | ||
console.error('Error during XML processing:', error); | ||
}); |
Oops, something went wrong.