Skip to content

Commit

Permalink
Bug Fixed: data null checks & default true fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DawnImpulse committed Jul 21, 2018
1 parent 68b16f9 commit 6c5969a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ Output will be -

### Versions

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

Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ OR PERFORMANCE OF THIS SOFTWARE.
*/
const typeOf = function (data) {
const objectConstructor = {}.constructor;
if (data.constructor === objectConstructor) {
if (data && data !== null && data.constructor === objectConstructor) {
return "OBJECT";
} else {
return "";
Expand All @@ -44,7 +44,7 @@ function jsonSort(data, sort) {
newData = {};

if (!sort)
sort = false;
sort = true;

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

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "json-keys-sort",
"version": "1.0.0",
"version": "1.0.1",
"description": "Sorting a json object based on keys either ascending or descending & even recursively",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 6c5969a

Please sign in to comment.