Skip to content

Commit

Permalink
Refactor data logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 2, 2022
1 parent a5cbfee commit fbaa56c
Show file tree
Hide file tree
Showing 9 changed files with 418 additions and 677 deletions.
562 changes: 0 additions & 562 deletions benchmark/history/history.json

This file was deleted.

239 changes: 197 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"os-name": "^5.0.1",
"p-event": "^5.0.1",
"p-locate": "^6.0.0",
"p-map": "^5.3.0",
"p-map-series": "^3.0.0",
"p-reduce": "^3.0.0",
"path-exists": "^5.0.0",
Expand Down
16 changes: 16 additions & 0 deletions src/history/data/contents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { UserError } from '../../error/main.js'

// Parse the contents of a rawResult
export const parseRawResult = function (contents) {
try {
return JSON.parse(contents)
} catch (error) {
throw new UserError(`History files is invalid JSON: ${error.message}`)
}
}

// Serialize the contents of a rawResult
export const serializeRawResult = function (rawResult) {
const contents = JSON.stringify(rawResult, undefined, 2)
return `${contents}\n`
}
Loading

0 comments on commit fbaa56c

Please sign in to comment.