Skip to content

Commit

Permalink
v1.3.0, Updated ES function syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudosavant committed Nov 5, 2021
1 parent 2f544cc commit 20421f3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/video-thumbnail.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

const round = (val, digits) => +val.toFixed(digits);

function store(key, val) {
const store = (key, val) => {
try {
localStorage.setItem(key, val);
console.info(`[localStorage] Persisted: ${key} `);
Expand All @@ -31,7 +31,7 @@
}
}

function retrieve(key) {
const retrieve = (key) => {
try {
return localStorage.getItem(key);
} catch (e) {
Expand All @@ -40,7 +40,7 @@
}
}

function keyEndsWith(partialKey) {
const keyEndsWith = (partialKey) => {
const keys = Object.keys(localStorage);
const fullKey = keys.find((key) => key.endsWith(partialKey));
return fullKey;
Expand Down Expand Up @@ -75,7 +75,7 @@
}
})();

function getVideo(url) {
const getVideo = (url) => {
const $player = document.createElement('video');
$player.crossorigin = 'anonymous';
$player.muted = true;
Expand All @@ -99,7 +99,7 @@
return promise;
}

async function videoToDataURI(videoElement, timestamp, size, mime, type) {
const videoToDataURI = async (videoElement, timestamp, size, mime, type) => {
const start = Date.now();
const $player = videoElement;

Expand Down Expand Up @@ -133,7 +133,7 @@
return response;
}

function canvasToBlob(canvas, type, quality) {
const canvasToBlob = (canvas, type, quality) => {
const promise = new Promise((resolve, reject) => {
try {
canvas.toBlob((blob) => resolve(URL.createObjectURL(blob)), type, quality);
Expand All @@ -145,7 +145,7 @@
return promise;
}

function seek($player, time) {
const seek = ($player, time) => {
const promise = new Promise((resolve, reject) => {
const errorHandler = (e) => reject('Error while seeking video', e);
$player.addEventListener('error', errorHandler, { once: true});
Expand All @@ -162,7 +162,7 @@
}
const isSeekable = (videoElement) => videoElement?.seekable?.end(0) === videoElement?.duration;

async function getThumbnailDataURI(url, opts) {
const getThumbnailDataURI = async (url, opts) => {
opts = {...opts} || {};

const isImageMimeType = (s) => (/image\/.+/i).test(s);
Expand Down

0 comments on commit 20421f3

Please sign in to comment.