Skip to content

Instantly share code, notes, and snippets.

View msmfsd's full-sized avatar
🎤
metal

Guiltfilter Records msmfsd

🎤
metal
View GitHub Profile
@msmfsd
msmfsd / es7-async-await.js
Last active February 4, 2024 17:38
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
@msmfsd
msmfsd / flattenDeep.js
Last active July 16, 2018 08:53
Flatten a n-dimensional nested Javascript array
/*
* Flatten deeply nested array without external library like Immutable
* Simplified ES6 version of lodash flattenDeep functionality
* Reference: https://lodash.com/docs#flattenDeep
* Requirements: Latest Chrome/FF browser or ES6 transpiler like Babel
*/
const INFINITY = 1 / 0
/*
* Utility flatten array function
@iest
iest / BzIframe.js
Created January 7, 2015 16:43
Basic react iframe with onLoad handler
'use strict';
var React = require('react');
var BzIframe = React.createClass({
propTypes: {
src: React.PropTypes.string.isRequired,
onLoad: React.PropTypes.func
},