GithubHelp home page GithubHelp logo

ramda-t's Introduction

ramda-t npm version

Experiment: Primitive, JSDoc-assisted runtime type checking for Ramda

It reads JSDoc documentation from the project's Ramda source file and uses the functions' @param annotations to determine valid argument types in function application.

features

  • Throws a TypeError when passing values of incorrect type to Ramda functions

usage

  1. npm install ramda-t in a project that has ramda installed.
  2. Require ramda-t instead of ramda.

example

var R = require('ramda-t');
var doubleAll = R.map(R.multiply(2));
doubleAll('foo'); // oops

issues

  • Lens value types are documented as Lens, despite being type of Function
  • How to smoothly make ramda-t part of development process but drop for production use?
  • R.reject takes @param Object as second argument, and dispatches to filter, a method of a different name than the function itself.

caveats

  • Relies on JSDoc @param annotations to be correct. Some may not be. The generated ramda.json may be edited to correct types.
  • R.map's second argument is type of Array. Becomes an issue when R.map is used to dispatch. Dispatched arguments are difficult to parse from JSDoc annotations because they're part of the description. Workaround: Check if value is dispatchable, i.e. has a method by the name of the function.

running ramda test suite with ramda-t

./scripts/test-ramda.sh
./scripts/test-ramda.sh propEq.js

debug output

Set DEBUG environment variable to ramda-t.

DEBUG=ramda-t node index.js

ramda-t's People

Contributors

raine avatar

Watchers

 avatar  avatar  avatar

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.