CodeSampleX

Exemple

bun 1.3.14: Differentiate TypedArray instances from plain index-keyed objects in Bun.deepEquals on Bun 1.3.14

Échantillon vérifié pour npm bun 1.3.14: Differentiate TypedArray instances from plain index-keyed objects in Bun.deepEquals on Bun 1.3.14. Le contrat s'est…

sha256:dcbbab2d29bd9e7dbeaa51796cae177029dc1d819a7b2d21ede7500c5b618a06

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
3
Clés de signature qui l’ont compilé
3
Environnement déclaré node linux x64 node node npm

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-17
node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-18
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-09-07

Cas

HOW
Objectif
Differentiate TypedArray instances from plain index-keyed objects in Bun.deepEquals on Bun 1.3.14
Paquets
Symboles
  • Bun.deepEquals
  • expect().toEqual
Environnement
node
Créé
2026-08-17T03:51:22Z

Contrat

  1. Bun.deepEquals returns false when comparing a numeric-keyed plain object to a Uint8Array with matching elements and length, verifying internal typed-array slots rather than only enumerable index properties
  2. Bun.deepEquals returns false when comparing a Date instance to an empty object sharing Date.prototype
  3. Bun.deepEquals returns true when comparing two Uint8Array instances containing identical byte sequences
  4. expect().toEqual in bun:test throws an assertion error when comparing a numeric-keyed plain object against a TypedArray

Fichiers

  • NOTES.md
  • csx.json
  • package-lock.json
  • package.json
  • test/bun-binary.mjs
  • test/contract.mjs

Télécharger l’artefact source (tar.gz)

Code source

NOTES.md
# Bun deep equality comparison

`search_known_solution` returned Bun CLI-packaging samples and the local version of this case, but no published contract for these equality calls.

