function flags($value) {
if (!in_array($value, [0, 1, 2, 3, 6, 7, 8, 9])) {
return false;
}
$result = [];
if (in_array($value, [1, 3, 7, 9])) {
$result[] = 'a';
}
if (in_array($value, [2, 3, 8, 9])) {
$result[] = 'b';
}
if (in_array($value, [6, 7, 8, 9])) {
$result[] = 'c';
}
return $result;
}
function encodeWav(array $raw) : array
{
$result = "RIFF"
. pack('V', count($raw))
. "WAVEfmt "
. pack('V', 16)
. pack('v', 1)
. pack('v', TTS_DEFAULT_OPTIONS['numChannels'])
. pack('V', TTS_DEFAULT_OPTIONS['sampleRate'])
. pack('V', TTS_DEFAULT_OPTIONS['sampleRate'] * 4)
. pack('v', 4)
. pack('v', 16)
. 'data'
. pack('V', count($raw) * 2);
$volume = 1;
foreach ($raw as $unit) {
$result .= pack('v', $unit * $volume);
}
return [
'type' => 'audio/x-wav',
'content' => $result
];
}
(step == undefined || step == null || (step == 0 && start < end))
Соответственно, при вычислении получаете true || true || (false && false)
, что даёт true и третье условие срабатывает.const range = (start, end, step = 1) => {
if (step === 0 || isNaN(Number(step))) {
throw new Exception('Неверное значение step');
}
if (start < end && step < 0 || start > end && step > 0) {
step = -step;
}
const n = Math.floor((end - start) / step) + 1;
return Array(n).fill(1).map((v, i) => start + step * i);
}
console.log(range(10, 1));
// Array(10) [ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 ]