- We are writing a digital textbook-reading app.
- Most of the time you have a "basic" license for your textbook, but one (and only one) of your computers can request an "enhanced" license.
- You can only print from the computer with the enhanced license.
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
// This event emitter emits events, but reserves the right to publish events to | |
// for its creator. It uses a WeakMap for true encapsulation. | |
const eesToEventMaps = new WeakMap(); | |
export default class EventEmitter { | |
constructor(publisher) { | |
const eventMap = Object.create(null); | |
eesToEventMaps.set(this, eventMap); |
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
"use strict"; | |
const vm = require("vm"); | |
const sandbox = { anObject: {} }; | |
const whatIsThis = vm.runInNewContext(` | |
const ForeignObject = anObject.constructor; | |
const ForeignFunction = ForeignObject.constructor; | |
const process = ForeignFunction("return process")(); | |
const require = process.mainModule.require; | |
require("fs"); |
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
"use strict"; | |
// Domenic needs a Tweeter | |
function Domenic(tweeter) { | |
this.tweeter = tweeter; | |
} | |
Domenic.inject = ["tweeter"]; | |
Domenic.prototype.doSomethingCool = function () { | |
return this.tweeter.tweet("Did something cool!"); |
Embedders of V8 should generally use the head of the branch corresponding to the minor version of V8 that ships in Chrome.
To find out what version this is,
- Go to https://omahaproxy.appspot.com/
- Find the latest stable Chrome version in the table
- Enter it into the "Translate a Chrome verison to a V8 version" box below the table.
- Ignore the last two parts.
What is a subset of HTML's reflection rules which we should make easy for web components?
HTML's reflection algorithms include:
- URL strings
- Enumeration strings ("limited to only known values")
Two origins, A and B, are said to be same site if the following returns true:
- Let siteA be the result of obtaining a site from A.
- Let siteB be the result of obtaining a site from B.
- Return true if siteA equals siteB.
Two origins, A and B, are said to be schemelessly-same site if the following returns true:
- Let siteA be the result of obtaining a site from A.
- Let siteB be the result of obtaining a site from B.
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
[Exposed=Window] | |
interface CharacterData : Node { | |
attribute [TreatNullAs=EmptyString] DOMString data; | |
readonly attribute unsigned long length; | |
DOMString substringData(unsigned long offset, unsigned long count); | |
void appendData(DOMString data); | |
void insertData(unsigned long offset, DOMString data); | |
void deleteData(unsigned long offset, unsigned long count); | |
void replaceData(unsigned long offset, unsigned long count, DOMString data); | |
}; |
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 getUserDetail(username) { | |
if (userCache[username]) { | |
return Promise.resolve(userCache[username]); | |
} | |
// Use the fetch API to get the information | |
return fetch('users/' + username + '.json') | |
.then(function(result) { | |
userCache[username] = result; | |
return result; |
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
import { languagesSet } from "./some-library.mjs"; | |
// Allowed | |
languagesSet.keys(); | |
languagesSet.entries(); | |
languagesSet.forEach(l => console.log); | |
languagesSet.size; | |
languagesSet.values(); | |
// Will throw TypeError |