libquickjs-ng-sys 0.13.0

QuickJS-NG Javascript Engine FFI bindings
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { assert } from "./assert.js";

// Every element takes the non-matching path (the predicate is never true).
{
    const o = {};
    assert([o, o, o].values().find(() => false), undefined);
    assert(new Array(1000).fill(o).values().find(() => false), undefined);
}

// The match path still returns the first match and forwards (value, index).
{
    const seen = [];
    const r = [10, 20, 30, 40].values().find((v, i) => { seen.push(v, i); return v === 30; });
    assert(r, 30);
    assert(seen.length, 6); // stopped at the third element
    assert(seen[0], 10); assert(seen[1], 0);
    assert(seen[4], 30); assert(seen[5], 2);
}