(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
import { injectScript } from '@module-federation/utilities'; | |
// example of dynamic remote import on server and client | |
const isServer = typeof window === 'undefined'; | |
//could also use | |
// getModule({ | |
// remoteContainer: { | |
// global: 'app2', | |
// url: 'http://localhost:3002/remoteEntry.js', | |
// }, | |
// modulePath: './sample' |
var data = [1, 2, 3, 13, 5, 6, 7, 8, 9, 10, 11]; | |
var predicate = element => element % 2 === 0; | |
function chunk(predicate, data) { | |
return data.map(predicate).reduce((prev, curr, i, arr) => { | |
if (curr) { | |
if (prev.length) { | |
let first = prev[prev.length - 1][1]; | |
prev.push([first, i + 1]); | |
} else { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
<!doctype html> | |
<html> | |
<head> | |
<title>Polymer and RequireJS</title> | |
<script src="http://polymer.github.io/cdn/polymer.min.js"></script> | |
</head> | |
<body> | |
<!-- #foo --> | |
<div id="foo">the foo has no joy.</div> | |
<polymer-element name="require-js" attributes="libnames event"> | |
<script> | |
(function() { | |
// Helper function to add a script. | |
var addScript = function(src) { | |
var script = document.createElement('script'); | |
script.src = src; | |
var s = document.querySelector('script'); | |
s.parentNode.insertBefore(script, s); | |
return script; |
// Detecting data URLs | |
// data URI - MDN https://developer.mozilla.org/en-US/docs/data_URIs | |
// The "data" URL scheme: http://tools.ietf.org/html/rfc2397 | |
// Valid URL Characters: http://tools.ietf.org/html/rfc2396#section2 | |
function isDataURL(s) { | |
return !!s.match(isDataURL.regex); | |
} | |
isDataURL.regex = /^\s*data:([a-z]+\/[a-z]+(;[a-z\-]+\=[a-z\-]+)?)?(;base64)?,[a-z0-9\!\$\&\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i; |
//------------------------------------------------------------- | |
// | |
// Hypothesis: | |
// | |
// Promises/A is a Monad | |
// | |
// To be a Monad, it must provide at least: | |
// - A unit (aka return or mreturn) operation that creates a corresponding | |
// monadic value from a non-monadic value. | |
// - A bind operation that applies a function to a monadic value |