Пример
es-define-property 1.0.1: defineProperty
Проверенный пример — npm es-define-property 1.0.1: defineProperty. Контракт выполнен на node 22 · linux alpine/x64 · docker и пройден.
sha256:aa035e7ea886caa527ef94e834395c946a367263fc8c9140a8db28dcd114c8da
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
windows 11 x64 npm
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-19 |
Кейс
HOW- Цель
- verify pkg:npm/es-define-property@1.0.1
- Пакеты
- Символы
-
- defineProperty
- Создан
- 2026-08-18T18:03:55Z
Контракт
- defineProperty defines value property on target object and returns the target object
- defineProperty configures writable and enumerable attributes according to property descriptor
- defineProperty defines getter and setter accessor properties on target object
- defineProperty throws TypeError when target is not an object or when descriptor is invalid
- wrapper defineCustomProperty matches direct defineProperty behavior
Файлы
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Исходный код
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 pkg:npm/es-define-property@1.0.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/es-define-property@1.0.1
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@11.8.0
- runtime: node@24.13.1
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:2afbe69c8f36a27381bfd1fba95cd27c296578b7088272013358a5de695fcb76","constraints":{"executionContext":"node"},"contract":["defineProperty defines value property on target object and returns the target object","defineProperty configures writable and enumerable attributes according to property descriptor","defineProperty defines getter and setter accessor properties on target object","defineProperty throws TypeError when target is not an object or when descriptor is invalid","wrapper defineCustomProperty matches direct defineProperty behavior"],"goal":"verify pkg:npm/es-define-property@1.0.1","kind":"HOW","packages":["pkg:npm/es-define-property@1.0.1"],"schemaVersion":1,"symbols":["defineProperty"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","os":"windows","osVersionBucket":"11","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/es-define-property@1.0.1"],"schemaVersion":1,"symbols":["defineProperty"],"verifierAdapter":"node-typescript@1"}
import defineProperty from 'es-define-property';
/**
* Defines or modifies a property on an object with the specified descriptor.
* @param {object} obj - The target object.
* @param {string|symbol} prop - The property name or symbol.
* @param {PropertyDescriptor} descriptor - The descriptor for the property.
* @returns {object} The object that was passed to the function.
*/
export function defineCustomProperty(obj, prop, descriptor) {
return defineProperty(obj, prop, descriptor);
}
export default defineProperty;
{
"name": "sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample",
"version": "1.0.0",
"dependencies": {
"es-define-property": "1.0.1"
}
},
"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"
}
}
}
}
{
"name": "sample",
"version": "1.0.0",
"type": "module",
"dependencies": {
"es-define-property": "1.0.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/es-define-property@1.0.1",
"kind": "HOW",
"packages": [
"pkg:npm/es-define-property@1.0.1"
],
"symbols": [
"defineProperty"
]
}
import assert from 'node:assert/strict';
import defineProperty from 'es-define-property';
import { defineCustomProperty } from '../index.mjs';
// Case 1: defineProperty defines value property on target object and returns the target object
{
const target = {};
const result = defineProperty(target, 'greeting', {
value: 'hello world',
writable: true,
enumerable: true,
configurable: true
});
assert.equal(result, target, 'defineProperty must return the modified target object');
assert.equal(target.greeting, 'hello world', 'property value must match the descriptor value');
}
// Case 2: defineProperty configures writable and enumerable attributes according to property descriptor
{
const obj = {};
defineProperty(obj, 'hidden', {
value: 42,
writable: false,
enumerable: false,
configurable: false
});
assert.equal(obj.hidden, 42, 'property value should be accessible');
assert.deepEqual(Object.keys(obj), [], 'non-enumerable property must not appear in Object.keys');
const descriptor = Object.getOwnPropertyDescriptor(obj, 'hidden');
assert.equal(descriptor.value, 42, 'descriptor value should be 42');
assert.equal(descriptor.writable, false, 'descriptor writable should be false');
assert.equal(descriptor.enumerable, false, 'descriptor enumerable should be false');
assert.equal(descriptor.configurable, false, 'descriptor configurable should be false');
// Writable false should prevent modification in strict mode
assert.throws(
() => {
'use strict';
obj.hidden = 99;
},
TypeError,
'writing to non-writable property should throw TypeError in strict mode'
);
}
// Case 3: defineProperty defines getter and setter accessor properties on target object
{
const person = {
_age: 20
};
let getterCalled = false;
let setterCalled = false;
defineProperty(person, 'age', {
get() {
getterCalled = true;
return this._age;
},
set(newAge) {
setterCalled = true;
this._age = newAge;
},
enumerable: true,
configurable: true
});
assert.equal(person.age, 20, 'getter should return current age');
assert.equal(getterCalled, true, 'getter function must be invoked');
person.age = 25;
assert.equal(setterCalled, true, 'setter function must be invoked');
assert.equal(person.age, 25, 'getter should return updated age');
}
// Case 4: defineProperty throws TypeError when target is not an object or when descriptor is invalid
{
assert.throws(
() => {
defineProperty(null, 'key', { value: 1 });
},
TypeError,
'defining property on null target should throw TypeError'
);
assert.throws(
() => {
defineProperty('primitive', 'key', { value: 1 });
},
TypeError,
'defining property on string primitive should throw TypeError'
);
assert.throws(
() => {
defineProperty({}, 'key', 'invalid descriptor');
},
TypeError,
'passing non-object descriptor should throw TypeError'
);
}
// Case 5: wrapper defineCustomProperty matches direct defineProperty behavior
{
const target = {};
const res = defineCustomProperty(target, 'status', {
value: 'active',
enumerable: true
});
assert.equal(res, target, 'wrapper should return target object');
assert.equal(target.status, 'active', 'wrapper should set property value');
}
console.log('PASS: all es-define-property contract assertions passed');
Исходный сидер
аноним