샘플
sprintf-js 1.1.3: sprintf
검증된 샘플 — npm sprintf-js 1.1.3: sprintf. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: assert string formatting with %s placeholder replaces…
sha256:fb16a10dc7e1ca3706d241b834cf38ba14a01dd374ee2cdf7afe0265bf99c74a
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-26 |
| 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 |
케이스
HOW- 목표
- verify sprintf in pkg:npm/sprintf-js@1.1.3
- 패키지
- 심벌
-
- sprintf
- 환경
- node 22.23.2
- 생성일
- 2026-08-26T11:20:10Z
컨트랙트
- assert string formatting with %s placeholder replaces string values accurately
- assert integer formatting supports zero padding and explicit positive and negative signs
- assert floating point formatting with precision specifier formats decimal places
- assert hexadecimal and binary format specifiers convert integers to hex and binary representations
- assert named parameter substitution replaces dictionary keys in format strings
- assert positional argument specifiers allow argument swapping and indexing
- assert JSON specifier %j serializes objects to JSON strings
- assert vsprintf formats strings using an array of arguments
파일
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
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 sprintf in pkg:npm/sprintf-js@1.1.3
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/sprintf-js@1.1.3
Demonstrate these symbols/APIs:
- sprintf
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- 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.
{"case":{"caseId":"case:sha256:61bad7e92f057138d1c806fe1ed48162aabfae76b736dfe16cebb40b422c49b4","constraints":{"executionContext":"node"},"contract":["assert string formatting with %s placeholder replaces string values accurately","assert integer formatting supports zero padding and explicit positive and negative signs","assert floating point formatting with precision specifier formats decimal places","assert hexadecimal and binary format specifiers convert integers to hex and binary representations","assert named parameter substitution replaces dictionary keys in format strings","assert positional argument specifiers allow argument swapping and indexing","assert JSON specifier %j serializes objects to JSON strings","assert vsprintf formats strings using an array of arguments"],"goal":"verify sprintf in pkg:npm/sprintf-js@1.1.3","kind":"HOW","packages":["pkg:npm/sprintf-js@1.1.3"],"schemaVersion":1,"symbols":["sprintf"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/sprintf-js@1.1.3"],"schemaVersion":1,"subject":"pkg:npm/sprintf-js@1.1.3","symbols":["sprintf"],"verifierAdapter":"node-typescript@1"}
const { sprintf, vsprintf } = require('sprintf-js');
function formatString(format, ...args) {
return sprintf(format, ...args);
}
function formatWithNamedKeys(format, obj) {
return sprintf(format, obj);
}
function formatWithPosition(format, ...args) {
return sprintf(format, ...args);
}
function formatNumber(format, num) {
return sprintf(format, num);
}
function formatJson(format, value) {
return sprintf(format, value);
}
function formatArray(format, argsArray) {
return vsprintf(format, argsArray);
}
module.exports = {
sprintf,
vsprintf,
formatString,
formatWithNamedKeys,
formatWithPosition,
formatNumber,
formatJson,
formatArray,
};
{
"name": "sample-sprintf-js",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-sprintf-js",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"sprintf-js": "1.1.3"
}
},
"node_modules/sprintf-js": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
"integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==",
"license": "BSD-3-Clause"
}
}
}
{
"name": "sample-sprintf-js",
"version": "1.0.0",
"description": "Minimal clean-room sample verifying sprintf formatting in sprintf-js",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"sprintf-js": "1.1.3"
}
}
{
"schemaVersion": 1,
"goal": "verify sprintf in pkg:npm/sprintf-js@1.1.3",
"kind": "HOW",
"packages": [
"pkg:npm/sprintf-js@1.1.3"
],
"symbols": [
"sprintf"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert';
import { sprintf, vsprintf } from 'sprintf-js';
import {
formatString,
formatWithNamedKeys,
formatWithPosition,
formatNumber,
formatJson,
formatArray,
} from '../index.js';
// 1. Basic string formatting with %s placeholder
const strResult = formatString('Hello, %s!', 'World');
assert.strictEqual(strResult, 'Hello, World!', 'Basic %s replacement must format properly');
// 2. Integer formatting with padding and signs
const paddedInt = formatNumber('%05d', 42);
assert.strictEqual(paddedInt, '00042', 'Integer with zero padding %05d must output 00042');
const positiveSigned = formatNumber('%+d', 100);
assert.strictEqual(positiveSigned, '+100', 'Positive integer with %+d must include plus sign');
const negativeSigned = formatNumber('%+d', -100);
assert.strictEqual(negativeSigned, '-100', 'Negative integer with %+d must include minus sign');
// 3. Floating point precision formatting with %f
const floatResult = formatNumber('%.2f', 3.141592);
assert.strictEqual(floatResult, '3.14', 'Floating point formatting %.2f must round to 2 decimals');
// 4. Hexadecimal and binary formatting with %x, %X, %b
const hexLower = formatNumber('%x', 255);
assert.strictEqual(hexLower, 'ff', 'Hexadecimal %x must output lowercase hex');
const hexUpper = formatNumber('%X', 255);
assert.strictEqual(hexUpper, 'FF', 'Hexadecimal %X must output uppercase hex');
const binaryVal = formatNumber('%b', 13);
assert.strictEqual(binaryVal, '1101', 'Binary %b must output binary string');
// 5. Named parameter substitution with %(key)s
const namedResult = formatWithNamedKeys('User %(name)s has %(count)d unread messages', {
name: 'Alice',
count: 5,
});
assert.strictEqual(
namedResult,
'User Alice has 5 unread messages',
'Named placeholder substitution must replace named keys'
);
// 6. Positional argument indexing (%2$s %1$s)
const posResult = formatWithPosition('%2$s comes before %1$s', 'second', 'First');
assert.strictEqual(
posResult,
'First comes before second',
'Positional argument indexing must swap arguments as specified'
);
// 7. JSON object formatting with %j
const jsonResult = formatJson('%j', { id: 1, active: true });
assert.strictEqual(
jsonResult,
'{"id":1,"active":true}',
'JSON formatting %j must serialize object to compact JSON'
);
// 8. Array argument formatting with vsprintf
const arrayResult = formatArray('%s is %d years old', ['Bob', 30]);
assert.strictEqual(
arrayResult,
'Bob is 30 years old',
'vsprintf must format string using an array of arguments'
);
console.log('All sprintf contract assertions passed.');
오리진 시더
익명