This file contains hidden or 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
<link rel="import" href="../core-scaffold/core-scaffold.html"> | |
<link rel="import" href="../core-header-panel/core-header-panel.html"> | |
<link rel="import" href="../core-menu/core-menu.html"> | |
<link rel="import" href="../core-item/core-item.html"> | |
<link rel="import" href="../core-icon-button/core-icon-button.html"> | |
<link rel="import" href="../core-toolbar/core-toolbar.html"> | |
<link rel="import" href="../core-menu/core-submenu.html"> | |
<link rel="import" href="../core-ajax/core-ajax.html"> | |
<polymer-element name="my-element"> |
This file contains hidden or 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 sumOfSeries = arr => (arr.length * (parseInt(arr[0], 10) + parseInt(arr[arr.length -1], 10)))/2 |
This file contains hidden or 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 generateSeriesIntegers = len => [ ...Array(len).keys() ].map( i => i + 1); |
This file contains hidden or 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 mergeTwoArrays = (a, b, unique = false) => unique != true ? a.concat(b) : [...new Set([...a, ...b])]; |
This file contains hidden or 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 apiURL = "https://pokeapi.co/api/v2/type/1"; | |
const pokemonFetch = async () => { | |
const initial = await fetch(apiURL); | |
const initialJson = await initial.json(); | |
const detailsData = initialJson.pokemon.map(async i => { | |
const preFetchData = await fetch(i.pokemon.url); | |
return preFetchData.json(); | |
}) |
This file contains hidden or 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
var checkIfObjectEmpty = obj => Object.keys(obj).length === 0 && obj.constructor === Object |
This file contains hidden or 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 RSS_URL = `https://cors-anywhere.herokuapp.com/https://archive.org/services/collection-rss.php?collection=podcast_jeff-regan-the-great-detec_426081250`; | |
const xmlToJson = (xml) => { | |
let obj = {}; | |
try { | |
xml.hasChildNodes(); | |
} catch (err) { | |
xml = new DOMParser().parseFromString(xml, "text/xml"); | |
} |
This file contains hidden or 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 unescapeHTML = str => | |
str.replace( | |
/&|<|>|'|"/g, | |
tag => | |
({ | |
'&': '&', | |
'<': '<', | |
'>': '>', | |
''': "'", | |
'"': '"' |
This file contains hidden or 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 b64DecodeUnicode = (str) => decodeURIComponent(Array.prototype.map.call(atob(str),(c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join("")); | |
const parseJWT = (token) => JSON.parse(b64DecodeUnicode(token.split(".")[1].replace("-", "+").replace("_", "/"))); |
This file contains hidden or 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 take = (arr, n = 1, fromStart = true) => fromStart ? arr.slice(0, n) : n < 0 ? arr.slice(n) : arr.slice(-1 * n); | |
let fruits = ['Banana', 'Orange', 'Lemon', 'Apple', 'Mango'] | |
take(fruits) | |
take(fruits, 3) | |
take(fruits, -3, false) | |
take(fruits, 3, false) |