@mapcss/preset-svg
Version:
SVG as CSS for MapCSS
24 lines (23 loc) • 714 B
JavaScript
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
/**
* Filters the given array, removing all elements that do not match the given predicate
* **in place. This means `array` will be modified!**.
*/
export function filterInPlace(array, predicate) {
let outputIndex = 0;
for (const cur of array) {
if (!predicate(cur)) {
continue;
}
array[outputIndex] = cur;
outputIndex += 1;
}
array.splice(outputIndex);
return array;
}
/**
* Produces a random number between the inclusive `lower` and `upper` bounds.
*/
export function randomInteger(lower, upper) {
return lower + Math.floor(Math.random() * (upper - lower + 1));
}