샘플
micromatch 4.0.8: capture
검증된 샘플 — npm micromatch 4.0.8: capture. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: micromatch.capture is exported as a function on the…
sha256:90ee8a050ea6f16a9f4c6e3886128780b713a8a9068ddda700c9cc8ec32eca0b
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 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-28 |
케이스
HOW- 목표
- verify micromatch.capture in pkg:npm/micromatch@4.0.8
- 패키지
- 심벌
-
- micromatch.capture
- 환경
- node 22.23.2
- 생성일
- 2026-08-28T02:39:22Z
컨트랙트
- micromatch.capture is exported as a function on the micromatch module
- micromatch.capture extracts matching wildcard segments from a path into an array of strings
- micromatch.capture captures multiple glob segments and globstars across path components
- micromatch.capture supports regex capture groups and patterns
- micromatch.capture respects match options such as dot and nocase
- micromatch.capture returns an empty array when matching a literal pattern without glob wildcards
- micromatch.capture returns undefined when the input string does not match the glob pattern
- micromatch.capture returns undefined when the pattern or input is null, undefined, or non-string
- micromatch.capture throws TypeError when the pattern is an empty string
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- 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 micromatch.capture in pkg:npm/micromatch@4.0.8
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/micromatch@4.0.8
Demonstrate these symbols/APIs:
- micromatch.capture
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:208221cb6a8bfb9dae8121f53cee04e4489d18bdf094c44e80e9ab5741bf10d4","contract":["micromatch.capture is exported as a function on the micromatch module","micromatch.capture extracts matching wildcard segments from a path into an array of strings","micromatch.capture captures multiple glob segments and globstars across path components","micromatch.capture supports regex capture groups and patterns","micromatch.capture respects match options such as dot and nocase","micromatch.capture returns an empty array when matching a literal pattern without glob wildcards","micromatch.capture returns undefined when the input string does not match the glob pattern","micromatch.capture returns undefined when the pattern or input is null, undefined, or non-string","micromatch.capture throws TypeError when the pattern is an empty string"],"goal":"verify micromatch.capture in pkg:npm/micromatch@4.0.8","kind":"HOW","packages":["pkg:npm/micromatch@4.0.8"],"schemaVersion":1,"symbols":["micromatch.capture"]},"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/micromatch@4.0.8"],"schemaVersion":1,"subject":"pkg:npm/micromatch@4.0.8","symbols":["micromatch.capture"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-micromatch-capture",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-micromatch-capture",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"micromatch": "4.0.8"
}
},
"node_modules/braces": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
"license": "MIT",
"dependencies": {
"fill-range": "^7.1.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/fill-range": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
"license": "MIT",
"dependencies": {
"to-regex-range": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"license": "MIT",
"engines": {
"node": ">=0.12.0"
}
},
"node_modules/micromatch": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"license": "MIT",
"dependencies": {
"braces": "^3.0.3",
"picomatch": "^2.3.1"
},
"engines": {
"node": ">=8.6"
}
},
"node_modules/picomatch": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
"integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
"license": "MIT",
"engines": {
"node": ">=8.6"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"license": "MIT",
"dependencies": {
"is-number": "^7.0.0"
},
"engines": {
"node": ">=8.0"
}
}
}
}
{
"name": "sample-micromatch-capture",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of micromatch.capture in micromatch@4.0.8",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"micromatch": "4.0.8"
}
}
{
"schemaVersion": 1,
"goal": "verify micromatch.capture in pkg:npm/micromatch@4.0.8",
"kind": "HOW",
"packages": [
"pkg:npm/micromatch@4.0.8"
],
"symbols": [
"micromatch.capture"
]
}
const micromatch = require('micromatch');
/**
* Capture glob wildcard values from a target string.
*
* @param {string} pattern - Glob pattern containing wildcards or capture groups
* @param {string} input - Target string to match against
* @param {object} [options] - Micromatch options (e.g. dot, nocase)
* @returns {string[]|undefined} Array of captured segments, or undefined if no match
*/
function captureSegments(pattern, input, options) {
return micromatch.capture(pattern, input, options);
}
/**
* Check whether a target string matches a glob pattern and return the captured values.
*
* @param {string} pattern - Glob pattern
* @param {string} input - Target string
* @param {object} [options] - Micromatch options
* @returns {{ matched: boolean, captures: string[]|null }} Match result object
*/
function matchAndCapture(pattern, input, options) {
const result = micromatch.capture(pattern, input, options);
if (result === undefined) {
return { matched: false, captures: null };
}
return { matched: true, captures: result };
}
module.exports = {
micromatch,
capture: micromatch.capture,
captureSegments,
matchAndCapture
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
micromatch,
capture,
captureSegments,
matchAndCapture
} = require('../src/index.js');
// 1. Module and function export verification
assert.equal(typeof micromatch, 'function', 'micromatch must be a function');
assert.equal(typeof micromatch.capture, 'function', 'micromatch.capture must be a function');
assert.equal(typeof capture, 'function', 'capture must be a function');
assert.equal(typeof captureSegments, 'function', 'captureSegments helper must be a function');
assert.equal(typeof matchAndCapture, 'function', 'matchAndCapture helper must be a function');
assert.equal(capture, micromatch.capture, 'capture should reference micromatch.capture');
// 2. Extracts matching wildcard segments from a path into an array of strings
const singleWildcard = micromatch.capture('test/*', 'test/foo');
assert.deepEqual(singleWildcard, ['foo'], 'single wildcard should capture the path segment');
assert.deepEqual(captureSegments('test/*', 'test/foo'), ['foo'], 'captureSegments should return captured array');
const fileExtCapture = micromatch.capture('src/*.js', 'src/server.js');
assert.deepEqual(fileExtCapture, ['server'], 'wildcard before extension should capture base name');
const prefixSuffixCapture = micromatch.capture('release-v*.tar.gz', 'release-v1.2.3.tar.gz');
assert.deepEqual(prefixSuffixCapture, ['1.2.3'], 'wildcard between prefix and suffix should capture middle part');
// 3. Captures multiple glob segments and globstars across path components
const multiSegments = micromatch.capture('*/*/*.ts', 'src/core/parser.ts');
assert.deepEqual(multiSegments, ['src', 'core', 'parser'], 'multiple wildcards should capture all path segments');
const globstarCapture = micromatch.capture('docs/**', 'docs/guides/advanced/setup.md');
assert.deepEqual(globstarCapture, ['guides/advanced/setup.md'], 'globstar should capture multi-level subpaths');
const globstarWithSuffix = micromatch.capture('packages/**/package.json', 'packages/client/sub/package.json');
assert.deepEqual(globstarWithSuffix, ['client/sub'], 'globstar between paths should capture intermediate path');
// 4. Supports regex capture groups and patterns
const regexGroup = micromatch.capture('*(a|b)/*', 'a/item');
assert.deepEqual(regexGroup, ['a', 'item'], 'extglob capture group should capture matching branch');
const extglobChoice = micromatch.capture('@(api|v1)/*.json', 'api/users.json');
assert.deepEqual(extglobChoice, ['api', 'users'], 'extglob choice should capture matched token');
// 5. Respects match options such as dot and nocase
const dotHiddenDefault = micromatch.capture('*', '.env');
assert.equal(dotHiddenDefault, undefined, 'dotfile should not match by default without dot option');
const dotHiddenEnabled = micromatch.capture('*', '.env', { dot: true });
assert.deepEqual(dotHiddenEnabled, ['.env'], 'dotfile should be captured when dot: true');
const nocaseDefault = micromatch.capture('foo/*', 'FOO/bar');
assert.equal(nocaseDefault, undefined, 'case mismatch should return undefined by default');
const nocaseEnabled = micromatch.capture('foo/*', 'FOO/bar', { nocase: true });
assert.deepEqual(nocaseEnabled, ['bar'], 'nocase: true should allow case-insensitive capture');
// 6. Returns an empty array when matching a literal pattern without glob wildcards
const literalMatch = micromatch.capture('config/settings.json', 'config/settings.json');
assert.deepEqual(literalMatch, [], 'literal match without glob characters should return empty array');
// 7. Returns undefined when the input string does not match the glob pattern
const nonMatching = micromatch.capture('src/*.ts', 'lib/index.js');
assert.equal(nonMatching, undefined, 'non-matching input should return undefined');
const helperNoMatch = matchAndCapture('src/*.ts', 'lib/index.js');
assert.deepEqual(helperNoMatch, { matched: false, captures: null }, 'helper should return structured non-match');
const helperMatch = matchAndCapture('src/*.ts', 'src/index.ts');
assert.deepEqual(helperMatch, { matched: true, captures: ['index'] }, 'helper should return structured match');
// 8. Returns undefined when the pattern or input is null, undefined, or non-string
assert.equal(micromatch.capture(null, 'foo/bar'), undefined, 'null pattern should return undefined');
assert.equal(micromatch.capture(undefined, 'foo/bar'), undefined, 'undefined pattern should return undefined');
assert.equal(micromatch.capture(123, 'foo/bar'), undefined, 'numeric pattern should return undefined');
assert.equal(micromatch.capture('foo/*', null), undefined, 'null input should return undefined');
assert.equal(micromatch.capture('foo/*', undefined), undefined, 'undefined input should return undefined');
assert.equal(micromatch.capture('foo/*', 123), undefined, 'numeric input should return undefined');
// 9. Throws TypeError when the pattern is an empty string
assert.throws(
() => micromatch.capture('', 'foo/bar'),
{
name: 'TypeError',
message: /Expected a non-empty string/
},
'micromatch.capture should throw TypeError when pattern is empty string'
);
console.log('All contract assertions passed successfully.');
오리진 시더
익명