|
1 | | -# strfy-js |
2 | | - |
3 | | -## Stringify JSON as JavaScript 🌴 |
4 | | - |
5 | | -<p align="center" width="100%"> |
6 | | - <a href="https://github.com/pyramation/strfy-js/actions/workflows/run-tests.yaml"> |
7 | | - <img height="20" src="https://github.com/pyramation/strfy-js/actions/workflows/run-tests.yaml/badge.svg" /> |
8 | | - </a> |
9 | | - <a href="https://github.com/pyramation/strfy-js/blob/main/LICENSE-MIT"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a> |
10 | | -</p> |
11 | | - |
12 | | -`strfy-js` is a custom JavaScript serialization library designed to extend the capabilities of JSON serialization. This library is particularly useful for generating JavaScript objects directly from JSON, enabling developers to work with JSON data more effectively within JavaScript environments. |
13 | | - |
14 | | -## Features |
15 | | - |
16 | | -- **🛠️ Extended Serialization**: Converts JSON to JavaScript objects, supporting output, such as properties without quotes, not typically handled by standard JSON. |
17 | | - |
18 | | -- **⚙️ Customizable**: Offers various options to customize the output, making it suitable for different use cases. Tailor the serialization process to meet your specific requirements. |
19 | | - |
20 | | -- **⚡ Lightweight and Fast**: Optimized for performance, making it a practical choice for applications that require fast serialization of large amounts of data. Ideal for handling high-load environments efficiently. |
21 | | - |
22 | | -## Installation |
23 | | - |
24 | | -To install `strfy-js`, use npm or yarn: |
25 | | - |
26 | | -```bash |
27 | | -npm install strfy-js |
28 | | -# or |
29 | | -yarn add strfy-js |
30 | | -``` |
31 | | - |
32 | | -## Usage |
33 | | - |
34 | | -Import `jsStringify` from `strfy-js` and use it to serialize JavaScript objects: |
35 | | - |
36 | | -```js |
37 | | -import { jsStringify } from 'strfy-js'; |
38 | | - |
39 | | -const obj = { |
40 | | - "$schema": "schema.json", |
41 | | - "chain_id": "cosmos-1", |
42 | | - "logo_URIs": { |
43 | | - "png": "cosmos.png" |
44 | | - }, |
45 | | - "binaries": { |
46 | | - "linux/amd64": "cosmos-bin.tar.gz" |
47 | | - } |
48 | | -}; |
49 | | - |
50 | | -const options = { |
51 | | - space: 2, |
52 | | - camelCase: true, |
53 | | - quotes: 'single' |
54 | | -}; |
55 | | - |
56 | | -console.log(jsStringify(obj, options)); |
57 | | -// OUTPUT: |
58 | | -{ |
59 | | - $schema: 'schema.json', |
60 | | - chainId: 'cosmos-1', |
61 | | - logoURIs: { |
62 | | - png: 'cosmos.png' |
63 | | - }, |
64 | | - binaries: { |
65 | | - "linux/amd64": 'cosmos-bin.tar.gz' |
66 | | - } |
67 | | -} |
68 | | -``` |
69 | | - |
70 | | -## Options |
71 | | - |
72 | | -`jsStringify` accepts the following options in the `StringifyOptions` interface: |
73 | | - |
74 | | -- `space` (optional): Specifies the number of spaces to use for indentation, defaults to `0`. |
75 | | -- `replacer` (optional): A function that alters the behavior of the stringification process by filtering and transforming the values. |
76 | | -- `quotes` (optional): Determines the type of quotes around strings. Can be `'single'`, `'double'`, or determined automatically to avoid escapes. |
77 | | -- `inlineArrayLimit` (optional): Allows arrays to be serialized inline if they have fewer elements than the specified limit. |
78 | | -- `camelCase` (optional): When set to `true`, object keys are transformed into camelCase. |
79 | | -- `camelCaseFn` (optional): A custom function that can be provided to convert object keys into camelCase using a custom transformation logic. |
80 | | - |
81 | | -## Contributing |
82 | | - |
83 | | -Contributions are welcome! Please fork the repository and submit a pull request with your enhancements. For major changes, please open an issue first to discuss what you would like to change. |
84 | | - |
85 | | -## License |
86 | | - |
87 | | -This project is licensed under the MIT License - see the `LICENSE` file for details. |
| 1 | +> ⚠️ **Archived Repository** |
| 2 | +> This repo has been merged into our consolidated utilities workspace. |
| 3 | +> Please use the new location instead: https://github.com/hyperweb-io/dev-utils/ |
0 commit comments