Sample
strip-final-newline 2.0.0
Verified sample for npm strip-final-newline 2.0.0. The contract ran on node 22 · linux alpine/x64 · docker and passed: stripFinalNewline removes a single…
sha256:171441a697fd850f25cb5d9170b588b6a5c29249dcbd79c2d0ae5d328482a72a
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux 24 · ubuntu · glibc 2.39 x64 npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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-28 |
Case
HOW- Goal
- verify pkg:npm/strip-final-newline@2.0.0
- Packages
- Created
- 2026-08-28T08:57:41Z
Contract
- stripFinalNewline removes a single trailing LF (\n) from a string
- stripFinalNewline removes a single trailing CRLF (\r\n) from a string
- stripFinalNewline preserves preceding newlines and only strips the final newline
- stripFinalNewline leaves strings without trailing newlines unchanged
- stripFinalNewline handles empty strings by returning an empty string
- stripFinalNewline removes trailing newline bytes from Buffer and Uint8Array instances
- stripFinalNewline preserves Buffer content when no trailing newline bytes exist
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
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/strip-final-newline@2.0.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/strip-final-newline@2.0.0
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:d63699b45a124ce8117a24e5f3de8b4e5f6910d1eefb4d1dcae045baec607d38","contract":["stripFinalNewline removes a single trailing LF (\\n) from a string","stripFinalNewline removes a single trailing CRLF (\\r\\n) from a string","stripFinalNewline preserves preceding newlines and only strips the final newline","stripFinalNewline leaves strings without trailing newlines unchanged","stripFinalNewline handles empty strings by returning an empty string","stripFinalNewline removes trailing newline bytes from Buffer and Uint8Array instances","stripFinalNewline preserves Buffer content when no trailing newline bytes exist"],"goal":"verify pkg:npm/strip-final-newline@2.0.0","kind":"HOW","packages":["pkg:npm/strip-final-newline@2.0.0"],"schemaVersion":1},"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/strip-final-newline@2.0.0"],"schemaVersion":1,"subject":"pkg:npm/strip-final-newline@2.0.0","verifierAdapter":"node-typescript@1"}
{
"name": "sample-strip-final-newline",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-strip-final-newline",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"strip-final-newline": "2.0.0"
}
},
"node_modules/strip-final-newline": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz",
"integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==",
"license": "MIT",
"engines": {
"node": ">=6"
}
}
}
}
{
"name": "sample-strip-final-newline",
"version": "1.0.0",
"private": true,
"description": "Clean-room code sample for strip-final-newline@2.0.0",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"strip-final-newline": "2.0.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/strip-final-newline@2.0.0",
"kind": "HOW",
"packages": [
"pkg:npm/strip-final-newline@2.0.0"
]
}
'use strict';
const stripFinalNewline = require('strip-final-newline');
/**
* Strips the final newline character from a string or Buffer/Uint8Array.
*
* @param {string|Buffer|Uint8Array} input - The input string or buffer.
* @returns {string|Buffer|Uint8Array} - The input without the trailing newline.
*/
function stripNewline(input) {
return stripFinalNewline(input);
}
module.exports = {
stripFinalNewline,
stripNewline
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { stripFinalNewline, stripNewline } = require('../src/index.js');
async function testAll() {
// 1. Export verification
assert.equal(typeof stripFinalNewline, 'function', 'stripFinalNewline must be a function');
assert.equal(typeof stripNewline, 'function', 'stripNewline helper must be a function');
// 2. Trailing LF (\n) removal from string
assert.equal(
stripFinalNewline('hello world\n'),
'hello world',
'should strip trailing LF'
);
assert.equal(
stripNewline('foo\n'),
'foo',
'helper should strip trailing LF'
);
// 3. Trailing CRLF (\r\n) removal from string
assert.equal(
stripFinalNewline('hello world\r\n'),
'hello world',
'should strip trailing CRLF'
);
assert.equal(
stripFinalNewline('windows style line\r\n'),
'windows style line',
'should strip trailing CRLF'
);
// 4. Multiple trailing newlines: only the last newline is removed
assert.equal(
stripFinalNewline('hello\n\n'),
'hello\n',
'should only strip the single final LF when multiple trailing newlines exist'
);
assert.equal(
stripFinalNewline('hello\r\n\r\n'),
'hello\r\n',
'should only strip the single final CRLF when multiple trailing newlines exist'
);
assert.equal(
stripFinalNewline('first line\nsecond line\n'),
'first line\nsecond line',
'should preserve intermediate newlines and strip final newline'
);
// 5. Strings without trailing newline remain unchanged
assert.equal(
stripFinalNewline('hello world'),
'hello world',
'should not modify strings without trailing newlines'
);
assert.equal(
stripFinalNewline(''),
'',
'should return empty string for empty string input'
);
assert.equal(
stripFinalNewline('\n'),
'',
'single newline should become empty string'
);
assert.equal(
stripFinalNewline('\r\n'),
'',
'single CRLF should become empty string'
);
// 6. Buffer / Uint8Array support: removes trailing LF and CRLF
const bufLF = Buffer.from('hello buffer\n');
const strippedBufLF = stripFinalNewline(bufLF);
assert.ok(Buffer.isBuffer(strippedBufLF), 'result should be a Buffer');
assert.equal(strippedBufLF.toString('utf8'), 'hello buffer', 'Buffer with trailing LF should be stripped');
const bufCRLF = Buffer.from('hello buffer\r\n');
const strippedBufCRLF = stripFinalNewline(bufCRLF);
assert.ok(Buffer.isBuffer(strippedBufCRLF), 'result should be a Buffer');
assert.equal(strippedBufCRLF.toString('utf8'), 'hello buffer', 'Buffer with trailing CRLF should be stripped');
const uint8LF = new Uint8Array([104, 101, 121, 10]); // "hey\n"
const strippedUint8 = stripFinalNewline(uint8LF);
assert.deepEqual(Array.from(strippedUint8), [104, 101, 121], 'Uint8Array with trailing LF should be stripped');
// 7. Buffer without trailing newline remains intact
const bufNoNL = Buffer.from('no newline');
const strippedNoNL = stripFinalNewline(bufNoNL);
assert.equal(strippedNoNL.toString('utf8'), 'no newline', 'Buffer without trailing newline should be unchanged');
console.log('All strip-final-newline contract tests passed successfully.');
}
testAll().catch((err) => {
console.error('Contract test failure:', err);
process.exit(1);
});
Origin Seeder
anonymous