CodeSampleX

Beispiel

archiver-utils 3.0.4

Verifiziertes Beispiel für npm archiver-utils 3.0.4. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: sanitizePath normalizes path…

sha256:a0ee0c3d4cfa62ddb9a8f3024710fe6a1df96638c8d8b90ef93e4fce33a2cc17

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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-28

Fall

HOW
Ziel
verify pkg:npm/archiver-utils@3.0.4
Pakete
Erstellt
2026-08-28T08:19:22Z

Contract

  1. sanitizePath normalizes path separators, strips Windows drive letters, and removes leading slashes and relative parent components
  2. unixifyPath normalizes path separators to forward slashes and strips Windows drive letters
  3. trailingSlashIt appends a trailing forward slash if the path string does not end with one
  4. dateify parses date strings or converts values into Date instances
  5. isStream returns true for readable and writable stream instances and false for non-stream objects
  6. normalizeInputSource converts strings and null into Buffer instances and pipes Stream instances through PassThrough
  7. collectStream buffers readable stream chunks and returns a complete Buffer via callback
  8. lazyReadStream returns a lazy readable stream instance for the given filepath
  9. file.exists synchronously checks if joined file paths exist
  10. file.expand matches wildcard glob patterns synchronously
  11. walkdir asynchronously traverses directories and collects file stats and relative paths

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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/archiver-utils@3.0.4
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/archiver-utils@3.0.4

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:4548d5167c9e171fb930d11fbd893445b188a6b5945842546483d47511864169","contract":["sanitizePath normalizes path separators, strips Windows drive letters, and removes leading slashes and relative parent components","unixifyPath normalizes path separators to forward slashes and strips Windows drive letters","trailingSlashIt appends a trailing forward slash if the path string does not end with one","dateify parses date strings or converts values into Date instances","isStream returns true for readable and writable stream instances and false for non-stream objects","normalizeInputSource converts strings and null into Buffer instances and pipes Stream instances through PassThrough","collectStream buffers readable stream chunks and returns a complete Buffer via callback","lazyReadStream returns a lazy readable stream instance for the given filepath","file.exists synchronously checks if joined file paths exist","file.expand matches wildcard glob patterns synchronously","walkdir asynchronously traverses directories and collects file stats and relative paths"],"goal":"verify pkg:npm/archiver-utils@3.0.4","kind":"HOW","packages":["pkg:npm/archiver-utils@3.0.4"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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/archiver-utils@3.0.4"],"schemaVersion":1,"subject":"pkg:npm/archiver-utils@3.0.4","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-archiver-utils",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-archiver-utils",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "archiver-utils": "3.0.4"
      }
    },
    "node_modules/archiver-utils": {
      "version": "3.0.4",
      "resolved": "https://registry.npmjs.org/archiver-utils/-/archiver-utils-3.0.4.tgz",
      "integrity": "sha512-KVgf4XQVrTjhyWmx6cte4RxonPLR9onExufI1jhvw/MQ4BB6IsZD5gT8Lq+u/+pRkWna/6JoHpiQioaqFP5Rzw==",
      "license": "MIT",
      "dependencies": {
        "glob": "^7.2.3",
        "graceful-fs": "^4.2.0",
        "lazystream": "^1.0.0",
        "lodash.defaults": "^4.2.0",
        "lodash.difference": "^4.5.0",
        "lodash.flatten": "^4.4.0",
        "lodash.isplainobject": "^4.0.6",
        "lodash.union": "^4.6.0",
        "normalize-path": "^3.0.0",
        "readable-stream": "^3.6.0"
      },
      "engines": {
        "node": ">= 10"
      }
    },
    "node_modules/balanced-match": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
      "license": "MIT"
    },
    "node_modules/brace-expansion": {
      "version": "1.1.18",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
      "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^1.0.0",
        "concat-map": "0.0.1"
      }
    },
    "node_modules/concat-map": {
      "version": "0.0.1",
      "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
      "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
      "license": "MIT"
    },
    "node_modules/core-util-is": {
      "version": "1.0.3",
      "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
      "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
      "license": "MIT"
    },
    "node_modules/fs.realpath": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
      "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
      "license": "ISC"
    },
    "node_modules/glob": {
      "version": "7.2.3",
      "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
      "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
      "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me",
      "license": "ISC",
      "dependencies": {
        "fs.realpath": "^1.0.0",
        "inflight": "^1.0.4",
        "inherits": "2",
        "minimatch": "^3.1.1",
        "once": "^1.3.0",
        "path-is-absolute": "^1.0.0"
      },
      "engines": {
        "node": "*"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    },
    "node_modules/graceful-fs": {
      "version": "4.2.11",
      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
      "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
      "license": "ISC"
    },
    "node_modules/inflight": {
      "version": "1.0.6",
      "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
      "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
      "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",
      "license": "ISC",
      "dependencies": {
        "once": "^1.3.0",
        "wrappy": "1"
      }
    },
    "node_modules/inherits": {
      "version": "2.0.4",
      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
      "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
      "license": "ISC"
    },
    "node_modules/isarray": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
      "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
      "license": "MIT"
    },
    "node_modules/lazystream": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.1.tgz",
      "integrity": "sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==",
      "license": "MIT",
      "dependencies": {
        "readable-stream": "^2.0.5"
      },
      "engines": {
        "node": ">= 0.6.3"
      }
    },
    "node_modules/lazystream/node_modules/readable-stream": {
      "version": "2.3.8",
      "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
      "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
      "license": "MIT",
      "dependencies": {
        "core-util-is": "~1.0.0",
        "inherits": "~2.0.3",
        "isarray": "~1.0.0",
        "process-nextick-args": "~2.0.0",
        "safe-buffer": "~5.1.1",
        "string_decoder": "~1.1.1",
        "util-deprecate": "~1.0.1"
      }
    },
    "node_modules/lazystream/node_modules/safe-buffer": {
      "version": "5.1.2",
      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
      "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
      "license": "MIT"
    },
    "node_modules/lazystream/node_modules/string_decoder": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
      "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
      "license": "MIT",
      "dependencies": {
        "safe-buffer": "~5.1.0"
      }
    },
    "node_modules/lodash.defaults": {
      "version": "4.2.0",
      "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz",
      "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==",
      "license": "MIT"
    },
    "node_modules/lodash.difference": {
      "version": "4.5.0",
      "resolved": "https://registry.npmjs.org/lodash.difference/-/lodash.difference-4.5.0.tgz",
      "integrity": "sha512-dS2j+W26TQ7taQBGN8Lbbq04ssV3emRw4NY58WErlTO29pIqS0HmoT5aJ9+TUQ1N3G+JOZSji4eugsWwGp9yPA==",
      "license": "MIT"
    },
    "node_modules/lodash.flatten": {
      "version": "4.4.0",
      "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz",
      "integrity": "sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==",
      "license": "MIT"
    },
    "node_modules/lodash.isplainobject": {
      "version": "4.0.6",
      "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
      "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==",
      "license": "MIT"
    },
    "node_modules/lodash.union": {
      "version": "4.6.0",
      "resolved": "https://registry.npmjs.org/lodash.union/-/lodash.union-4.6.0.tgz",
      "integrity": "sha512-c4pB2CdGrGdjMKYLA+XiRDO7Y0PRQbm/Gzg8qMj+QH+pFVAoTp5sBpO0odL3FjoPCGjK96p6qsP+yQoiLoOBcw==",
      "license": "MIT"
    },
    "node_modules/minimatch": {
      "version": "3.1.5",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
      "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
      "license": "ISC",
      "dependencies": {
        "brace-expansion": "^1.1.7"
      },
      "engines": {
        "node": "*"
      }
    },
    "node_modules/normalize-path": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
      "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/once": {
      "version": "1.4.0",
      "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
      "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
      "license": "ISC",
      "dependencies": {
        "wrappy": "1"
      }
    },
    "node_modules/path-is-absolute": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
      "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/process-nextick-args": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
      "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
      "license": "MIT"
    },
    "node_modules/readable-stream": {
      "version": "3.6.2",
      "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
      "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
      "license": "MIT",
      "dependencies": {
        "inherits": "^2.0.3",
        "string_decoder": "^1.1.1",
        "util-deprecate": "^1.0.1"
      },
      "engines": {
        "node": ">= 6"
      }
    },
    "node_modules/safe-buffer": {
      "version": "5.2.1",
      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
      "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/feross"
        },
        {
          "type": "patreon",
          "url": "https://www.patreon.com/feross"
        },
        {
          "type": "consulting",
          "url": "https://feross.org/support"
        }
      ],
      "license": "MIT"
    },
    "node_modules/string_decoder": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
      "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
      "license": "MIT",
      "dependencies": {
        "safe-buffer": "~5.2.0"
      }
    },
    "node_modules/util-deprecate": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
      "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
      "license": "MIT"
    },
    "node_modules/wrappy": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
      "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
      "license": "ISC"
    }
  }
}
package.json
{
  "name": "sample-archiver-utils",
  "version": "1.0.0",
  "private": true,
  "description": "verify pkg:npm/archiver-utils@3.0.4",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "archiver-utils": "3.0.4"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/archiver-utils@3.0.4",
  "kind": "HOW",
  "packages": [
    "pkg:npm/archiver-utils@3.0.4"
  ]
}
src/index.js
'use strict';

