CodeSampleX

Ejemplo

react-is 19.2.8: isSuspense

Muestra verificada para npm react-is 19.2.8: isSuspense. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.

sha256:0c371ffb11fd8cf489b1ac1a7b32eed11b33349edf8f7e809caa084d32c5f439

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
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

Caso

HOW
Objetivo
verify react-is.isSuspense in pkg:npm/react-is@19.2.8
Paquetes
Símbolos
  • react-is.isSuspense
Entorno
node 22.23.2
Creado
2026-09-06T20:23:29Z

Contrato

  1. isSuspense returns true for valid React 19 Suspense elements with Symbol.for('react.transitional.element')
  2. isSuspense returns false for standard DOM element objects and Fragment elements
  3. isSuspense returns false for plain objects, null, undefined, and primitives
  4. isSuspense returns false for the raw Suspense symbol when not wrapped in an element
  5. isSuspense returns false for legacy React 18 element objects using Symbol.for('react.element')
  6. typeOf returns Suspense symbol for valid React 19 Suspense elements

Archivos

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

Descargar el artefacto de código fuente (tar.gz)

Código fuente

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.isSuspense 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.isSuspense
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:c084f41bafec3a66cb0be76bb36e84d8b1ab027e355f663373f8dc07eedf3ff2","constraints":{"executionContext":"node"},"contract":["isSuspense returns true for valid React 19 Suspense elements with Symbol.for('react.transitional.element')","isSuspense returns false for standard DOM element objects and Fragment elements","isSuspense returns false for plain objects, null, undefined, and primitives","isSuspense returns false for the raw Suspense symbol when not wrapped in an element","isSuspense returns false for legacy React 18 element objects using Symbol.for('react.element')","typeOf returns Suspense symbol for valid React 19 Suspense elements"],"goal":"verify react-is.isSuspense in pkg:npm/react-is@19.2.8","kind":"HOW","packages":["pkg:npm/react-is@19.2.8"],"schemaVersion":1,"symbols":["react-is.isSuspense"]},"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/react-is@19.2.8"],"schemaVersion":1,"subject":"pkg:npm/react-is@19.2.8","symbols":["react-is.isSuspense"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-react-is-suspense",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-react-is-suspense",
      "version": "1.0.0",
      "license": "MIT-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-suspense",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of react-is.isSuspense in react-is 19.2.8",
  "main": "src/index.js",
  "license": "MIT-0",
  "dependencies": {
    "react-is": "19.2.8"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify react-is.isSuspense in pkg:npm/react-is@19.2.8",
  "kind": "HOW",
  "packages": [
    "pkg:npm/react-is@19.2.8"
  ],
  "symbols": [
    "react-is.isSuspense"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
'use strict';

const reactIs = require('react-is');

/**
 * Check if the given value is a valid React Suspense element.
 *
 * @param {*} value - The value to check.
 * @returns {boolean} True if the value is a Suspense element.
 */
function checkIsSuspense(value) {
  return reactIs.isSuspense(value);
}

/**
 * Get the element type symbol of a value using typeOf.
 *
 * @param {*} value - The value to inspect.
 * @returns {symbol|undefined} The React element type symbol or undefined.
 */
function identifyTypeOf(value) {
  return reactIs.typeOf(value);
}

exports.checkIsSuspense = checkIsSuspense;
exports.identifyTypeOf = identifyTypeOf;
exports.isSuspense = reactIs.isSuspense;
exports.Suspense = reactIs.Suspense;
exports.Element = reactIs.Element;
exports.typeOf = reactIs.typeOf;
test/contract.mjs
import assert from 'node:assert/strict';
import {
  checkIsSuspense,
  identifyTypeOf,
  isSuspense,
  Suspense,
  Element,
  typeOf,
} from '../src/index.js';

// 1. Export types verification
assert.equal(typeof isSuspense, 'function', 'isSuspense must be exported as a function');
assert.equal(typeof checkIsSuspense, 'function', 'checkIsSuspense helper must be a function');
assert.equal(typeof identifyTypeOf, 'function', 'identifyTypeOf helper must be a function');
assert.equal(typeof typeOf, 'function', 'typeOf must be exported as a function');
assert.equal(typeof Suspense, 'symbol', 'Suspense must be exported as a symbol');
assert.equal(typeof Element, 'symbol', 'Element must be exported as a symbol');
assert.equal(Suspense, Symbol.for('react.suspense'), 'Suspense symbol must match react.suspense');
assert.equal(Element, Symbol.for('react.transitional.element'), 'Element symbol must match react.transitional.element');

// 2. React 19 Suspense element detection
const suspenseElement = {
  $$typeof: Element,
  type: Suspense,
  props: { fallback: null, children: [] },
  key: null,
  ref: null,
};

assert.equal(isSuspense(suspenseElement), true, 'isSuspense must return true for valid React 19 Suspense element');
assert.equal(checkIsSuspense(suspenseElement), true, 'checkIsSuspense helper must return true for valid Suspense element');

// 3. Non-Suspense element rejection
const plainElement = {
  $$typeof: Element,
  type: 'div',
  props: { className: 'container' },
  key: null,
  ref: null,
};

const fragmentElement = {
  $$typeof: Element,
  type: Symbol.for('react.fragment'),
  props: {},
  key: null,
  ref: null,
};

assert.equal(isSuspense(plainElement), false, 'isSuspense must return false for standard DOM element');
assert.equal(checkIsSuspense(plainElement), false, 'checkIsSuspense must return false for standard DOM element');
assert.equal(isSuspense(fragmentElement), false, 'isSuspense must return false for Fragment element');

// 4. Non-element and primitive values rejection
assert.equal(isSuspense({}), false, 'isSuspense must return false for plain empty object');
assert.equal(isSuspense(null), false, 'isSuspense must return false for null');
assert.equal(isSuspense(undefined), false, 'isSuspense must return false for undefined');
assert.equal(isSuspense('suspense'), false, 'isSuspense must return false for string');
assert.equal(isSuspense(123), false, 'isSuspense must return false for number');
assert.equal(isSuspense(true), false, 'isSuspense must return false for boolean');
assert.equal(isSuspense(Symbol.for('react.suspense')), false, 'isSuspense must return false for raw Symbol without element envelope');
assert.equal(isSuspense(Suspense), false, 'isSuspense must return false for exported Suspense symbol');

// 5. Legacy React 18 element rejection
const legacySuspenseElement = {
  $$typeof: Symbol.for('react.element'),
  type: Suspense,
  props: { fallback: null, children: [] },
  key: null,
  ref: null,
};
assert.equal(isSuspense(legacySuspenseElement), false, 'isSuspense must return false for legacy React 18 element');

// 6. Element type identification
assert.equal(typeOf(suspenseElement), Suspense, 'typeOf must return Suspense symbol for Suspense element');
assert.equal(identifyTypeOf(suspenseElement), Suspense, 'identifyTypeOf helper must return Suspense symbol');
assert.notEqual(typeOf(plainElement), Suspense, 'typeOf for plainElement must not equal Suspense symbol');
assert.equal(typeOf({}), undefined, 'typeOf on non-element must return undefined');
assert.equal(typeOf(null), undefined, 'typeOf on null must return undefined');

console.log('All contract assertions for react-is.isSuspense in react-is@19.2.8 passed.');

Seeder de origen

anónimo