CodeSampleX

샘플

prelude-ls 1.2.1

검증된 샘플 — npm prelude-ls 1.2.1. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: map transforms elements in an array by applying a unary mapping…

sha256:a8fd21df6ff830d040784c0e6ac9fa075249234392e4feaeee07f5e617e50132

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-20

케이스

HOW
목표
verify pkg:npm/prelude-ls@1.2.1
패키지
환경
node 22.23.2
생성일
2026-08-20T21:57:16Z

컨트랙트

  1. map transforms elements in an array by applying a unary mapping function
  2. filter keeps elements satisfying a predicate and reject excludes elements satisfying a predicate
  3. partition splits an array into a pair of arrays of elements that pass and fail a predicate
  4. foldl reduces elements from the left with an accumulator and initial value, while foldr reduces from the right
  5. sum computes the arithmetic sum of numbers and product computes their product
  6. take extracts the first n elements and drop removes the first n elements from an array
  7. splitAt partitions an array at a specified index into a tuple of two sub-arrays
  8. takeWhile takes elements while a predicate holds true and dropWhile drops elements while a predicate holds true
  9. head returns the first element, tail returns all except the first, last returns the final element, and initial returns all except the last
  10. unique removes duplicate elements, intersection finds common elements, difference removes elements present in another list, and union merges lists without duplicates
  11. zip pairs corresponding elements from two lists and zipWith combines them using a binary function
  12. groupBy groups elements into an object keyed by the result of a grouping function and sortBy sorts elements by an extracted key
  13. pairsToObj constructs an object from key-value pairs and objToPairs extracts key-value pairs from an object
  14. capitalize, camelize, and dasherize format string casing, and words, unwords, lines, unlines split and join string sequences
  15. curry converts a multi-argument function into a curried function and flip reverses the order of the first two arguments
  16. isType validates the constructor type name of JavaScript values including String, Number, and Array

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.cjs

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
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
  - 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.
csx.json
{"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","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"}
package-lock.json
{
  "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"
      }
    }
  }
}
package.json
{
  "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"
  }
}
spec.json
{
  "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",
    "runtime": "node@22.23.2"
  }
}
test/contract.cjs
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]); // ((10 - 1) - 2) - 3 = 4
assert.strictEqual(foldedLeft, 4);
const foldedRight = foldr((x, acc) => x - acc, 0, [1, 2, 3, 4]); // 1 - (2 - (3 - (4 - 0))) = -2
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');

오리진 시더

익명