e => ~arr[0].indexOf(e)
А ~
это битовое NOT, преобразует -1 в 0, 0 в -1, 1 в -2, 2 в -3 и т.д. var a = [
[
[1, 2, 3],
[4, 5, 6]
],
[
[7, 8, 9],
[10, 11]
], {
x: 12,
y: [13, 14, {
x: 15,
y: 16
}]
}
];
function iterate(e) {
if (typeof e == 'object') Object.keys(e).forEach(i => iterate(e[i]));
else console.log(e);
}
iterate(a);
#!/bin/bash
# conv.sh
if [[ ! -n $1 ]]; then
echo "output filename rquired"
exit 1
fi
TMP=$(mktemp -d)
i=0
while read FILE; do
NEW=${TMP}/${FILE%.*}.jpg
echo "${FILE} -> ${NEW}"
convert -quality 70 "${FILE}" "${NEW}"
a[i]="${NEW}"
((i++))
done
echo "converting ${#a[@]} files to $1"
convert "${a[@]}" "$1"
rm -r ${TMP}
<code>
Например: <code>ls -v1 *.png | ./conv.sh result.pdf</code>