Last active
March 10, 2019 03:07
-
-
Save jack-guy/e613325e729958d1bd180f62270edd74 to your computer and use it in GitHub Desktop.
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
import { from, zip } from 'rxjs'; | |
import { scan } from 'rxjs/operators'; | |
const iceCreamFlavors = ['vanilla', 'chocolate', 'strawberry']; | |
const iceCreamPrices = ['$5.50', '$5.75', '$6.00']; | |
const iceCreamFlavorToPrice$ = zip( | |
from(iceCreamFlavors), | |
from(iceCreamPrices), | |
).pipe(scan((prev, [flavor, price]) => { | |
return { | |
...prev, | |
[flavor]: price | |
}; | |
}, {})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment