Skip to content

Commit f9ec02a

Browse files
committed
release: v2.1.0
updated readme & added .npmignore
1 parent 6526a78 commit f9ec02a

File tree

3 files changed

+87
-57
lines changed

3 files changed

+87
-57
lines changed

.npmignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# folders
2+
.idea
3+
.github
4+
.nyc_output
5+
coverage
6+
test
7+
exclude
8+
node_modules
9+
10+
# files
11+
.gitignore
12+
.npmignore
13+
.nycrc.json
14+
.travis.yml
15+
yarn.lock

README.md

Lines changed: 71 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,43 @@
1-
# json-keys-sort
2-
[![Build Status](https://travis-ci.org/DawnImpulse/json-keys-sort.svg?branch=master)](https://travis-ci.org/DawnImpulse/json-keys-sort) [![Coverage Status](https://coveralls.io/repos/github/DawnImpulse/json-keys-sort/badge.svg?branch=master)](https://coveralls.io/github/DawnImpulse/json-keys-sort?branch=master) ![wait-loop](https://img.shields.io/npm/dt/json-keys-sort.svg)
3-
> Sorting a json object based on keys either ascending or descending & even recursively
41

5-
### Latest Changes
6-
- **sort** now throws an error if not provided with an object
7-
- added support for Typescript
82

9-
### Example -
10-
> Note : focus on **keys** not values
11-
3+
# json-keys-sort
4+
![ts](https://badgen.net/badge/-/TypeScript?icon=typescript&label&labelColor=blue&color=555555) ![NPM](https://img.shields.io/npm/l/error-key) ![npm](https://img.shields.io/npm/v/json-keys-sort) [![Build Status](https://app.travis-ci.com/DawnImpulse/json-keys-sort.svg?branch=master)](https://app.travis-ci.com/DawnImpulse/json-keys-sort) [![Coverage Status](https://coveralls.io/repos/github/DawnImpulse/json-keys-sort/badge.svg?branch=master)](https://coveralls.io/github/DawnImpulse/json-keys-sort?branch=master) ![wait-loop](https://img.shields.io/npm/dt/json-keys-sort.svg) ![install size](https://packagephobia.com/badge?p=json-keys-sort) [![Buy us a tree](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen)](https://plant.treeware.earth/dawnimpulse/json-keys-sort)
5+
> Sorting a json object based on keys either ascending or descending & even recursively
6+
7+
### Latest Changes (v2.1.0)
8+
- **sortAsync** : this is a new function which returns a promise
9+
10+
### Installation
11+
`npm install json-keys-sort`
12+
or
13+
`yarn add json-keys-sort`
14+
15+
### Example -
16+
> Note : focus on **keys** not values
1217
~~~~
1318
const json = require('json-keys-sort');
1419
var data = {
15-
"zoho": 4,
16-
"drake": 2,
17-
"yogo": {
18-
"jout": "3.2",
19-
"aou": {
20-
"yoyo": "3.1.3",
21-
"aalo": "3.1.1",
22-
"go": "3.1.2"
23-
}
24-
},
25-
"abc": 1
26-
}
27-
28-
json.sort(data,true)
20+
"zoho": 4,
21+
"drake": 2,
22+
"yogo": {
23+
"jout": "3.2",
24+
"aou": {
25+
"yoyo": "3.1.3",
26+
"aalo": "3.1.1",
27+
"go": "3.1.2"
28+
}
29+
},
30+
"abc": 1
31+
}
32+
33+
// sync (return sorted data)
34+
json.sort(data, true)
35+
36+
// async (return promise of sorted data)
37+
json.sortAsync(data, true)
2938
~~~~
30-
31-
Output will be -
39+
40+
Output will be -
3241
~~~~
3342
{
3443
"abc": 1,
@@ -42,19 +51,21 @@ Output will be -
4251
"jout": "3.2"
4352
},
4453
"zoho": 4
45-
}
54+
}
4655
~~~~
47-
48-
+ function parameters
49-
- data : the json object to sort
50-
- sort :
51-
- true (default) : ascending sort , since it is default you can only call `json.sort(data)`
52-
- false : descending sort
53-
> Note : the function assumes that you always provide a json object
54-
55-
+ The function work recursively and sort all the inner json objects too.
56+
57+
+ function parameters (for both **sort** & **sortAsync**)
58+
- **data:** the json object to sort
59+
- **sort:**
60+
- true (default) : ascending sort , since it is default you can only call `json.sort(data)` or `json.sortAsync(data)`
61+
- false : descending sort
62+
63+
+ The function work recursively and sort all the inner json objects too.
5664

5765
### Versions
66+
+ `v2.1.0`
67+
+ **sortAsync** : this is a new function which returns a promise
68+
5869
+ `v2.0.0`
5970
+ New : **100%** code coverage
6071
+ Improvement : **sort** now throws an error if not provided with an object
@@ -64,7 +75,7 @@ Output will be -
6475

6576
+ `v1.3.0`
6677
+ Included support for typescript (added declaration file)
67-
78+
6879
+ `v1.2.0`
6980
+ Improvement : json array support
7081

@@ -75,31 +86,35 @@ Output will be -
7586
+ `v1.0.1`
7687
+ Bug Fixed : data null checks & default true fix
7788

78-
+ `v1.0.0`
89+
+ `v1.0.0`
7990
+ Initial release - containing basic `sort` function only.
8091

81-
> Pull requests are always welcomed (kindly sign commits with GPG keys. **THANKS**)
82-
83-
### Contact
84-
85-
+ Twitter - [@dawnimpulse](https://twitter.com/dawnimpulse)
86-
+ Email - [dawnimpulse@gmail.com](mailto:dawnimpulse@gmail.com)
87-
88-
89-
90-
### License (ISC)
91-
~~~~
92-
ISC Licence
9392

94-
Copyright 2018-2019 Saksham (DawnImpulse)
93+
> Pull requests are always welcomed (kindly sign commits with GPG keys. **THANKS**)
9594
96-
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
97-
provided that the above copyright notice and this permission notice appear in all copies.
9895

99-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
100-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
101-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
102-
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISIN
96+
### Contact
97+
Twitter - [@dawnimpulse](https://twitter.com/dawnimpulse)
98+
Email - [dawnimpulse@gmail.com](mailto://dawnimpulse@gmail.com)
99+
100+
### Treeware
101+
This package is [Treeware](https://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/dawnimpulse/json-keys-sort) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
102+
103+
104+
### License (ISC)
105+
~~~~
106+
ISC License
107+
108+
Copyright 2021, Saksham Khurana (DawnImpulse)
109+
110+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
111+
provided that the above copyright notice and this permission notice appear in all copies.
112+
113+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
114+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
115+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
116+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
117+
OR PERFORMANCE OF THIS SOFTWARE.
103118
~~~~
104119

105120
> Written with [StackEdit](https://stackedit.io/).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-keys-sort",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "Sorting a json object based on keys either ascending or descending & even recursively",
55
"main": "index.js",
66
"types": "index.d.ts",

0 commit comments

Comments
 (0)