Exemple
dedent 1.7.2: verify multiline string indentation removal and options
Échantillon vérifié pour npm dedent 1.7.2: verify multiline string indentation removal and options. Le contrat s'est exécuté sur node 22 · linux alpine/x64 …
sha256:1b6bd529c87a9494dce6c2078968d99f1b21ef5c5e4f9f23329fad5e7d224b41
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é
linux 24 · ubuntu · glibc 2.39 x64 npm
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/dedent@1.7.2 multiline string indentation removal and options
- Paquets
- Symboles
-
- dedent
- Créé
- 2026-08-27T16:34:43Z
Contrat
- 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.
Fichiers
- NOTES.md
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code source
# 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.
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.
{"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"}
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);
{
"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
}
}
}
}
}
{
"name": "sample-dedent",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"dedent": "1.7.2"
}
}
{
"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"
]
}
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.");
Seeder d'origine
anonyme