Created
December 30, 2018 13:37
-
-
Save dyrkow/efb1090763718b30b4c33112d4e25bb4 to your computer and use it in GitHub Desktop.
pipeline pattern
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 pipe = (...fns) => (param) => fns.reduce((result, func) => func(result), param) | |
// Создаем pipe для обработки значения из поля формы | |
const value = pipe(trim, limit, shield)('some value') | |
| | | | |
обрезать пробелы - - | - - - экранировать символы | |
ограничить значение по длине | |
trim, limit, shield типовые функции имеющие следующий интерфейс fn(value) => value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment