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
export default function currencyFormat(value: string | number): string { | |
return Number(value).toLocaleString("pt-BR", { | |
style: "currency", | |
currency: "BRL", | |
}) | |
} |
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 * as React from 'react'; | |
import * as WebBrowser from 'expo-web-browser'; | |
import * as Google from 'expo-auth-session/providers/google'; | |
import { Button } from 'react-native'; | |
WebBrowser.maybeCompleteAuthSession(); | |
export default function App() { | |
const [request, response, promptAsync] = Google.useAuthRequest({ | |
expoClientId: 'GOOGLE_GUID.apps.googleusercontent.com', |
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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
"55984366060".split("").reduce((p, c)=> p.replace("x", c),"(xx) xxxxx-xxxx") |
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 invertPromise (p: Promise<any>) { | |
return new Promise(function (resolve, reject) { | |
return p.then(reject, resolve) | |
}) | |
} | |
function firstOfResolve (promises: Array<Promise<any>>) { | |
return invertPromise(Promise.all(promises.map(p => { | |
return invertPromise(p) | |
}))) |
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 errorHandler(error: AxiosError) { | |
type ErrorBody = { | |
message?: string; | |
error?: string; | |
} | |
if (error.response) { | |
// error in server with a response | |
const data = (<ErrorBody>error.response.data) | |
const body = `${data.error}: ${data.message}`; | |
alert(body); |
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 mockedAxios = axios as jest.Mocked<typeof axios>; |
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
humanFormat: function(number) { | |
if (isNaN(number)) { | |
number = ""; | |
} else { | |
// number = Number(number).toLocaleString(this.options.locale, {maximumFractionDigits: 2, minimumFractionDigits: 2, style: 'currency', currency: 'BRL'}); | |
number = Number(number).toLocaleString(this.options.locale, { | |
maximumFractionDigits: this.options.precision, | |
minimumFractionDigits: this.options.precision, | |
}); |
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 blobfile = await (await fetch(`file://${uri}`)).blob() |