{"repo":"santinic/pampy.js","free":true,"listed":false,"github":"https://github.com/santinic/pampy.js","clone":"git clone https://github.com/santinic/pampy.js.git","description":"Pampy.js: Pattern Matching for JavaScript","language":"JavaScript","stars":549,"topics":["pattern-matching","javascript","lisp-interpreter","nodejs","functional","functional-programming"],"license":"MIT","category":"dev-tools","readme_excerpt":"Pampy.js: Pattern Matching for JavaScript Pampy.js is pretty small (250 lines, no dependencies), reasonably fast, and often makes your code more readable, and easier to reason about. There is also a Python version of Pampy. You can write many patterns Patterns are evaluated in the order they appear. You can write Fibonacci The operator means \"any other case I didn't think of\". If you already use , you can require ANY , which is exactly the same . You can write a Lisp calculator in 5 lines You can match so many things! You can match TAIL You can nest Arrays You can nest Objects. And you can use as key! Admittedly using as key is a bit of a trick, but it works for most situations. You can use functions as patterns You can pass [pattern, action] array pairs to matchPairs for better Prettier formatting. All the things you can match Pattern Example What it means Matched Example Arguments Passed to function NOT Matched Example --------------- -------------- --------------- ----------------------------- ------------------ \"hello\" only the string \"hello\" matches \"hello\" nothing any other value Number Any javascript number 2.35 2.35 any other value String Any javascript string \"hello\" \"hello\" any other value Array Any array object [1, 2] [1, 2] any other value Any value that value ANY The same as that value [1, 2, ] An Array that starts with 1, 2 and ends with any value [1, 2, 3] 3 [1, 2, 3, 4] [1, 2, TAIL] An Array that start with 1, 2 and ends with any sequence [1, 2, 3, 4] [3, 4] [","default_branch":null,"files":null,"tree":[],"storefront":"/r/santinic","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/santinic/pampy.js/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}