CodeSampleX

Sample

is-stream 2.0.1: verify isStream detects Node.js stream instances and differentiate readable writable duplex and transform streams

Verified sample for npm is-stream 2.0.1: verify isStream detects Node.js stream instances and differentiate readable writable duplex and transform streams.…

sha256:9abcd1c6c50d4dfe47b76aa135f65821263e8e0ba491c84fd005f2ba7a9d12ea

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
2
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-23
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

Case

HOW
Goal
verify isStream detects Node.js stream instances and differentiate readable writable duplex and transform streams
Packages
Symbols
  • isStream
  • isStream.duplex
  • isStream.readable
  • isStream.transform
  • isStream.writable
Environment
node 22.23.2
Created
2026-08-23T17:16:52Z

Contract

  1. isStream returns true for Node.js Stream instances and objects with a pipe method, and false for primitives and plain objects
  2. isStream.readable returns true for readable streams including Readable, Duplex, and Transform, and false for purely Writable streams or non-streams
  3. isStream.writable returns true for writable streams including Writable, Duplex, and Transform, and false for purely Readable streams or non-streams
  4. isStream.duplex returns true for streams that are both readable and writable such as Duplex and Transform, and false for purely Readable or Writable streams
  5. isStream.transform returns true for Transform and PassThrough streams, and false for standard Duplex, Readable, or Writable streams