const archiverUtils = require('archiver-utils');

function sanitizePath(filepath) {
  return archiverUtils.sanitizePath(filepath);
}

function unixifyPath(filepath) {
  return archiverUtils.unixifyPath(filepath);
}

function trailingSlashIt(str) {
  return archiverUtils.trailingSlashIt(str);
}

function dateify(dateish) {
  return archiverUtils.dateify(dateish);
}

function isStream(source) {
  return archiverUtils.isStream(source);
}

function normalizeInputSource(source) {
  return archiverUtils.normalizeInputSource(source);
}

function collectStream(stream) {
  return new Promise((resolve, reject) => {
    archiverUtils.collectStream(stream, (err, buffer) => {
      if (err) return reject(err);
      resolve(buffer);
    });
  });
}

function lazyReadStream(filepath) {
  return archiverUtils.lazyReadStream(filepath);
}

function checkFileExists(...args) {
  return archiverUtils.file.exists(...args);
}

function expandFiles(...args) {
  return archiverUtils.file.expand(...args);
}

function walkDirectory(dirpath, base) {
  return new Promise((resolve, reject) => {
    if (base !== undefined) {
      archiverUtils.walkdir(dirpath, base, (err, results) => {
        if (err) return reject(err);
        resolve(results);
      });
    } else {
      archiverUtils.walkdir(dirpath, (err, results) => {
        if (err) return reject(err);
        resolve(results);
      });
    }
  });
}

