Giter Site home page Giter Site logo

functional's People

Contributors

dependabot[bot] avatar ephetic avatar rodocite avatar

Stargazers

 avatar

Watchers

 avatar  avatar

functional's Issues

'Or' semantics

Custom predicate would already work, but it might be nice to specify multiple shapes/basic-predicates like m([m.OR(Number, String), fn])

Contructors as condition get called and usually truthy

import { matcher as m } from '@ephetic/functional'

const secondIsNumber = m(
  [ [m, Number], (a,b) => console.log(`${b} is a Number`)],
  [ [m, Array],  (a,b) => console.log(`${b} is an Array`)],
  [ m,           (a,b) => console.log(`${b} is not a Number or Array`)]
)

secondIsNumber('asdf', 2)   // 2 is a Number
secondIsNumber(2, {})       // [object Object] is an Array
secondIsNumber(2, 'asdf')   // asdf is an Array

Limit arg length

For Array conditions (i.e. argument checking), look into only passing as many arguments to fn as the length of the argument pattern, i.e. fn.apply(null, args.slice(0, cond.length).

This might be useful for when m functions are passed as callbacks to things that pass extra arguments. Wait, no; it's patterns will have to match those arguments. How about when the m function is given a callback as fn that expects an unknownish number of args. Yeah, maybe.

If nothing else, it would make it more predictable.

Check [head, ...rest] and object wrapping semantics

Not sure they even work. Once verified, improve the README.md notes on Arrays.

Array and rest matching

Since arrays are used to represent a parameter pattern, a literal array must be wrapped in an object {foo: [11,22,33]}. However, it would be nice to make sure the [head, ...rest] semantics work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.