Sample
yargs-parser 21.1.1
Verified sample for npm yargs-parser 21.1.1. The contract ran on node 22 · linux alpine/x64 · docker and passed: yargsParser parses command-line argument…
sha256:3246e0f5e686a30bf000a9f3911e478e2485c0d45540a5a7dacb67aeefa112d3
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
linux 24 · ubuntu · glibc 2.39 x64 npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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-23 |
Case
HOW- Goal
- verify pkg:npm/yargs-parser@21.1.1
- Packages
- Created
- 2026-08-23T08:19:27Z
Contract
- yargsParser parses command-line argument arrays and strings into key-value flags and positional arguments
- yargsParser handles typed options including boolean flags, aliases, numbers, defaults, and custom coercion
- yargsParser expands nested object structures via dot-notation and parses boolean negations
- yargsParser separates trailing positional arguments following the double-dash delimiter when populate-- configuration is enabled
- yargsParser.detailed returns detailed arguments object with parsed argv, configuration, aliases, and error state
- yargsParser utility methods convert strings with camelCase and decamelize and identify numeric strings with looksLikeNumber
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
Source
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/yargs-parser@21.1.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/yargs-parser@21.1.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:bedb924d5cff13d045a6c96fefca82e4b7c5c6093a5fd851723a1a16a44dad52","contract":["yargsParser parses command-line argument arrays and strings into key-value flags and positional arguments","yargsParser handles typed options including boolean flags, aliases, numbers, defaults, and custom coercion","yargsParser expands nested object structures via dot-notation and parses boolean negations","yargsParser separates trailing positional arguments following the double-dash delimiter when populate-- configuration is enabled","yargsParser.detailed returns detailed arguments object with parsed argv, configuration, aliases, and error state","yargsParser utility methods convert strings with camelCase and decamelize and identify numeric strings with looksLikeNumber"],"goal":"verify pkg:npm/yargs-parser@21.1.1","kind":"HOW","packages":["pkg:npm/yargs-parser@21.1.1"],"schemaVersion":1},"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/yargs-parser@21.1.1"],"schemaVersion":1,"subject":"pkg:npm/yargs-parser@21.1.1","verifierAdapter":"node-typescript@1"}
{
"name": "sample-yargs-parser",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-yargs-parser",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"yargs-parser": "21.1.1"
}
},
"node_modules/yargs-parser": {
"version": "21.1.1",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz",
"integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==",
"license": "ISC",
"engines": {
"node": ">=12"
}
}
}
}
{
"name": "sample-yargs-parser",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of yargs-parser@21.1.1",
"main": "src/index.mjs",
"type": "module",
"license": "MIT-0",
"dependencies": {
"yargs-parser": "21.1.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/yargs-parser@21.1.1",
"kind": "HOW",
"packages": [
"pkg:npm/yargs-parser@21.1.1"
]
}
import yargsParser from "yargs-parser";
/**
* Parses command-line arguments using yargs-parser.
*
* @param {string|string[]} args - Arguments string or array of argument strings.
* @param {object} [opts={}] - Parser configuration options.
* @returns {object} Parsed command-line arguments.
*/
export function parseArgs(args, opts = {}) {
return yargsParser(args, opts);
}
/**
* Parses arguments and returns detailed metadata including error and aliases.
*
* @param {string|string[]} args - Arguments string or array of argument strings.
* @param {object} [opts={}] - Parser configuration options.
* @returns {object} Detailed parsing result.
*/
export function parseDetailed(args, opts = {}) {
return yargsParser.detailed(args, opts);
}
/**
* Converts a hyphenated or delimited string into camelCase.
*
* @param {string} str - Input string.
* @returns {string} Camel-cased string.
*/
export function toCamelCase(str) {
return yargsParser.camelCase(str);
}
/**
* Converts a camelCase string into a delimited string.
*
* @param {string} str - Input string.
* @param {string} [joinString='-'] - Separator character.
* @returns {string} Decamelized string.
*/
export function toDecamelize(str, joinString = "-") {
return yargsParser.decamelize(str, joinString);
}
/**
* Determines whether a given value looks like a numeric string.
*
* @param {any} val - Value to test.
* @returns {boolean} True if the value appears numeric.
*/
export function looksLikeNumber(val) {
return yargsParser.looksLikeNumber(val);
}
export default yargsParser;
import assert from "node:assert/strict";
import yargsParser, {
parseArgs,
parseDetailed,
toCamelCase,
toDecamelize,
looksLikeNumber,
} from "../src/index.mjs";
// 1. yargsParser parses command-line argument arrays and strings into key-value flags and positional arguments
{
const parsedArray = yargsParser(["--port", "8080", "--host", "localhost", "build", "target"], {
number: ["port"],
});
assert.strictEqual(parsedArray.port, 8080);
assert.strictEqual(parsedArray.host, "localhost");
assert.deepStrictEqual(parsedArray._, ["build", "target"]);
const parsedString = parseArgs("--mode production file.js");
assert.strictEqual(parsedString.mode, "production");
assert.deepStrictEqual(parsedString._, ["file.js"]);
}
// 2. yargsParser handles typed options including boolean flags, aliases, numbers, defaults, and custom coercion
{
const parsed = parseArgs(["-f", "-c", "4", "--retries", "3"], {
alias: { f: "force", c: "count" },
boolean: ["force"],
number: ["count", "retries"],
default: { timeout: 5000 },
coerce: {
retries: (val) => val * 2,
},
});
assert.strictEqual(parsed.force, true);
assert.strictEqual(parsed.f, true);
assert.strictEqual(parsed.count, 4);
assert.strictEqual(parsed.c, 4);
assert.strictEqual(parsed.retries, 6);
assert.strictEqual(parsed.timeout, 5000);
}
// 3. yargsParser expands nested object structures via dot-notation and parses boolean negations
{
const parsed = parseArgs("--server.host 127.0.0.1 --server.port 3000 --no-ssl --no-cache");
assert.deepStrictEqual(parsed.server, { host: "127.0.0.1", port: 3000 });
assert.strictEqual(parsed.ssl, false);
assert.strictEqual(parsed.cache, false);
}
// 4. yargsParser separates trailing positional arguments following the double-dash delimiter when populate-- configuration is enabled
{
const parsed = parseArgs(["--watch", "--", "arg1", "arg2", "--opt-inside"], {
boolean: ["watch"],
configuration: { "populate--": true },
});
assert.strictEqual(parsed.watch, true);
assert.deepStrictEqual(parsed["--"], ["arg1", "arg2", "--opt-inside"]);
}
// 5. yargsParser.detailed returns detailed arguments object with parsed argv, configuration, aliases, and error state
{
const detailed = parseDetailed(["-e", "prod"], {
alias: { e: "env" },
});
assert.strictEqual(typeof detailed, "object");
assert.strictEqual(detailed.error, null);
assert.strictEqual(detailed.argv.env, "prod");
assert.strictEqual(detailed.argv.e, "prod");
assert.strictEqual(typeof detailed.configuration, "object");
assert.strictEqual(detailed.configuration["boolean-negation"], true);
}
// 6. yargsParser utility methods convert strings with camelCase and decamelize and identify numeric strings with looksLikeNumber
{
assert.strictEqual(toCamelCase("hello-world-parser"), "helloWorldParser");
assert.strictEqual(toCamelCase("foo_bar_baz"), "fooBarBaz");
assert.strictEqual(toDecamelize("helloWorldParser", "-"), "hello-world-parser");
assert.strictEqual(toDecamelize("fooBarBaz", "_"), "foo_bar_baz");
assert.strictEqual(looksLikeNumber("12345"), true);
assert.strictEqual(looksLikeNumber("3.1415"), true);
assert.strictEqual(looksLikeNumber("0xFF"), true);
assert.strictEqual(looksLikeNumber("notANumber"), false);
}
console.log("Contract test passed successfully.");
Origin Seeder
anonymous