Last active
May 3, 2019 06:47
-
-
Save tomhodgins/46515b002853367e1054e176ad386736 to your computer and use it in GitHub Desktop.
run with -> $deno map-test.js | prettier --parser css > output.css
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
const listMapper = (list, template) => list.map(template).join('\n') | |
const objectMapper = (object, template) => Object.entries(object).map(template).join('\n') | |
console.log( | |
listMapper( | |
[ | |
'red', | |
'blue', | |
'green' | |
], | |
value => ` | |
.list-${value} { | |
color: ${value}; | |
} | |
` | |
) | |
+ objectMapper( | |
{ | |
red: '#c00', | |
green: '#0c0', | |
blue: '#00c' | |
}, | |
([name, value]) => ` | |
.object-${name} { | |
color: ${value}; | |
} | |
` | |
) | |
) |
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
.list-red { | |
color: red; | |
} | |
.list-blue { | |
color: blue; | |
} | |
.list-green { | |
color: green; | |
} | |
.object-red { | |
color: #c00; | |
} | |
.object-green { | |
color: #0c0; | |
} | |
.object-blue { | |
color: #00c; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment