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 fs from 'fs' | |
export const listFilesInDirectory = async (path: string) => | |
new Promise((resolve, reject) => | |
fs.readdir(path, (err, content) => | |
err ? reject(err) : resolve(content) | |
) | |
) |
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
// pattern matching is a nice mechanism supported by most functional languages (eg see scala examples: https://docs.scala-lang.org/tour/pattern-matching.html) | |
// here are some ways to use javascript switch and if statement for pattern matching | |
// we are using IIFE pattern to immediately invoke switch (or if) statement | |
const value1 = 1; | |
// version using switch case | |
const value2 = (_ => { | |
switch (true) { | |
case value1 === 1: return 'first case'; | |
case value1 === 2: return 'second case'; |
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 webpack = require('webpack'); | |
const path = require('path'); | |
// Styleguidist (v11.2.0) doesn't display components with create ract app 5 | |
// This webpackConfig is a workaround for that | |
// For more information see https://github.com/styleguidist/react-styleguidist/issues/1910#issuecomment-1013763698 | |
const webpackConfig = { | |
module: { | |
rules: [ |