Skip to content

Instantly share code, notes, and snippets.

@tmikov
tmikov / small.js
Created April 5, 2024 01:15
A small JS file
print("Hello");
function small(a, f) {
globalThis.inner = [];
globalThis.inner.push( function () {
a[f(a)] = a[f(a+0) + 5];
});
}
@tmikov
tmikov / large.js
Created April 5, 2024 01:15
A large file that optionally touches a fraction of the code
This file has been truncated, but you can view the full file.
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]();
}
@tmikov
tmikov / native-state-example.js
Created October 19, 2023 21:09
Example of using NativeState to create a class with native data and methods.
// 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.