Skip to content

Instantly share code, notes, and snippets.

View bekliev's full-sized avatar
😉
Babe! How ya doin?

IBRAGIM (PARVIZ BEKLIEV) bekliev

😉
Babe! How ya doin?
View GitHub Profile
@bekliev
bekliev / SomeComponent.vue
Last active December 11, 2020 10:07 — forked from stwilz/curryMapGetters.js
A curry utility for passing additional arguments to `mapGetters`.
<template>
<section class="media-list">
<media-table
:rows="list.list"
:sord="list.order.sord"
:sidx="list.order.sidx"
:page="list.pagination.page"
:perPage="list.pagination.perPage"
:total="list.total"
@bekliev
bekliev / sum(1)(2)(3)(n).js
Last active March 10, 2020 01:46
sum function which returns another function
(() => {
console.clear();
console.log('sum is: ' + sum(1)(2)(3)(4));
function sum(a, b = 0) {
const res = a + b;
console.log({res, a, b});
/*
* Try to copy&paste to your browser's console
* OR open this image: https://user-images.githubusercontent.com/4066435/72851941-f7ec8f00-3ca4-11ea-9840-29511325a772.png
*/
function solution(str, maxEquals = 2) {
let result = ''
let equals = 0
for (const i in str) {
const prev = str.charAt(i - 1)
const curr = str.charAt(i)
@bekliev
bekliev / useCallbackCleanup.js
Last active December 10, 2020 20:00
Enhanced React useCallback hook with cleanup ability/feature (created in process of the issue: https://github.com/facebook/react/issues/15176#issuecomment-564029580)
import React from 'react';
/**
* memoized callback (a.k.a. useCallback) with cleanup ability/feature
*
* @param {Function} baseCallback callback that returns array with [callback, cleanup]
*
* callback - which will be passed to React.useCallback
*
* cleanup - which will be called in React.useEffect's cleanup function
@bekliev
bekliev / debounce.js
Last active March 10, 2020 01:56 — forked from lstanard/waitForFinalEvent()
debounce ES6
// Run callback with delay
const debounce = (delay, callback) => {
let timer;
return function() {
if (timer) clearTimeout(timer);
timer = setTimeout(() => callback.apply(this, arguments), delay);
};
};