Exemple
prelude-ls 1.2.1
Échantillon vérifié pour npm prelude-ls 1.2.1. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : map transforms elements in an…
sha256:2de7346d30486435e7df2b48b160855ebc5da7bebfe0dd009e3b607fe86f2e89
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.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-27 |
Cas
HOW- Objectif
- verify pkg:npm/prelude-ls@1.2.1
- Paquets
- Environnement
- node 22.23.2
- Créé
- 2026-08-27T15:45:50Z
Contrat
- map transforms elements in an array by applying a unary mapping function
- filter keeps elements satisfying a predicate and reject excludes elements satisfying a predicate
- partition splits an array into a pair of arrays of elements that pass and fail a predicate
- foldl reduces elements from the left with an accumulator and initial value, while foldr reduces from the right
- sum computes the arithmetic sum of numbers and product computes their product
- take extracts the first n elements and drop removes the first n elements from an array
- splitAt partitions an array at a specified index into a tuple of two sub-arrays
- takeWhile takes elements while a predicate holds true and dropWhile drops elements while a predicate holds true
- head returns the first element, tail returns all except the first, last returns the final element, and initial returns all except the last
- unique removes duplicate elements, intersection finds common elements, difference removes elements present in another list, and union merges lists without duplicates
- zip pairs corresponding elements from two lists and zipWith combines them using a binary function
- groupBy groups elements into an object keyed by the result of a grouping function and sortBy sorts elements by an extracted key
- pairsToObj constructs an object from key-value pairs and objToPairs extracts key-value pairs from an object
- capitalize, camelize, and dasherize format string casing, and words, unwords, lines, unlines split and join string sequences
- curry converts a multi-argument function into a curried function and flip reverses the order of the first two arguments
- isType validates the constructor type name of JavaScript values including String, Number, and Array
Fichiers
- PROMPT.md
- csx.json
- 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 pkg:npm/prelude-ls@1.2.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/prelude-ls@1.2.1
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:29b6756f064b622358cea71ee834b7506ccd726059b7106f882819d2ab198b09","constraints":{"executionContext":"node"},"contract":["map transforms elements in an array by applying a unary mapping function","filter keeps elements satisfying a predicate and reject excludes elements satisfying a predicate","partition splits an array into a pair of arrays of elements that pass and fail a predicate","foldl reduces elements from the left with an accumulator and initial value, while foldr reduces from the right","sum computes the arithmetic sum of numbers and product computes their product","take extracts the first n elements and drop removes the first n elements from an array","splitAt partitions an array at a specified index into a tuple of two sub-arrays","takeWhile takes elements while a predicate holds true and dropWhile drops elements while a predicate holds true","head returns the first element, tail returns all except the first, last returns the final element, and initial returns all except the last","unique removes duplicate elements, intersection finds common elements, difference removes elements present in another list, and union merges lists without duplicates","zip pairs corresponding elements from two lists and zipWith combines them using a binary function","groupBy groups elements into an object keyed by the result of a grouping function and sortBy sorts elements by an extracted key","pairsToObj constructs an object from key-value pairs and objToPairs extracts key-value pairs from an object","capitalize, camelize, and dasherize format string casing, and words, unwords, lines, unlines split and join string sequences","curry converts a multi-argument function into a curried function and flip reverses the order of the first two arguments","isType validates the constructor type name of JavaScript values including String, Number, and Array"],"goal":"verify pkg:npm/prelude-ls@1.2.1","kind":"HOW","packages":["pkg:npm/prelude-ls@1.2.1"],"schemaVersion":1},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/prelude-ls@1.2.1"],"schemaVersion":1,"subject":"pkg:npm/prelude-ls@1.2.1","verifierAdapter":"node-typescript@1"}
{
"name": "sample-prelude-ls",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-prelude-ls",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"prelude-ls": "1.2.1"
}
},
"node_modules/prelude-ls": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz",
"integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==",
"license": "MIT",
"engines": {
"node": ">= 0.8.0"
}
}
}
}
{
"name": "sample-prelude-ls",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for prelude-ls",
"license": "MIT-0",
"dependencies": {
"prelude-ls": "1.2.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/prelude-ls@1.2.1",
"kind": "HOW",
"packages": [
"pkg:npm/prelude-ls@1.2.1"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const assert = require('node:assert');
const prelude = require('prelude-ls');
const {
map,
filter,
reject,
partition,
foldl,
foldr,
sum,
product,
take,
drop,
splitAt,
takeWhile,
dropWhile,
head,
tail,
last,
initial,
reverse,
unique,
intersection,
difference,
union,
zip,
zipWith,
groupBy,
sortBy,
pairsToObj,
objToPairs,
keys,
values,
capitalize,
camelize,
dasherize,
words,
unwords,
lines,
unlines,
curry,
flip,
isType,
} = prelude;
// 1. map transforms elements in an array by applying a unary mapping function
const mapped = map((x) => x * 2, [1, 2, 3]);
assert.deepStrictEqual(mapped, [2, 4, 6]);
// 2. filter keeps elements satisfying a predicate and reject excludes elements satisfying a predicate
const filtered = filter((x) => x % 2 === 0, [1, 2, 3, 4, 5]);
assert.deepStrictEqual(filtered, [2, 4]);
const rejected = reject((x) => x % 2 === 0, [1, 2, 3, 4, 5]);
assert.deepStrictEqual(rejected, [1, 3, 5]);
// 3. partition splits an array into a pair of arrays of elements that pass and fail a predicate
const partitioned = partition((x) => x > 2, [1, 2, 3, 4, 5]);
assert.deepStrictEqual(partitioned, [
[3, 4, 5],
[1, 2],
]);
// 4. foldl reduces elements from the left with an accumulator and initial value, while foldr reduces from the right
const foldedLeft = foldl((acc, x) => acc - x, 10, [1, 2, 3]);
assert.strictEqual(foldedLeft, 4);
const foldedRight = foldr((x, acc) => x - acc, 0, [1, 2, 3, 4]);
assert.strictEqual(foldedRight, -2);
// 5. sum computes the arithmetic sum of numbers and product computes their product
assert.strictEqual(sum([10, 20, 30, 5]), 65);
assert.strictEqual(sum([]), 0);
assert.strictEqual(product([2, 3, 4, 5]), 120);
assert.strictEqual(product([]), 1);
// 6. take extracts the first n elements and drop removes the first n elements from an array
assert.deepStrictEqual(take(2, [10, 20, 30, 40]), [10, 20]);
assert.deepStrictEqual(take(0, [10, 20, 30]), []);
assert.deepStrictEqual(drop(2, [10, 20, 30, 40]), [30, 40]);
assert.deepStrictEqual(drop(5, [10, 20]), []);
// 7. splitAt partitions an array at a specified index into a tuple of two sub-arrays
assert.deepStrictEqual(splitAt(2, ['a', 'b', 'c', 'd']), [
['a', 'b'],
['c', 'd'],
]);
assert.deepStrictEqual(splitAt(0, ['a', 'b']), [[], ['a', 'b']]);
// 8. takeWhile takes elements while a predicate holds true and dropWhile drops elements while a predicate holds true
assert.deepStrictEqual(takeWhile((x) => x < 4, [1, 2, 3, 5, 2, 1]), [1, 2, 3]);
assert.deepStrictEqual(dropWhile((x) => x < 4, [1, 2, 3, 5, 2, 1]), [5, 2, 1]);
// 9. head returns the first element, tail returns all except the first, last returns the final element, and initial returns all except the last
assert.strictEqual(head([10, 20, 30]), 10);
assert.deepStrictEqual(tail([10, 20, 30]), [20, 30]);
assert.strictEqual(last([10, 20, 30]), 30);
assert.deepStrictEqual(initial([10, 20, 30]), [10, 20]);
assert.deepStrictEqual(reverse([1, 2, 3]), [3, 2, 1]);
// 10. unique removes duplicate elements, intersection finds common elements, difference removes elements present in another list, and union merges lists without duplicates
assert.deepStrictEqual(unique([1, 2, 2, 3, 1, 4]), [1, 2, 3, 4]);
assert.deepStrictEqual(intersection([1, 2, 3], [2, 3, 4]), [2, 3]);
assert.deepStrictEqual(difference([1, 2, 3, 4], [2, 4]), [1, 3]);
assert.deepStrictEqual(union([1, 2], [2, 3, 4]), [1, 2, 3, 4]);
// 11. zip pairs corresponding elements from two lists and zipWith combines them using a binary function
assert.deepStrictEqual(zip(['x', 'y', 'z'], [1, 2, 3]), [
['x', 1],
['y', 2],
['z', 3],
]);
assert.deepStrictEqual(zipWith((a, b) => `${a}:${b}`, ['a', 'b'], [10, 20]), [
'a:10',
'b:20',
]);
// 12. groupBy groups elements into an object keyed by the result of a grouping function and sortBy sorts elements by an extracted key
const grouped = groupBy((s) => s.length, ['a', 'bb', 'c', 'ddd', 'ee']);
assert.deepStrictEqual(grouped, {
'1': ['a', 'c'],
'2': ['bb', 'ee'],
'3': ['ddd'],
});
const sorted = sortBy((item) => item.score, [
{ id: 1, score: 30 },
{ id: 2, score: 10 },
{ id: 3, score: 20 },
]);
assert.deepStrictEqual(sorted, [
{ id: 2, score: 10 },
{ id: 3, score: 20 },
{ id: 1, score: 30 },
]);
// 13. pairsToObj constructs an object from key-value pairs and objToPairs extracts key-value pairs from an object
assert.deepStrictEqual(
pairsToObj([
['foo', 1],
['bar', 2],
]),
{ foo: 1, bar: 2 }
);
assert.deepStrictEqual(objToPairs({ alpha: 10, beta: 20 }), [
['alpha', 10],
['beta', 20],
]);
assert.deepStrictEqual(keys({ a: 1, b: 2 }), ['a', 'b']);
assert.deepStrictEqual(values({ a: 1, b: 2 }), [1, 2]);
// 14. capitalize, camelize, and dasherize format string casing, and words, unwords, lines, unlines split and join string sequences
assert.strictEqual(capitalize('prelude'), 'Prelude');
assert.strictEqual(camelize('functional-programming-helper'), 'functionalProgrammingHelper');
assert.strictEqual(dasherize('functionalProgrammingHelper'), 'functional-programming-helper');
assert.deepStrictEqual(words('foo bar baz'), ['foo', 'bar', 'baz']);
assert.strictEqual(unwords(['foo', 'bar', 'baz']), 'foo bar baz');
assert.deepStrictEqual(lines('line1\nline2\nline3'), ['line1', 'line2', 'line3']);
assert.strictEqual(unlines(['line1', 'line2']), 'line1\nline2');
// 15. curry converts a multi-argument function into a curried function and flip reverses the order of the first two arguments
const add3 = (a, b, c) => a + b + c;
const curriedAdd3 = curry(add3);
assert.strictEqual(curriedAdd3(1)(2)(3), 6);
assert.strictEqual(curriedAdd3(1, 2)(3), 6);
assert.strictEqual(curriedAdd3(1)(2, 3), 6);
const subtract = (a, b) => a - b;
const flippedSubtract = flip(subtract);
assert.strictEqual(flippedSubtract(2, 10), 8);
// 16. isType validates the constructor type name of JavaScript values including String, Number, and Array
assert.strictEqual(isType('String', 'hello'), true);
assert.strictEqual(isType('String', 123), false);
assert.strictEqual(isType('Number', 42), true);
assert.strictEqual(isType('Array', [1, 2, 3]), true);
assert.strictEqual(isType('Object', { a: 1 }), true);
assert.strictEqual(isType('Function', () => {}), true);
console.log('Contract passed');
Seeder d'origine
anonyme