Exemple
call-bind-apply-helpers 1.0.2
Échantillon vérifié pour npm call-bind-apply-helpers 1.0.2. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:071451cca1e5eee666101d425994b0966aebbf182e77714289205b3883485e43
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
windows 11 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify pkg:npm/call-bind-apply-helpers@1.0.2
- Paquets
- Créé
- 2026-08-18T18:07:12Z
Contrat
- 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
Fichiers
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code source
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.
{"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"}
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;
{
"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"
}
}
}
}
{
"name": "sample",
"version": "1.0.0",
"type": "module",
"dependencies": {
"call-bind-apply-helpers": "1.0.2"
}
}
{
"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"
]
}
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');
Seeder d'origine
anonyme