Exemplo
minimatch 10.2.6: match, filter, makeRe
Amostra verificada para npm minimatch 10.2.6: match, filter, makeRe. O contrato rodou em node 22 · linux alpine/x64 · docker e passou.
sha256:8bdf5d84fbb127053fab96294b7ae5884fc2cdb8567c761c5bf5cb88e6615970
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-20 |
Caso
HOW- Objetivo
- verify pkg:npm/minimatch@10.2.6
- Pacotes
- Símbolos
-
- match
- filter
- makeRe
- braceExpand
- defaults
- Ambiente
- node 22.23.2
- Criado
- 2026-08-20T07:45:53Z
Contrato
- minimatch matches file paths against glob patterns with support for wildcards and globstars
- minimatch.match filters an array of path strings returning only elements that match a pattern
- minimatch.filter returns a predicate function compatible with Array.prototype.filter for glob matching
- minimatch.makeRe compiles a glob pattern into a regular expression instance
- minimatch.braceExpand expands brace patterns into discrete pattern permutations
- minimatch.defaults creates a bound matcher function preset with default options
Arquivos
- PROMPT.md
- csx.json
- npm-shrinkwrap.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Código-fonte
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/minimatch@10.2.6
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/minimatch@10.2.6
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:38b1efffd9ed67c53b38256a0aedc5c8fb13ddf2e3ac37be1d179f9d96b5315b","constraints":{"executionContext":"node"},"contract":["minimatch matches file paths against glob patterns with support for wildcards and globstars","minimatch.match filters an array of path strings returning only elements that match a pattern","minimatch.filter returns a predicate function compatible with Array.prototype.filter for glob matching","minimatch.makeRe compiles a glob pattern into a regular expression instance","minimatch.braceExpand expands brace patterns into discrete pattern permutations","minimatch.defaults creates a bound matcher function preset with default options"],"goal":"verify pkg:npm/minimatch@10.2.6","kind":"HOW","packages":["pkg:npm/minimatch@10.2.6"],"schemaVersion":1,"symbols":["match","filter","makeRe","braceExpand","defaults"]},"contractCommand":["node","test/contract.js"],"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/minimatch@10.2.6"],"schemaVersion":1,"symbols":["match","filter","makeRe","braceExpand","defaults"],"verifierAdapter":"node-typescript@1"}
{
"name": "minimatch-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "minimatch-sample",
"version": "1.0.0",
"dependencies": {
"minimatch": "10.2.6"
}
},
"node_modules/balanced-match": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
"integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
"license": "MIT",
"engines": {
"node": "18 || 20 || >=22"
}
},
"node_modules/brace-expansion": {
"version": "5.0.9",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
"license": "MIT",
"dependencies": {
"balanced-match": "^4.0.2"
},
"engines": {
"node": "20 || >=22"
}
},
"node_modules/minimatch": {
"version": "10.2.6",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz",
"integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==",
"license": "BlueOak-1.0.0",
"dependencies": {
"brace-expansion": "^5.0.8"
},
"engines": {
"node": "18 || 20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
}
}
}
{
"name": "minimatch-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "minimatch-sample",
"version": "1.0.0",
"dependencies": {
"minimatch": "10.2.6"
}
},
"node_modules/balanced-match": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
"integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
"license": "MIT",
"engines": {
"node": "18 || 20 || >=22"
}
},
"node_modules/brace-expansion": {
"version": "5.0.9",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
"license": "MIT",
"dependencies": {
"balanced-match": "^4.0.2"
},
"engines": {
"node": "20 || >=22"
}
},
"node_modules/minimatch": {
"version": "10.2.6",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz",
"integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==",
"license": "BlueOak-1.0.0",
"dependencies": {
"brace-expansion": "^5.0.8"
},
"engines": {
"node": "18 || 20 || >=22"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
}
}
}
{
"name": "minimatch-sample",
"version": "1.0.0",
"dependencies": {
"minimatch": "10.2.6"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/minimatch@10.2.6",
"kind": "HOW",
"packages": [
"pkg:npm/minimatch@10.2.6"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const { minimatch, match, filter, makeRe, braceExpand, defaults } = require('minimatch');
/**
* Tests if a file path matches a glob pattern.
*
* @param {string} filePath - Path to test.
* @param {string} pattern - Glob pattern.
* @param {object} [options] - Minimatch options.
* @returns {boolean} True if matched, false otherwise.
*/
function isPathMatch(filePath, pattern, options) {
return minimatch(filePath, pattern, options);
}
/**
* Filters a list of file paths by glob pattern.
*
* @param {string[]} paths - Array of path strings.
* @param {string} pattern - Glob pattern.
* @param {object} [options] - Minimatch options.
* @returns {string[]} Filtered matching paths.
*/
function filterPaths(paths, pattern, options) {
return match(paths, pattern, options);
}
/**
* Creates a predicate filter function for Array.prototype.filter.
*
* @param {string} pattern - Glob pattern.
* @param {object} [options] - Minimatch options.
* @returns {function(string): boolean} Filter predicate function.
*/
function createPathFilter(pattern, options) {
return filter(pattern, options);
}
/**
* Compiles a glob pattern into a regular expression.
*
* @param {string} pattern - Glob pattern.
* @param {object} [options] - Minimatch options.
* @returns {RegExp|false} Compiled RegExp instance or false if invalid.
*/
function compilePattern(pattern, options) {
return makeRe(pattern, options);
}
/**
* Expands brace expressions in a glob pattern into discrete permutations.
*
* @param {string} pattern - Glob pattern containing braces.
* @param {object} [options] - Minimatch options.
* @returns {string[]} Array of expanded pattern strings.
*/
function expandBraces(pattern, options) {
return braceExpand(pattern, options);
}
/**
* Creates a matcher function with pre-configured default options.
*
* @param {object} defaultOptions - Default minimatch options.
* @returns {function(string, string, object=): boolean} Bound matcher function.
*/
function createScopedMatcher(defaultOptions) {
return defaults(defaultOptions);
}
module.exports = {
isPathMatch,
filterPaths,
createPathFilter,
compilePattern,
expandBraces,
createScopedMatcher,
};
const assert = require('node:assert/strict');
const {
isPathMatch,
filterPaths,
createPathFilter,
compilePattern,
expandBraces,
createScopedMatcher,
} = require('../src/index.js');
// Contract 1: minimatch matches file paths against glob patterns with support for wildcards and globstars
{
assert.strictEqual(isPathMatch('src/components/Button.jsx', 'src/**/*.jsx'), true);
assert.strictEqual(isPathMatch('src/components/Button.tsx', 'src/**/*.jsx'), false);
assert.strictEqual(isPathMatch('data/report_2026.csv', 'data/report_[0-9]*.csv'), true);
assert.strictEqual(isPathMatch('DATA/REPORT_2026.CSV', 'data/report_[0-9]*.csv', { nocase: true }), true);
}
// Contract 2: minimatch.match filters an array of path strings returning only elements that match a pattern
{
const fileList = [
'src/index.js',
'src/utils/helpers.js',
'src/components/App.tsx',
'test/index.test.js',
'docs/readme.md',
];
const jsFiles = filterPaths(fileList, 'src/**/*.js');
assert.deepStrictEqual(jsFiles, ['src/index.js', 'src/utils/helpers.js']);
}
// Contract 3: minimatch.filter returns a predicate function compatible with Array.prototype.filter for glob matching
{
const entries = ['main.ts', 'server.js', 'client.ts', 'styles.css'];
const tsFilter = createPathFilter('*.ts');
const result = entries.filter(tsFilter);
assert.deepStrictEqual(result, ['main.ts', 'client.ts']);
}
// Contract 4: minimatch.makeRe compiles a glob pattern into a regular expression instance
{
const regex = compilePattern('build/**/*.bundle.js');
assert.ok(regex instanceof RegExp);
assert.strictEqual(regex.test('build/static/app.bundle.js'), true);
assert.strictEqual(regex.test('build/static/app.chunk.css'), false);
}
// Contract 5: minimatch.braceExpand expands brace patterns into discrete pattern permutations
{
const pattern = 'pkg/{src,test}/*.{js,mjs}';
const expanded = expandBraces(pattern);
assert.deepStrictEqual(expanded, [
'pkg/src/*.js',
'pkg/src/*.mjs',
'pkg/test/*.js',
'pkg/test/*.mjs',
]);
}
// Contract 6: minimatch.defaults creates a bound matcher function preset with default options
{
const dotMatcher = createScopedMatcher({ dot: true });
assert.strictEqual(dotMatcher('.configrc', '*'), true);
assert.strictEqual(isPathMatch('.configrc', '*'), false);
}
Seeder de origem
anônimo