CodeSampleX

サンプル

matcher 3.0.0: isMatch

検証済みサンプル — npm matcher 3.0.0: isMatch. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: matcher filters an array of strings using wildcard…

sha256:3011bb00fc758ae68fc08086a2d2063f6a9befd3d2e8fb9023100dec1ecdce61

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。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 pkg:npm/matcher@3.0.0
パッケージ
シンボル
  • matcher
  • matcher.isMatch
環境
node 22.23.2
作成日
2026-08-28T04:57:36Z

コントラクト

  1. matcher filters an array of strings using wildcard patterns and negation patterns
  2. matcher.isMatch returns true if any input matches all positive patterns and does not match negated patterns
  3. matcher.isMatch supports caseSensitive matching option
  4. matcher throws TypeError when inputs or patterns are not arrays

ファイル

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

ソースアーティファクトをダウンロード (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 pkg:npm/matcher@3.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/matcher@3.0.0
Demonstrate these symbols/APIs:
  - matcher
  - matcher.isMatch

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:bc56179e38bdc5fadeb4ff7b711796d8097efd1b79083d1ddb4bdcd462102c1f","contract":["matcher filters an array of strings using wildcard patterns and negation patterns","matcher.isMatch returns true if any input matches all positive patterns and does not match negated patterns","matcher.isMatch supports caseSensitive matching option","matcher throws TypeError when inputs or patterns are not arrays"],"goal":"verify pkg:npm/matcher@3.0.0","kind":"HOW","packages":["pkg:npm/matcher@3.0.0"],"schemaVersion":1,"symbols":["matcher","matcher.isMatch"]},"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/matcher@3.0.0"],"schemaVersion":1,"subject":"pkg:npm/matcher@3.0.0","symbols":["matcher","matcher.isMatch"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-matcher",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-matcher",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "matcher": "3.0.0"
      }
    },
    "node_modules/escape-string-regexp": {
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
      "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
      "license": "MIT",
      "engines": {
        "node": ">=10"
      },
      "funding": {
        "url": "https://github.com/sponsors/sindresorhus"
      }
    },
    "node_modules/matcher": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/matcher/-/matcher-3.0.0.tgz",
      "integrity": "sha512-OkeDaAZ/bQCxeFAozM55PKcKU0yJMPGifLwV4Qgjitu+5MoAfSQN4lsLJeXZ1b8w0x+/Emda6MZgXS1jvsapng==",
      "license": "MIT",
      "dependencies": {
        "escape-string-regexp": "^4.0.0"
      },
      "engines": {
        "node": ">=10"
      }
    }
  }
}
package.json
{
  "name": "sample-matcher",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for matcher",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "matcher": "3.0.0"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/matcher@3.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/matcher@3.0.0"
  ],
  "symbols": [
    "matcher",
    "matcher.isMatch"
  ]
}
src/index.js
const matcher = require('matcher');

function filterInputs(inputs, patterns, options) {
  return matcher(inputs, patterns, options);
}

function checkMatch(input, pattern, options) {
  return matcher.isMatch(input, pattern, options);
}

module.exports = {
  filterInputs,
  checkMatch
};
test/contract.js
const assert = require('node:assert');
const matcher = require('matcher');
const { filterInputs, checkMatch } = require('../src/index.js');

// 1. Array filtering with wildcard patterns and negation
const filtered = matcher(['foo', 'bar', 'moo'], ['*oo', '!foo']);
assert.deepStrictEqual(filtered, ['moo'], 'matcher should filter inputs matching *oo and not foo');

const negated = matcher(['foo', 'bar', 'moo'], ['!*oo']);
assert.deepStrictEqual(negated, ['bar'], 'matcher should filter inputs not matching *oo');

const emptyPattern = matcher(['foo', 'bar'], []);
assert.deepStrictEqual(emptyPattern, ['foo', 'bar'], 'matcher should return all inputs if patterns array is empty');

// 2. matcher.isMatch basic and wildcard matching
assert.strictEqual(matcher.isMatch('unicorn', 'uni*'), true, 'isMatch should match prefix wildcard');
assert.strictEqual(matcher.isMatch('unicorn', '*corn'), true, 'isMatch should match suffix wildcard');
assert.strictEqual(matcher.isMatch('unicorn', 'un*rn'), true, 'isMatch should match middle wildcard');
assert.strictEqual(matcher.isMatch('rainbow', '!unicorn'), true, 'isMatch should support negated pattern');
assert.strictEqual(matcher.isMatch('foo bar baz', 'foo b* b*'), true, 'isMatch should match multi-word wildcard');
assert.strictEqual(matcher.isMatch(['foo', 'bar'], 'f*'), true, 'isMatch should match if any input matches pattern');
assert.strictEqual(matcher.isMatch('foo', ['f*', '*oo']), true, 'isMatch should match if input matches all patterns');
assert.strictEqual(matcher.isMatch(['foo', 'bar'], ['a*', 'b*']), false, 'isMatch should return false if no single input matches all patterns');

// 3. matcher.isMatch caseSensitive option
assert.strictEqual(matcher.isMatch('UNICORN', 'unicorn', { caseSensitive: false }), true, 'isMatch should match case-insensitively by default');
assert.strictEqual(matcher.isMatch('UNICORN', 'unicorn', { caseSensitive: true }), false, 'isMatch should not match different case when caseSensitive is true');
assert.strictEqual(matcher.isMatch('UNICORN', 'UNI*', { caseSensitive: true }), true, 'isMatch should match exact case when caseSensitive is true');

// 4. Error handling
assert.throws(() => {
  matcher('not-an-array', ['*']);
}, {
  name: 'TypeError'
}, 'matcher should throw TypeError when inputs is not an array');

assert.throws(() => {
  matcher(['foo'], 'not-an-array');
}, {
  name: 'TypeError'
}, 'matcher should throw TypeError when patterns is not an array');

// 5. Exported wrapper verification
assert.deepStrictEqual(filterInputs(['apple', 'banana', 'apricot'], ['ap*']), ['apple', 'apricot'], 'wrapper filterInputs should match ap*');
assert.strictEqual(checkMatch('hello world', 'hello*'), true, 'wrapper checkMatch should match prefix');

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

オリジンシーダー

匿名