Skip to content

Commit 7a2a96d

Browse files
committed
Fixed interface of Options not exported
1 parent 171e6e5 commit 7a2a96d

16 files changed

+220
-140
lines changed

.npmignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ src/
33
# Ignore development and configuration files
44
node_modules/
55
test/
6-
.git/
7-
.eslint*
8-
.prettier*
6+
.github
7+
.eslintrc.json
8+
.eslintignore
9+
.prettierignore
10+
.prettierrc.json
11+
jest.config.ts
912
coverage

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Change Log
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
5+
and this project adheres to [Semantic Versioning](http://semver.org/).
6+
7+
## [1.1.3] - 2023-08-30
8+
9+
Here we write upgrading notes for brands. It's a team effort to make them as
10+
straightforward as possible.
11+
12+
### Added
13+
- [json-to-plain-text](https://github.com/sumithemmadi/json-to-plain-text) Added seperator option.
14+
15+
### Changed
16+
17+
- [json-to-plain-text](https://github.com/sumithemmadi/json-to-plain-text) Made some updateds
18+
19+
20+
### Fixed
21+
- [json-to-plain-text](https://github.com/sumithemmadi/json-to-plain-text) interfaceof options `Options` is not exported. So , It is fixed in this version.

CODE_OF_CONDUCT.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Code of Conduct for https://github.com/sumithemmadi/json-to-plain-text
2+
3+
## Our Pledge
4+
5+
We, as members, contributors, and maintainers of this repository, pledge to foster an open, inclusive, and respectful environment for everyone who engages with our project. We are dedicated to providing a harassment-free experience, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to a positive environment include:
10+
11+
- Being respectful and considerate towards others.
12+
- Encouraging and supporting each other's ideas and contributions.
13+
- Providing and receiving constructive feedback with grace and openness.
14+
- Being empathetic and understanding towards differing perspectives.
15+
16+
Examples of unacceptable behavior include:
17+
18+
- Use of offensive, derogatory, or inappropriate language.
19+
- Harassment, trolling, or any form of personal attacks.
20+
- Publishing private information without explicit permission.
21+
- Engaging in any behavior that could be considered inappropriate or harmful.
22+
23+
## Responsibilities
24+
25+
Project maintainers are responsible for upholding the standards of conduct within the repository. They have the right and duty to remove, edit, or reject comments, code, and other contributions that violate this Code of Conduct.
26+
27+
## Scope
28+
29+
This Code of Conduct applies to all interactions within the repository, as well as to any public representation of the project. This includes comments, issues, pull requests, code reviews, and any other communication.
30+
31+
## Enforcement
32+
33+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [Your Contact Email]. All complaints will be reviewed promptly and treated with confidentiality and respect. Project maintainers are obligated to respect the privacy and security of the reporter of any incident.
34+
35+
## Consequences
36+
37+
Anyone found to be violating this Code of Conduct may face consequences, which can include:
38+
39+
1. **Warning**: A private, written warning from the project maintainers.
40+
2. **Temporary Ban**: A temporary ban from participating in the repository.
41+
3. **Permanent Ban**: A permanent ban from the repository and its related activities.
42+
43+
Project maintainers will use their discretion in determining the appropriate consequences for each case, considering the severity and impact of the violation.

README.md

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
[![License](https://img.shields.io/npm/l/json-to-plain-text.svg)](https://github.com/sumithemmadi/json-to-plain-text/blob/main/LICENSE)
77
[![Maintenance](https://img.shields.io/npms-io/maintenance-score/json-to-plain-text)](https://github.com/sumithemmadi/json-to-plain-text)
88
[![Issues](https://img.shields.io/github/issues/sumithemmadi/json-to-plain-text)](https://github.com/sumithemmadi/json-to-plain-text/issues)
9+
[![GitHub Sponsors](https://img.shields.io/github/sponsors/sumithemmadi)](https://github.com/sponsors/sumithemmadi)
10+
[![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=json-to-plain-text&query=$.install.pretty&label=install%20size)](https://packagephobia.now.sh/result?p=json-to-plain-text)
11+
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/json-to-plain-text)](https://bundlephobia.com/package/json-to-plain-text@latest)
12+
[![Known Vulnerabilities](https://snyk.io/test/npm/json-to-plain-text/badge.svg)](https://snyk.io/test/npm/json-to-plain-text)
913

1014
`json-to-plain-text` is a npm module that converts JSON-like data or plain JavaScript objects to a formatted plain text representation. It allows you to convert JSON-like data or plain JavaScript objects into human-readable format.
1115

@@ -19,7 +23,7 @@
1923

2024
2. Import the `jsonToPlainText` function:
2125

22-
```typescript
26+
```js
2327
import { jsonToPlainText } from "json-to-plain-text";
2428
```
2529

@@ -34,6 +38,7 @@ The `jsonToPlainText` function accepts two parameters: `data` and `options`.
3438
- `options` (optional): Configuration options for customizing the output. It is an object with the following properties:
3539

3640
- `color` (boolean, default: `true`): Whether to apply colors to the output or not. Set to `true` to add colors using the `chalk` library or `false` for plain text output.
41+
- `seperator` (string, default: `:`): seperate keys and values.
3742

3843
- `spacing` (boolean, default: `true`): Whether to include spacing before colons. Set to `true` for formatted spacing or `false` to remove spacing before colons.
3944

@@ -46,48 +51,45 @@ The `jsonToPlainText` function accepts two parameters: `data` and `options`.
4651
### Example
4752

4853
```typescript
49-
import { jsonToPlainText } from "json-to-plain-text";
50-
51-
const data = {
52-
"place_id": "173937105",
53-
"osm_type": "way",
54-
"osm_id": "319992693",
55-
"lat": "17.861533866867224",
56-
"lon": "78.8081441896764",
57-
"display_name": "Satadar Nagar, Ward 116 Allapur, Hyderabad, Kukatpally mandal, Telangana, 500018, India",
58-
"address": {
59-
"neighbourhood": "Satadar Nagar",
60-
"suburb": "Ward 116 Allapur",
61-
"city": "Hyderabad",
62-
"county": "Kukatpally mandal",
63-
"state": "Telangana",
64-
"postcode": "500018",
65-
"country": "India",
66-
"country_code": "in"
67-
},
68-
"extratags": {},
69-
"namedetails": {},
70-
"boundingbox": [
71-
"17.8598497",
72-
"17.8623087",
73-
"78.8079136",
74-
"78.8082658"
75-
],
76-
"distance": 2
77-
}
54+
import { jsonToPlainText, Options } from "json-to-plain-text";
55+
56+
let data = {
57+
place_id: "173937105",
58+
osm_type: "way",
59+
osm_id: "319992693",
60+
lat: "17.861533866867224",
61+
lon: "78.8081441896764",
62+
display_name:
63+
"Satadar Nagar, Ward 116 Allapur, Hyderabad, Kukatpally mandal, Telangana, 500018, India",
64+
address: {
65+
neighbourhood: "Satadar Nagar",
66+
suburb: "Ward 116 Allapur",
67+
city: "Hyderabad",
68+
county: "Kukatpally mandal",
69+
state: "Telangana",
70+
postcode: "500018",
71+
country: "India",
72+
country_code: "in",
73+
},
74+
extratags: {},
75+
namedetails: {},
76+
boundingbox: ["17.8598497", "17.8623087", "78.8079136", "78.8082658"],
77+
distance: 2,
78+
};
79+
7880

7981
// This is optional
80-
const options = {
82+
const options: Options = {
8183
color: true, // Whether to apply colors to the output or not
8284
spacing: true, // Whether to include spacing before colons or not
85+
seperator: ":", // seperate keys and values.
8386
squareBracketsForArray: false, // Whether to use square brackets for arrays or not
8487
doubleQuotesForKeys: false, // Whether to use double quotes for object keys or not
8588
doubleQuotesForValues: false, // Whether to use double quotes for string values or not
8689
}
8790

8891
// Convert the data to formatted plain text representation
8992
const plainText = jsonToPlainText(data, options);
90-
9193
console.log(plainText);
9294
```
9395

@@ -115,6 +117,17 @@ boundingbox : 17.8598497, 17.8623087, 78.8079136, 78.8082658
115117
distance : 2
116118
```
117119
120+
## 💝 Sponsor
121+
122+
If you find TruecallerJS helpful or inspiring, consider supporting me through GitHub Sponsors. Your sponsorship helps me dedicate more time and effort to open source development and creating impactful projects.
123+
124+
- **Sponsor Me**: [https://github.com/sponsors/sumithemmadi](https://github.com/sponsors/sumithemmadi/)
125+
126+
- <a href="https://www.buymeacoffee.com/sumithemmadi" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-red.png" alt="Buy Me A Coffee" style="height: 45px !important;width: 200px !important;" ></a>
127+
### 💖 Sponsors
128+
129+
[![Sponsors](https://sumithemmadi.github.io/sponsor.svg)](https://github.com/sponsors/sumithemmadi/)
130+
118131
## License
119132
120133
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

SECURITY.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Supported Versions
2+
3+
This section outlines the versions of the "json-to-plain-text" package that are currently eligible for receiving security updates and maintenance. It's essential to keep your software up to date to ensure the security and stability of your applications.
4+
5+
| Version | Supported | Notes |
6+
| ----------- | ------------------ | ------------------------- |
7+
| 1.1.x | :white_check_mark: | Latest and actively maintained version. Security updates and bug fixes will be provided. It's recommended to upgrade to this version. |
8+
| 1.0.x | :x: | This version is no longer receiving security updates. Users are advised to upgrade to the latest 1.1.x release for continued support. |
9+
| < 1.0 | :x: | Versions prior to 1.0 are not supported and may contain known security vulnerabilities. Users should upgrade to a supported version. |
10+
11+
It's our priority to provide a secure and reliable package for our users. We strongly encourage all users to stay up to date with the latest supported version to benefit from the latest security enhancements and bug fixes.
12+
13+
## Reporting a Vulnerability
14+
15+
I take security vulnerabilities seriously and appreciate the help of the community in identifying and addressing them. If you discover a security vulnerability in the "json-to-plain-text" package, please report it:
16+
17+
**Contact Information**: You can report the vulnerability by raiseing issue [json-to-plain-text](https://github.com/sumithemmadi/json-to-plain-text). Please provide a detailed description of the vulnerability and steps to reproduce it, if possible.
18+
19+
20+
Thank you for your dedication to the security of the "json-to-plain-text" package. Your responsible disclosure helps us provide a safer experience for all our users.

dist/cjs/index.d.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
interface Options {
22
color?: boolean;
33
spacing?: boolean;
4+
seperator?: string;
45
squareBracketsForArray?: boolean;
56
doubleQuotesForKeys?: boolean;
67
doubleQuotesForValues?: boolean;
@@ -13,6 +14,7 @@ interface Options {
1314
* @param options {Options} - (Optional) Configuration options for customizing the output.
1415
* - color {boolean} - Whether to apply colors to the output (default: true).
1516
* - spacing {boolean} - Whether to include spacing after colons (default: true).
17+
* - seperator {string} - seperator. Default ':',
1618
* - squareBracketsForArray {boolean} - Whether to use square brackets for arrays (default: false).
1719
* - doubleQuotesForKeys {boolean} - Whether to use double quotes for object keys (default: false).
1820
* - doubleQuotesForValues {boolean} - Whether to use double quotes for string values (default: false).
@@ -23,6 +25,7 @@ interface Options {
2325
* const options = {
2426
* color: true,
2527
* spacing: true,
28+
* seperator?: "=";
2629
* squareBracketsForArray: false,
2730
* doubleQuotesForKeys: false,
2831
* doubleQuotesForValues: false,
@@ -32,9 +35,9 @@ interface Options {
3235
*
3336
* // Output:
3437
* //
35-
* // name : "John",
36-
* // age : 30,
37-
* // isEmployed : true
38+
* // name = "John",
39+
* // age = 30,
40+
* // isEmployed = true
3841
*/
3942
declare function jsonToPlainText(data: unknown, options: Options): string;
40-
export { jsonToPlainText };
43+
export { jsonToPlainText, Options };

dist/cjs/index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const chalk_1 = __importDefault(require("chalk"));
3030
* @param options {Options} - (Optional) Configuration options for customizing the output.
3131
* - color {boolean} - Whether to apply colors to the output (default: true).
3232
* - spacing {boolean} - Whether to include spacing after colons (default: true).
33+
* - seperator {string} - seperator. Default ':',
3334
* - squareBracketsForArray {boolean} - Whether to use square brackets for arrays (default: false).
3435
* - doubleQuotesForKeys {boolean} - Whether to use double quotes for object keys (default: false).
3536
* - doubleQuotesForValues {boolean} - Whether to use double quotes for string values (default: false).
@@ -40,6 +41,7 @@ const chalk_1 = __importDefault(require("chalk"));
4041
* const options = {
4142
* color: true,
4243
* spacing: true,
44+
* seperator?: "=";
4345
* squareBracketsForArray: false,
4446
* doubleQuotesForKeys: false,
4547
* doubleQuotesForValues: false,
@@ -49,16 +51,17 @@ const chalk_1 = __importDefault(require("chalk"));
4951
*
5052
* // Output:
5153
* //
52-
* // name : "John",
53-
* // age : 30,
54-
* // isEmployed : true
54+
* // name = "John",
55+
* // age = 30,
56+
* // isEmployed = true
5557
*/
5658
function jsonToPlainText(data, options) {
5759
const visited = new Set();
5860
let indentLevel = 1;
5961
const defaultOptions = {
6062
color: true,
6163
spacing: true,
64+
seperator: ":",
6265
squareBracketsForArray: false,
6366
doubleQuotesForKeys: false,
6467
doubleQuotesForValues: false,
@@ -67,6 +70,7 @@ function jsonToPlainText(data, options) {
6770
const outputOptions = {
6871
color: mergedOptions.color,
6972
spacing: mergedOptions.spacing,
73+
seperator: mergedOptions.seperator,
7074
squareBracketsForArray: mergedOptions.squareBracketsForArray,
7175
doubleQuotesForKeys: mergedOptions.doubleQuotesForKeys,
7276
doubleQuotesForValues: mergedOptions.doubleQuotesForValues,
@@ -216,8 +220,8 @@ function jsonToPlainText(data, options) {
216220
return handlers[getType(data)](data, false).replace(/}json-to-plain-text-special-string-(\d+){/g, (match, number) => {
217221
const space = parseInt(number, 10);
218222
return outputOptions.spacing
219-
? " ".repeat(indentLevel - space) + " : "
220-
: " : ";
223+
? " ".repeat(indentLevel - space) + ` ${outputOptions.seperator} `
224+
: ` ${outputOptions.seperator} `;
221225
});
222226
}
223227
exports.jsonToPlainText = jsonToPlainText;

dist/index.d.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
interface Options {
22
color?: boolean;
33
spacing?: boolean;
4+
seperator?: string;
45
squareBracketsForArray?: boolean;
56
doubleQuotesForKeys?: boolean;
67
doubleQuotesForValues?: boolean;
@@ -13,6 +14,7 @@ interface Options {
1314
* @param options {Options} - (Optional) Configuration options for customizing the output.
1415
* - color {boolean} - Whether to apply colors to the output (default: true).
1516
* - spacing {boolean} - Whether to include spacing after colons (default: true).
17+
* - seperator {string} - seperator. Default ':',
1618
* - squareBracketsForArray {boolean} - Whether to use square brackets for arrays (default: false).
1719
* - doubleQuotesForKeys {boolean} - Whether to use double quotes for object keys (default: false).
1820
* - doubleQuotesForValues {boolean} - Whether to use double quotes for string values (default: false).
@@ -23,6 +25,7 @@ interface Options {
2325
* const options = {
2426
* color: true,
2527
* spacing: true,
28+
* seperator?: "=";
2629
* squareBracketsForArray: false,
2730
* doubleQuotesForKeys: false,
2831
* doubleQuotesForValues: false,
@@ -32,9 +35,9 @@ interface Options {
3235
*
3336
* // Output:
3437
* //
35-
* // name : "John",
36-
* // age : 30,
37-
* // isEmployed : true
38+
* // name = "John",
39+
* // age = 30,
40+
* // isEmployed = true
3841
*/
3942
declare function jsonToPlainText(data: unknown, options: Options): string;
40-
export { jsonToPlainText };
43+
export { jsonToPlainText, Options };

0 commit comments

Comments
 (0)