Displaying 1 to 17 from 17 results

match-when - :shell: Pattern matching for modern JavaScript

  •    Javascript

Note that when() is a catch-all pattern and, if used, should always be the last condition. If you forget it match() will throw a MissingCatchAllPattern exception if nothing was matched.

tiny-glob - 🚀 Super tiny and ~350% faster alternative to node-glob

  •    Javascript

Tiny and extremely fast library to match files and folders using glob patterns. "Globs" is the common name for a specific type of pattern used to match files and folders. It's the patterns you type when you do stuff like ls *.js in your shell or put src/* in a .gitignore file. When used to match filenames, it's sometimes called a "wildcard".

pun - A small library to enable pattern matching in javascript and coffeescript

  •    Javascript

A tiny functional programming library for Javascript/Coffeescript.

earl-grey - Programming language compiling to JavaScript

  •    Javascript

Counting all words in a block of test. Note that count-words is a variable name, not a subtraction (it is equivalent to the name countWords, if that's the notation you prefer). The each operator accepts multiple clauses, which makes it especially easy to work on heterogenous arrays.




bop - Bop is a very fast Boyer-Moore parser/matcher for String or Buffer patterns.

  •    Javascript

Bop, an ultra fast Boyer-Moore parser/matcher optimized for string and buffer patterns (<= 255 bytes), then it is ideal for parsing multipart/form-data streams, that have a pattern / boundary length < ~70 bytes.

funcy - An experiment in adding functional pattern matching to JavaScript

  •    Javascript

The above function implements a simple factorial function using pattern matching. When you call fact(10) the value ‘10’ is matched against the first pattern ‘0’. This match fails and the next pattern is evaluated. The ‘$’ in the next pattern is an example of a parameter. A parameter matches anything, so the match succeeds and ‘10’ is passed as an argument to the anonymous function. Since this is a recursive function it will match the second pattern until the argument to the function reaches zero and then terminates. Note that this example uses JavaScript ES6 syntax, code in previous JavaScript versions will be slightly more verbose. The fun method takes one or more pattern expressions and returns a function which, when called, will try to match the values passed to the patterns. If a match is found an anonymous function corresponding to the matched pattern is executed, and any extracted values passed to it as arguments.

p - Pattern matching in javascript for asynchronous iteration

  •    Javascript

Pattern matching in javascript for asynchronous iteration

pattern-matching-with-typescript - TypeScript does not have any pattern matching functionality built in

  •    Javascript

TypeScript does not have any pattern matching functionality built in. This article shows several ways how you can replicate the core of a simple pattern matcher using a few simple structures and functions within TypeScript. Resulting code will have improved maintainability and better runtime type safety when done right.


match - Erlang-like pattern matching in JavaScript.

  •    Javascript

Erlang-like pattern matching in JavaScript (use at your own risk). Unlike the proposal-pattern-matching, patterns inside the function arguments are quite limited supported. However, it can be extended using when().

pattern-match - A pattern-matching DSL for JSON-like trees of data.

  •    Javascript

A pattern matching DSL for JavaScript. The module is a function that takes an arbitrary JavaScript value and tests it against a pattern. If the match succeeds, the result is a sub-match object, which consists of the sub-components of the value that matched named sub-patterns (using the var pattern). If the match fails, a MatchError is thrown. Provides the cases by calling when in the order the cases should be tried. The library calls body with the thisArg provided to match as the binding of this.

bem-xjst - bem-xjst (eXtensible JavaScript Templates): declarative template engine for the browser and server

  •    Javascript

Declarative template engine for the browser and server with regular JS syntax. You can redefine or extend just a particular part of output not only by simple redefinition via new templates but also using ‘modes’. E.g. it may be a tag name or its content.

MissMatch - Pattern matching for JavaScript inspired by one of the great features of the Haskell language

  •    Javascript

Powerful pattern matching for javascript. Can match any kind of javascript value against patterns, bind values and execute handlers when a pattern matches. Options are, well, optional. If provided they must be in the form of an object. The only supported option at the moment is arrow. If set to true bound parameters will be passed as arguments to handler functions instead of injected into their this context. This is required to support arrow functions because they do not have their own this context (or rather this inside an arrow function refers to the surrounding context).

Kasai - A pattern matching library

  •    Javascript

Pattern matching allows for concise logic based on the value and shape of data. Kasai provides an intuitive interface for pattern matching in TypeScript and JavaScript.

react-pattern-match - Render based on assertions

  •    Javascript

Is this really pattern matching? No, but it is fun to pretend. Match uses lodash.isEqual to compare a given value vs one provided in the render callback.

tailored - A Pattern matching library for JavaScript

  •    Javascript

This is the pattern matching library ported from elixirscript. It allows you to create functions that will perform pattern matching on the input and either execute the corresponding function or throw a tailored.MatchError. tailored.defmatch(...clauses): Function - Takes one or more tailored.Clause objects and returns a pattern match function. It cycles through the clauses and if a corresponding pattern matches, and the guard is true, then the matching parameters are passed to the corresponding function that will execute. If no matching clause is found, a tailored.MatchError is thrown.

natch

  •    Javascript

Simple, natural pattern matching in JS. Akin to Clojure multimethods. The module's default export is a match function. The first argument to match is a discriminator projection: it sorts your input into one of a number of cases. The remaining arguments to match are handlers corresponding to the cases returned by the discriminator; the handler for the appropriate case will be applied to the input value and the result returned.