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 items = Array.from({length: 10}) | |
const handler = async () => { | |
const promises = await items.map((item) => { | |
const bool = Boolean(Math.random() < 0.5) | |
if (bool) { | |
return Promise.resolve('True') | |
}else { | |
return Promise.reject('False') | |
} |
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
[ | |
{ "name": "Abancay", "code": "PE-APU" }, | |
{ "name": "Acobamba", "code": "PE-HUV" }, | |
{ "name": "Acomayo", "code": "PE-CUS" }, | |
{ "name": "Aija", "code": "PE-ANC" }, | |
{ "name": "Alto Amazonas", "code": "PE-LOR" }, | |
{ "name": "Ambo", "code": "PE-HUC" }, | |
{ "name": "Andahuaylas", "code": "PE-APU" }, | |
{ "name": "Angaraes", "code": "PE-HUV" }, | |
{ "name": "Anta", "code": "PE-CUS" }, |
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
.post { | |
width:320px; | |
position: relative; | |
background-color: #dbdbdb; | |
} | |
.post::after { | |
display: block; | |
content: ""; | |
/* 1:1 */ |
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
window.PaymentComponent = zoid.create({ | |
tag: "payment-component", | |
url: "http://d2sftg1mzf8i5a.cloudfront.net/payments/form.html", | |
dimensions: { | |
width: "800px", | |
height: "600px", | |
}, | |
props: { | |
onClick: { | |
type: "function", |
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
class FormState { | |
constructor(){ | |
this.fields = {}; | |
this.subscribers = []; | |
} | |
subscribe(callback) { | |
this.subscribers.push(callback) | |
} |
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
class Timer { | |
constructor() { | |
this.time = 0; | |
this.interval = -1; | |
} | |
start() { | |
if (this.interval === -1) { | |
this.interval = setInterval(() => { | |
this.time++; |
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
function verificar() { | |
const arr1_skus = arr1.rate.items.map(arr => arr.sku); | |
const skus = ['1', '2', '3', '4', '5']; | |
let checks = 0; | |
arr1_skus.map(sku => skus.includes(sku) && (checks = checks + 1)); | |
return checks === arr1_skus.length ? true : false; | |
} |
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 addToCartInLocalStorage = product => { | |
if (!localStorage.getItem("cart")) { | |
localStorage.setItem("cart", JSON.stringify([])); | |
} | |
let cartProducts = JSON.parse(localStorage.getItem("cart")); | |
cartProducts.push(product); | |
localStorage.setItem("cart", JSON.stringify(cartProducts)); | |
}; |
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, { useReducer } from "react"; | |
import * as TheReducer from "./Context/context"; | |
function ComoUsarReducer() { | |
const [state, dispatch] = useReducer( | |
TheReducer.default, | |
TheReducer.initialState | |
); |
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 { ApolloClient } from "apollo-client"; | |
import { HttpLink } from "apollo-link-http"; | |
import { InMemoryCache } from "apollo-cache-inmemory"; | |
import { setContext } from "apollo-link-context"; | |
const middlewareLink = setContext(() => ({ | |
headers: { | |
"X-Shopify-Storefront-Access-Token": "{Token del storefront}" | |
} | |
})); |
NewerOlder