CodeSampleX

Beispiel

@tanstack/query-core 5.90.20: notifyManager

Verifiziertes Beispiel für npm @tanstack/query-core 5.90.20: notifyManager. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:6906aa92e9ce4d0ca1f4efb44264e86d4031c17a91de4aba32582f3da771792f

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-03

Fall

HOW
Ziel
verify pkg:npm/%40tanstack/query-core@5.90.20
Pakete
Symbole
  • notifyManager
Erstellt
2026-09-03T08:52:45Z

Contract

  1. assert notifyManager exposes batch, schedule, batchCalls, setScheduler, setNotifyFunction, and setBatchNotifyFunction
  2. assert notifyManager batch executes callback synchronously and returns result
  3. assert notifyManager batch delays scheduled callbacks until outer batch completes
  4. assert notifyManager nested batch flushes queued callbacks only when outermost batch exits
  5. assert notifyManager batchCalls schedules invocations through notifyManager queue
  6. assert notifyManager setScheduler allows custom scheduler function
  7. assert notifyManager setNotifyFunction wraps individual notification executions
  8. assert notifyManager setBatchNotifyFunction wraps batched notification flush

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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/%40tanstack/query-core@5.90.20
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40tanstack/query-core@5.90.20
Demonstrate these symbols/APIs:
  - notifyManager

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:d1b3e183b6a8404da0d7eeef8e24f709d40f7402080cc955d462027be91c7441","contract":["assert notifyManager exposes batch, schedule, batchCalls, setScheduler, setNotifyFunction, and setBatchNotifyFunction","assert notifyManager batch executes callback synchronously and returns result","assert notifyManager batch delays scheduled callbacks until outer batch completes","assert notifyManager nested batch flushes queued callbacks only when outermost batch exits","assert notifyManager batchCalls schedules invocations through notifyManager queue","assert notifyManager setScheduler allows custom scheduler function","assert notifyManager setNotifyFunction wraps individual notification executions","assert notifyManager setBatchNotifyFunction wraps batched notification flush"],"goal":"verify pkg:npm/%40tanstack/query-core@5.90.20","kind":"HOW","packages":["pkg:npm/%40tanstack/query-core@5.90.20"],"schemaVersion":1,"symbols":["notifyManager"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40tanstack/query-core@5.90.20"],"schemaVersion":1,"subject":"pkg:npm/%40tanstack/query-core@5.90.20","symbols":["notifyManager"],"verifierAdapter":"node-typescript@1"}
index.mjs
import { notifyManager } from '@tanstack/query-core';

/**
 * Executes a callback within a batch transaction.
 * Notifications scheduled inside the callback are queued until the outermost batch completes.
 *
 * @template T
 * @param {() => T} callback
 * @returns {T}
 */
export function runBatch(callback) {
  return notifyManager.batch(callback);
}

/**
 * Wraps a callback so that calling it schedules execution via notifyManager.
 *
 * @template {Array<unknown>} T
 * @param {(...args: T) => void} callback
 * @returns {(...args: T) => void}
 */
export function createBatchedCallback(callback) {
  return notifyManager.batchCalls(callback);
}

/**
 * Schedules a callback for execution.
 *
 * @param {() => void} callback
 */
export function scheduleNotification(callback) {
  notifyManager.schedule(callback);
}

/**
 * Configures a custom scheduler function.
 *
 * @param {(callback: () => void) => void} scheduler
 */
export function configureScheduler(scheduler) {
  notifyManager.setScheduler(scheduler);
}

/**
 * Configures a custom notify function.
 *
 * @param {(callback: () => void) => void} fn
 */
export function configureNotifyFunction(fn) {
  notifyManager.setNotifyFunction(fn);
}

/**
 * Configures a custom batch notify function.
 *
 * @param {(callback: () => void) => void} fn
 */
export function configureBatchNotifyFunction(fn) {
  notifyManager.setBatchNotifyFunction(fn);
}

