diff --git a/.circleci/config.yml b/.circleci/config.yml index 06d3de6..392d99e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/.nvmrc b/.nvmrc index b4e002a..569aa9b 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v6.10 \ No newline at end of file +v8.9.0 \ No newline at end of file diff --git a/index.js b/index.js index 7db6dec..9460095 100644 --- a/index.js +++ b/index.js @@ -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] } diff --git a/index.test.js b/index.test.js index 0432256..67665cd 100644 --- a/index.test.js +++ b/index.test.js @@ -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": { diff --git a/package.json b/package.json index 8aadbf7..b31f101 100644 --- a/package.json +++ b/package.json @@ -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": {