샘플
get-caller-file 2.0.5
검증된 샘플 — npm get-caller-file 2.0.5. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: getCallerFile returns the caller file path of the invoking…
sha256:7db40b3af8c39f559c459dbb1e0bb29459aab82c46e44bf0ed40cb4f59317b10
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 2
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-23 |
| 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 pkg:npm/get-caller-file@2.0.5
- 생성일
- 2026-08-23T08:22:27Z
컨트랙트
- getCallerFile returns the caller file path of the invoking function at default position 2
- getCallerFile inspects callers at custom stack depth positions
- getCallerFile throws TypeError when position depth exceeds or equals Error.stackTraceLimit
- getCallerFile preserves existing Error.prepareStackTrace handler across invocations
- getCallerFile returns undefined when requested stack position exceeds stack depth within limits
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- 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 pkg:npm/get-caller-file@2.0.5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/get-caller-file@2.0.5
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:bd427d4cca7e34f8cccfe0b0591517cb275e78be87ee3c13c9c712630c9ea74d","contract":["getCallerFile returns the caller file path of the invoking function at default position 2","getCallerFile inspects callers at custom stack depth positions","getCallerFile throws TypeError when position depth exceeds or equals Error.stackTraceLimit","getCallerFile preserves existing Error.prepareStackTrace handler across invocations","getCallerFile returns undefined when requested stack position exceeds stack depth within limits"],"goal":"verify pkg:npm/get-caller-file@2.0.5","kind":"HOW","packages":["pkg:npm/get-caller-file@2.0.5"],"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/get-caller-file@2.0.5"],"schemaVersion":1,"subject":"pkg:npm/get-caller-file@2.0.5","verifierAdapter":"node-typescript@1"}
{
"name": "sample-get-caller-file",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-get-caller-file",
"version": "1.0.0",
"dependencies": {
"get-caller-file": "2.0.5"
}
},
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"license": "ISC",
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
}
}
}
{
"name": "sample-get-caller-file",
"version": "1.0.0",
"type": "module",
"private": true,
"description": "Clean-room code sample for get-caller-file@2.0.5",
"main": "src/index.mjs",
"license": "MIT-0",
"dependencies": {
"get-caller-file": "2.0.5"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/get-caller-file@2.0.5",
"kind": "HOW",
"packages": [
"pkg:npm/get-caller-file@2.0.5"
]
}
import getCallerFile from 'get-caller-file';
/**
* Returns the caller file of the immediate invocation.
*
* @param {number} [position=2] - The stack frame position to inspect.
* @returns {string|undefined} Caller file path or undefined if out of range.
*/
export function whoCalledMe(position) {
return getCallerFile(position);
}
/**
* Returns the caller of the outer caller using an increased stack position depth.
*
* @returns {string|undefined} Caller file path.
*/
export function nestedCaller() {
return whoCalledMe(3);
}
export default getCallerFile;
import assert from 'node:assert/strict';
import { fileURLToPath } from 'node:url';
import getCallerFile, { whoCalledMe, nestedCaller } from '../src/index.mjs';
// 1. getCallerFile returns the caller file path of the invoking function at default position 2
function directCaller() {
return getCallerFile();
}
const thisFilePath = fileURLToPath(import.meta.url);
const callerResult = directCaller();
assert.ok(callerResult, 'callerResult should be non-empty string');
assert.ok(
callerResult === import.meta.url || callerResult === thisFilePath || callerResult.includes('contract.mjs'),
`callerResult (${callerResult}) should match contract.mjs`
);
// Helper function whoCalledMe correctly resolves caller to test/contract.mjs
const helperCaller = whoCalledMe();
assert.ok(helperCaller, 'helperCaller should be non-empty string');
assert.ok(
helperCaller === import.meta.url || helperCaller === thisFilePath || helperCaller.includes('contract.mjs'),
`helperCaller (${helperCaller}) should reference contract.mjs`
);
// 2. getCallerFile inspects callers at custom stack depth positions
function outerCaller() {
return nestedCaller();
}
const nestedResult = outerCaller();
assert.ok(nestedResult, 'nestedResult should be non-empty string');
assert.ok(
nestedResult === import.meta.url || nestedResult === thisFilePath || nestedResult.includes('contract.mjs'),
`nestedResult (${nestedResult}) should resolve to contract.mjs`
);
// 3. getCallerFile throws TypeError when position depth exceeds or equals Error.stackTraceLimit
assert.throws(
() => getCallerFile(Error.stackTraceLimit),
{
name: 'TypeError'
},
'getCallerFile should throw TypeError when position >= Error.stackTraceLimit'
);
// 4. getCallerFile preserves existing Error.prepareStackTrace handler across invocations
const customPrepareStackTrace = (_, stack) => stack;
Error.prepareStackTrace = customPrepareStackTrace;
try {
directCaller();
assert.equal(Error.prepareStackTrace, customPrepareStackTrace, 'prepareStackTrace handler should be preserved');
} finally {
Error.prepareStackTrace = undefined;
}
// 5. getCallerFile returns undefined when requested stack position exceeds stack depth within limits
const originalLimit = Error.stackTraceLimit;
Error.stackTraceLimit = 50;
try {
const outOfRange = getCallerFile(40);
assert.equal(outOfRange, undefined, 'out of range position should return undefined');
} finally {
Error.stackTraceLimit = originalLimit;
}
console.log('All pkg:npm/get-caller-file@2.0.5 contract assertions passed successfully.');
오리진 시더
익명