CodeSampleX

샘플

call-bind-apply-helpers 1.0.2

검증된 샘플 — npm call-bind-apply-helpers 1.0.2. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: callBind binds a function call with receiver and…

sha256:071451cca1e5eee666101d425994b0966aebbf182e77714289205b3883485e43

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

실행 증거

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

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 windows 11 x64 npm

검증 실행 환경

환경 컨트랙트 단계 실행일
node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-19

케이스

HOW
목표
verify pkg:npm/call-bind-apply-helpers@1.0.2
패키지
생성일
2026-08-18T18:07:12Z

컨트랙트

  1. callBind binds a function call with receiver and prepends receiver on subsequent calls
  2. callBind with fixed receiver binds thisArg permanently
  3. callBind with fixed receiver and bound arguments partially applies arguments
  4. callBind throws TypeError when passed empty arguments or non-function
  5. actualApply invokes a target function with thisArg and args array
  6. applyBind creates an apply-based bound caller
  7. functionCall and functionApply reference intrinsic Function prototypes
  8. wrapper bindHelper matches direct callBind behavior

파일

  • PROMPT.md
  • csx.json
  • index.mjs
  • 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 pkg:npm/call-bind-apply-helpers@1.0.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/call-bind-apply-helpers@1.0.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:4794c6896c8c00964451734084506ea41ac9a8679ca657c07071e83c3391c59d","contract":["callBind binds a function call with receiver and prepends receiver on subsequent calls","callBind with fixed receiver binds thisArg permanently","callBind with fixed receiver and bound arguments partially applies arguments","callBind throws TypeError when passed empty arguments or non-function","actualApply invokes a target function with thisArg and args array","applyBind creates an apply-based bound caller","functionCall and functionApply reference intrinsic Function prototypes","wrapper bindHelper matches direct callBind behavior"],"goal":"verify pkg:npm/call-bind-apply-helpers@1.0.2","kind":"HOW","packages":["pkg:npm/call-bind-apply-helpers@1.0.2"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","os":"windows","osVersionBucket":"11","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/call-bind-apply-helpers@1.0.2"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
index.mjs
import callBind from 'call-bind-apply-helpers';

/**
 * Binds a function call with the provided receiver and optional initial arguments.
 * @param {Function} fn - The target function to bind.
 * @param {*} [thisArg] - Optional fixed receiver.
 * @param {...*} [args] - Initial arguments to bind.
 * @returns {Function} Bound caller function.
 */
export function bindHelper(fn, thisArg, ...args) {
  if (arguments.length === 1) {
    return callBind([fn]);
  }
  return callBind([fn, thisArg, ...args]);
}

export default callBind;
package-lock.json
{
  "name": "sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample",
      "version": "1.0.0",
      "dependencies": {
        "call-bind-apply-helpers": "1.0.2"
      }
    },
    "node_modules/call-bind-apply-helpers": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
      "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
      "license": "MIT",
      "dependencies": {
        "es-errors": "^1.3.0",
        "function-bind": "^1.1.2"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/es-errors": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
      "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/function-bind": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
      "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
      "license": "MIT",
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    }
  }
}
package.json
{
  "name": "sample",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "call-bind-apply-helpers": "1.0.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/call-bind-apply-helpers@1.0.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/call-bind-apply-helpers@1.0.2"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import callBind from 'call-bind-apply-helpers';
import actualApply from 'call-bind-apply-helpers/actualApply';
import applyBind from 'call-bind-apply-helpers/applyBind';
import functionCall from 'call-bind-apply-helpers/functionCall';
import functionApply from 'call-bind-apply-helpers/functionApply';
import reflectApply from 'call-bind-apply-helpers/reflectApply';
import { bindHelper } from '../index.mjs';

// Case 1: callBind binds a function call with receiver and prepends receiver on subsequent calls
{
  function sum(a, b) {
    return (this ? this.base : 0) + a + b;
  }

  const boundSum = callBind([sum]);
  const ctx = { base: 10 };
  const result = boundSum(ctx, 2, 3);
  assert.equal(result, 15, 'boundSum should invoke sum with ctx as thisArg');
}

// Case 2: callBind with fixed receiver binds thisArg permanently
{
  function getGreeting(name) {
    return `${this.prefix}, ${name}!`;
  }

  const context = { prefix: 'Hello' };
  const greet = callBind([getGreeting, context]);
  assert.equal(greet('World'), 'Hello, World!', 'greet should use bound context');
}

// Case 3: callBind with fixed receiver and bound arguments partially applies arguments
{
  function compute(a, b, c) {
    return (this.factor * a) + b - c;
  }

  const ctx = { factor: 2 };
  const boundCompute = callBind([compute, ctx, 5]);
  assert.equal(boundCompute(3, 1), 12, 'should compute (2 * 5) + 3 - 1 = 12');
}

// Case 4: callBind throws TypeError when passed empty arguments or non-function
{
  assert.throws(
    () => {
      callBind([]);
    },
    TypeError,
    'callBind with empty array should throw TypeError'
  );

  assert.throws(
    () => {
      callBind(['not-a-function']);
    },
    TypeError,
    'callBind with non-function should throw TypeError'
  );
}

// Case 5: actualApply invokes a target function with thisArg and args array
{
  function multiply(x, y) {
    return this.scale * x * y;
  }

  const ctx = { scale: 3 };
  const res = actualApply(multiply, ctx, [4, 5]);
  assert.equal(res, 60, 'actualApply should apply arguments with context');
}

// Case 6: applyBind creates an apply-based bound caller
{
  function joinItems(sep) {
    return this.items.join(sep);
  }

  const caller = applyBind(joinItems);
  const context = { items: ['a', 'b', 'c'] };
  assert.equal(caller(context, [', ']), 'a, b, c', 'applyBind caller should invoke function with apply signature');
}

// Case 7: functionCall and functionApply reference intrinsic Function prototypes
{
  assert.equal(functionCall, Function.prototype.call, 'functionCall should be Function.prototype.call');
  assert.equal(functionApply, Function.prototype.apply, 'functionApply should be Function.prototype.apply');
  if (typeof reflectApply === 'function') {
    assert.equal(reflectApply, Reflect.apply, 'reflectApply should be Reflect.apply');
  }
}

// Case 8: wrapper bindHelper matches direct callBind behavior
{
  function format(suffix) {
    return `${this.name}:${suffix}`;
  }

  const helperWithReceiver = bindHelper(format, { name: 'item' });
  assert.equal(helperWithReceiver('ok'), 'item:ok', 'bindHelper with receiver should match callBind behavior');

  const helperUnbound = bindHelper(format);
  assert.equal(helperUnbound({ name: 'custom' }, 'val'), 'custom:val', 'bindHelper without receiver should match callBind behavior');
}

console.log('PASS: all call-bind-apply-helpers contract assertions passed');

오리진 시더

익명