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
/* | |
I was just reading through Eric Elliott's ["10 Tips for Better Redux Architecture"](https://medium.com/javascript-scene/10-tips-for-better-redux-architecture-69250425af44) and found myself a little thrown by some of his sample code. Rather than justshrug it off, I took a few minutes to break down the pros/cons of his appoach and a couple other implimentations I was kicking around. | |
*/ | |
// Eric's original implimentation | |
const createChat_v1 = ({ | |
id = 0, | |
msg = '', | |
user = 'Anonymous', | |
timeStamp = 1472322852680 |
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
export default var Silver = Object.create(Reflect, { | |
// ownEntries has a similar API to Object.entries, but it uses the same | |
// enumeration logic as Reflect.keys | |
ownEntries: { | |
writable: true, | |
enumerable: false, | |
configurable: true, | |
value: function(obj) { | |
return Reflect.ownKeys(obj).map(key => [key, obj[key]]); | |
} |
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
// Static defaults | |
function fn({a = 1, b = 2} = {}) { | |
return `${a}, ${b}` | |
} | |
fn() // 1, 2 | |
fn({b: 'beta'}) // 1, beta | |
/** |
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
function clickPromise(el) { | |
// Create pointers for proimse chain methods | |
let _resolve = null | |
let _reject = null | |
const p = new Promise((resolve, reject) => { | |
// Cache the promise chain methods for future use | |
_resolve = resolve | |
_reject = reject |
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
function assignProps(source, dest, props) { | |
const descriptors = {}; | |
props.forEach(name => { | |
let desc = Object.getOwnPropertyDescriptor(source, name); | |
if (desc && desc.enumerable) { | |
descriptors[name] = desc; | |
} | |
}); | |
Object.defineProperties(dest, descriptors); | |
} |
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
Copyright 2019 Google LLC | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
https://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, |
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
javascript:(function(){ | |
var log = (...a) => console.log(...a); | |
const url = new URL(document.location.href); | |
if (url.hostname.endsWith('youtube.com')) { | |
const id = url.searchParams.get('v'); | |
window.location = `https://www.youtube.com/timedtext_video?v=${id}`; | |
} | |
})() |
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
let alreadyClicked = false; | |
let timer; | |
chrome.action.onClicked.addListener(function(tab) { | |
let wasClicked = alreadyClicked; | |
// Reset state | |
if (wasClicked) { | |
clearTimeout(timer); | |
alreadyClicked = false; |
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
// Copyright 2021 Google LLC. | |
// SPDX-License-Identifier: Apache-2.0 | |
let videos = [ | |
{ | |
url: 'https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4', | |
type: 'video/mp4', | |
}, { | |
url: 'https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm', | |
type: 'video/webm', |
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
// Copyright 2021 Google LLC | |
// | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file or at | |
// https://developers.google.com/open-source/licenses/bsd | |
// Use importScripts to load other JS files | |
import { demo } from './lib.js'; | |
console.log(demo.greeting); |