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
interface IBase{ | |
id:number | |
name:string | |
} | |
interface ISchool extends IBase{ | |
courses:IBase[] | |
addCourse(course:IBase):void | |
} | |
class University implements ISchool{ |
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 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()), |
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 compose = (...fns)=>initialValue=>fns.reduceRight((acc,currFun)=>currFun(acc),initialValue) |
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
interface IAccount{ | |
numberAccount:number | |
credit:number | |
currency:string | |
} | |
interface SavingsBank{ | |
interest:number | |
applyInterest():void | |
} | |
type TypeAccountAndSaving= IAccount & SavingsBank |
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
// 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 | |
} |
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
// 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 |
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 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) | |
}) |
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 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, |
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 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}), | |
} |
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 vocales = (text,vowels=['a','e','i','o','u'])=>( | |
text.split('').reduce((acc,curr)=>( | |
vowels.includes(curr) ? | |
++acc: | |
acc | |
),0) | |
) |