CodeSampleX

Beispiel

react-is 19.2.8: Memo

Verifiziertes Beispiel für npm react-is 19.2.8: Memo. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand: Memo exports the react.memo…

sha256:e3630386dc7b98f0749dc2dbf3b5565de2f7cd6ff6e4fb6847174d395c428712

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

Fall

HOW
Ziel
verify react-is.Memo in pkg:npm/react-is@19.2.8
Pakete
Symbole
  • react-is.Memo
Erstellt
2026-09-06T05:13:50Z

Contract

  1. Memo exports the react.memo symbol identifier in React 19
  2. isMemo returns true for React 19 transitional elements wrapping memo component types
  3. typeOf returns Memo symbol for valid memo elements
  4. isMemo returns false for React 18 legacy element symbols
  5. isMemo returns false for unmounted memo component definition objects
  6. isValidElementType recognizes memo component definitions
  7. isMemo returns false for standard DOM elements and primitives

Dateien

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • 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 react-is.Memo in pkg:npm/react-is@19.2.8
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/react-is@19.2.8
Demonstrate these symbols/APIs:
  - react-is.Memo

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:a34b00df2c13bcdaf7b6020641adf0fa12c317ef7d9d28604382190bce59af69","contract":["Memo exports the react.memo symbol identifier in React 19","isMemo returns true for React 19 transitional elements wrapping memo component types","typeOf returns Memo symbol for valid memo elements","isMemo returns false for React 18 legacy element symbols","isMemo returns false for unmounted memo component definition objects","isValidElementType recognizes memo component definitions","isMemo returns false for standard DOM elements and primitives"],"goal":"verify react-is.Memo in pkg:npm/react-is@19.2.8","kind":"HOW","packages":["pkg:npm/react-is@19.2.8"],"schemaVersion":1,"symbols":["react-is.Memo"]},"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/react-is@19.2.8"],"schemaVersion":1,"subject":"pkg:npm/react-is@19.2.8","symbols":["react-is.Memo"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-react-is-memo",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-react-is-memo",
      "version": "1.0.0",
      "dependencies": {
        "react-is": "19.2.8"
      }
    },
    "node_modules/react-is": {
      "version": "19.2.8",
      "resolved": "https://registry.npmjs.org/react-is/-/react-is-19.2.8.tgz",
      "integrity": "sha512-s5un28nYxKJw5gvUHyW5PCC28CvBqLu9r3cWgzHT4Vo/5fqqkFcdRYsGcKf50WMPpjjFZS5d76fn3YCo2njKwQ==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-react-is-memo",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of react-is.Memo in React 19",
  "type": "module",
  "main": "src/index.js",
  "dependencies": {
    "react-is": "19.2.8"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify react-is.Memo in pkg:npm/react-is@19.2.8",
  "kind": "HOW",
  "packages": [
    "pkg:npm/react-is@19.2.8"
  ],
  "symbols": [
    "react-is.Memo"
  ]
}
src/index.js
import { Memo, isMemo, typeOf, isValidElementType } from 'react-is';

/**
 * Symbol used by React 19 for transitional elements.
 */
export const REACT_TRANSITIONAL_ELEMENT_TYPE = Symbol.for('react.transitional.element');

/**
 * Legacy Symbol used by React 18 and earlier for elements.
 */
export const REACT_LEGACY_ELEMENT_TYPE = Symbol.for('react.element');

/**
 * Check if the provided value is a React memo element using react-is.
 *
 * @param {*} value - Value to inspect.
 * @returns {boolean} True if the value is a memo element.
 */
export function checkIsMemo(value) {
  return isMemo(value);
}

/**
 * Check if the provided value is a valid memo component definition.
 *
 * @param {*} value - Value to inspect.
 * @returns {boolean} True if the value is a valid memo component type.
 */
export function checkIsValidMemoType(value) {
  return (
    typeof value === 'object' &&
    value !== null &&
    value.$$typeof === Memo &&
    isValidElementType(value)
  );
}

/**
 * Create a mock React 19 transitional element wrapping a memo component.
 *
 * @param {Function} [renderFn] - Inner render component.
 * @returns {object} Mock transitional element.
 */
export function createTransitionalMemoElement(renderFn = () => null) {
  const memoType = {
    $$typeof: Memo,
    type: renderFn,
    compare: null,
  };
  return {
    $$typeof: REACT_TRANSITIONAL_ELEMENT_TYPE,
    type: memoType,
    props: {},
    key: null,
    ref: null,
  };
}

/**
 * Create a mock legacy element wrapping a memo component.
 *
 * @param {Function} [renderFn] - Inner render component.
 * @returns {object} Mock legacy element.
 */
export function createLegacyMemoElement(renderFn = () => null) {
  const memoType = {
    $$typeof: Memo,
    type: renderFn,
    compare: null,
  };
  return {
    $$typeof: REACT_LEGACY_ELEMENT_TYPE,
    type: memoType,
    props: {},
    key: null,
    ref: null,
  };
}

export {
  Memo,
  isMemo,
  typeOf,
  isValidElementType,
};
test/contract.mjs
import assert from 'node:assert/strict';
import {
  Memo,
  isMemo,
  typeOf,
  isValidElementType,
  REACT_TRANSITIONAL_ELEMENT_TYPE,
  REACT_LEGACY_ELEMENT_TYPE,
  checkIsMemo,
  checkIsValidMemoType,
  createTransitionalMemoElement,
  createLegacyMemoElement,
} from '../src/index.js';

// 1. Symbol and Function exports verification
assert.equal(typeof Memo, 'symbol', 'Memo should export a symbol');
assert.equal(Memo, Symbol.for('react.memo'), 'Memo must match Symbol.for("react.memo")');
assert.equal(typeof isMemo, 'function', 'isMemo should be a function');
assert.equal(typeof typeOf, 'function', 'typeOf should be a function');
assert.equal(typeof isValidElementType, 'function', 'isValidElementType should be a function');
assert.equal(typeof checkIsMemo, 'function', 'checkIsMemo helper should be a function');
assert.equal(typeof checkIsValidMemoType, 'function', 'checkIsValidMemoType helper should be a function');

// 2. React 19 Transitional Memo Element verification
const transitionalMemoElem = createTransitionalMemoElement(() => null);
assert.equal(isMemo(transitionalMemoElem), true, 'isMemo must return true for React 19 transitional memo elements');
assert.equal(checkIsMemo(transitionalMemoElem), true, 'checkIsMemo helper must return true for React 19 transitional memo elements');
assert.equal(typeOf(transitionalMemoElem), Memo, 'typeOf must return Memo symbol for valid memo elements');

// 3. React 18 / Legacy Memo Element verification
const legacyMemoElem = createLegacyMemoElement(() => null);
assert.equal(isMemo(legacyMemoElem), false, 'React 19 react-is does not match legacy react.element symbol for isMemo');
assert.notEqual(typeOf(legacyMemoElem), Memo, 'typeOf does not return Memo for legacy react.element symbols');

// 4. Raw Memo Component Type Object (unmounted definition) verification
const rawMemoComponent = {
  $$typeof: Memo,
  type: () => null,
  compare: null,
};
assert.equal(isMemo(rawMemoComponent), false, 'isMemo must return false for raw memo component definitions without element envelope');
assert.equal(isValidElementType(rawMemoComponent), true, 'isValidElementType must recognize raw memo component definitions');
assert.equal(checkIsValidMemoType(rawMemoComponent), true, 'checkIsValidMemoType helper must return true for valid memo component types');

// 5. Negative assertions for non-memo elements and invalid values
const plainTransitionalElement = {
  $$typeof: REACT_TRANSITIONAL_ELEMENT_TYPE,
  type: 'div',
  props: {},
  key: null,
  ref: null,
};
assert.equal(isMemo(plainTransitionalElement), false, 'plain transitional element is not a memo element');
assert.equal(isMemo(null), false, 'null is not a memo element');
assert.equal(isMemo(undefined), false, 'undefined is not a memo element');
assert.equal(isMemo({}), false, 'empty object is not a memo element');
assert.equal(isMemo('div'), false, 'primitive string is not a memo element');
assert.equal(isMemo(123), false, 'primitive number is not a memo element');
assert.equal(isMemo(() => null), false, 'plain function component is not a memo element');
assert.equal(isMemo(Memo), false, 'Memo symbol itself is not a memo element');

// 6. isValidElementType negative checks
assert.equal(isValidElementType(null), false, 'isValidElementType returns false for null');
assert.equal(isValidElementType(undefined), false, 'isValidElementType returns false for undefined');
assert.equal(isValidElementType(Memo), false, 'isValidElementType returns false for raw Memo symbol');

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

Ursprungs-Seeder

anonym