CodeSampleX

Ejemplo

concat-map 0.0.1: concatMap

Muestra verificada para npm concat-map 0.0.1: concatMap. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó.

sha256:3c35da16dc4652f977320aa8b68a84d5758fea2b26cf595b4ca1b257d820df96

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
2
Claves de firma que lo compilaron
1
Entorno declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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
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-07

Caso

HOW
Objetivo
verify concatMap in pkg:npm/concat-map@0.0.1
Paquetes
Símbolos
  • concatMap
Creado
2026-08-27T05:12:56Z

Contrato

  1. concatMap(xs, fn) transforms elements by fn and concatenates resulting arrays into a flattened array
  2. concatMap(xs, fn) appends scalar non-array return values directly to the result array
  3. concatMap(xs, fn) drops elements when fn returns an empty array
  4. concatMap(xs, fn) provides element and 0-based index to the callback function
  5. concatMap(xs, fn) returns an empty array when given an empty input array

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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 concatMap in pkg:npm/concat-map@0.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/concat-map@0.0.1
Demonstrate these symbols/APIs:
  - concatMap

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:a9c24f92e14f44b95936ea431357c07cdc78971537f8bfe907be0d59ce0f0a8e","contract":["concatMap(xs, fn) transforms elements by fn and concatenates resulting arrays into a flattened array","concatMap(xs, fn) appends scalar non-array return values directly to the result array","concatMap(xs, fn) drops elements when fn returns an empty array","concatMap(xs, fn) provides element and 0-based index to the callback function","concatMap(xs, fn) returns an empty array when given an empty input array"],"goal":"verify concatMap in pkg:npm/concat-map@0.0.1","kind":"HOW","packages":["pkg:npm/concat-map@0.0.1"],"schemaVersion":1,"symbols":["concatMap"]},"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/concat-map@0.0.1"],"schemaVersion":1,"subject":"pkg:npm/concat-map@0.0.1","symbols":["concatMap"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-concat-map",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-concat-map",
      "version": "1.0.0",
      "dependencies": {
        "concat-map": "0.0.1"
      }
    },
    "node_modules/concat-map": {
      "version": "0.0.1",
      "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
      "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-concat-map",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "concat-map": "0.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify concatMap in pkg:npm/concat-map@0.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/concat-map@0.0.1"
  ],
  "symbols": [
    "concatMap"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import concatMap from 'concat-map';

// 1. transforms elements by fn and concatenates resulting arrays into a flattened array
const nums = [1, 2, 3];
const result1 = concatMap(nums, (x) => [x, x * 10]);
assert.deepStrictEqual(result1, [1, 10, 2, 20, 3, 30]);

// 2. appends scalar non-array return values directly to the result array
const mixed = ['a', 'b', 'c'];
const result2 = concatMap(mixed, (x, i) => (i % 2 === 0 ? [x, x.toUpperCase()] : x));
assert.deepStrictEqual(result2, ['a', 'A', 'b', 'c', 'C']);

// 3. drops elements when fn returns an empty array
const evens = [1, 2, 3, 4, 5, 6];
const result3 = concatMap(evens, (x) => (x % 2 === 0 ? [x] : []));
assert.deepStrictEqual(result3, [2, 4, 6]);

// 4. provides element and 0-based index to the callback function
const seenIndices = [];
const seenElements = [];
const result4 = concatMap(['first', 'second'], (item, idx) => {
  seenElements.push(item);
  seenIndices.push(idx);
  return [`${idx}:${item}`];
});
assert.deepStrictEqual(seenElements, ['first', 'second']);
assert.deepStrictEqual(seenIndices, [0, 1]);
assert.deepStrictEqual(result4, ['0:first', '1:second']);

// 5. returns an empty array when given an empty input array
const result5 = concatMap([], (x) => [x]);
assert.deepStrictEqual(result5, []);

Seeder de origen

anónimo