Skip to content

Instantly share code, notes, and snippets.

View OzanKurt's full-sized avatar
🍻
Cheers!

Ozan Kurt OzanKurt

🍻
Cheers!
View GitHub Profile
@OzanKurt
OzanKurt / localStorage.async.js
Created January 13, 2023 01:56 — forked from JustSteveKing/localStorage.async.js
Using JavaScript Promises to stop render blocking with localStorage
class Storage {
get(item) {
const request = new Promise((resolve, reject) => {
let data = localStorage.getItem(item);
console.log(`Start of promise`);
(data) ? resolve(data) : reject();
});
request.then((data) => {
console.log(`promise resolved`);
@OzanKurt
OzanKurt / arr_dot.js
Created December 8, 2020 00:51
Laravel's Arr::dot function for Javascript.
/**
* Laravel's Arr::dot function for Javascript.
* IMPORTANT: Requires lodash installed.
*/
function dot(array, prepend) {
results = []
prepend = prepend || ''
$.each(array, function(key, value) {
if ((_.isObject(value) || _.isArray(value)) && ! _.isEmpty(value)) {