Skip to content

Commit 93b2b6c

Browse files
committed
Improve recursiveSearchValues & update tests
1 parent 7cd93df commit 93b2b6c

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

Readme.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ xlsx to JSON parser. Also support i18next format. Relies on node-xlsx.
1414
### Yep, it can append new files to exist now! *Cheers* 😎
1515

1616
### What's new
17-
* v,0.3.3 - Update Readme.md
17+
* v.0.3.4 - Improve recursiveSearchValues & update tests
18+
* v.0.3.3 - Update Readme.md
1819
* v.0.3.2 - Fix known issues with one level template
1920
* v.0.3.1 - Update Readme.md
2021
* v.0.3.0 - Add config tests. Fix parser. Now it's work as NPM module correctly

__tests__/tests.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ describe('getValuesFromArray', () => {
5555
expect(recursiveSearchValues(mockSecondObj)).toEqual(mockSecondObj);
5656
});
5757

58-
it('recursiveSearchValues with empty object return undefined' , () => {
59-
expect(recursiveSearchValues(emptyObj)).toEqual(undefined);
58+
it('recursiveSearchValues with empty object return false' , () => {
59+
expect(recursiveSearchValues(emptyObj)).toEqual(false);
6060
});
6161

6262
it('is getConfig still object', () => {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xlsx-json-parser",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"description": "Parse xls/xlsx to json. i18next format",
55
"main": "index.js",
66
"author": "Roman iRodger Dvoryanov <[email protected]> (http://irodger.ru)",

utils/getConfig.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const config = {
1414
xlsxDir: path + (configFile.xlsxDir || selfConfig.xlsxDir) + '/',
1515
jsonDir: path + (configFile.jsonDir || selfConfig.jsonDir) + '/',
1616
fileTemplate(lang, template) {
17-
return configFile.fileTemplate ? configFile.fileTemplate(lang, template) : selfConfig.fileTemplate(lang, template)
17+
return configFile.fileTemplate ? configFile.fileTemplate(lang, template) : selfConfig.fileTemplate(lang, template);
1818
}
1919
};
2020

utils/recursiveSearchValues.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* @returns boolean
55
*/
66
function recursiveSearchValues (obj) {
7+
if (!Object.keys(obj).length) return false;
8+
79
for(let key in obj) {
810
if (obj.hasOwnProperty(key)) {
911
if (typeof obj[key] === 'object') {
@@ -13,7 +15,7 @@ function recursiveSearchValues (obj) {
1315
return obj[key];
1416
}
1517
} else {
16-
return obj
18+
return obj;
1719
}
1820
} else {
1921
return false;

0 commit comments

Comments
 (0)