This sample makes only a current-version claim: Bun 1.3.14 distinguishes typed arrays and real Date objects from plain objects that imitate their enumerable properties or prototype. It does not claim an unverified release boundary.
csx.json
{"case":{"believed":"Bun.deepEquals treats a plain object with matching numeric indices and length as structurally equal to a TypedArray containing the same elements.","caseId":"case:sha256:1a3b617ef5fc5f273471dc80c3f9e964ba5d2b24570054704e4608acb2dab87b","contract":["Bun.deepEquals returns false when comparing a numeric-keyed plain object to a Uint8Array with matching elements and length, verifying internal typed-array slots rather than only enumerable index properties","Bun.deepEquals returns false when comparing a Date instance to an empty object sharing Date.prototype","Bun.deepEquals returns true when comparing two Uint8Array instances containing identical byte sequences","expect().toEqual in bun:test throws an assertion error when comparing a numeric-keyed plain object against a TypedArray"],"goal":"Differentiate TypedArray instances from plain index-keyed objects in Bun.deepEquals on Bun 1.3.14","kind":"HOW","packages":["pkg:npm/bun@1.3.14"],"schemaVersion":1,"symbols":["Bun.deepEquals","expect().toEqual"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/bun@1.3.14"],"schemaVersion":1,"symbols":["Bun.deepEquals","expect().toEqual"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "bun-deepequals-patch",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "bun-deepequals-patch",
      "version": "1.0.0",
      "dependencies": {
        "bun": "1.3.14"
      }
    },
    "node_modules/@oven/bun-darwin-aarch64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-darwin-aarch64/-/bun-darwin-aarch64-1.3.14.tgz",
      "integrity": "sha512-Omj20SuiHBOUjUBIyqtkNjSUIjOtEOJwmbix/ZyFH4BaQ6OZTaaRWIR4TjHVz0yadHgli6lLTiAh1uarnvD49A==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "darwin"
      ]
    },
    "node_modules/@oven/bun-darwin-x64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64/-/bun-darwin-x64-1.3.14.tgz",
      "integrity": "sha512-FFj3QdU/OhlDyZOJ8CWfN5eWLpRlT4qjZg7lMQi7jA6GuoY5ajlO1zWLP/MuHYRSbXQUvV52RejNi8DVnAp13w==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "darwin"
      ]
    },
    "node_modules/@oven/bun-darwin-x64-baseline": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64-baseline/-/bun-darwin-x64-baseline-1.3.14.tgz",
      "integrity": "sha512-OSfsTZstc898HHElhU4NccaBGOSSDn5VfahiVTnidZ9B/+wb7WTyfZJaBeJcfjwJ9H2W9uTh2TGtl3UfcXgV9g==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "darwin"
      ]
    },
    "node_modules/@oven/bun-freebsd-aarch64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-freebsd-aarch64/-/bun-freebsd-aarch64-1.3.14.tgz",
      "integrity": "sha512-LIKrXaFxAHybVO5Pf+9XP2FHUj/5APvXTUKk9dqHm5iFz4oH+W24cmhjkJirNujh9hKeTyrpWSe3no9JZKowIw==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "freebsd"
      ]
    },
    "node_modules/@oven/bun-freebsd-x64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-freebsd-x64/-/bun-freebsd-x64-1.3.14.tgz",
      "integrity": "sha512-uwD+fGUH1ADpIF3B1U2jWzzb20QwRLZfj5QZ28GUCGrAJ/nTmWrD6YYGsblCY1wuhldRez3lU40AyuvSCyLYmw==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "freebsd"
      ]
    },
    "node_modules/@oven/bun-linux-aarch64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64/-/bun-linux-aarch64-1.3.14.tgz",
      "integrity": "sha512-X5SsPZHs+iYO8R/efIcRtc7gT2Q2DgPfliCxEkx4cXBumwkw0c/EsHMNwH3EgGpCDaZ7IYVPhpCG/xBOQHEwZw==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@oven/bun-linux-aarch64-android": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-android/-/bun-linux-aarch64-android-1.3.14.tgz",
      "integrity": "sha512-y4kq5b85lsrmFb9Xvi4w9mA5IEFJkLMrSmYn06q24KjL9rUWDWO3VFZEtteZxUN5+ec3Zm5S8OnJw1umaCbVjA==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "android"
      ]
    },
    "node_modules/@oven/bun-linux-aarch64-musl": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-musl/-/bun-linux-aarch64-musl-1.3.14.tgz",
      "integrity": "sha512-jmqOA92Cd1NL/1XBd4bFkJLxQ86K0RW7ohxS2qzzAvuitO4JiIxjjTeCspoU44zCozH72HpfZfUE2On31OjnWA==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@oven/bun-linux-x64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64/-/bun-linux-x64-1.3.14.tgz",
      "integrity": "sha512-7OVTAKvwfPmSbIV1HpdOoVVx5VRc427GuPPne93N6vk4eQBPId9nXmZDh9/zGaKPdbVjVtQSZafWQoUjx38Utw==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@oven/bun-linux-x64-android": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-android/-/bun-linux-x64-android-1.3.14.tgz",
      "integrity": "sha512-qe9e1d+3VAEU7nAA2ol9Jvmy/o99PVMSgZhHn7Q/9O3YcDrfEqyQ8zm4zoe5qTEo8HZH0dN03Le0Ys2eQPs7eg==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "android"
      ]
    },
    "node_modules/@oven/bun-linux-x64-baseline": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-baseline/-/bun-linux-x64-baseline-1.3.14.tgz",
      "integrity": "sha512-q/8EdOC0yUE8FPeoOVq8/Pw5I9/tJaYmUfO/uDUAREx8IUnOJH1RJ5A3BjFqre8pvJoiZA9AovPJq5FnNNjSxA==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@oven/bun-linux-x64-musl": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl/-/bun-linux-x64-musl-1.3.14.tgz",
      "integrity": "sha512-GBCB/k/sIqcr06eTNgg7g46qiUv35Jasx4XiccJ/n7RGqrE4RWUD/XJBbWFprVPjvqd59+QtSnS99XGqvftHfg==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@oven/bun-linux-x64-musl-baseline": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl-baseline/-/bun-linux-x64-musl-baseline-1.3.14.tgz",
      "integrity": "sha512-n6iE71G4lQE4XkrZhQQcL5YUlxDbnq6nqV7zeQi33PMsLT/0kYE+RvHOtBWZ3w0wMdXZfINmp63hIb9ijUBGtw==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@oven/bun-windows-aarch64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-windows-aarch64/-/bun-windows-aarch64-1.3.14.tgz",
      "integrity": "sha512-T7s3x/BsVKQObGU6QDkZeI6wKynzqGbBH1yI77jrrj5siElclxr3DQrDIk8CV4G5/SJq2HHq4kpLyYY2DKCSmA==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/@oven/bun-windows-x64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64/-/bun-windows-x64-1.3.14.tgz",
      "integrity": "sha512-mUFWL3BoYkNpjd8e9PqROiFF/1Xeotq20mABJsiQH62jM1g5zqWh4khw1RZ6bX8Q8fWvlPaxG1PjofkmjUi3vg==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/@oven/bun-windows-x64-baseline": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64-baseline/-/bun-windows-x64-baseline-1.3.14.tgz",
      "integrity": "sha512-uIjLUC1S9DWgICzuoMba7vurBJnBruE4S5CxnvmZkdqWVXRzx1Rgu636HoH+k0qeaQCFh3jeG3JQ1y6fRHv0sw==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/bun": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/bun/-/bun-1.3.14.tgz",
      "integrity": "sha512-aB6GVd42x1Y5ie1K16SF+oLGtgSkwX9hgoDdIW88pjvfTccU8F1vfpoOt34QLv0dZ1v3XimtaxPlZUG81Gx9Zg==",
      "cpu": [
        "arm64",
        "x64"
      ],
      "hasInstallScript": true,
      "license": "MIT",
      "os": [
        "darwin",
        "linux",
        "android",
        "freebsd",
        "win32"
      ],
      "bin": {
        "bun": "bin/bun.exe",
        "bunx": "bin/bunx.exe"
      },
      "optionalDependencies": {
        "@oven/bun-darwin-aarch64": "1.3.14",
        "@oven/bun-darwin-x64": "1.3.14",
        "@oven/bun-darwin-x64-baseline": "1.3.14",
        "@oven/bun-freebsd-aarch64": "1.3.14",
        "@oven/bun-freebsd-x64": "1.3.14",
        "@oven/bun-linux-aarch64": "1.3.14",
        "@oven/bun-linux-aarch64-android": "1.3.14",
        "@oven/bun-linux-aarch64-musl": "1.3.14",
        "@oven/bun-linux-x64": "1.3.14",
        "@oven/bun-linux-x64-android": "1.3.14",
        "@oven/bun-linux-x64-baseline": "1.3.14",
        "@oven/bun-linux-x64-musl": "1.3.14",
        "@oven/bun-linux-x64-musl-baseline": "1.3.14",
        "@oven/bun-windows-aarch64": "1.3.14",
        "@oven/bun-windows-x64": "1.3.14",
        "@oven/bun-windows-x64-baseline": "1.3.14"
      }
    }
  }
}
package.json
{
  "name": "bun-deepequals-patch",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "bun": "1.3.14"
  }
}
test/bun-binary.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);

