pamatcher is a pattern matching library for JavaScript iterators. Example of use in browser.
pamatcher demo
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>pamatcher demo</title> | |
<script src="https://jspm.io/system@0.19.js"></script> | |
<script type="text/javascript"> | |
System.import('npm:pamatcher').then(function(pamatcher) { | |
var matcher = pamatcher( | |
(i) => i < 10, | |
{ repeat: (i) => i%2==0 }, | |
(i) => i > 10 | |
); | |
var result = matcher.test([1, 4, 8, 44, 55]); | |
if(result) { | |
document.write("Pattern matches!"); | |
} else { | |
document.write("Pattern doesn't match."); | |
} | |
}); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment