CodeSampleX

샘플

serialize-error 7.0.1: deserializeError

검증된 샘플 — npm serialize-error 7.0.1: deserializeError. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: deserializeError passes through existing…

sha256:7f2cdd9a3cdb14f1ea397cab46e7100165443c892969a2d019a49a135ee18903

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 linux 24 · ubuntu · glibc 2.39 x64 npm

검증 실행 환경

환경 컨트랙트 단계 실행일
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-04

케이스

HOW
목표
verify serialize-error.deserializeError in pkg:npm/serialize-error@7.0.1
패키지
심벌
  • serialize-error.deserializeError
생성일
2026-09-04T11:13:33Z

컨트랙트

  1. deserializeError passes through existing Error instances unchanged
  2. deserializeError deserializes error object restoring name, message, stack, and code
  3. deserializeError preserves custom enumerable properties on error object
  4. deserializeError keeps name, message, and stack as non-enumerable properties
  5. deserializeError handles circular references in custom properties
  6. deserializeError ignores function properties on serialized object
  7. deserializeError wraps primitive string value into NonError instance
  8. deserializeError wraps primitive number and boolean into NonError instance
  9. deserializeError wraps null and undefined into NonError instance
  10. deserializeError wraps array into NonError instance

파일

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.mjs

소스 아티팩트 내려받기 (tar.gz)

소스

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 serialize-error.deserializeError in pkg:npm/serialize-error@7.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/serialize-error@7.0.1
Demonstrate these symbols/APIs:
  - serialize-error.deserializeError

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:71816cb67851b502adba12b13de4efd213889050319a2dd4811911c788ab405a","contract":["deserializeError passes through existing Error instances unchanged","deserializeError deserializes error object restoring name, message, stack, and code","deserializeError preserves custom enumerable properties on error object","deserializeError keeps name, message, and stack as non-enumerable properties","deserializeError handles circular references in custom properties","deserializeError ignores function properties on serialized object","deserializeError wraps primitive string value into NonError instance","deserializeError wraps primitive number and boolean into NonError instance","deserializeError wraps null and undefined into NonError instance","deserializeError wraps array into NonError instance"],"goal":"verify serialize-error.deserializeError in pkg:npm/serialize-error@7.0.1","kind":"HOW","packages":["pkg:npm/serialize-error@7.0.1"],"schemaVersion":1,"symbols":["serialize-error.deserializeError"]},"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/serialize-error@7.0.1"],"schemaVersion":1,"subject":"pkg:npm/serialize-error@7.0.1","symbols":["serialize-error.deserializeError"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-serialize-error-deserialize-error",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-serialize-error-deserialize-error",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "serialize-error": "7.0.1"
      }
    },
    "node_modules/serialize-error": {
      "version": "7.0.1",
      "resolved": "https://registry.npmjs.org/serialize-error/-/serialize-error-7.0.1.tgz",
      "integrity": "sha512-8I8TjW5KMOKsZQTvoxjuSIa7foAwPWGOts+6o7sgjz41/qMD9VQHEDxi6PBvK2l0MXUmqZyNpUK+T2tQaaElvw==",
      "license": "MIT",
      "dependencies": {
        "type-fest": "^0.13.1"
      },
      "engines": {
        "node": ">=10"
      }
    },
    "node_modules/type-fest": {
      "version": "0.13.1",
      "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz",
      "integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==",
      "license": "(MIT OR CC0-1.0)",
      "engines": {
        "node": ">=10"
      }
    }
  }
}
package.json
{
  "name": "sample-serialize-error-deserialize-error",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "serialize-error": "7.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify serialize-error.deserializeError in pkg:npm/serialize-error@7.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/serialize-error@7.0.1"
  ],
  "symbols": [
    "serialize-error.deserializeError"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { deserializeError } from 'serialize-error';

// 1. deserializeError passes through existing Error instances unchanged
{
  const err = new TypeError('original error');
  const result = deserializeError(err);
  assert.equal(result, err);
  assert.equal(result instanceof TypeError, true);
}

// 2. deserializeError deserializes error object restoring name, message, stack, and code
{
  const serialized = {
    name: 'CustomError',
    message: 'failed operation',
    stack: 'CustomError: failed operation\n    at Object.<anonymous>',
    code: 'ERR_FAILED'
  };
  const result = deserializeError(serialized);
  assert.equal(result instanceof Error, true);
  assert.equal(result.name, 'CustomError');
  assert.equal(result.message, 'failed operation');
  assert.equal(result.stack, 'CustomError: failed operation\n    at Object.<anonymous>');
  assert.equal(result.code, 'ERR_FAILED');
}

// 3. deserializeError preserves custom enumerable properties on error object
{
  const serialized = {
    message: 'with details',
    status: 404,
    context: { userId: '123' }
  };
  const result = deserializeError(serialized);
  assert.equal(result.status, 404);
  assert.deepEqual(result.context, { userId: '123' });
}

// 4. deserializeError keeps name, message, and stack as non-enumerable properties
{
  const serialized = {
    name: 'MyError',
    message: 'secret message',
    stack: 'stack line',
    code: 'ERR_CODE',
    custom: 'visible'
  };
  const result = deserializeError(serialized);
  const keys = Object.keys(result);
  assert.equal(keys.includes('name'), false);
  assert.equal(keys.includes('message'), false);
  assert.equal(keys.includes('stack'), false);
  assert.equal(keys.includes('code'), true);
  assert.equal(keys.includes('custom'), true);
}

// 5. deserializeError handles circular references in custom properties
{
  const circular = { message: 'circular test', nested: {} };
  circular.nested.self = circular.nested;
  const result = deserializeError(circular);
  assert.equal(result.nested.self, '[Circular]');
}

// 6. deserializeError ignores function properties on serialized object
{
  const serialized = {
    message: 'fn test',
    helper: () => 'noop'
  };
  const result = deserializeError(serialized);
  assert.equal('helper' in result, false);
}

// 7. deserializeError wraps primitive string value into NonError instance
{
  const result = deserializeError('something bad');
  assert.equal(result instanceof Error, true);
  assert.equal(result.name, 'NonError');
  assert.equal(result.message, '"something bad"');
}

// 8. deserializeError wraps primitive number and boolean into NonError instance
{
  const numResult = deserializeError(404);
  assert.equal(numResult.name, 'NonError');
  assert.equal(numResult.message, '404');

  const boolResult = deserializeError(false);
  assert.equal(boolResult.name, 'NonError');
  assert.equal(boolResult.message, 'false');
}

// 9. deserializeError wraps null and undefined into NonError instance
{
  const nullResult = deserializeError(null);
  assert.equal(nullResult.name, 'NonError');
  assert.equal(nullResult.message, 'null');

  const undefResult = deserializeError(undefined);
  assert.equal(undefResult.name, 'NonError');
  assert.equal(undefResult.message, '');
}

// 10. deserializeError wraps array into NonError instance
{
  const arrResult = deserializeError(['error1', 'error2']);
  assert.equal(arrResult.name, 'NonError');
  assert.equal(arrResult.message, '["error1","error2"]');
}

오리진 시더

익명