CodeSampleX

Пример

micromatch 4.0.8: not

Проверенный пример — npm micromatch 4.0.8: not. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден: micromatch.not is exported as a function…

sha256:432dec622d830858fd0fac856e4ad9fd41ef118d3d4a745b83faebc870b2c2c8

Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла. Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди. 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.not in pkg:npm/micromatch@4.0.8
Пакеты
Символы
  • micromatch.not
Окружение
node 22.23.2
Создан
2026-08-28T02:52:36Z

Контракт

  1. micromatch.not is exported as a function on the micromatch module
  2. micromatch.not returns an array containing only items that do not match a single glob pattern
  3. micromatch.not returns an array excluding items matching any glob pattern in an array of patterns
  4. micromatch.not supports glob options including nocase, dot, and basename
  5. micromatch.not throws TypeError when the list input is null, undefined, or a number

Файлы

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

Скачать артефакт с исходным кодом (tar.gz)

Исходный код

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.not 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.not

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:e625ef0f3d1fde064b2bb9678a18bf0917c38e3067729a1c7410a1fdb2fc64d3","contract":["micromatch.not is exported as a function on the micromatch module","micromatch.not returns an array containing only items that do not match a single glob pattern","micromatch.not returns an array excluding items matching any glob pattern in an array of patterns","micromatch.not supports glob options including nocase, dot, and basename","micromatch.not throws TypeError when the list input is null, undefined, or a number"],"goal":"verify micromatch.not in pkg:npm/micromatch@4.0.8","kind":"HOW","packages":["pkg:npm/micromatch@4.0.8"],"schemaVersion":1,"symbols":["micromatch.not"]},"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.not"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-micromatch-not",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-micromatch-not",
      "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-not",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of micromatch.not in micromatch@4.0.8",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "micromatch": "4.0.8"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify micromatch.not in pkg:npm/micromatch@4.0.8",
  "kind": "HOW",
  "packages": [
    "pkg:npm/micromatch@4.0.8"
  ],
  "symbols": [
    "micromatch.not"
  ]
}
src/index.js
const micromatch = require('micromatch');

/**
 * Exclude items from a list of paths that match any given glob pattern.
 *
 * @param {string|string[]} list - List of paths or single path to filter
 * @param {string|string[]} patterns - Glob pattern(s) to exclude
 * @param {object} [options] - Micromatch options
 * @returns {string[]} Array of strings that do not match the patterns
 */
function excludeMatches(list, patterns, options) {
  return micromatch.not(list, patterns, options);
}

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

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

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

// 2. Returns an array excluding items matching a single glob pattern
const files = ['src/index.js', 'src/index.test.js', 'README.md', 'package.json', 'docs/guide.md'];

// '*.md' does not match path separators, so only top-level README.md is excluded
assert.deepEqual(
  micromatch.not(files, '*.md'),
  ['src/index.js', 'src/index.test.js', 'package.json', 'docs/guide.md'],
  'micromatch.not with single-level glob should only exclude top-level matches'
);

// '**/*.md' matches across directories, excluding both README.md and docs/guide.md
assert.deepEqual(
  micromatch.not(files, '**/*.md'),
  ['src/index.js', 'src/index.test.js', 'package.json'],
  'micromatch.not with recursive glob should exclude nested matches'
);
assert.deepEqual(
  excludeMatches(files, '**/*.md'),
  ['src/index.js', 'src/index.test.js', 'package.json'],
  'excludeMatches helper should match micromatch.not behavior'
);

// 3. Returns an array excluding items matching any glob pattern in an array
assert.deepEqual(
  micromatch.not(files, ['**/*.test.js', '**/*.md']),
  ['src/index.js', 'package.json'],
  'micromatch.not should exclude items matching any pattern in array'
);
assert.deepEqual(
  micromatch.not(['a.js', 'b.txt', 'c.css'], ['*']),
  [],
  'micromatch.not should return empty array when all items match pattern'
);
assert.deepEqual(
  micromatch.not(['a.js', 'b.txt'], ['*.png', '*.gif']),
  ['a.js', 'b.txt'],
  'micromatch.not should return all items when none match the patterns'
);

// 4. Supports options: nocase, dot, basename
assert.deepEqual(
  micromatch.not(['FILE.JS', 'image.PNG', 'data.json'], ['*.js'], { nocase: true }),
  ['image.PNG', 'data.json'],
  'micromatch.not should support nocase option'
);
assert.deepEqual(
  micromatch.not(['.env', '.gitignore', 'index.js'], '.*', { dot: true }),
  ['index.js'],
  'micromatch.not should support dot option for hidden files'
);
assert.deepEqual(
  micromatch.not(['src/util/helper.js', 'src/util/helper.test.js', 'src/main.js'], '*.test.js', { basename: true }),
  ['src/util/helper.js', 'src/main.js'],
  'micromatch.not should support basename option matching filename only'
);

// 5. Throws TypeError when first argument is not a valid list or string
assert.throws(
  () => micromatch.not(null, '*.js'),
  {
    name: 'TypeError',
    message: /Expected input to be a string/
  },
  'micromatch.not should throw TypeError when input list is null'
);
assert.throws(
  () => micromatch.not(undefined, '*.js'),
  {
    name: 'TypeError',
    message: /Expected input to be a string/
  },
  'micromatch.not should throw TypeError when input list is undefined'
);
assert.throws(
  () => micromatch.not(12345, '*.js'),
  {
    name: 'TypeError',
    message: /Expected input to be a string/
  },
  'micromatch.not should throw TypeError when input list is a number'
);

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

Исходный сидер

аноним