This file contains hidden or 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
| function capitalize() { | |
| try { | |
| if (typeof this !== 'string') throw new Error('Capitalize must be used in a String value.'); | |
| const str = this.split(' ') | |
| .map(v => { | |
| return v.split('') | |
| .map((v,i) => (i === 0) ? v.toUpperCase() : v) | |
| .join(''); | |
| }).join(' '); | |
| return str; |
This file contains hidden or 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
| /* | |
| @el = DOM element | |
| @full = true | default: false // If true check if any part of the element is in the viewport | |
| */ | |
| function isInViewport (el, full) { | |
| var full = full || false; | |
| // check if the element is a jQuery object | |
| if (typeof jQuery === "function" && el instanceof jQuery) { | |
| el = el[0]; |
This file contains hidden or 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 xhr from 'promised-xhr'; | |
| async function mostrarDatos () { | |
| try { | |
| const data = await xhr.get('/api/resource'); | |
| const data2 = await xhr.get(data.body.url); | |
| console.log(`${data2.body}!`); | |
| } catch (err) { | |
| console.log(err); |
This file contains hidden or 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 xhr from 'promised-xhr'; | |
| async function* obtenerDatos () { | |
| try { | |
| let finised = false; | |
| let page = 0; | |
| while(!finished) { | |
| page++; | |
| const { body: data } = await xhr.get(`/api/resource?page=${page}`); |
This file contains hidden or 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 xhr from 'xhr'; | |
| xhr({ | |
| url: '/api/resource' | |
| }, response => { | |
| console.log(response); | |
| }, error => { | |
| console.log(error); | |
| }); |
This file contains hidden or 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 xhr from 'promised-xhr'; | |
| function* obtenerDatos () { | |
| try { | |
| const data = yield xhr.get('/api/resource'); | |
| const data2 = yield xhr.get(data.url); | |
| return `${data2}!`; | |
| } catch (error) { | |
| throw error; | |
| } |
This file contains hidden or 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 xhr from 'promised-xhr'; | |
| xhr.get('/api/resource') | |
| .then(response => { | |
| console.log(response); | |
| }) | |
| .catch(err => { | |
| console.log(err); | |
| }); |
This file contains hidden or 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 xhr from 'xhr'; | |
| const config = { url: '/api/resource' } | |
| xhr(config, response => { | |
| xhr(config, response => { | |
| xhr(config, response => { | |
| xhr(config, response => { | |
| xhr(config, response => { | |
| xhr(config, response => { |
This file contains hidden or 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 fs from 'fs'; | |
| fs.readFile('archivo.txt', (error, data) => { | |
| if (error) throw error; | |
| console.log(data.toString()); | |
| }); |
This file contains hidden or 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 xhr from 'promised-xhr'; | |
| xhr.get('/api/resource') | |
| .then(response => { | |
| let body = response.body; | |
| // modificamos el body de alguna forma | |
| return body; | |
| }) | |
| .then(body => { | |
| // volvemos a modificar el body |
OlderNewer