module.exports = {
  sanitizePath,
  unixifyPath,
  trailingSlashIt,
  dateify,
  isStream,
  normalizeInputSource,
  collectStream,
  lazyReadStream,
  checkFileExists,
  expandFiles,
  walkDirectory,
  archiverUtils
};
test/contract.js
'use strict';

const assert = require('node:assert');
const fs = require('node:fs');
const path = require('node:path');
const os = require('node:os');
const { Readable, PassThrough } = require('node:stream');
const archiverUtils = require('archiver-utils');
const {
  sanitizePath,
  unixifyPath,
  trailingSlashIt,
  dateify,
  isStream,
  normalizeInputSource,
  collectStream,
  lazyReadStream,
  checkFileExists,
  expandFiles,
  walkDirectory
} = require('../src/index.js');

async function testAll() {
  // 1. sanitizePath
  assert.strictEqual(sanitizePath('nested\\path\\to\\file.txt'), 'nested/path/to/file.txt');
  assert.strictEqual(sanitizePath('../../../relative/file.txt'), 'relative/file.txt');
  assert.strictEqual(sanitizePath('dir/sub/file.txt'), 'dir/sub/file.txt');
  assert.strictEqual(archiverUtils.sanitizePath('some\\folder/sub/'), 'some/folder/sub/');

  // 2. unixifyPath
  assert.strictEqual(unixifyPath('windows\\style\\path'), 'windows/style/path');
  assert.strictEqual(unixifyPath('foo\\bar\\baz'), 'foo/bar/baz');
  assert.strictEqual(archiverUtils.unixifyPath('already/unix/path'), 'already/unix/path');

  // 3. trailingSlashIt
  assert.strictEqual(trailingSlashIt('path/to/dir'), 'path/to/dir/');
  assert.strictEqual(trailingSlashIt('path/to/dir/'), 'path/to/dir/');
  assert.strictEqual(archiverUtils.trailingSlashIt(''), '/');

  // 4. dateify
  const fixedDate = new Date('2026-01-01T12:00:00.000Z');
  assert.strictEqual(dateify(fixedDate).getTime(), fixedDate.getTime());
  const parsedDate = dateify('2026-01-01T12:00:00.000Z');
  assert.ok(parsedDate instanceof Date);
  assert.strictEqual(parsedDate.getTime(), fixedDate.getTime());
  assert.ok(dateify(null) instanceof Date);
  assert.ok(archiverUtils.dateify(undefined) instanceof Date);

  // 5. isStream
  const readable = new Readable({ read() {} });
  assert.strictEqual(isStream(readable), true);
  assert.strictEqual(isStream(new PassThrough()), true);
  assert.strictEqual(isStream({}), false);
  assert.strictEqual(isStream('string'), false);
  assert.strictEqual(isStream(null), false);
  assert.strictEqual(archiverUtils.isStream(undefined), false);

  // 6. normalizeInputSource
  const strNormalized = normalizeInputSource('test string');
  assert.ok(Buffer.isBuffer(strNormalized));
  assert.strictEqual(strNormalized.toString(), 'test string');

  const nullNormalized = normalizeInputSource(null);
  assert.ok(Buffer.isBuffer(nullNormalized));
  assert.strictEqual(nullNormalized.length, 0);

  const buf = Buffer.from('buffer data');
  assert.strictEqual(normalizeInputSource(buf), buf);

  const streamSrc = new Readable({ read() {} });
  const streamNormalized = normalizeInputSource(streamSrc);
  assert.ok(isStream(streamNormalized));

  // 7. collectStream
  const collectSource = new Readable({
    read() {
      this.push(Buffer.from('hello '));
      this.push(Buffer.from('world'));
      this.push(null);
    }
  });
  const collected = await collectStream(collectSource);
  assert.ok(Buffer.isBuffer(collected));
  assert.strictEqual(collected.toString('utf8'), 'hello world');

  // 8. lazyReadStream, file.exists, file.expand, walkdir
  const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'archiver-utils-test-'));
  const tempSubDir = path.join(tempDir, 'sub');
  fs.mkdirSync(tempSubDir);
  const tempFile1 = path.join(tempDir, 'file1.txt');
  const tempFile2 = path.join(tempSubDir, 'file2.txt');
  fs.writeFileSync(tempFile1, 'hello from file1');
  fs.writeFileSync(tempFile2, 'hello from file2');

  try {
    // file.exists
    assert.strictEqual(checkFileExists(tempFile1), true);
    assert.strictEqual(checkFileExists(tempDir, 'file1.txt'), true);
    assert.strictEqual(checkFileExists(tempDir, 'nonexistent.txt'), false);

    // file.expand
    const expanded = expandFiles({ cwd: tempDir }, '**/*.txt');
    assert.ok(expanded.includes('file1.txt'));
    assert.ok(expanded.includes(path.join('sub', 'file2.txt')) || expanded.includes('sub/file2.txt'));

    // lazyReadStream
    const lazyStream = lazyReadStream(tempFile1);
    assert.ok(isStream(lazyStream));
    const lazyCollected = await collectStream(lazyStream);
    assert.strictEqual(lazyCollected.toString('utf8'), 'hello from file1');

    // walkdir
    const walkResults = await walkDirectory(tempDir);
    assert.ok(Array.isArray(walkResults));
    const relativePaths = walkResults.map(r => r.relative);
    assert.ok(relativePaths.includes('file1.txt'));
    assert.ok(relativePaths.includes('sub'));
    assert.ok(relativePaths.includes('sub/file2.txt'));
  } finally {
    fs.rmSync(tempDir, { recursive: true, force: true });
  }

  console.log('All contract tests passed.');
}

testAll().catch((err) => {
  console.error('Contract test failure:', err);
  process.exit(1);
});

Ursprungs-Seeder

anonym