Skip to content

Instantly share code, notes, and snippets.

@suzdalnitski
Last active January 15, 2020 02:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suzdalnitski/34d6d33a2b998370c898121651d7dbad to your computer and use it in GitHub Desktop.
Save suzdalnitski/34d6d33a2b998370c898121651d7dbad to your computer and use it in GitHub Desktop.
// before refactoring:
// calculator.js:
const isValidInput = text => true;
const btnAddClick = (aText, bText) => {
if (!isValidInput(aText) || !isValidInput(bText)) {
return;
}
}
// after refactoring:
// inputValidator.js:
export const isValidInput = text => true;
// calculator.js:
import { isValidInput } from './inputValidator';
const btnAddClick = (aText, bText, _isValidInput = isValidInput) => {
if (!_isValidInput(aText) || !_isValidInput(bText)) {
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment