CodeSampleX

Exemplo

react-is 18.3.1: isSuspense

Amostra verificada para npm react-is 18.3.1: isSuspense. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: isSuspense returns true for valid…

sha256:a30b8e5c202103568520056cec248dd4fdfb106ec2b15a1e25fc75b468de2385

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
1
Chaves de assinatura que o compilaram
1
Ambiente declarado linux 24 · ubuntu · glibc 2.39 x64 npm

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
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-30

Caso

HOW
Objetivo
verify react-is.isSuspense in pkg:npm/react-is@18.3.1
Pacotes
Símbolos
  • react-is.isSuspense
Criado
2026-08-30T10:00:32Z

Contrato

  1. isSuspense returns true for valid React Suspense elements
  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. typeOf returns Suspense symbol for React Suspense elements

Arquivos

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

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

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@18.3.1
Kind: HOW

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

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:575d72d01b4041c355fdde99842b7904a403c31a35cbb0ecfd284bd295e49e38","contract":["isSuspense returns true for valid React Suspense elements","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","typeOf returns Suspense symbol for React Suspense elements"],"goal":"verify react-is.isSuspense in pkg:npm/react-is@18.3.1","kind":"HOW","packages":["pkg:npm/react-is@18.3.1"],"schemaVersion":1,"symbols":["react-is.isSuspense"]},"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@18.3.1"],"schemaVersion":1,"subject":"pkg:npm/react-is@18.3.1","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",
      "dependencies": {
        "react-is": "18.3.1"
      }
    },
    "node_modules/react-is": {
      "version": "18.3.1",
      "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz",
      "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==",
      "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 18.3.1",
  "type": "module",
  "main": "src/index.js",
  "dependencies": {
    "react-is": "18.3.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify react-is.isSuspense in pkg:npm/react-is@18.3.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/react-is@18.3.1"
  ],
  "symbols": [
    "react-is.isSuspense"
  ]
}
src/index.js
import { isSuspense, Suspense, typeOf } from '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.
 */
export function checkIsSuspense(value) {
  return 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.
 */
export function identifyTypeOf(value) {
  return typeOf(value);
}

export { isSuspense, Suspense, typeOf };
test/contract.mjs
import assert from 'node:assert/strict';
import {
  checkIsSuspense,
  identifyTypeOf,
  isSuspense,
  Suspense,
  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');

// 2. Suspense element detection
const suspenseElement = {
  $$typeof: Symbol.for('react.element'),
  type: Symbol.for('react.suspense'),
  props: { fallback: null, children: [] },
  key: null,
  ref: null,
};

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

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

const fragmentElement = {
  $$typeof: Symbol.for('react.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. 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.equal(typeOf(plainElement) !== Suspense, true, 'typeOf for plainElement must not equal Suspense symbol');
assert.equal(typeOf({}), undefined, 'typeOf on non-element must return undefined');

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

Seeder de origem

anônimo