I hereby claim:
- I am wjramos on github.
- I am wjramos (https://keybase.io/wjramos) on keybase.
- I have a public key ASBlIYXoxdN24wSZ9C6EYcrduxL2CAo4fDhqjXy-Tf81xQo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| export default (() => { | |
| let hooks = [] | |
| let currentIndex = 0 | |
| const render = Component => { | |
| // Run effects | |
| const component = Component() | |
| component.render() |
| export function extractNodeText(node) { | |
| if (typeof node === 'string') return node; | |
| if (React.isValidElement(node)) { | |
| const { messageKey, messagesMap } = node.props; | |
| if (messageKey && messagesMap) { | |
| return messagesMap[messageKey]; | |
| } |
| import React, { PureComponent } from 'react'; | |
| import PropTypes from 'prop-types'; | |
| export default class ViewportTrigger extends PureComponent { | |
| static propTypes = { | |
| onViewportEnter: PropTypes.func, | |
| onViewportLeave: PropTypes.func, | |
| children: PropTypes.node, | |
| threshold: PropTypes.number, | |
| }; |
| // ******************* | |
| // Filesystem utils | |
| // ***************** | |
| export const isDirectory = source => fs.lstatSync(source).isDirectory(); | |
| export const removePath = (source, filePaths = []) => filePaths.map(filePath => filePath.replace(source, '')); | |
| export const listDirFiles = source => fs.readdirSync(source).map(name => path.join(source, name)); | |
| export const listFiles = source => listDirFiles(source).filter(source => !isDirectory(source)); | |
| export const listDirs = source => listDirFiles(source).filter(isDirectory); | |
| export const removeExtension = fileName => fileName.split('.')[0]; | |
| export const getFileName = filePath => removeExtension(filePath.split('/').pop()); |
| const assert = require('assert'); | |
| const GREEN = '\x1b[32m'; | |
| const RED = '\x1b[31m'; | |
| const WHITE = '\x1b[37m'; | |
| class Test { | |
| constructor() { | |
| this.failures = []; | |
| this.count = 0; |
| const assert = require('assert'); | |
| const GREEN = '\x1b[32m'; | |
| const RED = '\x1b[31m'; | |
| const WHITE = '\x1b[37m'; | |
| const printFailure = failure => console.error(`${RED} | |
| ❌ FAILURE: ${failure}`); | |
| const printSuccess = success => console.log(`${GREEN} |
| import AWS from 'aws-sdk'; | |
| const { AWS_REGION = 'us-east-1', NODE_ENV = 'development', AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY } = process.env; | |
| const config = { | |
| region: AWS_REGION, | |
| accessKeyId: AWS_ACCESS_KEY_ID, | |
| secretAccessKey: AWS_SECRET_ACCESS_KEY, | |
| }; | |
| AWS.config.update(config); |
| export default class Cache { | |
| constructor(ttl = 300000) { // 5 Minutes | |
| this.ttl = ttl; | |
| this.expirations = new Map(); | |
| this.cache = new Map(); | |
| } | |
| isExpired(key) { | |
| return (!this.cache.has(key)) || | |
| (this.cache.has(key) && (!this.expirations.has(key) || this.expirations.get(key) < Date.now())); |