Skip to content

Instantly share code, notes, and snippets.

View avrcoelho's full-sized avatar

André Coelho avrcoelho

View GitHub Profile
const transactions = [
{
id: 3,
sourceAccount: "A",
targetAccount: "B",
amount: 100,
category: "eating_out",
time: "2018-03-02T10:34:30.000Z",
},
{
@avrcoelho
avrcoelho / MaskJS.js
Last active August 28, 2020 16:19
Mask for string
const mask = (value, pattern) => {
let index = 0;
const string = value.toString();
return pattern.replace(/#/g, () => string[index++] || '');
}
mask('1145820412', '(##) ####-####')
@avrcoelho
avrcoelho / uploadFileSaga.js
Created December 10, 2019 01:32 — forked from jpgorman/uploadFileSaga.js
Example of using redux-saga eventChannel with axios/fetch etc
import {eventChannel, END} from 'redux-saga'
function createUploaderChannel(key, files){
return eventChannel(emit => {
const onProgress = ({total, loaded}) => {
const percentage = Math.round((loaded * 100) / total)
emit(percentage)
}