CodeSampleX

Sample

gopd 1.2.0: get own property descriptor using gopd

Verified sample for npm gopd 1.2.0: get own property descriptor using gopd. The contract ran on node 22 · linux alpine/x64 · docker and passed.

sha256:a8095343450ac4da1509c6adee69a02d38acca36795bc5617be1a926e02344ef

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment windows 11 x64 npm

Verification-run environments

Environment Contract Stages Run
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

Case

HOW
Goal
get own property descriptor using gopd
Packages
Symbols
  • gopd
Created
2026-08-18T17:56:03Z

Contract

  1. gopd returns descriptor for own data property on an object
  2. gopd returns undefined for non-existent property
  3. gopd returns undefined for inherited property not directly on object
  4. gopd returns descriptor with accessor functions for getter and setter

Files

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

Download the source artifact (tar.gz)

Source

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: get own property descriptor using gopd
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/gopd@1.2.0
Demonstrate these symbols/APIs:
  - gopd
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.
csx.json
{"case":{"caseId":"case:sha256:35e8ba49e0d3a91b37af13586a872d86ba32dd4556c57a85112b24e8502c0d5c","constraints":{"executionContext":"node"},"contract":["gopd returns descriptor for own data property on an object","gopd returns undefined for non-existent property","gopd returns undefined for inherited property not directly on object","gopd returns descriptor with accessor functions for getter and setter"],"goal":"get own property descriptor using gopd","kind":"HOW","packages":["pkg:npm/gopd@1.2.0"],"schemaVersion":1,"symbols":["gopd"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","os":"windows","osVersionBucket":"11","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/gopd@1.2.0"],"schemaVersion":1,"symbols":["gopd"],"verifierAdapter":"node-typescript@1"}
index.mjs
import gOPD from 'gopd';

/**
 * Retrieves the property descriptor of a given own property on an object.
 * @param {object} obj
 * @param {string|symbol} prop
 * @returns {PropertyDescriptor | undefined}
 */
export function getDescriptor(obj, prop) {
  if (typeof gOPD !== 'function') {
    throw new Error('Object.getOwnPropertyDescriptor is not supported in this environment');
  }
  return gOPD(obj, prop);
}
package-lock.json
{
  "name": "sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample",
      "version": "1.0.0",
      "dependencies": {
        "gopd": "1.2.0"
      }
    },
    "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"
      }
    }
  }
}
package.json
{
  "name": "sample",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "gopd": "1.2.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "get own property descriptor using gopd",
  "kind": "HOW",
  "packages": [
    "pkg:npm/gopd@1.2.0"
  ],
  "symbols": [
    "gopd"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@11.8.0",
    "runtime": "node@24.13.1"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import gOPD from 'gopd';

assert.equal(typeof gOPD, 'function', 'gopd must be a function in Node.js');

// Contract 1: gopd returns descriptor for own data property on an object
{
  const target = { a: 42 };
  const desc = gOPD(target, 'a');
  assert.notEqual(desc, undefined);
  assert.equal(desc.value, 42);
  assert.equal(desc.writable, true);
  assert.equal(desc.enumerable, true);
  assert.equal(desc.configurable, true);
}

// Contract 2: gopd returns undefined for non-existent property
{
  const target = { a: 42 };
  const desc = gOPD(target, 'b');
  assert.equal(desc, undefined);
}

// Contract 3: gopd returns undefined for inherited property not directly on object
{
  const proto = { inherited: 'val' };
  const target = Object.create(proto);
  target.own = 'ownVal';

  assert.notEqual(gOPD(target, 'own'), undefined);
  assert.equal(gOPD(target, 'inherited'), undefined);
}

// Contract 4: gopd returns descriptor with accessor functions for getter and setter
{
  const getter = () => 123;
  const setter = () => {};
  const target = {};
  Object.defineProperty(target, 'accessorProp', {
    get: getter,
    set: setter,
    enumerable: false,
    configurable: true
  });

  const desc = gOPD(target, 'accessorProp');
  assert.notEqual(desc, undefined);
  assert.equal(desc.get, getter);
  assert.equal(desc.set, setter);
  assert.equal(desc.enumerable, false);
  assert.equal(desc.configurable, true);
  assert.equal(desc.value, undefined);
  assert.equal(desc.writable, undefined);
}

console.log('All contract assertions passed successfully.');

Origin Seeder

anonymous