Commit f7eedbe2 authored by Michele Memoli's avatar Michele Memoli

Added an ability to split items and create custom headers

parent fa6ecd5b
account_type:
- viewer
- subscriber
- contributer
headers:
- device
- form
- platform
- orientation
- screen
- size
favourited:
- favourite
- not-favourited
devices:
- iPhone 6|mobile|iOS|portrait
- iPhone 5|mobile|iOS|portrait
- Retina iPad|tablet|iOS|portrait
- Retina iPad|tablet|iOS|landscape
- Google Pixel|mobile|Android|portrait
- Nexus 10|tablet|Android|portrait
- Nexus 10|tablet|Android|landscape
layout:
- small
- medium
- large
privacy:
- public
- private
screens:
- Home|L
- Search|S
- Add Project|M
- Dispute|L
- favouriting|S
......@@ -5,13 +5,22 @@ const yaml = require('node-yaml');
const input = yaml.readSync('./config.yml')
const headers = Object.keys(input)
const values = headers.reduce((curr, facet) => {
const [, ...facets] = Object.keys(input)
const {
headers
} = input;
const writer = csvWriter({ headers })
const values = facets.reduce((curr, facet) => {
return curr.concat([input[facet]])
}, [])
const cp = Combinatorics.cartesianProduct(...values)
const writer = csvWriter({ headers })
writer.pipe(fs.createWriteStream('out.csv'))
cp.map(scenario => writer.write(scenario));
cp.map(scenario => {
const arrays = scenario.map(facet => facet.split('|'))
const result = [].concat.apply([], arrays)
writer.write(result)
});
writer.end()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment