CodeSampleX

Sample

es-toolkit 1.32.0: Validate interval boundaries with inRange strictly requiring minimum to be less than maximum rather than auto-swapping inverted bounds

Verified sample for npm es-toolkit 1.32.0: Validate interval boundaries with inRange strictly requiring minimum to be less than maximum rather than…

sha256:0221e315cd48cbe5d2a72a629e6e86d51ec5d7ba4f7b456f57870e80f8505218

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
2
Signing keys that built it
2
Declared environment node linux x64 node node npm

Verification-run environments

Environment Contract Stages Run
node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-16
node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-18

Case

HOW
Goal
Validate interval boundaries with inRange strictly requiring minimum to be less than maximum rather than auto-swapping inverted bounds
Packages
Symbols
  • inRange
Environment
node
Created
2026-08-16T16:32:39Z

Contract

  1. inRange throws an Error when minimum is greater than or equal to maximum, such as when passing inverted bounds (3, 4, 2) or equal bounds (3, 5, 5), rather than automatically swapping them.
  2. inRange throws an Error when passed a single negative upper bound (-2, -4) because minimum defaults to 0 and 0 is not strictly less than -4.
  3. inRange returns a boolean when given strictly ordered bounds (3, 2, 4) or a positive single upper bound (3, 5).
  4. es-toolkit/compat inRange swaps inverted bounds rather than throwing an Error for legacy Lodash compatibility.

Files

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

Download the source artifact (tar.gz)

Source

NOTES.md
# Notes: es-toolkit inRange Bound Strictness

### What search_known_solution answered
- `search_known_solution` returned existing sample `sha256:15d8a4044edfbbf1d1e8b51fc3f826390610222b7f745e2703a3eeafb20d7e11` ("Replace lodash helpers with es-toolkit without changing behaviour"), which covers general helper replacements (`chunk`, `groupBy`, `debounce`, `pick`).
- This sample proves a distinct runtime trap: strict bound validation in `es-toolkit`'s `inRange` function, which throws a runtime `Error` when boundaries are inverted, equal, or when a negative single bound is passed.

### What a model would have written instead
- A model would write `inRange(val, max, min)` or `inRange(val, -5)` expecting Lodash-style auto-swapping or negative range handling where bounds are swapped or defaulted to 0 without throwing an exception.

### How the wrong version fails
- Inverted bounds or negative single bounds fail loudly at runtime with `Error: The maximum value must be greater than the minimum value.`, unlike Lodash which silently swaps bounds and returns a boolean.
csx.json
{"case":{"believed":"inRange automatically tolerates inverted boundary arguments and single negative upper bounds by swapping them or defaulting the lower bound to zero without throwing an error.","caseId":"case:sha256:a58fceb2e840919f4e85021a3e97b9a33afa6413c601cae73d8a5375cbb209e0","contract":["inRange throws an Error when minimum is greater than or equal to maximum, such as when passing inverted bounds (3, 4, 2) or equal bounds (3, 5, 5), rather than automatically swapping them.","inRange throws an Error when passed a single negative upper bound (-2, -4) because minimum defaults to 0 and 0 is not strictly less than -4.","inRange returns a boolean when given strictly ordered bounds (3, 2, 4) or a positive single upper bound (3, 5).","es-toolkit/compat inRange swaps inverted bounds rather than throwing an Error for legacy Lodash compatibility."],"goal":"Validate interval boundaries with inRange strictly requiring minimum to be less than maximum rather than auto-swapping inverted bounds","kind":"HOW","packages":["pkg:npm/es-toolkit@1.32.0"],"schemaVersion":1,"symbols":["inRange"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/es-toolkit@1.32.0"],"schemaVersion":1,"symbols":["inRange"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "npm-es-toolkit-v1",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "npm-es-toolkit-v1",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "es-toolkit": "1.32.0"
      }
    },
    "node_modules/es-toolkit": {
      "version": "1.32.0",
      "resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.32.0.tgz",
      "integrity": "sha512-ZfSfHP1l6ubgW/B/FRtqb9bYdMvI6jizbOSfbwwJNcOQ1QE6TFsC3jpQkZ900uUPSR3t3SU5Ds7UWKnYz+uP8Q==",
      "license": "MIT",
      "workspaces": [
        "docs",
        "benchmarks"
      ]
    }
  }
}
package.json
{
  "name": "npm-es-toolkit-v1",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "dependencies": {
    "es-toolkit": "1.32.0"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';
import { inRange } from 'es-toolkit';
import { inRange as mathInRange } from 'es-toolkit/math';
import { inRange as compatInRange } from 'es-toolkit/compat';

// 1. Strictly ordered bounds return boolean without throwing
assert.strictEqual(inRange(3, 2, 4), true);
assert.strictEqual(inRange(1, 2, 4), false);
assert.strictEqual(mathInRange(3, 2, 4), true);

// 2. Single positive upper bound defaults minimum to 0
assert.strictEqual(inRange(3, 5), true);
assert.strictEqual(inRange(5, 5), false);
assert.strictEqual(inRange(6, 5), false);

// 3. Inverted bounds throw an Error in standard es-toolkit rather than auto-swapping
assert.throws(
  () => inRange(3, 4, 2),
  {
    name: 'Error',
    message: 'The maximum value must be greater than the minimum value.',
  }
);

// 4. Equal minimum and maximum throw an Error in standard es-toolkit
assert.throws(
  () => inRange(3, 5, 5),
  {
    name: 'Error',
    message: 'The maximum value must be greater than the minimum value.',
  }
);
assert.throws(
  () => inRange(0, 0),
  {
    name: 'Error',
    message: 'The maximum value must be greater than the minimum value.',
  }
);

// 5. Single negative bound throws an Error because minimum defaults to 0 and 0 is not less than -4
assert.throws(
  () => inRange(-2, -4),
  {
    name: 'Error',
    message: 'The maximum value must be greater than the minimum value.',
  }
);

// 6. es-toolkit/compat inRange swaps inverted bounds rather than throwing
assert.strictEqual(compatInRange(3, 4, 2), true);

Origin Seeder

csx-seed