Skip to content

Instantly share code, notes, and snippets.

@jakubbarczyk
jakubbarczyk / fetch-all-dominaria-cards.js
Created July 8, 2018 14:45
Fetch all Dominaria cards from Magic: the Gathering API
'use-strict'
const api = 'https://api.magicthegathering.io/v1'
const dominariaPage1 = fetch(new Request(Resource(Page(1))))
const dominariaPage2 = fetch(new Request(Resource(Page(2))))
const dominariaPage3 = fetch(new Request(Resource(Page(3))))
Promise
.all([dominariaPage1, dominariaPage2, dominariaPage3])
@jakubbarczyk
jakubbarczyk / get-own-property-types.js
Created December 23, 2017 13:05
Utility function that maps object's own property types.
function getOwnPropertyTypes(val) {
'use strict';
if (val && typeof val === 'object') {
return Object.getOwnPropertyNames(val)
.reduce((obj, key) => Object.defineProperty(obj, key, { value: typeof val[key] }), {})
}
return {};
}