function formatCnpjCpf($value)
{
$cnpj_cpf = preg_replace("/\D/", '', $value);
if (strlen($cnpj_cpf) === 11) {
return preg_replace("/(\d{3})(\d{3})(\d{3})(\d{2})/", "\$1.\$2.\$3-\$4", $cnpj_cpf);
}
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
# | |
# CORS header support | |
# | |
# One way to use this is by placing it into a file called "cors_support" | |
# under your Nginx configuration directory and placing the following | |
# statement inside your **location** block(s): | |
# | |
# include cors_support; | |
# | |
# As of Nginx 1.7.5, add_header supports an "always" parameter which |
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
const pause = (data, time) => new Promise(resolve => setTimeout(() => resolve(data), time)); | |
const pauseReject = (data, time) => | |
new Promise((resolve, reject) => | |
setTimeout(() => reject(new Error(`Something went wrong in the ${data} promise`)), time) | |
); | |
const parallelErrorHandlingWrong = () => { | |
const firstPromise = pause('first', 3000); | |
const secondPromise = pauseReject('second', 2000); | |
const thirdPromise = pause('third', 1000); |