サンプル
pathval 2.0.1: getPathValue
検証済みサンプル — npm pathval 2.0.1: getPathValue. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: getPathValue is exported as a function from the…
sha256:1694bfc8bf02ef27e04c1cc1e7d8f4ce390450c4facff17f9d7b0cf760e9d7c7
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 2
- ビルドした署名鍵
- 1
宣言された環境
linux 24 · ubuntu · glibc 2.39 x64 npm
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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 |
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-07 |
ケース
HOW- ゴール
- verify getPathValue in pkg:npm/pathval@2.0.1
- パッケージ
- シンボル
-
- getPathValue
- 作成日
- 2026-08-26T11:06:33Z
コントラクト
- getPathValue is exported as a function from the pathval module
- getPathValue retrieves shallow and deeply nested object properties using dot-delimited path strings
- getPathValue retrieves array elements by index using bracket notation and supports chained object properties within arrays
- getPathValue resolves property keys containing literal dots and brackets when escaped with backslashes
- getPathValue returns undefined for non-existent direct properties and null when intermediate path segments do not exist
- getPathValue returns null without throwing when the target object is null or undefined
- getPathValue resolves property and index access on primitive values including string characters and string length
- getPathValue prevents prototype pollution by returning undefined when querying prototype, constructor, or __proto__ properties
- getPathValue accurately preserves and retrieves falsy values such as false, 0, empty string, and null
ファイル
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- 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 getPathValue in pkg:npm/pathval@2.0.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/pathval@2.0.1
Demonstrate these symbols/APIs:
- getPathValue
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:d8480a77fe50424148a1c99b01a64954e9c218a43ab47a51b18d234d235be805","contract":["getPathValue is exported as a function from the pathval module","getPathValue retrieves shallow and deeply nested object properties using dot-delimited path strings","getPathValue retrieves array elements by index using bracket notation and supports chained object properties within arrays","getPathValue resolves property keys containing literal dots and brackets when escaped with backslashes","getPathValue returns undefined for non-existent direct properties and null when intermediate path segments do not exist","getPathValue returns null without throwing when the target object is null or undefined","getPathValue resolves property and index access on primitive values including string characters and string length","getPathValue prevents prototype pollution by returning undefined when querying prototype, constructor, or __proto__ properties","getPathValue accurately preserves and retrieves falsy values such as false, 0, empty string, and null"],"goal":"verify getPathValue in pkg:npm/pathval@2.0.1","kind":"HOW","packages":["pkg:npm/pathval@2.0.1"],"schemaVersion":1,"symbols":["getPathValue"]},"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/pathval@2.0.1"],"schemaVersion":1,"subject":"pkg:npm/pathval@2.0.1","symbols":["getPathValue"],"verifierAdapter":"node-typescript@1"}
{
"name": "verify-pathval-get-path-value",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "verify-pathval-get-path-value",
"version": "1.0.0",
"dependencies": {
"pathval": "2.0.1"
}
},
"node_modules/pathval": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz",
"integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==",
"license": "MIT",
"engines": {
"node": ">= 14.16"
}
}
}
}
{
"name": "verify-pathval-get-path-value",
"version": "1.0.0",
"private": true,
"type": "module",
"dependencies": {
"pathval": "2.0.1"
}
}
{
"schemaVersion": 1,
"goal": "verify getPathValue in pkg:npm/pathval@2.0.1",
"kind": "HOW",
"packages": [
"pkg:npm/pathval@2.0.1"
],
"symbols": [
"getPathValue"
]
}
import { getPathValue, getPathInfo, hasProperty, setPathValue } from 'pathval';
/**
* Retrieve the value located at a string path in an object.
*
* @param {Object} obj - Target object to query
* @param {string} path - Dot/bracket notation path (e.g. "a.b[0].c")
* @returns {*} The value at the path or undefined if not found
*/
export function getValueByPath(obj, path) {
return getPathValue(obj, path);
}
export { getPathValue, getPathInfo, hasProperty, setPathValue };
export default getPathValue;
import assert from 'node:assert/strict';
import { getPathValue } from 'pathval';
import { getValueByPath } from '../src/index.mjs';
// 1. Module export verification
{
assert.equal(typeof getPathValue, 'function');
assert.equal(typeof getValueByPath, 'function');
}
// 2. getPathValue retrieves shallow and deeply nested object properties using dot-delimited path strings
{
const data = {
user: {
name: 'Alice',
profile: {
age: 30,
city: 'Seoul'
}
},
version: '2.0.1'
};
assert.equal(getPathValue(data, 'version'), '2.0.1');
assert.equal(getPathValue(data, 'user.name'), 'Alice');
assert.equal(getPathValue(data, 'user.profile.age'), 30);
assert.equal(getPathValue(data, 'user.profile.city'), 'Seoul');
assert.equal(getValueByPath(data, 'user.name'), 'Alice');
}
// 3. getPathValue retrieves array elements by index using bracket notation and supports chained object properties within arrays
{
const catalog = {
departments: [
{
name: 'Engineering',
members: ['Alice', 'Bob'],
leads: [
{ role: 'Tech Lead', level: 5 },
{ role: 'Team Lead', level: 4 }
]
},
{
name: 'Design',
members: ['Charlie']
}
]
};
assert.equal(getPathValue(catalog, 'departments[0].name'), 'Engineering');
assert.equal(getPathValue(catalog, 'departments[0].members[0]'), 'Alice');
assert.equal(getPathValue(catalog, 'departments[0].members[1]'), 'Bob');
assert.equal(getPathValue(catalog, 'departments[0].leads[1].role'), 'Team Lead');
assert.equal(getPathValue(catalog, 'departments[1].name'), 'Design');
assert.equal(getPathValue(catalog, 'departments[1].members[0]'), 'Charlie');
}
// 4. getPathValue resolves property keys containing literal dots and brackets when escaped with backslashes
{
const complexKeys = {
'service.endpoint': 'https://example.com/api',
'matrix[0]': {
'nested.key': 42
},
config: {
'port:8080.ssl': true
}
};
assert.equal(getPathValue(complexKeys, 'service\\.endpoint'), 'https://example.com/api');
assert.equal(getPathValue(complexKeys, 'matrix\\[0\\].nested\\.key'), 42);
assert.equal(getPathValue(complexKeys, 'config.port:8080\\.ssl'), true);
}
// 5. getPathValue returns undefined for non-existent direct properties and null when intermediate path segments do not exist
{
const target = {
user: {
name: 'Alice'
}
};
assert.equal(getPathValue(target, 'unknown'), undefined);
assert.equal(getPathValue(target, 'user.missingField'), undefined);
assert.equal(getPathValue(target, 'user.missingField.nested'), null);
assert.equal(getPathValue(target, 'deeply.nested.non.existent.path'), null);
}
// 6. getPathValue returns null without throwing when the target object is null or undefined
{
assert.equal(getPathValue(null, 'user.name'), null);
assert.equal(getPathValue(undefined, 'user.name'), null);
assert.equal(getPathValue(null, 'items[0]'), null);
assert.equal(getPathValue(undefined, 'items[0]'), null);
}
// 7. getPathValue resolves property and index access on primitive values including string characters and string length
{
assert.equal(getPathValue('hello world', 'length'), 11);
assert.equal(getPathValue('hello', '[0]'), 'h');
assert.equal(getPathValue('hello', '[4]'), 'o');
assert.equal(getPathValue(12345, 'toString'), Number.prototype.toString);
}
// 8. getPathValue prevents prototype pollution by returning undefined when querying prototype, constructor, or __proto__ properties
{
const sampleObj = { data: 'valid' };
assert.equal(getPathValue(sampleObj, '__proto__'), undefined);
assert.equal(getPathValue(sampleObj, 'constructor'), undefined);
assert.equal(getPathValue(sampleObj, 'prototype'), undefined);
assert.equal(getPathValue(sampleObj, 'data.__proto__'), undefined);
}
// 9. getPathValue accurately preserves and retrieves falsy values such as false, 0, empty string, and null
{
const falsyData = {
flags: [false, 0, '', null, undefined, NaN],
settings: {
enabled: false,
count: 0,
prefix: '',
fallback: null
}
};
assert.equal(getPathValue(falsyData, 'flags[0]'), false);
assert.equal(getPathValue(falsyData, 'flags[1]'), 0);
assert.equal(getPathValue(falsyData, 'flags[2]'), '');
assert.equal(getPathValue(falsyData, 'flags[3]'), null);
assert.equal(getPathValue(falsyData, 'flags[4]'), undefined);
assert.ok(Number.isNaN(getPathValue(falsyData, 'flags[5]')));
assert.equal(getPathValue(falsyData, 'settings.enabled'), false);
assert.equal(getPathValue(falsyData, 'settings.count'), 0);
assert.equal(getPathValue(falsyData, 'settings.prefix'), '');
assert.equal(getPathValue(falsyData, 'settings.fallback'), null);
}
console.log('All pathval getPathValue contract tests passed successfully.');
オリジンシーダー
匿名