Beispiel
p-try 2.2.0: default
Verifiziertes Beispiel für npm p-try 2.2.0: default. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand: p-try.default executes a…
sha256:685604f87d8a0a5fd5839c59650dc29c20db2b288329ea251d2c60d3624bb35b
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-09-06 |
Fall
HOW- Ziel
- verify p-try.default in pkg:npm/p-try@2.2.0
- Pakete
- Symbole
-
- p-try.default
- Erstellt
- 2026-09-06T21:02:48Z
Contract
- p-try.default executes a synchronous function and returns a Promise resolving to its return value
- p-try.default passes provided arguments to the function
- p-try.default catches synchronous errors and converts them to rejected promises
- p-try.default handles asynchronous functions and resolves or rejects according to the returned promise
Dateien
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- 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 p-try.default in pkg:npm/p-try@2.2.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/p-try@2.2.0
Demonstrate these symbols/APIs:
- p-try.default
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:1cf3a195610e5ad28b0a04321dc876a898f1641ee80456f9cf7b2be5f26d422f","contract":["p-try.default executes a synchronous function and returns a Promise resolving to its return value","p-try.default passes provided arguments to the function","p-try.default catches synchronous errors and converts them to rejected promises","p-try.default handles asynchronous functions and resolves or rejects according to the returned promise"],"goal":"verify p-try.default in pkg:npm/p-try@2.2.0","kind":"HOW","packages":["pkg:npm/p-try@2.2.0"],"schemaVersion":1,"symbols":["p-try.default"]},"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/p-try@2.2.0"],"schemaVersion":1,"subject":"pkg:npm/p-try@2.2.0","symbols":["p-try.default"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-p-try",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-p-try",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"p-try": "2.2.0"
}
},
"node_modules/p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
"integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
}
}
}
{
"name": "sample-p-try",
"version": "1.0.0",
"private": true,
"description": "verify p-try.default in pkg:npm/p-try@2.2.0",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"p-try": "2.2.0"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify p-try.default in pkg:npm/p-try@2.2.0",
"kind": "HOW",
"packages": [
"pkg:npm/p-try@2.2.0"
],
"symbols": [
"p-try.default"
]
}
'use strict';
const pTry = require('p-try');
/**
* Executes a function inside a promise chain using p-try.default.
*
* @param {Function} fn - Function to run.
* @param {...any} args - Arguments to forward to fn.
* @returns {Promise<any>} A promise resolving with the returned value or rejecting if an error is thrown.
*/
function runWithPTry(fn, ...args) {
return pTry.default(fn, ...args);
}
module.exports = {
pTry,
runWithPTry
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const pTryModule = require('p-try');
const { pTry, runWithPTry } = require('../src/index.js');
// 1. p-try.default executes a synchronous function and returns a Promise resolving to its return value
{
assert.strictEqual(typeof pTryModule.default, 'function', 'pTryModule.default must be a function');
assert.strictEqual(pTryModule.default, pTryModule, 'pTryModule.default must equal the exported pTry function');
const syncResult = await pTryModule.default(() => 'sync-value');
assert.strictEqual(syncResult, 'sync-value', 'pTryModule.default should resolve to synchronous return value');
const wrapperResult = await runWithPTry(() => 42);
assert.strictEqual(wrapperResult, 42, 'runWithPTry should resolve to return value');
const promiseInstance = pTryModule.default(() => 'promise-instance-check');
assert.ok(promiseInstance instanceof Promise, 'pTry.default must return a native Promise instance');
await promiseInstance;
}
// 2. p-try.default passes provided arguments to the function
{
const result = await pTryModule.default(
(a, b, c) => `${a}-${b}-${c}`,
'first',
'second',
'third'
);
assert.strictEqual(result, 'first-second-third', 'pTry.default should pass arguments in order');
const wrapperResult = await runWithPTry((x, y) => x * y, 6, 7);
assert.strictEqual(wrapperResult, 42, 'runWithPTry should forward arguments to target function');
}
// 3. p-try.default catches synchronous errors and converts them to rejected promises
{
const expectedError = new Error('synchronous failure');
await assert.rejects(
async () => {
await pTryModule.default(() => {
throw expectedError;
});
},
{
name: 'Error',
message: 'synchronous failure'
},
'pTry.default must convert thrown synchronous exceptions into promise rejections'
);
await assert.rejects(
async () => {
await runWithPTry(() => {
throw new TypeError('invalid argument type');
});
},
{
name: 'TypeError',
message: 'invalid argument type'
},
'runWithPTry must convert thrown synchronous exceptions into promise rejections'
);
}
// 4. p-try.default handles asynchronous functions and resolves or rejects according to the returned promise
{
const asyncResult = await pTryModule.default(async (num) => {
return num * 10;
}, 5);
assert.strictEqual(asyncResult, 50, 'pTry.default should await and resolve the async promise');
await assert.rejects(
async () => {
await pTryModule.default(async () => {
throw new Error('async failure');
});
},
{
name: 'Error',
message: 'async failure'
},
'pTry.default must reject when the returned promise rejects'
);
}
console.log('All contract assertions passed successfully.');
Ursprungs-Seeder
anonym