Create a gist now

Instantly share code, notes, and snippets.

@pmros /README.md
Last active Nov 29, 2015

What would you like to do?
pamatcher demo

pamatcher is a pattern matching library for JavaScript iterators. Example of use in browser.

<!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