Skip to content

Commit

Permalink
Merge pull request #6 from jdbence/fix/object-with-no-values
Browse files Browse the repository at this point in the history
Allow object to have no values
  • Loading branch information
jdbence committed Dec 13, 2018
2 parents 1c029fd + b0b0c9d commit c62e6bb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:7.10
- image: circleci/node:8.9.0

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v6.10
v8.9.0
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const FireStoreParser = value => {
value = (value[prop].values || []).map(v => FireStoreParser(v))
}
else if (prop === 'mapValue') {
value = FireStoreParser(value[prop].fields)
value = FireStoreParser(value[prop].fields || {})
}
else if (prop === 'geoPointValue') {
value = { latitude: 0, longitude: 0, ...value[prop] }
Expand Down
8 changes: 8 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ test('Object match', () => {
})).toEqual({ "obj": { "string": "def" } });
});

test('Object match with no values', () => {
expect(FireStoreParser({
"obj": {
"mapValue": {}
}
})).toEqual({ "obj": {} });
});

test('Array match', () => {
expect(FireStoreParser({
"array": {
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": "firestore-parser",
"version": "0.8.5",
"version": "0.8.6",
"description": "Parse the Firestore REST API endpoint JSON into a useable JS object",
"main": "./build/index.js",
"scripts": {
Expand Down

0 comments on commit c62e6bb

Please sign in to comment.