Exemple
fast-xml-parser 5.11.0: XMLParser.parse
Échantillon vérifié pour npm fast-xml-parser 5.11.0: XMLParser.parse. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:0d92300575f9f036f7060aa791bf17c6e653d3fef001fd38d8aac0c237d6c05f
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é
node 22 windows 11 x64 node 22 javascript npm 10
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-19 |
Cas
HOW- Objectif
- verify XMLParser.parse in pkg:npm/fast-xml-parser@5.11.0
- Paquets
- Symboles
-
- XMLParser.parse
- Environnement
- node 22
- Créé
- 2026-08-19T06:13:29Z
Contrat
- XMLParser.parse parses valid XML string into nested JavaScript object
- XMLParser.parse parses attributes when ignoreAttributes is false
- XMLParser.parse parses repeated child elements into an array
Fichiers
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
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 XMLParser.parse in pkg:npm/fast-xml-parser@5.11.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/fast-xml-parser@5.11.0
Demonstrate these symbols/APIs:
- XMLParser.parse
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@11.8.0
- runtime: node@24.13.1
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:32c0e81ff7ca251ef7e77736777912f3578b9955708bd0aa93e64715e7c95493","constraints":{"executionContext":"node"},"contract":["XMLParser.parse parses valid XML string into nested JavaScript object","XMLParser.parse parses attributes when ignoreAttributes is false","XMLParser.parse parses repeated child elements into an array"],"goal":"verify XMLParser.parse in pkg:npm/fast-xml-parser@5.11.0","kind":"HOW","packages":["pkg:npm/fast-xml-parser@5.11.0"],"schemaVersion":1,"symbols":["XMLParser.parse"]},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"javascript","moduleSystem":"cjs","os":"windows","osVersionBucket":"11","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/fast-xml-parser@5.11.0"],"schemaVersion":1,"symbols":["XMLParser.parse"],"verifierAdapter":"node-typescript@1"}
const { XMLParser } = require('fast-xml-parser');
function parseXmlDocument(xmlContent, options = {}) {
const parser = new XMLParser(options);
return parser.parse(xmlContent);
}
module.exports = {
parseXmlDocument,
XMLParser,
};
{
"name": "verify-fast-xml-parser",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "verify-fast-xml-parser",
"version": "1.0.0",
"dependencies": {
"fast-xml-parser": "5.11.0"
}
},
"node_modules/@nodable/entities": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@nodable/entities/-/entities-3.0.0.tgz",
"integrity": "sha512-8L9xFeTYKhm49xfIypoe2W5wV1m/3Z58kT+7kR9A8OyFxcPduI4VmxaUMQyKYrRjUoLLSXv6EKKID5Tvj9cUVw==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/nodable"
}
],
"license": "MIT"
},
"node_modules/anynum": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/anynum/-/anynum-1.0.1.tgz",
"integrity": "sha512-N6//FLET/tXYNM/F6ABca1oH6fWB+KlTt909Le28WMDBk8oaT4vY17DCrwg2MvmuqUKt3Ni4N5dGJ/EoBgcO6A==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT"
},
"node_modules/fast-xml-builder": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/fast-xml-builder/-/fast-xml-builder-1.3.1.tgz",
"integrity": "sha512-pIM/1n3ntFXKYrUZwW7QCK0gAW7XY+wzj1YMIV3tLDvPj/V+zTGJK5e3/4WJfwj0qWw2ElNXiTixda/R+3YSug==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT",
"dependencies": {
"path-expression-matcher": "^1.6.2",
"xml-naming": "^0.3.0"
}
},
"node_modules/fast-xml-parser": {
"version": "5.11.0",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-5.11.0.tgz",
"integrity": "sha512-9IGxMqvqLOnqP+Egi1nqDHKv5k8aZ7r9n558enxcucmyVGEBNPAU+MOg/8jPIS7rO7sSq4gFm1/nHtiaubMruw==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT",
"dependencies": {
"@nodable/entities": "^3.0.0",
"fast-xml-builder": "^1.2.0",
"is-unsafe": "^2.0.0",
"path-expression-matcher": "^1.6.2",
"strnum": "^2.4.2",
"xml-naming": "^0.3.0"
},
"bin": {
"fxparser": "src/cli/cli.js"
}
},
"node_modules/is-unsafe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-unsafe/-/is-unsafe-2.0.0.tgz",
"integrity": "sha512-2LdV822R+wmI86unXA93WCFpL6g+av8ynWk0nrHyJqGop5VoocYsSLFgN8jrfalT6iGeLNM4KXuVSsULP53kEA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT"
},
"node_modules/path-expression-matcher": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.6.2.tgz",
"integrity": "sha512-enSlaiat05iasnzmgNxRj8reFdj3puY2QpNgP1aPIaVfT6nn9ICuPoFlKHk8EN22HcwewshO+mN2DGbkCEOtqQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT",
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/strnum": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/strnum/-/strnum-2.4.2.tgz",
"integrity": "sha512-rDG3Ah4TV0k1hWvLSzkZtMmLN9+eS+h3knq4MP6A42Y3Yh5qGNnOUs1jJkoSr8FG5dsL28c7KgkIBzSEykqtuw==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT",
"dependencies": {
"anynum": "^1.0.1"
}
},
"node_modules/xml-naming": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/xml-naming/-/xml-naming-0.3.0.tgz",
"integrity": "sha512-ghig2TBE/H11aOVgmahA3MhimvkBr6JIYknH/Dhdk10nXwdbIqBJsbfMxpvFPG8bAw77gN29aQWvKpmVoPlvPQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"license": "MIT",
"engines": {
"node": ">=16.0.0"
}
}
}
}
{
"name": "verify-fast-xml-parser",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for fast-xml-parser XMLParser.parse",
"main": "index.js",
"scripts": {
"test": "node test/contract.cjs"
},
"dependencies": {
"fast-xml-parser": "5.11.0"
}
}
{
"schemaVersion": 1,
"goal": "verify XMLParser.parse in pkg:npm/fast-xml-parser@5.11.0",
"kind": "HOW",
"packages": [
"pkg:npm/fast-xml-parser@5.11.0"
],
"symbols": [
"XMLParser.parse"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@11.8.0",
"runtime": "node@24.13.1"
}
}
const assert = require('node:assert/strict');
const { XMLParser } = require('fast-xml-parser');
const { parseXmlDocument } = require('../index.js');
// 1. Basic XML parsing
const basicParser = new XMLParser();
const xml1 = '<bookstore><book><title>Everyday Italian</title><price>30.00</price></book></bookstore>';
const parsed1 = basicParser.parse(xml1);
assert.ok(parsed1.bookstore, 'bookstore object should exist');
assert.equal(parsed1.bookstore.book.title, 'Everyday Italian');
assert.equal(parsed1.bookstore.book.price, 30.0);
// 2. XML with attributes
const attrParser = new XMLParser({
ignoreAttributes: false,
attributeNamePrefix: '@_',
});
const xml2 = '<note id="501" category="reminder"><to>Tove</to><from>Jani</from><body>Reminder text</body></note>';
const parsed2 = attrParser.parse(xml2);
assert.equal(parsed2.note['@_id'], '501');
assert.equal(parsed2.note['@_category'], 'reminder');
assert.equal(parsed2.note.to, 'Tove');
assert.equal(parsed2.note.from, 'Jani');
assert.equal(parsed2.note.body, 'Reminder text');
// 3. Repeated elements as array
const xml3 = '<catalog><item><id>1</id><name>Item 1</name></item><item><id>2</id><name>Item 2</name></item></catalog>';
const parsed3 = basicParser.parse(xml3);
assert.ok(Array.isArray(parsed3.catalog.item), 'repeated elements should parse as array');
assert.equal(parsed3.catalog.item.length, 2);
assert.equal(parsed3.catalog.item[0].id, 1);
assert.equal(parsed3.catalog.item[1].name, 'Item 2');
// 4. Verification through module export helper
const parsedHelper = parseXmlDocument(xml1);
assert.equal(parsedHelper.bookstore.book.title, 'Everyday Italian');
console.log('All XMLParser.parse contract assertions passed successfully.');
Seeder d'origine
anonyme