Пример
es-toolkit 1.50.0: Replace lodash helpers with es-toolkit without changing behaviour
Проверенный пример — npm es-toolkit 1.50.0: Replace lodash helpers with es-toolkit without changing behaviour. Контракт выполнен на node 22 · linux…
sha256:15d8a4044edfbbf1d1e8b51fc3f826390610222b7f745e2703a3eeafb20d7e11
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 2
- Ключи подписи, собравшие его
- 2
Заявленная среда
node 22 linux x64 node 22 javascript npm
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-13 |
| node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-17 |
Кейс
MIGRATION- Цель
- Replace lodash helpers with es-toolkit without changing behaviour
- Пакеты
- Символы
-
- chunk
- groupBy
- debounce
- pick
- Окружение
- node 22
- Создан
- 2026-08-13T18:27:02Z
Контракт
- import the same helpers from es-toolkit
- assert chunk, groupBy and pick behave as their lodash equivalents
- assert debounce delays and coalesces calls
- assert the module is ESM with named exports
Файлы
- csx.json
- package-lock.json
- package.json
- src/index.mjs
- test/contract.mjs
Исходный код
{"case":{"caseId":"case:sha256:a5d109d8910b0b4c80fab27451410041c2b16706ddebe70d05001999371607cc","constraints":{"moduleSystem":"esm","runtime":"node"},"contract":["import the same helpers from es-toolkit","assert chunk, groupBy and pick behave as their lodash equivalents","assert debounce delays and coalesces calls","assert the module is ESM with named exports"],"goal":"Replace lodash helpers with es-toolkit without changing behaviour","kind":"MIGRATION","packages":["pkg:npm/es-toolkit@1.50.0"],"schemaVersion":1,"symbols":["chunk","groupBy","debounce","pick"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"javascript","moduleSystem":"esm","os":"linux","packageManager":"npm","runtime":"node","runtimeVersion":"22","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/es-toolkit@1.50.0"],"schemaVersion":1,"symbols":["chunk","groupBy","debounce","pick"],"verifierAdapter":"node-typescript@1"}
{
"name": "csx-sample-es-toolkit-lodash-swap",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "csx-sample-es-toolkit-lodash-swap",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"es-toolkit": "1.50.0"
}
},
"node_modules/es-toolkit": {
"version": "1.50.0",
"resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.50.0.tgz",
"integrity": "sha512-OyZKhUVvEep9ITEiwHn8GKnMRQIVqoSIX7WnRbkWgJkllCujilqP2rD0u979tkl8wqyc8ICwlc1UBVv/Sl1G6w==",
"license": "MIT",
"workspaces": [
"docs",
"benchmarks",
"tests/types"
]
}
}
}
{
"name": "csx-sample-es-toolkit-lodash-swap",
"version": "1.0.0",
"private": true,
"type": "module",
"license": "MIT-0",
"dependencies": {
"es-toolkit": "1.50.0"
}
}
import { chunk, groupBy, pick, debounce } from 'es-toolkit';
// es-toolkit is a drop-in for the lodash functions most projects actually
// use, with native ESM and no CommonJS interop dance. The behaviours worth
// checking before swapping: groupBy keys are strings, pick ignores absent
// keys rather than inventing undefined entries, and debounce coalesces.
export function pageRows(rows, size) {
return chunk(rows, size);
}
export function byStatus(rows) {
return groupBy(rows, (r) => r.status);
}
export function summarize(row) {
return pick(row, ['id', 'status']);
}
export function makeDebounced(fn, ms) {
return debounce(fn, ms);
}
import { strict as assert } from 'node:assert';
import { pageRows, byStatus, summarize, makeDebounced } from '../src/index.mjs';
assert.deepEqual(pageRows([1, 2, 3, 4, 5], 2), [[1, 2], [3, 4], [5]]);
const rows = [{ id: 1, status: 'ok', note: 'x' }, { id: 2, status: 'fail' },
{ id: 3, status: 'ok' }];
const grouped = byStatus(rows);
assert.deepEqual(Object.keys(grouped).sort(), ['fail', 'ok']);
assert.equal(grouped.ok.length, 2);
assert.deepEqual(summarize(rows[0]), { id: 1, status: 'ok' });
// A key that is not there is omitted, not set to undefined.
assert.deepEqual(Object.keys(summarize({ id: 9 })), ['id']);
let calls = 0;
const d = makeDebounced(() => { calls += 1; }, 20);
d(); d(); d();
assert.equal(calls, 0, 'debounced calls do not run immediately');
await new Promise((r) => setTimeout(r, 60));
assert.equal(calls, 1, 'three rapid calls coalesce into one');
console.log('CONTRACT PASS: es-toolkit matched the lodash helpers it replaces');