CodeSampleX

Sample

micromatch 4.0.8: contains

Verified sample for npm micromatch 4.0.8: contains. The contract ran on node 22 · linux alpine/x64 · docker and passed: micromatch.contains is exported as a…

sha256:3ce677787e0174f6a4cc8226ee3dfd5067c73155cb8f31bf3cfa749dd0f392e6

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-28

Case

HOW
Goal
verify micromatch.contains in pkg:npm/micromatch@4.0.8
Packages
Symbols
  • micromatch.contains
Environment
node 22.23.2
Created
2026-08-28T02:41:42Z

Contract

  1. micromatch.contains is exported as a function on the micromatch module
  2. micromatch.contains returns true when pattern matches substring or glob within path
  3. micromatch.contains returns false when pattern does not match any part of the path
  4. micromatch.contains accepts array of patterns and returns true if any pattern matches
  5. micromatch.contains supports glob options such as nocase and dot
  6. micromatch.contains handles empty strings and leading relative path prefixes
  7. micromatch.contains throws TypeError when first argument is not a string

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

Download the source artifact (tar.gz)

Source

PROMPT.md
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.contains 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.contains

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.
csx.json
{"case":{"caseId":"case:sha256:26512fdca0e68720efe301acf379dc3fff97dc6af6767f877af254bcf8779a2b","contract":["micromatch.contains is exported as a function on the micromatch module","micromatch.contains returns true when pattern matches substring or glob within path","micromatch.contains returns false when pattern does not match any part of the path","micromatch.contains accepts array of patterns and returns true if any pattern matches","micromatch.contains supports glob options such as nocase and dot","micromatch.contains handles empty strings and leading relative path prefixes","micromatch.contains throws TypeError when first argument is not a string"],"goal":"verify micromatch.contains in pkg:npm/micromatch@4.0.8","kind":"HOW","packages":["pkg:npm/micromatch@4.0.8"],"schemaVersion":1,"symbols":["micromatch.contains"]},"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.contains"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-micromatch-contains",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-micromatch-contains",
      "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"
      }
    }
  }
}
package.json
{
  "name": "sample-micromatch-contains",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of micromatch.contains in micromatch@4.0.8",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "micromatch": "4.0.8"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify micromatch.contains in pkg:npm/micromatch@4.0.8",
  "kind": "HOW",
  "packages": [
    "pkg:npm/micromatch@4.0.8"
  ],
  "symbols": [
    "micromatch.contains"
  ]
}
src/index.js
const micromatch = require('micromatch');

/**
 * Check if a file path contains the specified pattern or matches any substring.
 *
 * @param {string} filepath - File path to test
 * @param {string|string[]} patterns - Glob pattern or array of patterns
 * @param {object} [options] - Micromatch options
 * @returns {boolean} True if any pattern matches any part of filepath
 */
function containsPattern(filepath, patterns, options) {
  return micromatch.contains(filepath, patterns, options);
}

/**
 * Filter a list of file paths to only those that contain any of the given patterns.
 *
 * @param {string[]} filepaths - Array of file paths to filter
 * @param {string|string[]} patterns - Patterns to check for containment
 * @param {object} [options] - Micromatch options
 * @returns {string[]} Filtered array of matching file paths
 */
function filterContaining(filepaths, patterns, options) {
  if (!Array.isArray(filepaths)) {
    return [];
  }
  return filepaths.filter((file) => micromatch.contains(file, patterns, options));
}

