Skip to content

Commit 6e10591

Browse files
committed
Import strfy-js history into history/strfy-js/
2 parents 84dbfeb + 0c2d4b0 commit 6e10591

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+5908
-0
lines changed

history/strfy-js/.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

history/strfy-js/.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
dist/
3+
main/
4+
module/
5+
coverage/

history/strfy-js/.eslintrc.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
module.exports = {
2+
plugins: ['prettier'],
3+
extends: ['eslint:recommended', 'prettier'],
4+
parser: 'esprima',
5+
parserOptions: {
6+
ecmaVersion: 11,
7+
requireConfigFile: false,
8+
sourceType: 'module',
9+
ecmaFeatures: {
10+
jsx: true
11+
}
12+
},
13+
env: {
14+
es6: true,
15+
browser: true,
16+
node: true,
17+
jest: true
18+
},
19+
rules: {
20+
'no-debugger': 2,
21+
'no-alert': 2,
22+
'no-await-in-loop': 0,
23+
'no-prototype-builtins': 0,
24+
'no-return-assign': ['error', 'except-parens'],
25+
'no-restricted-syntax': [
26+
2,
27+
'ForInStatement',
28+
'LabeledStatement',
29+
'WithStatement'
30+
],
31+
'no-unused-vars': [
32+
0,
33+
{
34+
ignoreSiblings: true,
35+
argsIgnorePattern: 'React|res|next|^_'
36+
}
37+
],
38+
'prefer-const': [
39+
'error',
40+
{
41+
destructuring: 'all'
42+
}
43+
],
44+
'no-unused-expressions': [
45+
2,
46+
{
47+
allowTaggedTemplates: true
48+
}
49+
],
50+
'no-console': 1,
51+
'comma-dangle': 2,
52+
'jsx-quotes': [2, 'prefer-double'],
53+
'linebreak-style': ['error', 'unix'],
54+
quotes: [
55+
2,
56+
'single',
57+
{
58+
avoidEscape: true,
59+
allowTemplateLiterals: true
60+
}
61+
],
62+
'prettier/prettier': [
63+
'error',
64+
{
65+
trailingComma: 'none',
66+
singleQuote: true,
67+
printWidth: 80
68+
}
69+
]
70+
}
71+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
6+
pull_request:
7+
types: [opened, reopened]
8+
9+
workflow_dispatch:
10+
11+
jobs:
12+
run-tests:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: checkout 🛎️
16+
uses: actions/checkout@v4
17+
18+
- name: node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 20.9.0
22+
23+
- name: Deps
24+
run: |
25+
yarn
26+
yarn build
27+
28+
- name: Test
29+
run: |
30+
yarn test

history/strfy-js/.gitignore

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# dist
12+
main
13+
module
14+
15+
# Directory for instrumented libs generated by jscoverage/JSCover
16+
lib-cov
17+
18+
# Coverage directory used by tools like istanbul
19+
coverage
20+
21+
# nyc test coverage
22+
.nyc_output
23+
24+
# Compiled binary addons (http://nodejs.org/api/addons.html)
25+
build/Release
26+
27+
# Dependency directories
28+
node_modules
29+
jspm_packages
30+
31+
# Optional npm cache directory
32+
.npm
33+
34+
# Optional REPL history
35+
.node_repl_history
36+
37+
# Editors
38+
.idea
39+
40+
# Lib
41+
lib
42+
43+
# npm package lock
44+
package-lock.json
45+
yarn.lock
46+
47+
# others
48+
.DS_Store

history/strfy-js/.npmignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
*.log
2+
npm-debug.log*
3+
4+
protobuf
5+
out
6+
*.proto
7+
8+
# snapshots
9+
*.snap
10+
11+
# Coverage directory used by tools like istanbul
12+
coverage
13+
.nyc_output
14+
15+
# Dependency directories
16+
node_modules
17+
18+
# npm package lock
19+
package-lock.json
20+
yarn.lock
21+
22+
# project files
23+
__snapshots__
24+
__fixtures__
25+
test-utils
26+
__tests__
27+
.editorconfig
28+
.eslintignore
29+
.eslintrc.js
30+
.gitignore
31+
.travis.yml
32+
.vscode
33+
CHANGELOG.md

history/strfy-js/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scripts-prepend-node-path=true
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"[javascriptreact]": {
4+
"editor.formatOnSave": false
5+
},
6+
"[javascript]": {
7+
"editor.formatOnSave": false
8+
},
9+
"editor.codeActionsOnSave": {
10+
"source.fixAll.eslint": "explicit"
11+
},
12+
"eslint.validate": [
13+
"javascript",
14+
"javascriptreact"
15+
],
16+
"editor.insertSpaces": true,
17+
"editor.tabSize": 2
18+
}

history/strfy-js/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2022 Dan Lynch <[email protected]>
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.

history/strfy-js/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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.

0 commit comments

Comments
 (0)