Beispiel
@babel/plugin-transform-destructuring 7.29.7
Verifiziertes Beispiel für npm @babel/plugin-transform-destructuring 7.29.7. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.
sha256:50abf2ab3b1e255477dd28e51c0d95fca8556e785a0053d04b406a54d8435a3a
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 alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-21 |
Fall
HOW- Ziel
- verify pkg:npm/%40babel/plugin-transform-destructuring@7.29.7
- Erstellt
- 2026-08-21T06:49:26Z
Contract
- Plugin default export is a function factory asserting Babel 7 compatibility
- Plugin factory returns a plugin object named transform-destructuring with required AST visitors
- Transforms array destructuring with indices, default fallback values, hole skips, and rest elements
- Transforms object destructuring with property extraction, alias renaming, defaults, and object rest properties
- Transforms nested destructuring patterns combining array and object structures
- Transforms assignment expression destructuring with existing variable bindings
- Transforms destructuring in ForOf loops and CatchClause parameter bindings
- Supports compiler assumptions including iterableIsArray and objectRestNoSymbols
- Exports buildObjectExcludingKeys and unshiftForXStatementBody AST manipulation helpers
- Helper functions correctly initialize plugin and transform JavaScript source code
Dateien
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
Quelltext
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 pkg:npm/%40babel/plugin-transform-destructuring@7.29.7
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40babel/plugin-transform-destructuring@7.29.7
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:43dfc2cc3d26ca5c3472b0b0758a5ebd964f8d92381272acfc87fe452fb012ae","contract":["Plugin default export is a function factory asserting Babel 7 compatibility","Plugin factory returns a plugin object named transform-destructuring with required AST visitors","Transforms array destructuring with indices, default fallback values, hole skips, and rest elements","Transforms object destructuring with property extraction, alias renaming, defaults, and object rest properties","Transforms nested destructuring patterns combining array and object structures","Transforms assignment expression destructuring with existing variable bindings","Transforms destructuring in ForOf loops and CatchClause parameter bindings","Supports compiler assumptions including iterableIsArray and objectRestNoSymbols","Exports buildObjectExcludingKeys and unshiftForXStatementBody AST manipulation helpers","Helper functions correctly initialize plugin and transform JavaScript source code"],"goal":"verify pkg:npm/%40babel/plugin-transform-destructuring@7.29.7","kind":"HOW","packages":["pkg:npm/%40babel/plugin-transform-destructuring@7.29.7"],"schemaVersion":1},"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/%40babel/plugin-transform-destructuring@7.29.7"],"schemaVersion":1,"subject":"pkg:npm/%40babel/plugin-transform-destructuring@7.29.7","verifierAdapter":"node-typescript@1"}
{
"name": "sample-babel-plugin-transform-destructuring",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-babel-plugin-transform-destructuring",
"version": "1.0.0",
"dependencies": {
"@babel/plugin-transform-destructuring": "7.29.7"
}
},
"node_modules/@babel/code-frame": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz",
"integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==",
"license": "MIT",
"dependencies": {
"@babel/helper-validator-identifier": "^7.29.7",
"js-tokens": "^4.0.0",
"picocolors": "^1.1.1"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/compat-data": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz",
"integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/core": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz",
"integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/code-frame": "^7.29.7",
"@babel/generator": "^7.29.7",
"@babel/helper-compilation-targets": "^7.29.7",
"@babel/helper-module-transforms": "^7.29.7",
"@babel/helpers": "^7.29.7",
"@babel/parser": "^7.29.7",
"@babel/template": "^7.29.7",
"@babel/traverse": "^7.29.7",
"@babel/types": "^7.29.7",
"@jridgewell/remapping": "^2.3.5",
"convert-source-map": "^2.0.0",
"debug": "^4.1.0",
"gensync": "^1.0.0-beta.2",
"json5": "^2.2.3",
"semver": "^6.3.1"
},
"engines": {
"node": ">=6.9.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/babel"
}
},
"node_modules/@babel/generator": {
"version": "7.29.8",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz",
"integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==",
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.29.8",
"@babel/types": "^7.29.8",
"@jridgewell/gen-mapping": "^0.3.12",
"@jridgewell/trace-mapping": "^0.3.28",
"jsesc": "^3.0.2"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-compilation-targets": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz",
"integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/compat-data": "^7.29.7",
"@babel/helper-validator-option": "^7.29.7",
"browserslist": "^4.24.0",
"lru-cache": "^5.1.1",
"semver": "^6.3.1"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-globals": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz",
"integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-module-imports": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz",
"integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/traverse": "^7.29.7",
"@babel/types": "^7.29.7"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-module-transforms": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz",
"integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/helper-module-imports": "^7.29.7",
"@babel/helper-validator-identifier": "^7.29.7",
"@babel/traverse": "^7.29.7"
},
"engines": {
"node": ">=6.9.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0"
}
},
"node_modules/@babel/helper-plugin-utils": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.29.7.tgz",
"integrity": "sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-string-parser": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz",
"integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-identifier": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz",
"integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-option": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz",
"integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helpers": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.7.tgz",
"integrity": "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/template": "^7.29.7",
"@babel/types": "^7.29.7"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/parser": {
"version": "7.29.8",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.8.tgz",
"integrity": "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==",
"license": "MIT",
"dependencies": {
"@babel/types": "^7.29.8"
},
"bin": {
"parser": "bin/babel-parser.js"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@babel/plugin-transform-destructuring": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.29.7.tgz",
"integrity": "sha512-iPX8aD6H9zV5s7ZsqTdNocPN/MGQ5sSMnElKrktxjJRMnB2jN/1p2+R7GkfD6CAYoVFqy5A4XnSIUeGgJzIWpg==",
"license": "MIT",
"dependencies": {
"@babel/helper-plugin-utils": "^7.29.7",
"@babel/traverse": "^7.29.7"
},
"engines": {
"node": ">=6.9.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
}
},
"node_modules/@babel/template": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz",
"integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==",
"license": "MIT",
"dependencies": {
"@babel/code-frame": "^7.29.7",
"@babel/parser": "^7.29.7",
"@babel/types": "^7.29.7"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/traverse": {
"version": "7.29.8",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.8.tgz",
"integrity": "sha512-I5z7H3bf/41ktsNVLtpN0wAa336HkqIHQ5BuPLEhTkt1jVSyZpeNKIzTgEWmlxjdg81R0IgUCcaE+Ok3NvrfZg==",
"license": "MIT",
"dependencies": {
"@babel/code-frame": "^7.29.7",
"@babel/generator": "^7.29.8",
"@babel/helper-globals": "^7.29.7",
"@babel/parser": "^7.29.8",
"@babel/template": "^7.29.7",
"@babel/types": "^7.29.8",
"debug": "^4.3.1"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/types": {
"version": "7.29.8",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz",
"integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==",
"license": "MIT",
"dependencies": {
"@babel/helper-string-parser": "^7.29.7",
"@babel/helper-validator-identifier": "^7.29.7"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@jridgewell/gen-mapping": {
"version": "0.3.13",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
"integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
"license": "MIT",
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.5.0",
"@jridgewell/trace-mapping": "^0.3.24"
}
},
"node_modules/@jridgewell/remapping": {
"version": "2.3.5",
"resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz",
"integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==",
"license": "MIT",
"peer": true,
"dependencies": {
"@jridgewell/gen-mapping": "^0.3.5",
"@jridgewell/trace-mapping": "^0.3.24"
}
},
"node_modules/@jridgewell/resolve-uri": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
"license": "MIT",
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
"license": "MIT"
},
"node_modules/@jridgewell/trace-mapping": {
"version": "0.3.31",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
"license": "MIT",
"dependencies": {
"@jridgewell/resolve-uri": "^3.1.0",
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"node_modules/baseline-browser-mapping": {
"version": "2.11.16",
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.16.tgz",
"integrity": "sha512-H/bNPUFHewJHyCTdjn1n3Pit5+2GmWT6mmeHImPX+8MA9NA6b67jO4gYmi4jTbCJb2otq34KMZnovndDPqJwhQ==",
"license": "Apache-2.0",
"peer": true,
"bin": {
"baseline-browser-mapping": "dist/cli.cjs"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/browserslist": {
"version": "4.28.8",
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.8.tgz",
"integrity": "sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA==",
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/browserslist"
},
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/browserslist"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"baseline-browser-mapping": "^2.11.12",
"caniuse-lite": "^1.0.30001809",
"electron-to-chromium": "^1.5.402",
"node-releases": "^2.0.53",
"update-browserslist-db": "^1.3.0"
},
"bin": {
"browserslist": "cli.js"
},
"engines": {
"node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001809",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001809.tgz",
"integrity": "sha512-xxWVywk6a6Arlk+hymeycyn/VgqEfLDxupvhH/xiY5SJ/18kmi9o6MiO320DCUzypORHLtvh0I4i04tUhCNHNQ==",
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/browserslist"
},
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/caniuse-lite"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"license": "CC-BY-4.0",
"peer": true
},
"node_modules/convert-source-map": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",
"integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",
"license": "MIT",
"peer": true
},
"node_modules/debug": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/electron-to-chromium": {
"version": "1.5.412",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.412.tgz",
"integrity": "sha512-z4rMe3esBzlzovKHj4gxJnsCGZRK5l4baUvm+gCGJBPE+gsyUMKsuU9tnEUtI1dOebXz1ytAPGjvXhmQ7rIPwA==",
"license": "ISC",
"peer": true
},
"node_modules/escalade": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
"integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=6"
}
},
"node_modules/gensync": {
"version": "1.0.0-beta.2",
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
"integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"license": "MIT"
},
"node_modules/jsesc": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz",
"integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==",
"license": "MIT",
"bin": {
"jsesc": "bin/jsesc"
},
"engines": {
"node": ">=6"
}
},
"node_modules/json5": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
"license": "MIT",
"peer": true,
"bin": {
"json5": "lib/cli.js"
},
"engines": {
"node": ">=6"
}
},
"node_modules/lru-cache": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
"integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
"license": "ISC",
"peer": true,
"dependencies": {
"yallist": "^3.0.2"
}
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/node-releases": {
"version": "2.0.53",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.53.tgz",
"integrity": "sha512-D9UOmYG3UH1V+ENW56t5QXBwJw1YEY18ruVeus89Rw+SyIgjPkCO84bRzO3uNIYosJbNwiabWVn48o3uJLjxFQ==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=18"
}
},
"node_modules/picocolors": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
"license": "ISC"
},
"node_modules/semver": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"license": "ISC",
"peer": true,
"bin": {
"semver": "bin/semver.js"
}
},
"node_modules/update-browserslist-db": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.1.tgz",
"integrity": "sha512-ZZ61DsRsOnakl74HAmp3oSN4aXUmEWXf+i/yv0h7tIBfICc3VdrFErQKUUKPgu3AMsTUMbcongALEN4l6GSUrQ==",
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/browserslist"
},
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/browserslist"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"escalade": "^3.2.0",
"picocolors": "^1.1.1"
},
"bin": {
"update-browserslist-db": "cli.js"
},
"peerDependencies": {
"browserslist": ">= 4.21.0"
}
},
"node_modules/yallist": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
"license": "ISC",
"peer": true
}
}
}
{
"name": "sample-babel-plugin-transform-destructuring",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"@babel/plugin-transform-destructuring": "7.29.7"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40babel/plugin-transform-destructuring@7.29.7",
"kind": "HOW",
"packages": [
"pkg:npm/%40babel/plugin-transform-destructuring@7.29.7"
]
}
import * as babel from '@babel/core';
import destructuringPluginPkg, {
buildObjectExcludingKeys as libBuildObjectExcludingKeys,
unshiftForXStatementBody as libUnshiftForXStatementBody
} from '@babel/plugin-transform-destructuring';
/**
* Normalizes and returns the plugin factory function.
* @returns {Function} Babel plugin factory function.
*/
export function getDestructuringPlugin() {
return destructuringPluginPkg.default || destructuringPluginPkg;
}
/**
* Creates and initializes the destructuring plugin instance.
* @param {object} [api] - Optional Babel API object.
* @param {object} [options] - Optional plugin options.
* @returns {object} Plugin instance with name and visitor.
*/
export function createDestructuringPlugin(api, options = {}) {
const plugin = getDestructuringPlugin();
const babelApi = api || {
types: babel.types,
template: babel.template,
traverse: babel.traverse,
assertVersion: (range) => Boolean(range)
};
return plugin(babelApi, options);
}
/**
* Transforms JavaScript source code using @babel/plugin-transform-destructuring.
* @param {string} source - JavaScript source code to transform.
* @param {object} [options] - Additional Babel transform options and assumptions.
* @returns {import('@babel/core').BabelFileResult} Babel transform result object.
*/
export function transformDestructuring(source, options = {}) {
const plugin = getDestructuringPlugin();
const { assumptions, pluginOptions = {}, ...babelOptions } = options;
return babel.transformSync(source, {
plugins: [[plugin, pluginOptions]],
assumptions: assumptions || {},
configFile: false,
babelrc: false,
...babelOptions
});
}
export const buildObjectExcludingKeys = libBuildObjectExcludingKeys;
export const unshiftForXStatementBody = libUnshiftForXStatementBody;
import assert from 'node:assert/strict';
import * as babel from '@babel/core';
import destructuringPluginPkg, {
buildObjectExcludingKeys,
unshiftForXStatementBody
} from '@babel/plugin-transform-destructuring';
import {
getDestructuringPlugin,
createDestructuringPlugin,
transformDestructuring
} from '../src/index.mjs';
// 1. Plugin default export is a function factory asserting Babel 7 compatibility
const plugin = destructuringPluginPkg.default || destructuringPluginPkg;
assert.equal(typeof plugin, 'function', 'Plugin default export must be a function');
let assertedVersion = null;
const mockApi = {
types: babel.types,
template: babel.template,
traverse: babel.traverse,
assertVersion(range) {
assertedVersion = range;
}
};
const instance = plugin(mockApi, {});
assert.equal(assertedVersion, 7, 'Plugin must assert Babel version 7 compatibility');
// 2. Plugin factory returns a plugin object named transform-destructuring with required AST visitors
assert.equal(typeof instance, 'object', 'Plugin factory must return an object');
assert.equal(instance.name, 'transform-destructuring', 'Plugin name must be transform-destructuring');
assert.equal(typeof instance.visitor, 'object', 'Plugin must provide visitor object');
assert.equal(typeof instance.visitor.VariableDeclaration, 'function', 'Visitor must provide VariableDeclaration');
assert.equal(typeof instance.visitor.AssignmentExpression, 'function', 'Visitor must provide AssignmentExpression');
assert.equal(typeof instance.visitor.ForXStatement, 'function', 'Visitor must provide ForXStatement');
assert.equal(typeof instance.visitor.CatchClause, 'function', 'Visitor must provide CatchClause');
assert.equal(typeof instance.visitor.ExportNamedDeclaration, 'function', 'Visitor must provide ExportNamedDeclaration');
// 3. Transforms array destructuring with indices, default fallback values, hole skips, and rest elements
{
const code = `
function runArray() {
const sourceArray = [10, 20];
const [first, , third = 'defaultThird', ...tail] = sourceArray;
return { first, third, tail };
}
`;
const result = transformDestructuring(code);
assert.ok(result.code.includes('first ='), 'Transformed code must assign first element');
assert.ok(result.code.includes('third ='), 'Transformed code must assign third element with fallback');
const evaluated = new Function(result.code + '; return runArray();')();
assert.equal(evaluated.first, 10, 'First element must be destructured');
assert.equal(evaluated.third, 'defaultThird', 'Default fallback value must be applied');
assert.deepEqual(evaluated.tail, [], 'Rest elements must be empty array');
}
// 4. Transforms object destructuring with property extraction, alias renaming, defaults, and object rest properties
{
const code = `
function runObject() {
const sourceObj = { a: 100, b: 'custom', extra1: true, extra2: 'ignored' };
const { a, b: aliasB = 'defaultB', missing: missingVal = 'defaultVal', ...restObj } = sourceObj;
return { a, aliasB, missingVal, restObj };
}
`;
const result = transformDestructuring(code);
const evaluated = new Function(result.code + '; return runObject();')();
assert.equal(evaluated.a, 100, 'Direct property must be extracted');
assert.equal(evaluated.aliasB, 'custom', 'Aliased property must retain original value');
assert.equal(evaluated.missingVal, 'defaultVal', 'Missing property must receive default value');
assert.deepEqual(evaluated.restObj, { extra1: true, extra2: 'ignored' }, 'Rest properties must contain non-destructured fields');
}
// 5. Transforms nested destructuring patterns combining array and object structures
{
const code = `
function runNested() {
const data = { profile: { name: 'Alice', items: ['firstItem', 'secondItem'] } };
const { profile: { name, items: [leadItem, ...subItems] } } = data;
return { name, leadItem, subItems };
}
`;
const result = transformDestructuring(code);
const evaluated = new Function(result.code + '; return runNested();')();
assert.equal(evaluated.name, 'Alice', 'Nested property name must be destructured');
assert.equal(evaluated.leadItem, 'firstItem', 'Nested array element must be destructured');
assert.deepEqual(evaluated.subItems, ['secondItem'], 'Nested array rest elements must be extracted');
}
// 6. Transforms assignment expression destructuring with existing variable bindings
{
const code = `
function runAssignment() {
let valA = 0;
let valB = 0;
let objX = 0;
let objY = 0;
[valA, valB] = [11, 22];
({ objX, objY } = { objX: 33, objY: 44 });
return { valA, valB, objX, objY };
}
`;
const result = transformDestructuring(code);
const evaluated = new Function(result.code + '; return runAssignment();')();
assert.deepEqual(evaluated, { valA: 11, valB: 22, objX: 33, objY: 44 }, 'Assignment destructuring must mutate existing bindings');
}
// 7. Transforms destructuring in ForOf loops and CatchClause parameter bindings
{
const code = `
function runControlFlow() {
const loopResults = [];
const entries = [['k1', 10], ['k2', 20]];
for (const [k, v] of entries) {
loopResults.push(k + '=' + v);
}
let caughtDetails = null;
try {
throw { status: 404, msg: 'NotFound' };
} catch ({ status, msg }) {
caughtDetails = status + ':' + msg;
}
return { loopResults, caughtDetails };
}
`;
const result = transformDestructuring(code);
const evaluated = new Function(result.code + '; return runControlFlow();')();
assert.deepEqual(evaluated.loopResults, ['k1=10', 'k2=20'], 'ForOf destructuring must execute correctly');
assert.equal(evaluated.caughtDetails, '404:NotFound', 'Catch clause destructuring must extract error properties');
}
// 8. Supports compiler assumptions including iterableIsArray and objectRestNoSymbols
{
const codeArray = 'const [a, b] = sourceList;';
const resultOptimized = transformDestructuring(codeArray, {
assumptions: {
iterableIsArray: true
}
});
assert.ok(!resultOptimized.code.includes('_toArray'), 'iterableIsArray assumption should eliminate iterator helper');
assert.ok(resultOptimized.code.includes('sourceList[0]'), 'iterableIsArray assumption should direct-index array');
const restCode = `
function runRest() {
const sourceObj = { a: 1, b: 2, c: 3 };
const { a, ...rest } = sourceObj;
return rest;
}
`;
const resultRest = transformDestructuring(restCode, {
assumptions: {
objectRestNoSymbols: true
}
});
const evalRest = new Function(resultRest.code + '; return runRest();')();
assert.deepEqual(evalRest, { b: 2, c: 3 }, 'objectRestNoSymbols assumption must extract plain object keys');
}
// 9. Exports buildObjectExcludingKeys and unshiftForXStatementBody AST manipulation helpers
{
assert.equal(typeof buildObjectExcludingKeys, 'function', 'buildObjectExcludingKeys must be an exported function');
assert.equal(typeof unshiftForXStatementBody, 'function', 'unshiftForXStatementBody must be an exported function');
// Verify buildObjectExcludingKeys constructs AST expression node
const excludedKeys = [
{ key: babel.types.identifier('excludeMe'), computed: false }
];
const objRef = babel.types.identifier('targetObj');
const mockScope = {
block: babel.types.program([]),
getProgramParent: () => mockScope,
push: () => {},
generateUidIdentifier: (name) => babel.types.identifier('_' + name)
};
const astExpr = buildObjectExcludingKeys(excludedKeys, objRef, mockScope, (name) => babel.types.identifier('_' + name), true, true);
assert.ok(astExpr && astExpr.type, 'buildObjectExcludingKeys must return an AST node');
// Verify unshiftForXStatementBody prepends statement into block
const loopBodyBlock = babel.types.blockStatement([]);
const mockStatementPath = {
ensureBlock: () => {},
scope: { hasBinding: () => false },
get: () => ({ scope: { bindings: {} } }),
node: { body: loopBodyBlock }
};
const newStmt = babel.types.expressionStatement(babel.types.stringLiteral('prepended'));
unshiftForXStatementBody(mockStatementPath, [newStmt]);
assert.equal(loopBodyBlock.body.length, 1, 'unshiftForXStatementBody must insert statements into body');
assert.equal(loopBodyBlock.body[0], newStmt, 'unshiftForXStatementBody must prepend statement');
}
// 10. Helper functions correctly initialize plugin and transform JavaScript source code
{
const helperInstance = createDestructuringPlugin();
assert.equal(helperInstance.name, 'transform-destructuring', 'Helper plugin must return valid plugin instance');
const helperPlugin = getDestructuringPlugin();
assert.equal(typeof helperPlugin, 'function', 'getDestructuringPlugin must return factory function');
const result = transformDestructuring('function testHelper() { const { success } = { success: true }; return success; }');
const evaluated = new Function(result.code + '; return testHelper();')();
assert.equal(evaluated, true, 'Helper transform function must produce functional output code');
}
console.log('Contract assertions passed.');
Ursprungs-Seeder
anonym