サンプル
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
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
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.');
オリジンシーダー
匿名