{
  "slug": "k6-javascript-adds-byte-set-and-raw-json-built-ins-6b42457c663f",
  "title": "k6 JavaScript adds byte, Set, and raw JSON built-ins",
  "tools": [
    "k6"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-09-21T15:17:03.000Z",
  "announced_at": "2026-09-21T15:17:03.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When preparing binary test data or checking response fields, use the documented `Uint8Array` conversions and `Set` operations. To serialize an exact numeric JSON value, pass its decimal text to `JSON.rawJSON()` before `JSON.stringify()`; k6 v2.3.0 release notes document these examples.",
    "examples": [
      "const bytes = Uint8Array.fromHex('6b36');\nconsole.log(bytes.toBase64()); // azY=",
      "const expected = new Set(['id', 'name', 'email']);\nconst received = new Set(['id', 'name']);\nconsole.log([...expected.difference(received)]); // [\"email\"]",
      "JSON.stringify({ id: JSON.rawJSON('9007199254740993') });\n// '{\"id\":9007199254740993}'"
    ],
    "gotchas": [
      "Version: v2.3.0",
      "Uint8Array.fromHex(hex) (required): Creates byte data from a hex string; the release example uses `'6b36'`.",
      "Uint8Array.prototype.toBase64() (required): Converts `Uint8Array` data to base64.",
      "Set.prototype.difference(other) (required): Returns the set difference; the example finds expected fields absent from the received set.",
      "Set.prototype.intersection(other): Set operation named in the release notes; parameter details are not stated there.",
      "Set.prototype.union(other): Set operation named in the release notes; parameter details are not stated there.",
      "JSON.rawJSON(text) (required): Creates a raw JSON value; the example passes numeric text so it serializes without rounding through a JavaScript `Number`."
    ]
  },
  "why_it_matters": "When writing test data or response assertions, encode binary values, compare sets, or preserve an exact numeric JSON value.",
  "sources": [
    "https://github.com/grafana/k6/releases/tag/v2.3.0"
  ],
  "rank": 0.95045,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v2+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "wave2a-20261017",
    "verdict_id": "wave2a-20261017:wave2a-20261017-65a244af489b5976-7:gate",
    "evidence_hash": "dba6ea361338a6ce929886692010d6448197e9e669546fe9ff9e6f7cea7e9e36"
  },
  "review": {
    "draft_hash": "90dbe6fbed5aabb7f4ff552b6840dab9082ce0049d0c3d05640f3437a919ea50",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "wave2a-20261017:gate",
    "reason": "2 of 3 judge runs approved with p_yes >= 0.9 (mean 0.95 >= 0.9; 2 needed) and Jev gave 0.74 (>= 0.6 needed)."
  }
}
