Skip to content

Commit 6c5969a

Browse files
committed
Bug Fixed: data null checks & default true fix
1 parent 68b16f9 commit 6c5969a

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ Output will be -
5454

5555
### Versions
5656

57+
+ `v1.0.1`
58+
+ Bug Fixed : data null checks & default true fix
5759
+ `v1.0.0`
5860
+ Initial release - containing basic `sort` function only.
5961

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ OR PERFORMANCE OF THIS SOFTWARE.
2222
*/
2323
const typeOf = function (data) {
2424
const objectConstructor = {}.constructor;
25-
if (data.constructor === objectConstructor) {
25+
if (data && data !== null && data.constructor === objectConstructor) {
2626
return "OBJECT";
2727
} else {
2828
return "";
@@ -44,7 +44,7 @@ function jsonSort(data, sort) {
4444
newData = {};
4545

4646
if (!sort)
47-
sort = false;
47+
sort = true;
4848

4949
keys = Object.keys(data).sort();
5050

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": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Sorting a json object based on keys either ascending or descending & even recursively",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)