CodeSampleX

Sample

is-generator-fn 2.1.0: isGeneratorFn

Verified sample for npm is-generator-fn 2.1.0: isGeneratorFn. The contract ran on node 22 · linux alpine/x64 · docker and passed.

sha256:4950ea4c98aad480bca2d9ac40bbd040e406f660bd5119827412da115efb2fae

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 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

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-27

Case

HOW
Goal
verify pkg:npm/is-generator-fn@2.1.0
Packages
Symbols
  • isGeneratorFn
Environment
node 22.23.2
Created
2026-08-27T16:27:28Z

Contract

  1. assert generator function declaration and expression return true
  2. assert standard synchronous function and arrow function return false
  3. assert async function and async generator function return false
  4. assert generator iterator object instance returns false
  5. assert non-function primitives and objects return false
  6. assert isGeneratorFn.default export compatibility

Files

  • PROMPT.md
  • csx.json
  • index.js
  • 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: verify pkg:npm/is-generator-fn@2.1.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/is-generator-fn@2.1.0
Demonstrate these symbols/APIs:
  - isGeneratorFn

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:0acb04823e0323990cc1f914f865e2efd97e77bfe8b24760cd1135c401804b72","contract":["assert generator function declaration and expression return true","assert standard synchronous function and arrow function return false","assert async function and async generator function return false","assert generator iterator object instance returns false","assert non-function primitives and objects return false","assert isGeneratorFn.default export compatibility"],"goal":"verify pkg:npm/is-generator-fn@2.1.0","kind":"HOW","packages":["pkg:npm/is-generator-fn@2.1.0"],"schemaVersion":1,"symbols":["isGeneratorFn"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/is-generator-fn@2.1.0"],"schemaVersion":1,"subject":"pkg:npm/is-generator-fn@2.1.0","symbols":["isGeneratorFn"],"verifierAdapter":"node-typescript@1"}
index.js
const isGeneratorFn = require('is-generator-fn');

function checkGenerator(fn) {
  return isGeneratorFn(fn);
}

module.exports = {
  isGeneratorFn,
  checkGenerator,
};
package-lock.json
{
  "name": "sample-is-generator-fn",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-is-generator-fn",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "is-generator-fn": "2.1.0"
      }
    },
    "node_modules/is-generator-fn": {
      "version": "2.1.0",
      "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz",
      "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==",
      "license": "MIT",
      "engines": {
        "node": ">=6"
      }
    }
  }
}
package.json
{
  "name": "sample-is-generator-fn",
  "version": "1.0.0",
  "description": "Minimal clean-room sample verifying isGeneratorFn in is-generator-fn",
  "main": "index.js",
  "license": "MIT-0",
  "dependencies": {
    "is-generator-fn": "2.1.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/is-generator-fn@2.1.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/is-generator-fn@2.1.0"
  ],
  "symbols": [
    "isGeneratorFn"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import isGeneratorFn from 'is-generator-fn';
import { checkGenerator } from '../index.js';

// 1. Generator function declaration and expression return true
function* sampleGenerator() {
  yield 1;
  yield 2;
}
const anonGen = function* () {
  yield 'a';
};
const customGenCtor = Object.getPrototypeOf(function* () {}).constructor;
const instantiatedGen = new customGenCtor('yield 42');

assert.strictEqual(isGeneratorFn(sampleGenerator), true, 'Generator function declaration must return true');
assert.strictEqual(isGeneratorFn(anonGen), true, 'Anonymous generator function expression must return true');
assert.strictEqual(isGeneratorFn(instantiatedGen), true, 'GeneratorFunction instance must return true');
assert.strictEqual(checkGenerator(sampleGenerator), true, 'checkGenerator helper must return true for generator function');

// 2. Standard synchronous function and arrow function return false
function regularFn() {
  return 1;
}
const arrowFn = () => 2;

assert.strictEqual(isGeneratorFn(regularFn), false, 'Regular function declaration must return false');
assert.strictEqual(isGeneratorFn(arrowFn), false, 'Arrow function must return false');
assert.strictEqual(checkGenerator(regularFn), false, 'checkGenerator helper must return false for regular function');

// 3. Async function and async generator function return false
async function asyncFn() {
  return 3;
}
const asyncArrowFn = async () => 4;
async function* asyncGenFn() {
  yield 5;
}

assert.strictEqual(isGeneratorFn(asyncFn), false, 'Async function must return false');
assert.strictEqual(isGeneratorFn(asyncArrowFn), false, 'Async arrow function must return false');
assert.strictEqual(isGeneratorFn(asyncGenFn), false, 'Async generator function must return false');

// 4. Generator iterator object instance returns false
const iteratorObj = sampleGenerator();
assert.strictEqual(isGeneratorFn(iteratorObj), false, 'Generator iterator instance must return false');

// 5. Non-function primitives and objects return false
assert.strictEqual(isGeneratorFn(null), false, 'null must return false');
assert.strictEqual(isGeneratorFn(undefined), false, 'undefined must return false');
assert.strictEqual(isGeneratorFn(42), false, 'number must return false');
assert.strictEqual(isGeneratorFn('function* () {}'), false, 'string must return false');
assert.strictEqual(isGeneratorFn({}), false, 'plain object must return false');
assert.strictEqual(isGeneratorFn([]), false, 'array must return false');
assert.strictEqual(isGeneratorFn(true), false, 'boolean must return false');
assert.strictEqual(isGeneratorFn(Symbol('gen')), false, 'symbol must return false');

// 6. Default export and property compatibility
assert.strictEqual(typeof isGeneratorFn, 'function', 'isGeneratorFn must be a function');
assert.strictEqual(isGeneratorFn.default, isGeneratorFn, 'isGeneratorFn.default must point to isGeneratorFn');

console.log('All is-generator-fn contract assertions passed.');

Origin Seeder

anonymous