Exemplo
define-data-property 1.1.4: define data property on object with custom descriptor attributes
Amostra verificada para npm define-data-property 1.1.4: define data property on object with custom descriptor attributes. O contrato rodou em node 22 · linux…
sha256:d53e78c0c1b3d361623f983bc6d8b45e12a29efc3a18d7320c4aa6b950de8a99
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
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-26 |
Caso
HOW- Objetivo
- define data property on object with custom descriptor attributes
- Pacotes
- Símbolos
-
- defineDataProperty
- Ambiente
- node 22.23.2
- Criado
- 2026-08-26T09:00:43Z
Contrato
- defines basic data property with default enumerable, writable, and configurable attributes
- defines non-enumerable property when nonEnumerable is true
- defines non-writable property when nonWritable is true
- defines non-configurable property when nonConfigurable is true
- defines data property on object using Symbol property keys
- preserves existing property descriptor flags when null is passed for attribute flags
- throws TypeError when target object or property name is invalid
Arquivos
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
Código-fonte
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: define data property on object with custom descriptor attributes
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/define-data-property@1.1.4
Demonstrate these symbols/APIs:
- defineDataProperty
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.
{"case":{"caseId":"case:sha256:d647c3f5d1fc320fa842bffda2a164357f72acc82c16ae82124f535a61a1915e","contract":["defines basic data property with default enumerable, writable, and configurable attributes","defines non-enumerable property when nonEnumerable is true","defines non-writable property when nonWritable is true","defines non-configurable property when nonConfigurable is true","defines data property on object using Symbol property keys","preserves existing property descriptor flags when null is passed for attribute flags","throws TypeError when target object or property name is invalid"],"goal":"define data property on object with custom descriptor attributes","kind":"HOW","packages":["pkg:npm/define-data-property@1.1.4"],"schemaVersion":1,"symbols":["defineDataProperty"]},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/define-data-property@1.1.4"],"schemaVersion":1,"subject":"pkg:npm/define-data-property@1.1.4","symbols":["defineDataProperty"],"verifierAdapter":"node-typescript@1"}
const defineDataProperty = require('define-data-property');
module.exports = {
defineDataProperty
};
{
"name": "sample-define-data-property",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-define-data-property",
"version": "1.0.0",
"dependencies": {
"define-data-property": "1.1.4"
}
},
"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/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"
}
}
}
}
{
"name": "sample-define-data-property",
"version": "1.0.0",
"private": true,
"description": "Clean-room code sample for define-data-property@1.1.4",
"main": "index.js",
"dependencies": {
"define-data-property": "1.1.4"
}
}
{
"schemaVersion": 1,
"goal": "define data property on object with custom descriptor attributes",
"kind": "HOW",
"packages": [
"pkg:npm/define-data-property@1.1.4"
],
"symbols": [
"defineDataProperty"
]
}
const assert = require('node:assert/strict');
const defineDataProperty = require('define-data-property');
async function run() {
// 1. defines basic data property with default enumerable, writable, and configurable attributes
{
const target = {};
defineDataProperty(target, 'foo', 'bar');
assert.equal(target.foo, 'bar');
const desc = Object.getOwnPropertyDescriptor(target, 'foo');
assert.deepEqual(desc, {
value: 'bar',
writable: true,
enumerable: true,
configurable: true
});
}
// 2. defines non-enumerable property when nonEnumerable is true
{
const target = {};
defineDataProperty(target, 'hidden', 42, true);
assert.equal(target.hidden, 42);
assert.equal(Object.keys(target).includes('hidden'), false);
const desc = Object.getOwnPropertyDescriptor(target, 'hidden');
assert.equal(desc.enumerable, false);
assert.equal(desc.writable, true);
assert.equal(desc.configurable, true);
}
// 3. defines non-writable property when nonWritable is true
{
const target = {};
defineDataProperty(target, 'readonly', 'immutable', false, true);
assert.equal(target.readonly, 'immutable');
const desc = Object.getOwnPropertyDescriptor(target, 'readonly');
assert.equal(desc.writable, false);
assert.equal(desc.enumerable, true);
assert.equal(desc.configurable, true);
assert.throws(() => {
'use strict';
target.readonly = 'mutated';
}, TypeError);
}
// 4. defines non-configurable property when nonConfigurable is true
{
const target = {};
defineDataProperty(target, 'locked', 'static', false, false, true);
assert.equal(target.locked, 'static');
const desc = Object.getOwnPropertyDescriptor(target, 'locked');
assert.equal(desc.configurable, false);
assert.equal(desc.writable, true);
assert.equal(desc.enumerable, true);
assert.throws(() => {
'use strict';
delete target.locked;
}, TypeError);
}
// 5. defines data property on object using Symbol property keys
{
const target = {};
const symKey = Symbol('sampleKey');
defineDataProperty(target, symKey, 'symbolValue');
assert.equal(target[symKey], 'symbolValue');
const desc = Object.getOwnPropertyDescriptor(target, symKey);
assert.equal(desc.value, 'symbolValue');
assert.equal(desc.enumerable, true);
}
// 6. preserves existing property descriptor flags when null is passed for attribute flags
{
const target = {};
Object.defineProperty(target, 'existing', {
value: 'initial',
writable: true,
enumerable: false,
configurable: true
});
defineDataProperty(target, 'existing', 'updated', null, null, null);
assert.equal(target.existing, 'updated');
const desc = Object.getOwnPropertyDescriptor(target, 'existing');
assert.equal(desc.value, 'updated');
assert.equal(desc.enumerable, false);
assert.equal(desc.writable, true);
assert.equal(desc.configurable, true);
}
// 7. throws TypeError when target object or property name is invalid
{
assert.throws(() => defineDataProperty(null, 'foo', 'bar'), TypeError);
assert.throws(() => defineDataProperty(undefined, 'foo', 'bar'), TypeError);
assert.throws(() => defineDataProperty(123, 'foo', 'bar'), TypeError);
assert.throws(() => defineDataProperty({}, 123, 'bar'), TypeError);
assert.throws(() => defineDataProperty({}, 'foo', 'bar', 'not-a-bool'), TypeError);
assert.throws(() => defineDataProperty({}, 'foo', 'bar', false, 'not-a-bool'), TypeError);
}
}
run().catch((err) => {
console.error(err);
process.exit(1);
});
Seeder de origem
anônimo