@calipsa/video-utils
Version:
Video utilities
19 lines • 592 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
exports.default = (arr, newSize) => {
if (newSize < 1) {
return [];
}
if (arr.length <= newSize) {
return arr.slice();
}
if (newSize === 1) {
const midIndex = arr.length - 1 >> 1;
return [arr[midIndex]];
}
const ratio = (arr.length - 1) / (newSize - 1);
const indices = (0, lodash_1.range)(newSize).map(i => Math.round(i * ratio));
return indices.map(i => arr[i]);
};
//# sourceMappingURL=downsampleArray.js.map