CodeSampleX

Beispiel

dedent 1.7.2: verify multiline string indentation removal and options

Verifiziertes Beispiel für npm dedent 1.7.2: verify multiline string indentation removal and options. Der Vertrag lief auf node 22 · linux alpine/x64 …

sha256:1b6bd529c87a9494dce6c2078968d99f1b21ef5c5e4f9f23329fad5e7d224b41

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@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-27

Fall

HOW
Ziel
verify pkg:npm/dedent@1.7.2 multiline string indentation removal and options
Pakete
Symbole
  • dedent
Erstellt
2026-08-27T16:34:43Z

Contract

  1. Calling dedent as a tagged template literal strips common indentation and leading/trailing blank lines.
  2. Calling dedent as a function strips common indentation from string input.
  3. dedent.withOptions({ alignValues: true }) aligns subsequent lines of multiline interpolated values to the interpolation column.
  4. dedent.withOptions({ trimWhitespace: false }) preserves leading and trailing whitespace around the dedented text.
  5. dedent.withOptions({ escapeSpecialCharacters: false }) preserves backslashes before special characters in template strings.

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

NOTES.md
# Dedent multiline string indentation removal and options in Node.js

`pkg:npm/dedent@1.7.2` provides template tag and function call utilities to strip common leading indentation and leading/trailing blank lines from multiline strings.

## Key Features & Invocations
1. **Tagged Template Literal**: Calling `dedent` as a template tag strips common indentation from multiline text while preserving relative indentation.
2. **Function Call**: Calling `dedent(...)` directly with a string input strips leading indentation identically.
3. **Custom Options (`dedent.withOptions`)**:
   - `alignValues`: When `true`, multiline string interpolations (`${...}`) maintain indentation relative to the interpolation column.
   - `trimWhitespace`: When `false`, leading and trailing whitespace and blank lines are preserved.
   - `escapeSpecialCharacters`: When `false`, backslashes before special characters such as `$` in raw template strings are retained.
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/dedent@1.7.2 multiline string indentation removal and options
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/dedent@1.7.2
Demonstrate these symbols/APIs:
  - dedent

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:d454e588cd038ef3b8b96da427f8121c029e715378105fcd0ddf153ff90e8d8f","contract":["Calling dedent as a tagged template literal strips common indentation and leading/trailing blank lines.","Calling dedent as a function strips common indentation from string input.","dedent.withOptions({ alignValues: true }) aligns subsequent lines of multiline interpolated values to the interpolation column.","dedent.withOptions({ trimWhitespace: false }) preserves leading and trailing whitespace around the dedented text.","dedent.withOptions({ escapeSpecialCharacters: false }) preserves backslashes before special characters in template strings."],"goal":"verify pkg:npm/dedent@1.7.2 multiline string indentation removal and options","kind":"HOW","packages":["pkg:npm/dedent@1.7.2"],"schemaVersion":1,"symbols":["dedent"]},"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/dedent@1.7.2"],"schemaVersion":1,"subject":"pkg:npm/dedent@1.7.2","symbols":["dedent"],"verifierAdapter":"node-typescript@1"}
index.mjs
import dedent from "dedent";

// Example 1: Tagged template literal
const multiline = dedent`
  function example() {
    return true;
  }
`;

// Example 2: Function call
const functionCall = dedent(`
  first line
    nested line
`);

// Example 3: Customized options
const customDedent = dedent.withOptions({
  alignValues: true,
  trimWhitespace: true,
});

const items = dedent`
  - first
  - second
`;

const formatted = customDedent`
  List:
    ${items}
`;

console.log("Dedent multiline string output:\n" + multiline);
console.log("\nFunction call output:\n" + functionCall);
console.log("\nCustom options output:\n" + formatted);
package-lock.json
{
  "name": "sample-dedent",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-dedent",
      "version": "1.0.0",
      "dependencies": {
        "dedent": "1.7.2"
      }
    },
    "node_modules/dedent": {
      "version": "1.7.2",
      "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.7.2.tgz",
      "integrity": "sha512-WzMx3mW98SN+zn3hgemf4OzdmyNhhhKz5Ay0pUfQiMQ3e1g+xmTJWp/pKdwKVXhdSkAEGIIzqeuWrL3mV/AXbA==",
      "license": "MIT",
      "peerDependencies": {
        "babel-plugin-macros": "^3.1.0"
      },
      "peerDependenciesMeta": {
        "babel-plugin-macros": {
          "optional": true
        }
      }
    }
  }
}
package.json
{
  "name": "sample-dedent",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "dedent": "1.7.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/dedent@1.7.2 multiline string indentation removal and options",
  "kind": "HOW",
  "packages": [
    "pkg:npm/dedent@1.7.2"
  ],
  "symbols": [
    "dedent"
  ]
}
test/contract.mjs
import assert from "node:assert/strict";
import dedent from "dedent";

// 1. Tagged template literal usage strips common indentation and leading/trailing blank lines
const tagged = dedent`
  line 1
    line 2
  line 3
`;
assert.equal(tagged, "line 1\n  line 2\nline 3");

// 2. Function call usage strips indentation from string input
const called = dedent(`
  function call
    indented
`);
assert.equal(called, "function call\n  indented");

// 3. Option: alignValues aligns multiline interpolated strings to the column where they are injected
const multilineItem = dedent`
  item A
  item B
`;
const aligned = dedent.withOptions({ alignValues: true })`
  Header:
    ${multilineItem}
  Footer
`;
assert.equal(aligned, "Header:\n  item A\n  item B\nFooter");

// 4. Option: trimWhitespace: false preserves leading and trailing whitespace
const untrimmed = dedent.withOptions({ trimWhitespace: false })`
  first
  second
`;
assert.equal(untrimmed, "\nfirst\nsecond\n");

// 5. Option: escapeSpecialCharacters: false keeps backslash before special characters
const escapedDefault = dedent`
  \$hello
`;
assert.equal(escapedDefault, "$hello");

const unescaped = dedent.withOptions({ escapeSpecialCharacters: false })`
  \$hello
`;
assert.equal(unescaped, "\\$hello");

console.log("Contract verified.");

Ursprungs-Seeder

anonym