CodeSampleX

Beispiel

write-file-atomic 6.0.0: sync

Verifiziertes Beispiel für npm write-file-atomic 6.0.0: sync. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:1c98f78eff0a287df608775be7255da215a149bed969c4f36f4ebaa82ee1375c

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-10-18

Fall

HOW
Ziel
verify write-file-atomic.sync in pkg:npm/write-file-atomic@6.0.0
Pakete
Symbole
  • write-file-atomic.sync
Erstellt
2026-10-18T10:48:12Z

Contract

  1. writeFileAtomic.sync(filename, data, options) atomically writes string or Buffer/TypedArray data to a temporary file via imurmurhash and renames it over filename.
  2. Passing options.mode sets file permissions on creation, and subsequent writeFileAtomic.sync calls without options.mode preserve existing file permissions.
  3. options.tmpfileCreated(tmpfile) is invoked synchronously after opening the temporary file and before rename removes the temporary path.

Dateien

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

Quellartefakt herunterladen (tar.gz)

Quelltext

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify write-file-atomic.sync in pkg:npm/write-file-atomic@6.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/write-file-atomic@6.0.0
Demonstrate these symbols/APIs:
  - write-file-atomic.sync

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"case":{"caseId":"case:sha256:c8b650a17bbdb864ce38f5755bb7c9fbb93f9e9a5441c9df00a507d8b462638d","contract":["writeFileAtomic.sync(filename, data, options) atomically writes string or Buffer/TypedArray data to a temporary file via imurmurhash and renames it over filename.","Passing options.mode sets file permissions on creation, and subsequent writeFileAtomic.sync calls without options.mode preserve existing file permissions.","options.tmpfileCreated(tmpfile) is invoked synchronously after opening the temporary file and before rename removes the temporary path."],"goal":"verify write-file-atomic.sync in pkg:npm/write-file-atomic@6.0.0","kind":"HOW","packages":["pkg:npm/write-file-atomic@6.0.0"],"schemaVersion":1,"symbols":["write-file-atomic.sync"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/write-file-atomic@6.0.0"],"schemaVersion":1,"subject":"pkg:npm/write-file-atomic@6.0.0","symbols":["write-file-atomic.sync"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-write-file-atomic-sync",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-write-file-atomic-sync",
      "version": "1.0.0",
      "dependencies": {
        "write-file-atomic": "6.0.0"
      }
    },
    "node_modules/imurmurhash": {
      "version": "0.1.4",
      "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
      "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==",
      "license": "MIT",
      "engines": {
        "node": ">=0.8.19"
      }
    },
    "node_modules/signal-exit": {
      "version": "4.1.0",
      "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
      "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==",
      "license": "ISC",
      "engines": {
        "node": ">=14"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    },
    "node_modules/write-file-atomic": {
      "version": "6.0.0",
      "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-6.0.0.tgz",
      "integrity": "sha512-GmqrO8WJ1NuzJ2DrziEI2o57jKAVIQNf8a18W3nCYU3H7PNWqCCVTeH6/NQE93CIllIgQS98rrmVkYgTX9fFJQ==",
      "license": "ISC",
      "dependencies": {
        "imurmurhash": "^0.1.4",
        "signal-exit": "^4.0.1"
      },
      "engines": {
        "node": "^18.17.0 || >=20.5.0"
      }
    }
  }
}
package.json
{
  "name": "sample-write-file-atomic-sync",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "write-file-atomic": "6.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify write-file-atomic.sync in pkg:npm/write-file-atomic@6.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/write-file-atomic@6.0.0"
  ],
  "symbols": [
    "write-file-atomic.sync"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import writeFileAtomic from 'write-file-atomic';

const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'wfa-sync-'));

try {
  // 1. Write string data with default utf8 encoding
  const file1 = path.join(tmpDir, 'text.txt');
  let createdTmpFile = null;
  writeFileAtomic.sync(file1, 'hello atomic', {
    mode: 0o600,
    tmpfileCreated(tmpfile) {
      createdTmpFile = tmpfile;
      assert.equal(fs.existsSync(tmpfile), true);
    }
  });

  assert.equal(typeof createdTmpFile, 'string');
  assert.equal(fs.existsSync(createdTmpFile), false);
  assert.equal(fs.readFileSync(file1, 'utf8'), 'hello atomic');
  const stat1 = fs.statSync(file1);
  assert.equal(stat1.mode & 0o777, 0o600);

  // 2. Overwrite existing file and preserve mode when options is an encoding string
  writeFileAtomic.sync(file1, 'updated content', 'utf8');
  assert.equal(fs.readFileSync(file1, 'utf8'), 'updated content');
  assert.equal(fs.statSync(file1).mode & 0o777, 0o600);

  // 3. Write Buffer (ArrayBufferView) with fsync: false
  const file2 = path.join(tmpDir, 'binary.bin');
  const buf = Buffer.from([0xde, 0xad, 0xbe, 0xef]);
  writeFileAtomic.sync(file2, buf, { fsync: false });
  assert.deepEqual(fs.readFileSync(file2), buf);
} finally {
  fs.rmSync(tmpDir, { recursive: true, force: true });
}

Ursprungs-Seeder

anonym