-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a2315e
commit 5e433ee
Showing
7 changed files
with
38 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
class JsonOutput { | ||
constructor(options) { | ||
this.options = options; | ||
this.values = []; | ||
} | ||
constructor(options) { | ||
this.options = options; | ||
this.values = []; | ||
} | ||
|
||
get asObject() { | ||
return this.values.map(values => { | ||
return values.reduce((acc, value, index) => { | ||
acc[this.options.head[index]] = value; | ||
return acc; | ||
}, {}); | ||
}); | ||
} | ||
get asObject() { | ||
return this.values.map(values => { | ||
return values.reduce((acc, value, index) => { | ||
acc[this.options.head[index]] = value; | ||
return acc; | ||
}, {}); | ||
}); | ||
} | ||
|
||
push(value) { | ||
this.values.push(value); | ||
} | ||
push(value) { | ||
this.values.push(value); | ||
} | ||
|
||
toString() { | ||
return JSON.stringify(this.asObject); | ||
} | ||
toString() { | ||
return JSON.stringify(this.asObject); | ||
} | ||
} | ||
|
||
module.exports = JsonOutput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const commaNumber = require('comma-number'); | ||
const plain = num => num; | ||
|
||
module.exports = json => json ? plain : commaNumber; | ||
module.exports = json => (json ? plain : commaNumber); |