Skip to content

Instantly share code, notes, and snippets.

View ThomRoman's full-sized avatar

ThomRoman

View GitHub Profile
interface IBase{
id:number
name:string
}
interface ISchool extends IBase{
courses:IBase[]
addCourse(course:IBase):void
}
class University implements ISchool{
const fetch = require('node-fetch')
const ajax = domain => resource=>{
const url = `${domain}/${resource}`
return {
create: data => fetch(url,{
method:'POST',
body:JSON.stringify(data)
})
.then(response=>response.json()),
const compose = (...fns)=>initialValue=>fns.reduceRight((acc,currFun)=>currFun(acc),initialValue)
interface IAccount{
numberAccount:number
credit:number
currency:string
}
interface SavingsBank{
interest:number
applyInterest():void
}
type TypeAccountAndSaving= IAccount & SavingsBank
// avoid installing @types
// ./src/typings-typescript-npm.d.js
// Permite informar al transpilador de Typescript los nuevos tipos de datos
declare module 'lodash' {
export function random(min:number,max:number):number
}
// https://stackoverflow.com/questions/43576089/arrow-functions-using-call-apply-bind-not-working
function alert_(name,lastname){
alert(`${name} ${lastname}`)
}
function debounce (callback,time){
let timeoutId
return function(){
if(timeoutId)
clearTimeout(timeoutId)
const context = this
const words = [
'thom','carlos','Erick','Thomas'
]
const input = document.querySelector('input')
const result = document.querySelector('.result')
const renderResultDebounce = debounce(renderResult,500)
input.addEventListener('keyup',event=>{
renderResultDebounce(event.target.value)
})
const paseo = steps =>{
if(steps.length!==10)
return false
const {n,s,e,o} = steps.reduce((acc,curr)=>({
...acc,
[curr]:acc[curr]+1
}),{
n:0,
s:0,
e:0,
const paseo = steps = {
if(steps.length !==10)
return false
const {x,y} = steps.reduce((acc,curr)=>{
const actions = {
n:({x,y})=>({x,y:y+1}),
s:({x,y})=>({x,y:y-1}),
e:({x,y})=>({x:x+1,y}),
o:({x,y})=>({x:x-1,y}),
}
const vocales = (text,vowels=['a','e','i','o','u'])=>(
text.split('').reduce((acc,curr)=>(
vowels.includes(curr) ?
++acc:
acc
),0)
)