sless-examples/hello-node/code/handler-job.js
2026-03-09 17:57:29 +04:00

12 lines
545 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 2026-03-08
// handler-job.js — batch-функция: суммирует числа и считает среднее.
// Используется с sless_job (одноразовый запуск).
// event.numbers — массив чисел, например [1, 2, 3, 4, 5]
exports.handle = async (event) => {
const numbers = event.numbers || [];
const sum = numbers.reduce((acc, n) => acc + n, 0);
const avg = numbers.length > 0 ? sum / numbers.length : 0;
return { input: numbers, sum, avg, count: numbers.length };
};