module.exports = {
  micromatch,
  contains: micromatch.contains,
  containsPattern,
  filterContaining
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const {
  micromatch,
  contains,
  containsPattern,
  filterContaining
} = require('../src/index.js');

// 1. Module and function export verification
assert.equal(typeof micromatch, 'function', 'micromatch must be a function');
assert.equal(typeof micromatch.contains, 'function', 'micromatch.contains must be a function');
assert.equal(typeof contains, 'function', 'contains must be a function');
assert.equal(typeof containsPattern, 'function', 'containsPattern must be a function');
assert.equal(typeof filterContaining, 'function', 'filterContaining must be a function');
assert.equal(contains, micromatch.contains, 'contains should reference micromatch.contains');

// 2. Returns true when pattern matches substring or glob within path
assert.equal(
  micromatch.contains('aa/bb/cc', '*b'),
  true,
  'micromatch.contains should match glob pattern in path segment'
);
assert.equal(
  micromatch.contains('src/components/Button.tsx', 'components'),
  true,
  'micromatch.contains should match substring in path'
);
assert.equal(
  micromatch.contains('src/components/Button.tsx', '*.tsx'),
  true,
  'micromatch.contains should match file extension glob'
);
assert.equal(
  micromatch.contains('src/components/Button.tsx', 'Button.*'),
  true,
  'micromatch.contains should match filename glob'
);
assert.equal(
  containsPattern('dist/bundle.min.js', 'bundle'),
  true,
  'containsPattern helper should match substring in path'
);

// 3. Returns false when pattern does not match any part of the path
assert.equal(
  micromatch.contains('aa/bb/cc', '*d'),
  false,
  'micromatch.contains should return false when glob does not match'
);
assert.equal(
  micromatch.contains('src/components/Button.tsx', 'styles'),
  false,
  'micromatch.contains should return false when substring is absent'
);
assert.equal(
  micromatch.contains('src/components/Button.tsx', '*.vue'),
  false,
  'micromatch.contains should return false for unmatched extension'
);
assert.equal(
  containsPattern('docs/readme.md', '*.rs'),
  false,
  'containsPattern helper should return false when extension is unmatched'
);

// 4. Accepts array of patterns and returns true if any pattern matches
assert.equal(
  micromatch.contains('src/models/user.ts', ['*.js', '*models*']),
  true,
  'micromatch.contains should return true if any pattern in array matches'
);
assert.equal(
  micromatch.contains('src/models/user.ts', ['*.js', '*.css']),
  false,
  'micromatch.contains should return false if no pattern in array matches'
);

// 5. Supports glob options such as nocase and dot
assert.equal(
  micromatch.contains('SRC/COMPONENTS/BUTTON.TSX', '*button*', { nocase: true }),
  true,
  'micromatch.contains should support nocase option'
);
assert.equal(
  micromatch.contains('src/.config/settings.json', '.config', { dot: true }),
  true,
  'micromatch.contains should support dot option for hidden path segments'
);

// 6. filterContaining helper correctly filters an array using micromatch.contains
const files = [
  'src/components/Header.jsx',
  'src/utils/math.ts',
  'docs/api.md',
  'tests/unit/Header.test.jsx'
];
assert.deepEqual(
  filterContaining(files, ['components', 'tests']),
  ['src/components/Header.jsx', 'tests/unit/Header.test.jsx'],
  'filterContaining should return only files containing specified patterns'
);
assert.deepEqual(
  filterContaining(null, ['components']),
  [],
  'filterContaining should return empty array for non-array input'
);

// 7. Handles empty strings and leading relative path prefixes
assert.equal(
  micromatch.contains('', 'foo'),
  false,
  'micromatch.contains should return false for empty string target'
);
assert.equal(
  micromatch.contains('foo', ''),
  false,
  'micromatch.contains should return false for empty pattern'
);
assert.equal(
  micromatch.contains('', ''),
  false,
  'micromatch.contains should return false when both target and pattern are empty'
);
assert.equal(
  micromatch.contains('./src/index.js', 'src'),
  true,
  'micromatch.contains should match with leading relative prefix ./'
);

// 8. Throws TypeError when first argument is not a string
assert.throws(
  () => micromatch.contains(null, '*.js'),
  {
    name: 'TypeError',
    message: /Expected a string/
  },
  'micromatch.contains should throw TypeError when str is null'
);
assert.throws(
  () => micromatch.contains(undefined, '*.js'),
  {
    name: 'TypeError',
    message: /Expected a string/
  },
  'micromatch.contains should throw TypeError when str is undefined'
);
assert.throws(
  () => micromatch.contains(123, '*.js'),
  {
    name: 'TypeError',
    message: /Expected a string/
  },
  'micromatch.contains should throw TypeError when str is number'
);
assert.throws(
  () => micromatch.contains(['foo.js'], '*.js'),
  {
    name: 'TypeError',
    message: /Expected a string/
  },
  'micromatch.contains should throw TypeError when str is array'
);

console.log('Contract tests passed successfully.');

Origin Seeder

anonymous