function isMuslLinux() {
  if (process.platform !== 'linux') return false;
  if (fs.existsSync('/etc/alpine-release')) return true;
  return !process.report?.getReport?.().header?.glibcVersionRuntime;
}

export function findBunBinary() {
  const packageJsonPath = require.resolve('bun/package.json');
  const packageDirectory = path.dirname(packageJsonPath);
  const metadata = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
  const executable = process.platform === 'win32' ? 'bun.exe' : 'bun';
  const packageArchitecture = process.arch === 'arm64' ? 'aarch64' : process.arch;
  const candidates = [];

  if (isMuslLinux()) {
    if (packageArchitecture === 'x64') {
      candidates.push('@oven/bun-linux-x64-musl-baseline');
    }
    candidates.push(`@oven/bun-linux-${packageArchitecture}-musl`);
  } else {
    candidates.push(null);
  }

  const paths = candidates.map((packageName) => packageName
    ? path.join(packageDirectory, '..', ...packageName.split('/'), 'bin', executable)
    : path.join(packageDirectory, 'bin', executable));
  const binary = paths.find((candidate) => fs.existsSync(candidate));
  assert.ok(binary, 'resolved bun package must contain a compatible platform executable');
  return { binary, metadata };
}
test/contract.mjs
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import { findBunBinary } from './bun-binary.mjs';

