Advertise here

Z– Native Pattern Matching for Javascript

November 27, 2017     612    
Z– Native Pattern Matching for Javascript

The pattern matching is basically a switch on steroids, you can create powerful conditions such based on Object properties or Array content without manipulating the Object or Array itself.

Benefits

  • Conditionals without array or object manipulation
  • Write functional declarative code instead imperative
  • Reduces code complexity and bugs
  • Code reuse via recursion

Avaiable Patterns

  • Matches by value: (x = 1) =>, (x = null) =>, (x = 'true') =>
  • Matches by object or array: (x = {a: 1}) =>, (x = [1, 2]) =>
  • Matches by type: (x = String) =>, (x = Boolean) =>
  • Matches by instance: (x = Date) =>, (x = Person) =>
  • Matches by spiting array into elements and tail (head, tail) => , (a, b, c, tail) =>, etc…

Related Plugins

Latest Plugins