export { notifyManager };
export default notifyManager;
package-lock.json
{
  "name": "sample-query-core-verify",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-query-core-verify",
      "version": "1.0.0",
      "dependencies": {
        "@tanstack/query-core": "5.90.20"
      }
    },
    "node_modules/@tanstack/query-core": {
      "version": "5.90.20",
      "resolved": "https://registry.npmjs.org/@tanstack/query-core/-/query-core-5.90.20.tgz",
      "integrity": "sha512-OMD2HLpNouXEfZJWcKeVKUgQ5n+n3A2JFmBaScpNDUqSrQSjiveC7dKMe53uJUg1nDG16ttFPz2xfilz6i2uVg==",
      "license": "MIT",
      "funding": {
        "type": "github",
        "url": "https://github.com/sponsors/tannerlinsley"
      }
    }
  }
}
package.json
{
  "name": "sample-query-core-verify",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "@tanstack/query-core": "5.90.20"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40tanstack/query-core@5.90.20",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40tanstack/query-core@5.90.20"
  ],
  "symbols": [
    "notifyManager"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { defaultScheduler } from '@tanstack/query-core';
import {
  notifyManager,
  runBatch,
  createBatchedCallback,
  scheduleNotification,
  configureScheduler,
  configureNotifyFunction,
  configureBatchNotifyFunction,
} from '../index.mjs';

// 1. assert notifyManager exposes batch, schedule, batchCalls, setScheduler, setNotifyFunction, and setBatchNotifyFunction
{
  assert.strictEqual(typeof notifyManager.batch, 'function');
  assert.strictEqual(typeof notifyManager.schedule, 'function');
  assert.strictEqual(typeof notifyManager.batchCalls, 'function');
  assert.strictEqual(typeof notifyManager.setScheduler, 'function');
  assert.strictEqual(typeof notifyManager.setNotifyFunction, 'function');
  assert.strictEqual(typeof notifyManager.setBatchNotifyFunction, 'function');
}

// 2. assert notifyManager batch executes callback synchronously and returns result
{
  let executed = false;
  const result = runBatch(() => {
    executed = true;
    return 'computed-value';
  });
  assert.strictEqual(executed, true);
  assert.strictEqual(result, 'computed-value');
}

// 3. assert notifyManager batch delays scheduled callbacks until outer batch completes
{
  configureScheduler((cb) => { cb(); });

  const timeline = [];
  runBatch(() => {
    scheduleNotification(() => timeline.push('queued-1'));
    scheduleNotification(() => timeline.push('queued-2'));
    timeline.push('inside-batch');
  });

  assert.deepStrictEqual(timeline, ['inside-batch', 'queued-1', 'queued-2']);
}

// 4. assert notifyManager nested batch flushes queued callbacks only when outermost batch exits
{
  configureScheduler((cb) => { cb(); });

  const nestedTimeline = [];
  runBatch(() => {
    scheduleNotification(() => nestedTimeline.push('outer-scheduled-1'));
    runBatch(() => {
      scheduleNotification(() => nestedTimeline.push('inner-scheduled'));
      nestedTimeline.push('inside-nested-batch');
    });
    nestedTimeline.push('after-nested-batch');
  });

  assert.deepStrictEqual(nestedTimeline, [
    'inside-nested-batch',
    'after-nested-batch',
    'outer-scheduled-1',
    'inner-scheduled',
  ]);
}

// 5. assert notifyManager batchCalls schedules invocations through notifyManager queue
{
  configureScheduler((cb) => { cb(); });

  const events = [];
  const batchedFn = createBatchedCallback((arg) => {
    events.push(`fn:${arg}`);
  });

  runBatch(() => {
    batchedFn('alpha');
    batchedFn('beta');
    events.push('synchronous-point');
  });

  assert.deepStrictEqual(events, ['synchronous-point', 'fn:alpha', 'fn:beta']);
}

// 6. assert notifyManager setScheduler allows custom scheduler function
{
  let customSchedulerRan = false;
  configureScheduler((cb) => {
    customSchedulerRan = true;
    cb();
  });

  scheduleNotification(() => {});
  assert.strictEqual(customSchedulerRan, true);
}

// 7. assert notifyManager setNotifyFunction wraps individual notification executions
{
  configureScheduler((cb) => { cb(); });

  let notifyCallCount = 0;
  configureNotifyFunction((cb) => {
    notifyCallCount++;
    cb();
  });

  scheduleNotification(() => {});
  assert.strictEqual(notifyCallCount, 1);
}

// 8. assert notifyManager setBatchNotifyFunction wraps batched notification flush
{
  configureScheduler((cb) => { cb(); });

  let batchNotifyCallCount = 0;
  configureBatchNotifyFunction((cb) => {
    batchNotifyCallCount++;
    cb();
  });

  runBatch(() => {
    scheduleNotification(() => {});
    scheduleNotification(() => {});
  });

  assert.strictEqual(batchNotifyCallCount, 1);
}

// Teardown: restore defaults
configureScheduler(defaultScheduler);
configureNotifyFunction((cb) => { cb(); });
configureBatchNotifyFunction((cb) => { cb(); });

console.log('All notifyManager contract assertions passed.');

Ursprungs-Seeder

anonym