This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Primitive Data Types | |
const name = 'Yasemen'; | |
const firstNumber = 3; | |
const isHealthy = true; | |
let userName; | |
let data = null; | |
// Complex Data Types | |
function getName() { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm i -D eslint | |
npx eslint --init | |
npx install-peerdeps --dev eslint-config-airbnb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type GenericFunction<R = any> = (...args: any[]) => R; | |
const once = <R = any>(f: GenericFunction<R>) => { | |
let isRun = false, result: R; | |
return (...args: any[]) => { | |
if (!isRun) { | |
result = f(...args); | |
isRun= true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const curry = fn => { | |
let argCount = 0; | |
const numberOfArgs = fn.length; | |
if (numberOfArgs === 0) return fn; | |
const _magic_ = arg => { | |
++argCount; | |
fn = fn.bind(null, arg); | |
if (argCount === numberOfArgs) return fn(); | |
return (arg) => _magic_(arg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useRef, useEffect } from 'react' | |
import { onShow, OnShow } from '@solariss/react-on-show' | |
// Function based | |
function MyComponent() { | |
const ref = useRef(null) | |
useEffect(() => { | |
onShow(this.ref.current, () => { | |
console.log('Event is triggered.') | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useRef } from 'react' | |
import { OnShow } from '@solariss/react-on-show' | |
export default function Div() { | |
const ref = useRef(null) | |
return ( | |
<OnShow handler={() => ref.current.innerHTML = 'Now you can see me.'}> | |
<div ref={ref}>I am not in the screen now</div> | |
</OnShow> | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useRef } from 'react' | |
import { onShow } from '@solariss/react-on-show' | |
export default function Div() { | |
const ref = useRef(null) | |
useEffect(() => { | |
onShow(ref.current, () => ref.current.innerHTML = 'Now you can see me.') | |
}, []) | |
return ( | |
<div ref={ref}>I am not in the screen now</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const Tuple = function() { | |
const types = Array.prototype.slice.call(arguments, 0) | |
function _T() { | |
const generateId = () => { | |
let id = '' | |
for (let i = 0; i < 8; ++i) { | |
const randomChoice = Math.floor(Math.random() * 2) | |
if (randomChoice % 2 === 0) { | |
id = id.concat(Math.floor(Math.random() * 10).toString()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const map = (iterable, f) => { | |
if (Array.isArray(iterable) && !Array.prototype.get) { | |
Array.prototype.get = function(index) { | |
return this[index] | |
} | |
} | |
if (!iterable.push) throw new Error('Iterable does not implement push method.') | |
if (!iterable.get) throw new Error('Iterable does not implement get method.') | |
let i = 0 | |
const length = iterable.length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "2.0.0", | |
"tasks": [ | |
{ | |
"label": "clear-out", | |
"type": "shell", | |
"command": "Remove-Item -LiteralPath out -Force -Recurse; mkdir out", | |
"problemMatcher": [] | |
}, | |
{ |
NewerOlder