const { binary: bunBin } = findBunBinary();

// Verify Bun version
const versionRun = spawnSync(bunBin, ["--version"], { encoding: "utf8" });
assert.strictEqual(versionRun.status, 0, `bun --version failed: ${versionRun.stderr}`);
const resolvedVersion = versionRun.stdout.trim();
assert(resolvedVersion.startsWith("1."), `Unexpected bun version: ${resolvedVersion}`);

// In-line contract assertions evaluated inside Bun runtime
const bunTestCode = `
import assert from "node:assert/strict";
import { expect } from "bun:test";

// 1. Bun.deepEquals returns false when comparing a numeric-keyed plain object to a Uint8Array with matching elements and length, verifying internal typed-array slots rather than only enumerable index properties
const plainIndexedObj = { 0: 5, 1: 6, 2: 7 };
const uint8Arr = new Uint8Array([5, 6, 7]);
assert.strictEqual(Bun.deepEquals(plainIndexedObj, uint8Arr), false);
assert.strictEqual(Bun.deepEquals(uint8Arr, plainIndexedObj), false);

// 2. Bun.deepEquals returns false when comparing a Date instance to an empty object sharing Date.prototype
function FakeDate() {}
FakeDate.prototype = Date.prototype;
const realDate = new Date("2025-01-01T00:00:00.000Z");
const fakeDate = new FakeDate();
const createdDateProto = Object.create(Date.prototype);

assert.strictEqual(Bun.deepEquals(realDate, fakeDate), false);
assert.strictEqual(Bun.deepEquals(fakeDate, realDate), false);
assert.strictEqual(Bun.deepEquals(realDate, createdDateProto), false);
assert.strictEqual(Bun.deepEquals(createdDateProto, realDate), false);

// 3. Bun.deepEquals returns true when comparing two Uint8Array instances containing identical byte sequences
const identicalUint8Arr = new Uint8Array([5, 6, 7]);
assert.strictEqual(Bun.deepEquals(uint8Arr, identicalUint8Arr), true);
assert.strictEqual(Bun.deepEquals(identicalUint8Arr, uint8Arr), true);

// 4. expect().toEqual in bun:test throws an assertion error when comparing a numeric-keyed plain object against a TypedArray
let threwExpected = false;
try {
  expect(plainIndexedObj).toEqual(uint8Arr);
} catch (err) {
  threwExpected = true;
}
assert.strictEqual(threwExpected, true, "expect(plainIndexedObj).toEqual(uint8Arr) must throw");

console.log(JSON.stringify({ status: "PASSED", version: Bun.version }));
`;

const testRun = spawnSync(bunBin, ["-e", bunTestCode], { encoding: "utf8" });
assert.strictEqual(
  testRun.status,
  0,
  `Bun runtime contract assertions failed:\nSTDOUT:\n${testRun.stdout}\nSTDERR:\n${testRun.stderr}`
);

const parsed = JSON.parse(testRun.stdout.trim());
assert.strictEqual(parsed.status, "PASSED");

Seeder d'origine

csx-seed