Sample
micromatch 4.0.8: scan
Verified sample for npm micromatch 4.0.8: scan. The contract ran on node 22 · linux alpine/x64 · docker and passed: micromatch.scan is exported as a function…
sha256:764a06eaa7c89a10388debf253ce962c68b17718f1f6dcc86aa743cf4d726555
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
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
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-27 |
Case
HOW- Goal
- verify micromatch.scan in pkg:npm/micromatch@4.0.8
- Packages
- Symbols
-
- micromatch.scan
- Environment
- node 22.23.2
- Created
- 2026-08-27T13:25:32Z
Contract
- micromatch.scan is exported as a function on the micromatch module
- micromatch.scan parses a glob pattern into base directory and glob suffix
- micromatch.scan detects leading prefixes and negation flag
- micromatch.scan returns path segments when parts option is enabled
- micromatch.scan returns token metadata with depth and glob flags when tokens option is enabled
- micromatch.scan identifies literal paths without glob characters as isGlob false
- micromatch.scan throws TypeError when input is null or undefined
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 micromatch.scan 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.scan
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:7930bd2b8f129a9beb6845ed0911304529d2c319c0b4324a8b5bdbcc26c1a0b8","contract":["micromatch.scan is exported as a function on the micromatch module","micromatch.scan parses a glob pattern into base directory and glob suffix","micromatch.scan detects leading prefixes and negation flag","micromatch.scan returns path segments when parts option is enabled","micromatch.scan returns token metadata with depth and glob flags when tokens option is enabled","micromatch.scan identifies literal paths without glob characters as isGlob false","micromatch.scan throws TypeError when input is null or undefined"],"goal":"verify micromatch.scan in pkg:npm/micromatch@4.0.8","kind":"HOW","packages":["pkg:npm/micromatch@4.0.8"],"schemaVersion":1,"symbols":["micromatch.scan"]},"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.scan"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-micromatch-scan",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-micromatch-scan",
"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-scan",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of micromatch.scan in micromatch@4.0.8",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"micromatch": "4.0.8"
}
}
{
"schemaVersion": 1,
"goal": "verify micromatch.scan in pkg:npm/micromatch@4.0.8",
"kind": "HOW",
"packages": [
"pkg:npm/micromatch@4.0.8"
],
"symbols": [
"micromatch.scan"
]
}
const micromatch = require('micromatch');
/**
* Scan a glob pattern and return parsed metadata.
*
* @param {string} pattern - Glob pattern or path to scan
* @param {object} [options] - Micromatch scan options
* @returns {object} Scan result containing base, glob, isGlob, etc.
*/
function scanPattern(pattern, options) {
return micromatch.scan(pattern, options);
}
/**
* Extract the static base directory prefix from a glob pattern.
*
* @param {string} pattern - Glob pattern to scan
* @returns {string} Static base path before any glob syntax
*/
function getBaseDirectory(pattern) {
const parsed = micromatch.scan(pattern);
return parsed.base;
}
/**
* Check if the given pattern contains any glob characters.
*
* @param {string} pattern - Pattern to check
* @returns {boolean} True if the pattern contains glob syntax
*/
function isGlobPattern(pattern) {
const parsed = micromatch.scan(pattern);
return Boolean(parsed.isGlob);
}
module.exports = {
micromatch,
scan: micromatch.scan,
scanPattern,
getBaseDirectory,
isGlobPattern
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
micromatch,
scan,
scanPattern,
getBaseDirectory,
isGlobPattern
} = require('../src/index.js');
// 1. Module and function export verification
assert.equal(typeof micromatch, 'function', 'micromatch must be a function');
assert.equal(typeof micromatch.scan, 'function', 'micromatch.scan must be a function');
assert.equal(typeof scan, 'function', 'scan must be a function');
assert.equal(typeof scanPattern, 'function', 'scanPattern must be a function');
assert.equal(typeof getBaseDirectory, 'function', 'getBaseDirectory must be a function');
assert.equal(typeof isGlobPattern, 'function', 'isGlobPattern must be a function');
assert.equal(scan, micromatch.scan, 'scan should reference micromatch.scan');
// 2. Parses glob pattern into base directory and glob suffix
const parsed = micromatch.scan('src/components/**/*.tsx');
assert.equal(parsed.base, 'src/components', 'base should extract directory prefix before globs');
assert.equal(parsed.glob, '**/*.tsx', 'glob should extract the pattern portion');
assert.equal(parsed.isGlob, true, 'isGlob should be true for glob patterns');
assert.equal(parsed.negated, false, 'negated should be false for standard patterns');
assert.equal(getBaseDirectory('src/components/**/*.tsx'), 'src/components', 'getBaseDirectory helper should match base');
assert.equal(isGlobPattern('src/components/**/*.tsx'), true, 'isGlobPattern helper should be true');
// 3. Detects leading prefixes and negation flag
const negatedScan = micromatch.scan('!./assets/*.png');
assert.equal(negatedScan.prefix, '!./', 'prefix should capture leading negation and relative prefix');
assert.equal(negatedScan.base, 'assets', 'base should resolve to directory');
assert.equal(negatedScan.glob, '*.png', 'glob should capture wildcard filename');
assert.equal(negatedScan.negated, true, 'negated should be true when pattern starts with exclamation');
// 4. Returns path segments when parts option is enabled
const partsScan = micromatch.scan('app/routes/admin/*.js', { parts: true });
assert.equal(partsScan.isGlob, true, 'isGlob should be true');
assert.deepEqual(partsScan.parts, ['app', 'routes', 'admin', '*.js'], 'parts should contain array of path segments');
assert.equal(partsScan.base, 'app/routes/admin', 'base should be app/routes/admin');
assert.equal(partsScan.glob, '*.js', 'glob should be *.js');
// 5. Returns token metadata with depth and glob flags when tokens option is enabled
const tokensScan = micromatch.scan('src/utils/*.ts', { tokens: true });
assert.equal(Array.isArray(tokensScan.tokens), true, 'tokens should be an array');
assert.equal(tokensScan.tokens.length, 3, 'tokens should have 3 segments');
assert.deepEqual(
tokensScan.tokens,
[
{ value: 'src', depth: 1, isGlob: false },
{ value: 'utils', depth: 1, isGlob: false },
{ value: '*.ts', depth: 1, isGlob: true }
],
'tokens array should have segment values, depth, and isGlob flags'
);
// 6. Identifies literal paths without glob characters as isGlob false
const literalScan = micromatch.scan('config/settings.json');
assert.equal(literalScan.isGlob, false, 'isGlob should be false for non-glob path');
assert.equal(literalScan.base, 'config/settings.json', 'base should equal full path when no glob');
assert.equal(literalScan.glob, '', 'glob should be empty string for literal path');
assert.equal(getBaseDirectory('config/settings.json'), 'config/settings.json', 'getBaseDirectory should return full path');
assert.equal(isGlobPattern('config/settings.json'), false, 'isGlobPattern should return false');
// 7. Throws TypeError when input is null or undefined
assert.throws(
() => micromatch.scan(null),
{
name: 'TypeError'
},
'micromatch.scan should throw TypeError when pattern is null'
);
assert.throws(
() => micromatch.scan(undefined),
{
name: 'TypeError'
},
'micromatch.scan should throw TypeError when pattern is undefined'
);
console.log('Contract tests passed successfully.');
Origin Seeder
anonymous