Files

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

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 isStream detects Node.js stream instances and differentiate readable writable duplex and transform streams
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/is-stream@2.0.1
Demonstrate these symbols/APIs:
  - isStream
  - isStream.duplex
  - isStream.readable
  - isStream.transform
  - isStream.writable
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:225b415596d80df259b8372791405b51676ef3e427d40abab45a9509f67b54fe","constraints":{"executionContext":"node"},"contract":["isStream returns true for Node.js Stream instances and objects with a pipe method, and false for primitives and plain objects","isStream.readable returns true for readable streams including Readable, Duplex, and Transform, and false for purely Writable streams or non-streams","isStream.writable returns true for writable streams including Writable, Duplex, and Transform, and false for purely Readable streams or non-streams","isStream.duplex returns true for streams that are both readable and writable such as Duplex and Transform, and false for purely Readable or Writable streams","isStream.transform returns true for Transform and PassThrough streams, and false for standard Duplex, Readable, or Writable streams"],"goal":"verify isStream detects Node.js stream instances and differentiate readable writable duplex and transform streams","kind":"HOW","packages":["pkg:npm/is-stream@2.0.1"],"schemaVersion":1,"symbols":["isStream","isStream.duplex","isStream.readable","isStream.transform","isStream.writable"]},"contractCommand":["node","test/contract.js"],"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-stream@2.0.1"],"schemaVersion":1,"subject":"pkg:npm/is-stream@2.0.1","symbols":["isStream","isStream.duplex","isStream.readable","isStream.transform","isStream.writable"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-is-stream",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-is-stream",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "is-stream": "2.0.1"
      }
    },
    "node_modules/is-stream": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz",
      "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      },
      "funding": {
        "url": "https://github.com/sponsors/sindresorhus"
      }
    }
  }
}
package.json
{
  "name": "sample-is-stream",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for is-stream",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "is-stream": "2.0.1"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify isStream detects Node.js stream instances and differentiate readable writable duplex and transform streams",
  "kind": "HOW",
  "packages": [
    "pkg:npm/is-stream@2.0.1"
  ],
  "symbols": [
    "isStream",
    "isStream.duplex",
    "isStream.readable",
    "isStream.transform",
    "isStream.writable"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
'use strict';

const isStream = require('is-stream');

function inspectStream(value) {
  return {
    isStream: isStream(value),
    isReadable: isStream.readable(value),
    isWritable: isStream.writable(value),
    isDuplex: isStream.duplex(value),
    isTransform: isStream.transform(value)
  };
}

module.exports = {
  inspectStream
};
test/contract.js
'use strict';

const assert = require('node:assert');
const { Stream, Readable, Writable, Duplex, Transform, PassThrough } = require('node:stream');
const isStream = require('is-stream');
const { inspectStream } = require('../src/index.js');

// 1. isStream: returns true for Stream instances and pipe-capable objects, false for primitives and plain objects
assert.strictEqual(isStream(new Stream()), true, 'Stream base instance should be a stream');
assert.strictEqual(isStream(new Readable({ read() {} })), true, 'Readable should be a stream');
assert.strictEqual(isStream(new Writable({ write(c, e, cb) { cb(); } })), true, 'Writable should be a stream');
assert.strictEqual(isStream(new Duplex({ read() {}, write(c, e, cb) { cb(); } })), true, 'Duplex should be a stream');
assert.strictEqual(isStream(new Transform({ transform(c, e, cb) { cb(null, c); } })), true, 'Transform should be a stream');
assert.strictEqual(isStream(new PassThrough()), true, 'PassThrough should be a stream');
assert.strictEqual(isStream({ pipe: () => {} }), true, 'Object with pipe method should be considered a stream');

assert.strictEqual(isStream(null), false, 'null is not a stream');
assert.strictEqual(isStream(undefined), false, 'undefined is not a stream');
assert.strictEqual(isStream(123), false, 'number is not a stream');
assert.strictEqual(isStream('hello'), false, 'string is not a stream');
assert.strictEqual(isStream(true), false, 'boolean is not a stream');
assert.strictEqual(isStream({}), false, 'plain object is not a stream');
assert.strictEqual(isStream([]), false, 'array is not a stream');
assert.strictEqual(isStream(() => {}), false, 'function is not a stream');

// 2. isStream.readable: true for Readable, Duplex, Transform, false for purely Writable or non-streams
const readable = new Readable({ read() {} });
const writable = new Writable({ write(c, e, cb) { cb(); } });
const duplex = new Duplex({ read() {}, write(c, e, cb) { cb(); } });
const transform = new Transform({ transform(c, e, cb) { cb(null, c); } });
const passThrough = new PassThrough();

assert.strictEqual(isStream.readable(readable), true, 'Readable should be readable');
assert.strictEqual(isStream.readable(duplex), true, 'Duplex should be readable');
assert.strictEqual(isStream.readable(transform), true, 'Transform should be readable');
assert.strictEqual(isStream.readable(passThrough), true, 'PassThrough should be readable');
assert.strictEqual(isStream.readable(writable), false, 'Writable should not be readable');
assert.strictEqual(isStream.readable(new Stream()), false, 'Raw Stream base should not be readable');
assert.strictEqual(isStream.readable({}), false, 'plain object should not be readable');

// 3. isStream.writable: true for Writable, Duplex, Transform, false for purely Readable or non-streams
assert.strictEqual(isStream.writable(writable), true, 'Writable should be writable');
assert.strictEqual(isStream.writable(duplex), true, 'Duplex should be writable');
assert.strictEqual(isStream.writable(transform), true, 'Transform should be writable');
assert.strictEqual(isStream.writable(passThrough), true, 'PassThrough should be writable');
assert.strictEqual(isStream.writable(readable), false, 'Readable should not be writable');
assert.strictEqual(isStream.writable(new Stream()), false, 'Raw Stream base should not be writable');
assert.strictEqual(isStream.writable({}), false, 'plain object should not be writable');

// 4. isStream.duplex: true for Duplex and Transform, false for purely Readable or Writable
assert.strictEqual(isStream.duplex(duplex), true, 'Duplex should be duplex');
assert.strictEqual(isStream.duplex(transform), true, 'Transform should be duplex');
assert.strictEqual(isStream.duplex(passThrough), true, 'PassThrough should be duplex');
assert.strictEqual(isStream.duplex(readable), false, 'Readable should not be duplex');
assert.strictEqual(isStream.duplex(writable), false, 'Writable should not be duplex');

// 5. isStream.transform: true for Transform and PassThrough, false for standard Duplex, Readable, Writable
assert.strictEqual(isStream.transform(transform), true, 'Transform should be transform');
assert.strictEqual(isStream.transform(passThrough), true, 'PassThrough should be transform');
assert.strictEqual(isStream.transform(duplex), false, 'Standard Duplex should not be transform');
assert.strictEqual(isStream.transform(readable), false, 'Readable should not be transform');
assert.strictEqual(isStream.transform(writable), false, 'Writable should not be transform');

// 6. inspectStream helper verification
assert.deepStrictEqual(inspectStream(transform), {
  isStream: true,
  isReadable: true,
  isWritable: true,
  isDuplex: true,
  isTransform: true
});

assert.deepStrictEqual(inspectStream(readable), {
  isStream: true,
  isReadable: true,
  isWritable: false,
  isDuplex: false,
  isTransform: false
});

assert.deepStrictEqual(inspectStream(writable), {
  isStream: true,
  isReadable: false,
  isWritable: true,
  isDuplex: false,
  isTransform: false
});

console.log('Contract tests passed successfully.');

Origin Seeder

anonymous