Exemple
parse-conflict-json 4.0.0: isDiff
Échantillon vérifié pour npm parse-conflict-json 4.0.0: isDiff. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.
sha256:7f4e1cdd426c1ac0189b5e8f5f2441170c70df22284e8505d3e45b0d749a9bbc
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
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify parse-conflict-json.isDiff in pkg:npm/parse-conflict-json@4.0.0
- Paquets
- Symboles
-
- parse-conflict-json.isDiff
- Créé
- 2026-10-18T09:57:11Z
Contrat
- parse-conflict-json assigns isDiff onto module.exports via Object.assign, so ES modules access it from the default export (parseConflictJson.isDiff)
- isDiff(str) returns the closing-marker RegExp match array from str.match(/>{7,}/g) (e.g. ['>>>>>>>']) rather than boolean true when all three conflict markers (<{7,}, ={7,}, >{7,}) are present
- isDiff(str) matches markers of 7 or more characters and returns one element per closing marker block when multiple conflicts exist
- isDiff(str) short-circuits and returns null (not false) for clean JSON, when any of the three markers is absent, or when a marker has fewer than 7 characters
- isDiff(value) throws TypeError when passed a non-string value without a .match method such as null, undefined, or a number
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code source
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 parse-conflict-json.isDiff in pkg:npm/parse-conflict-json@4.0.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/parse-conflict-json@4.0.0
Demonstrate these symbols/APIs:
- parse-conflict-json.isDiff
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.
{"case":{"caseId":"case:sha256:6ec33f9131b01fedea82c8b27cf3731ef10b7ac0d704f9a04bcf7c7c7d65143c","contract":["parse-conflict-json assigns isDiff onto module.exports via Object.assign, so ES modules access it from the default export (parseConflictJson.isDiff)","isDiff(str) returns the closing-marker RegExp match array from str.match(/\u003e{7,}/g) (e.g. ['\u003e\u003e\u003e\u003e\u003e\u003e\u003e']) rather than boolean true when all three conflict markers (\u003c{7,}, ={7,}, \u003e{7,}) are present","isDiff(str) matches markers of 7 or more characters and returns one element per closing marker block when multiple conflicts exist","isDiff(str) short-circuits and returns null (not false) for clean JSON, when any of the three markers is absent, or when a marker has fewer than 7 characters","isDiff(value) throws TypeError when passed a non-string value without a .match method such as null, undefined, or a number"],"goal":"verify parse-conflict-json.isDiff in pkg:npm/parse-conflict-json@4.0.0","kind":"HOW","packages":["pkg:npm/parse-conflict-json@4.0.0"],"schemaVersion":1,"symbols":["parse-conflict-json.isDiff"]},"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/parse-conflict-json@4.0.0"],"schemaVersion":1,"subject":"pkg:npm/parse-conflict-json@4.0.0","symbols":["parse-conflict-json.isDiff"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-parse-conflict-json-isdiff",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-parse-conflict-json-isdiff",
"version": "1.0.0",
"dependencies": {
"parse-conflict-json": "4.0.0"
}
},
"node_modules/json-parse-even-better-errors": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-4.0.0.tgz",
"integrity": "sha512-lR4MXjGNgkJc7tkQ97kb2nuEMnNCyU//XYVH0MKTGcXEiSudQ5MKGKen3C5QubYy0vmq+JGitUg92uuywGEwIA==",
"license": "MIT",
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
},
"node_modules/just-diff": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/just-diff/-/just-diff-6.0.2.tgz",
"integrity": "sha512-S59eriX5u3/QhMNq3v/gm8Kd0w8OS6Tz2FS1NG4blv+z0MuQcBRJyFWjdovM0Rad4/P4aUPFtnkNjMjyMlMSYA==",
"license": "MIT"
},
"node_modules/just-diff-apply": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/just-diff-apply/-/just-diff-apply-5.5.0.tgz",
"integrity": "sha512-OYTthRfSh55WOItVqwpefPtNt2VdKsq5AnAK6apdtR6yCH8pr0CmSr710J0Mf+WdQy7K/OzMy7K2MgAfdQURDw==",
"license": "MIT"
},
"node_modules/parse-conflict-json": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/parse-conflict-json/-/parse-conflict-json-4.0.0.tgz",
"integrity": "sha512-37CN2VtcuvKgHUs8+0b1uJeEsbGn61GRHz469C94P5xiOoqpDYJYwjg4RY9Vmz39WyZAVkR5++nbJwLMIgOCnQ==",
"license": "ISC",
"dependencies": {
"json-parse-even-better-errors": "^4.0.0",
"just-diff": "^6.0.0",
"just-diff-apply": "^5.2.0"
},
"engines": {
"node": "^18.17.0 || >=20.5.0"
}
}
}
}
{
"name": "sample-parse-conflict-json-isdiff",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"parse-conflict-json": "4.0.0"
},
"scripts": {
"test": "node test/contract.mjs"
}
}
{
"schemaVersion": 1,
"goal": "verify parse-conflict-json.isDiff in pkg:npm/parse-conflict-json@4.0.0",
"kind": "HOW",
"packages": [
"pkg:npm/parse-conflict-json@4.0.0"
],
"symbols": [
"parse-conflict-json.isDiff"
]
}
import assert from 'node:assert/strict';
import parseConflictJson from 'parse-conflict-json';
const { isDiff } = parseConflictJson;
assert.equal(typeof parseConflictJson, 'function');
assert.equal(typeof isDiff, 'function');
// 1. Standard 2-way or 3-way git conflict markers return the closing marker regex match array
const conflictJson = [
'{',
'<<<<<<< HEAD',
' "version": "1.0.0"',
'||||||| parent',
' "version": "0.9.0"',
'=======',
' "version": "1.1.0"',
'>>>>>>> feature',
'}'
].join('\n');
const singleMatch = isDiff(conflictJson);
assert.ok(Array.isArray(singleMatch));
assert.deepEqual(singleMatch, ['>>>>>>>']);
// 2. Multiple conflict blocks in one string return all closing marker matches
const multiConflictJson = [
'<<<<<<< HEAD',
'{"a": 1}',
'=======',
'{"a": 2}',
'>>>>>>> branch-a',
'<<<<<<< HEAD',
'{"b": 1}',
'=======',
'{"b": 2}',
'>>>>>>> branch-b'
].join('\n');
assert.deepEqual(isDiff(multiConflictJson), ['>>>>>>>', '>>>>>>>']);
// 3. Markers with 7 or more characters (e.g. 8 chars) also match
const extendedMarkers = '<<<<<<<<\n{"x":1}\n========\n{"x":2}\n>>>>>>>>\n';
assert.deepEqual(isDiff(extendedMarkers), ['>>>>>>>>']);
// 4. Clean JSON or partial/short markers (< 7 chars) short-circuit and return null
assert.equal(isDiff('{"name": "example", "version": "1.0.0"}'), null);
assert.equal(isDiff('<<<<<<< HEAD\n{"a": 1}\n=======\n{"a": 2}'), null);
assert.equal(isDiff('<<<<<<< HEAD\n{"a": 1}\n>>>>>>> branch'), null);
assert.equal(isDiff('{"a": 1}\n=======\n{"a": 2}\n>>>>>>> branch'), null);
assert.equal(isDiff('<<<<<<\n{"a": 1}\n=======\n{"a": 2}\n>>>>>>>'), null);
// 5. Non-string inputs without .match throw TypeError
assert.throws(() => isDiff(null), TypeError);
assert.throws(() => isDiff(undefined), TypeError);
assert.throws(() => isDiff(42), TypeError);
Seeder d'origine
anonyme