Skip to content

Instantly share code, notes, and snippets.

:octocat:
Suck it and see

Guseyn Ismayylov Guseyn

:octocat:
Suck it and see
Block or report user

Report or block Guseyn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Guseyn
Guseyn / invertTree.js
Last active Apr 9, 2019
Invert Tree In Pure OO style
View invertTree.js
class TreeNode {
constructor (value, left, right) {
this.value = value
this.left = left
this.right = right
}
invert () {
if (!this.left && !this.right) {
return this
@Guseyn
Guseyn / mapLimit.js
Last active Apr 16, 2019
mapLimit via callbacks
View mapLimit.js
function mapLimit (col, limit, mapFunc, doneFunc, newCol = [], index = { value: 0 }, freeThreads = { value: limit }) {
if (freeThreads.value > 0 && index.value < col.length) {
// Save current index
const curIndex = index.value
// Now the number of free threads is lower on 1
freeThreads.value -= 1
mapFunc((err, newItem) => {
if (err) {
// Smth bad happend, we call doneFunc with err
@Guseyn
Guseyn / solution.js
Created Mar 25, 2019
theorem.applytojob.com solution
View solution.js
const assert = require('assert')
function flattenArray (nestedArray, resArray = []) {
for (let i = 0; i < nestedArray.length; i++) {
if (Array.isArray(nestedArray[i])) {
flattenArray(nestedArray[i], resArray)
} else {
resArray.push(nestedArray[i])
}
}
You can’t perform that action at this time.