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 createCounterWithGenerator() { | |
let count = 0; // Shared mutable variable | |
const increment = (by = 1) => count += by; | |
function* doSteps(steps) { | |
for (let i = 0; i < steps; i++) | |
yield increment(); // Use the default parameter for `by` in `increment` | |
} |
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
/// Pseudocode implementation of jsi::Object::setNativeState() | |
function setNativeState(obj, ns) { obj.__ns = ns; } | |
/// Pseudocode implementation of jsi::object::getNativeState() | |
function getNativeState(obj) { return obj.__ns; } | |
/// This is a HostFunction, shown as JS pseudo-code | |
/// Create and initialize NativeState instance. | |
function _installNativeState(constructor, object, ...args) { | |
switch (constructor.name) { | |
case "Camera": |
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
print("Hello"); | |
function small(a, f) { | |
globalThis.inner = []; | |
globalThis.inner.push( function () { | |
a[f(a)] = a[f(a+0) + 5]; | |
}); | |
} |
This file has been truncated, but you can view the full file.
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
print("Hello"); | |
var run = true; | |
var ratio = 0.5; | |
if (run) { | |
large([0,1,2,3,4,5], function f(){ return 0; }); | |
for(let i = 0; i < globalThis.inner.length * ratio; ++i) | |
globalThis.inner[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
// Call into a native function that returns an object with all native | |
// functions. | |
let $natives = getNativeFuncs(); | |
function MyClass(a, b) { | |
this.a = a; | |
this.b = b; | |
// The following call performs the native initialization. It creates a | |
// C++ NativeState instance, initializes it with whatever it needs, and | |
// calls jsi::Object::setNativeState() on the object to attach it. |