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
export default (() => { | |
let hooks = [] | |
let currentIndex = 0 | |
const render = Component => { | |
// Run effects | |
const component = Component() | |
component.render() |
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
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]; | |
} |
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
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, | |
}; |
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
// ******************* | |
// 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()); |
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 assert = require('assert'); | |
const GREEN = '\x1b[32m'; | |
const RED = '\x1b[31m'; | |
const WHITE = '\x1b[37m'; | |
class Test { | |
constructor() { | |
this.failures = []; | |
this.count = 0; |
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 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} |
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
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); |
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
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())); |
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
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); |
NewerOlder