video-ad-sdk
Version:
VAST/VPAID SDK that allows video ads to be played on top of any player
13 lines (12 loc) • 357 B
JavaScript
import { parseTime } from './parseTime';
const isPercentage = (offset) => {
const percentageRegex = /^\d+(\.\d+)?%$/g;
return percentageRegex.test(offset);
};
// eslint-disable-next-line sonar/function-return-type
export const parseOffset = (offset) => {
if (isPercentage(offset)) {
return offset;
}
return parseTime(offset);
};