CodeSampleX

Exemplo

define-properties 1.2.1: supportsDescriptors

Amostra verificada para npm define-properties 1.2.1: supportsDescriptors. O contrato rodou em node 22 · linux alpine/x64 · docker e passou.

sha256:ed16b4e3d48c3fa4aff02f05f5fa0ddaafc428cd12f782ab8e37191c42dfd247

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 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

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 define-properties.supportsDescriptors in pkg:npm/define-properties@1.2.1
Pacotes
Símbolos
  • define-properties.supportsDescriptors
Ambiente
node 22.23.2
Criado
2026-08-30T17:17:10Z

Contrato

  1. assert supportsDescriptors is a boolean indicating property descriptor support
  2. assert defineProperties attaches properties non-enumerably when supportsDescriptors is true
  3. assert defineProperties does not overwrite existing properties by default
  4. assert defineProperties overwrites existing properties when predicate is true
  5. assert defineProperties uses custom predicate function to conditionally overwrite
  6. assert defineProperties defines symbol properties when supported

Arquivos

  • PROMPT.md
  • csx.json
  • index.js
  • package-lock.json
  • package.json
  • spec.json
  • 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 define-properties.supportsDescriptors in pkg:npm/define-properties@1.2.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/define-properties@1.2.1
Demonstrate these symbols/APIs:
  - define-properties.supportsDescriptors

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:5507283d8168bd04ef8d31d14aecd4a1e2d3af4fcdf7060109df3335c9932b13","constraints":{"executionContext":"node"},"contract":["assert supportsDescriptors is a boolean indicating property descriptor support","assert defineProperties attaches properties non-enumerably when supportsDescriptors is true","assert defineProperties does not overwrite existing properties by default","assert defineProperties overwrites existing properties when predicate is true","assert defineProperties uses custom predicate function to conditionally overwrite","assert defineProperties defines symbol properties when supported"],"goal":"verify define-properties.supportsDescriptors in pkg:npm/define-properties@1.2.1","kind":"HOW","packages":["pkg:npm/define-properties@1.2.1"],"schemaVersion":1,"symbols":["define-properties.supportsDescriptors"]},"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/define-properties@1.2.1"],"schemaVersion":1,"subject":"pkg:npm/define-properties@1.2.1","symbols":["define-properties.supportsDescriptors"],"verifierAdapter":"node-typescript@1"}
index.js
const defineProperties = require('define-properties');

const supportsDescriptors = defineProperties.supportsDescriptors;

function defineHelper(target, properties, predicates = {}) {
  defineProperties(target, properties, predicates);
  return target;
}

module.exports = {
  defineProperties,
  supportsDescriptors,
  defineHelper,
};
package-lock.json
{
  "name": "sample-define-properties",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-define-properties",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "define-properties": "1.2.1"
      }
    },
    "node_modules/define-data-property": {
      "version": "1.1.4",
      "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
      "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
      "license": "MIT",
      "dependencies": {
        "es-define-property": "^1.0.0",
        "es-errors": "^1.3.0",
        "gopd": "^1.0.1"
      },
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/define-properties": {
      "version": "1.2.1",
      "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz",
      "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==",
      "license": "MIT",
      "dependencies": {
        "define-data-property": "^1.0.1",
        "has-property-descriptors": "^1.0.0",
        "object-keys": "^1.1.1"
      },
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/es-define-property": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
      "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/es-errors": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
      "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/gopd": {
      "version": "1.2.0",
      "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
      "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/has-property-descriptors": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
      "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
      "license": "MIT",
      "dependencies": {
        "es-define-property": "^1.0.0"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/object-keys": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
      "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      }
    }
  }
}
package.json
{
  "name": "sample-define-properties",
  "version": "1.0.0",
  "description": "Clean-room sample verifying define-properties.supportsDescriptors in define-properties",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "define-properties": "1.2.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify define-properties.supportsDescriptors in pkg:npm/define-properties@1.2.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/define-properties@1.2.1"
  ],
  "symbols": [
    "define-properties.supportsDescriptors"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import defineProperties from 'define-properties';
import {
  defineProperties as importedDefine,
  supportsDescriptors,
  defineHelper,
} from '../index.js';

// 1. assert supportsDescriptors is a boolean indicating property descriptor support
assert.strictEqual(typeof supportsDescriptors, 'boolean', 'supportsDescriptors should be a boolean');
assert.strictEqual(supportsDescriptors, true, 'supportsDescriptors should be true in modern Node environments');
assert.strictEqual(defineProperties.supportsDescriptors, true, 'defineProperties.supportsDescriptors must be true');
assert.strictEqual(importedDefine.supportsDescriptors, true, 'importedDefine.supportsDescriptors must match');

// 2. assert defineProperties attaches properties non-enumerably when supportsDescriptors is true
const targetObj = {};
defineProperties(targetObj, {
  foo: 'bar',
  numeric: 42,
});
assert.strictEqual(targetObj.foo, 'bar', 'Property foo should be defined with value bar');
assert.strictEqual(targetObj.numeric, 42, 'Property numeric should be defined with value 42');
assert.strictEqual(Object.prototype.propertyIsEnumerable.call(targetObj, 'foo'), false, 'foo must be non-enumerable');
assert.strictEqual(Object.prototype.propertyIsEnumerable.call(targetObj, 'numeric'), false, 'numeric must be non-enumerable');
assert.deepStrictEqual(Object.keys(targetObj), [], 'Object.keys should return empty array for non-enumerable properties');
const descFoo = Object.getOwnPropertyDescriptor(targetObj, 'foo');
assert.strictEqual(descFoo.enumerable, false, 'Descriptor enumerable must be false');
assert.strictEqual(descFoo.configurable, true, 'Descriptor configurable must be true');
assert.strictEqual(descFoo.writable, true, 'Descriptor writable must be true');

// 3. assert defineProperties does not overwrite existing properties by default
const existingObj = { existing: 'original' };
defineProperties(existingObj, {
  existing: 'modified',
  newProp: 'added',
});
assert.strictEqual(existingObj.existing, 'original', 'Existing property should not be overwritten by default');
assert.strictEqual(existingObj.newProp, 'added', 'New property should be added');

// 4. assert defineProperties overwrites existing properties when predicate is true
const overwriteObj = { prop: 'initial' };
defineProperties(overwriteObj, {
  prop: 'updated',
}, {
  prop: true,
});
assert.strictEqual(overwriteObj.prop, 'updated', 'Property should be overwritten when predicate is true');

// 5. assert defineProperties uses custom predicate function to conditionally overwrite
const predicateObj = { count: 10 };
defineProperties(predicateObj, {
  count: 20,
}, {
  count: () => false,
});
assert.strictEqual(predicateObj.count, 10, 'Property should not be overwritten when predicate returns false');

defineProperties(predicateObj, {
  count: 30,
}, {
  count: () => true,
});
assert.strictEqual(predicateObj.count, 30, 'Property should be overwritten when predicate returns true');

// 6. assert defineProperties defines symbol properties when supported
const sym = Symbol('testSymbol');
const symObj = {};
defineHelper(symObj, {
  [sym]: 'symbolValue',
});
assert.strictEqual(symObj[sym], 'symbolValue', 'Symbol property should be defined correctly');
assert.strictEqual(Object.prototype.propertyIsEnumerable.call(symObj, sym), false, 'Symbol property must be non-enumerable');
const descSym = Object.getOwnPropertyDescriptor(symObj, sym);
assert.strictEqual(descSym.enumerable, false, 'Symbol descriptor enumerable must be false');

console.log('All define-properties.supportsDescriptors contract assertions passed.');

Seeder de origem

anônimo