flowchart TB
JsValue
JsValue-->JsObject
subgraph primitives [Primitive Types]
JsBoolean
JsNumber
JsString
JsNull
JsUndefined
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"; | |
{ | |
let abp = ArrayBuffer.prototype; | |
const VIEW = Symbol('view'); | |
function getView(receiver) { | |
return receiver[VIEW] || | |
(receiver[VIEW] = new Uint8Array(receiver)); | |
} |
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
// inspired by https://github.com/raganwald/homoiconic/blob/master/2011/11/sans-titre.md#readme | |
// and by https://groups.google.com/a/dartlang.org/group/misc/browse_thread/thread/611c04100ac17142 | |
// traditional method chaining with combinators: | |
console.log(range(1, 3) | |
.concat(range(4, 6)) | |
.map(function(x) { return x * x }) | |
.filter(function(x) { return x % 2 === 0 }) | |
.reverse()); |
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
const ATTRIBUTES = ['A', 'B', 'C', 'D', 'E', 'F']; | |
// type attribute = 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | |
// type value = "x" | "" | |
// type combo = [value] | |
function combos() { | |
return combosFrom(ATTRIBUTES, 0); | |
} |
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
// Calculating the geometric mean in log space avoids overflow when | |
// working with anything more than very small data sets. | |
// | |
// The formula can be calculated with simple algebraic identities: | |
// | |
// n√(Prod^n x_i) | |
// = { e^ln(x) = x } | |
// n√(Prod^n e^ln(x_i)) | |
// = { e^a x e^b = e^(a+b) } | |
// n√(e^(Sum^n ln(x_i))) |
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
// Version 1. Simple recursive function. Blows the stack for large nodes. | |
function replace(node, from, to) { | |
switch (node.type) { | |
case IF: | |
return { | |
type: IF, | |
test: replace(node.test, from, to), | |
then: replace(node.then, from, to), | |
else: replace(node.else, from, to) | |
}; |
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 default export | |
import.default("Spinner").then(Spinner => { | |
widget.appendChild(new Spinner(...)) | |
}); | |
// import namespace object | |
import.namespace("fs").then(fs => { | |
fs.readFile(...) | |
}); |
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
(({}+[])[!![]+!![]+!![]]+[]+(![]+[])[+!![]]+(+(!![]+!![]+!![]+[]+(+!![])))[(!![]+[])[+![]]+[]+({}+[])[+!![]]+[][(![]+[])[!![]+!![]+!![]]+[]+(![]+[])[!![]+!![]]+([][![]]+[])[!![]+!![]+!![]+!![]+!![]]+({}+[])[!![]+!![]+!![]+!![]+!![]]+(!![]+[])[!![]+!![]+!![]]][({}+[])[!![]+!![]+!![]+!![]+!![]]+[]+(![]+[])[+!![]]+(![]+[])[!![]+!![]]+(![]+[])[!![]+!![]]](+[![]]+[]+(!![]+[])[({}+[])[!![]+!![]+!![]+!![]+!![]]+[]+({}+[])[+!![]]+([][![]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]+(!![]+[])[+!![]]+([][![]]+[])[+![]]+({}+[])[!![]+!![]+!![]+!![]+!![]]+(!![]+[])[+![]]+({}+[])[+!![]]+(!![]+[])[+!![]]])[(![]+[])[+![]]+[]+([][![]]+[])[!![]+!![]+!![]+!![]+!![]]+(![]+[])[!![]+!![]]+(!![]+[])[+![]]+(!![]+[])[!![]+!![]+!![]]+(!![]+[])[+!![]]]([][({}+[])[!![]+!![]+!![]+!![]+!![]]+[]+({}+[])[+!![]]+([][![]]+[])[+!![]]+(![]+[])[!![]+!![]+!![]]+(!![]+[])[+![]]+(!![]+[])[+!![]]+([][![]]+[])[+![]]+({}+[])[!![]+!![]+!![]+!![]+!![]]+(!![]+[])[+![]]+({}+[])[+!![]]+(!![]+[])[+!![]]][({}+[])[!![]+!![]+!![]+!![]+!![]]+[]+({}+[])[ |