Skip to content

Instantly share code, notes, and snippets.

View akbarjondev's full-sized avatar

Akbarjon akbarjondev

View GitHub Profile
@akbarjondev
akbarjondev / reverseInPlace.js
Created November 21, 2023 06:27
Reverse in place algorithm for arrays
function reverseInPlace(arr) {
let length = arr.length,
middle = Math.floor(length / 2),
temp = null
for(let i = 0; i < middle; i++) {
temp = arr[i]
arr[i] = arr[arr.length - 1 - i]
arr[arr.length - 1 - i] = temp
}
@akbarjondev
akbarjondev / delay.js
Created November 22, 2023 13:32
Function for delaying executing next line of code
function delay(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
}
@akbarjondev
akbarjondev / lazy.js
Created January 7, 2024 13:45
Custom lazy function in React
export const lazy = (componentFactoryPromise) => {
const componentPromise = componentFactoryPromise()
let Component
componentPromise.then(C => {
Component = C.default
})
return (props) => {
if(!Component) {
throw componentPromise