Comparing version 0.1.5 to 0.1.6
{ | ||
"name": "midata", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Read data from a midata file", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "jest" | ||
"test": "jest", | ||
"prepare": "husky install", | ||
"lint": "eslint ." | ||
}, | ||
@@ -19,24 +21,17 @@ "keywords": [ | ||
"devDependencies": { | ||
"eslint": "^5.5.0", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-config-prettier": "^3.0.1", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-prettier": "^2.6.2", | ||
"husky": "^3.0.5", | ||
"jest": "^25.0.0", | ||
"lint-staged": "^9.3.0", | ||
"prettier": "^1.14.2" | ||
"@davidgarvie/eslint-config": "^2.0.0", | ||
"eslint": "^8.1.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.25.2", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"husky": "^7.0.0", | ||
"jest": "^27.3.1", | ||
"lint-staged": "^11.2.6", | ||
"prettier": "^2.4.1" | ||
}, | ||
"dependencies": {}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.{js,json,md}": [ | ||
"prettier --write", | ||
"git add" | ||
"*.js": [ | ||
"eslint --fix" | ||
] | ||
} | ||
} |
@@ -6,3 +6,3 @@ const parseData = require("./parseData"); | ||
parseData, | ||
validateData | ||
validateData, | ||
}; |
@@ -8,8 +8,8 @@ function parseData(data) { | ||
const rows = data.split(/\n/); | ||
const keys = rows[0].split(";").filter(x => x.length > 1); | ||
const keys = rows[0].split(";").filter((x) => x.length > 1); | ||
rows.shift(); | ||
const result = rows | ||
.map(x => x.split(";")) | ||
.filter(x => x.length > 1) | ||
.map(x => { | ||
.map((x) => x.split(";")) | ||
.filter((x) => x.length > 1) | ||
.map((x) => { | ||
const obj = {}; | ||
@@ -16,0 +16,0 @@ x.forEach((value, index) => { |
const { parseData, validateData } = require("./helpers"); | ||
function midata(data) { | ||
try { | ||
validateData(data); | ||
return parseData(data); | ||
} catch (e) { | ||
throw e; | ||
} | ||
validateData(data); | ||
return parseData(data); | ||
} | ||
module.exports = midata; |
3395
9
49