Sample
function-bind 1.1.2: bind a function to a context with partial arguments using function-bind
Verified sample for npm function-bind 1.1.2: bind a function to a context with partial arguments using function-bind. The contract ran on node 22 · linux…
sha256:bd8e8235756ac8a10da9988c9736be28ff6032e6a597ed0987566ebc912a6be0
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
- 1
- Signing keys that built it
- 1
Declared environment
windows 11 x64 npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| 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 |
Case
HOW- Goal
- bind a function to a context with partial arguments using function-bind
- Packages
- Symbols
-
- function-bind
- Created
- 2026-08-18T18:02:20Z
Contract
- bind binds context and prepends arguments to function calls
- bind correctly calculates the length of the bound function
- bind creates a constructor that instantiates the target when called with new
- bind throws a TypeError when called on a non-function target
Files
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
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: bind a function to a context with partial arguments using function-bind
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/function-bind@1.1.2
Demonstrate these symbols/APIs:
- function-bind
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@11.8.0
- runtime: node@24.13.1
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:80b6ca41baa2684659d09f13e783f8c3dd8e1e4185eb011721dcc8d919609102","constraints":{"executionContext":"node"},"contract":["bind binds context and prepends arguments to function calls","bind correctly calculates the length of the bound function","bind creates a constructor that instantiates the target when called with new","bind throws a TypeError when called on a non-function target"],"goal":"bind a function to a context with partial arguments using function-bind","kind":"HOW","packages":["pkg:npm/function-bind@1.1.2"],"schemaVersion":1,"symbols":["function-bind"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","os":"windows","osVersionBucket":"11","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/function-bind@1.1.2"],"schemaVersion":1,"symbols":["function-bind"],"verifierAdapter":"node-typescript@1"}
import bind from 'function-bind';
/**
* Binds a function to a context object with optional prepended arguments.
* @param {Function} fn - The target function to bind.
* @param {*} thisArg - The value to be passed as the this parameter to the target function.
* @param {...*} args - Arguments to prepend to arguments provided to the bound function.
* @returns {Function} A copy of the given function with the specified this value and initial arguments.
*/
export function bindFunction(fn, thisArg, ...args) {
return bind.call(fn, thisArg, ...args);
}
export default bind;
{
"name": "sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample",
"version": "1.0.0",
"dependencies": {
"function-bind": "1.1.2"
}
},
"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": {
"function-bind": "1.1.2"
}
}
{
"schemaVersion": 1,
"goal": "bind a function to a context with partial arguments using function-bind",
"kind": "HOW",
"packages": [
"pkg:npm/function-bind@1.1.2"
],
"symbols": [
"function-bind"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@11.8.0",
"runtime": "node@24.13.1"
}
}
import assert from 'node:assert/strict';
import bind from 'function-bind';
assert.equal(typeof bind, 'function', 'function-bind must be a function');
// Contract 1: bind binds context and prepends arguments to function calls
{
function greet(greeting, punctuation) {
return `${greeting}, ${this.name}${punctuation}`;
}
const context = { name: 'World' };
const sayHello = bind.call(greet, context, 'Hello');
assert.equal(sayHello('!'), 'Hello, World!');
assert.equal(sayHello('?'), 'Hello, World?');
function add(a, b, c) {
return (this ? this.base : 0) + a + b + c;
}
const boundAdd = bind.call(add, { base: 10 }, 1, 2);
assert.equal(boundAdd(3), 16);
}
// Contract 2: bind correctly calculates the length of the bound function
{
function sum4(a, b, c, d) {
return a + b + c + d;
}
const bound0 = bind.call(sum4, null);
assert.equal(bound0.length, 4);
const bound1 = bind.call(sum4, null, 1);
assert.equal(bound1.length, 3);
const bound3 = bind.call(sum4, null, 1, 2, 3);
assert.equal(bound3.length, 1);
const bound4 = bind.call(sum4, null, 1, 2, 3, 4);
assert.equal(bound4.length, 0);
const bound5 = bind.call(sum4, null, 1, 2, 3, 4, 5);
assert.equal(bound5.length, 0);
}
// Contract 3: bind creates a constructor that instantiates the target when called with new
{
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.getDistance = function () {
return Math.sqrt(this.x * this.x + this.y * this.y);
};
const YPoint = bind.call(Point, null, 0);
const p = new YPoint(5);
assert.equal(p instanceof Point, true);
assert.equal(p.x, 0);
assert.equal(p.y, 5);
assert.equal(p.getDistance(), 5);
}
// Contract 4: bind throws a TypeError when called on a non-function target
{
assert.throws(
() => bind.call(null, {}),
TypeError
);
assert.throws(
() => bind.call(123, {}),
TypeError
);
assert.throws(
() => bind.call('string', {}),
TypeError
);
}
console.log('All contract assertions passed successfully.');
Origin Seeder
anonymous