npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ramda-loader

v0.5.2

Published

Indispensable RamdaJs Webpack loader for writing and debugging functional code

Downloads

12

Readme

Native functional programming in JavaScript with Ramda and Webpack

Build Status npm version dependencies

Write beautiful functional programming code in JavaScript without namespacing or importing functions by hand.

Enforces Ramda names for a clean and consistent code base. Features enhanced debbuging that gives you precise stack traces for point-free programming with Ramda.

Install

$ npm install --save-dev ramda-loader

Add the loader to your webpack.config.js:

module.exports = {
    // ...
    module: {
      loaders: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          loader: 'ramda-loader',
          query: {
            debug: true, // Will wrap Ramda functions in error handles with file name, line number and char location
            strict: true, // Will disallow variables that have the same name as Ramda functions
            imports: true // Will add import statements for every Ramda function found
          }
        }
      ]
    }
}

Description

ramda-loader uses Abstract Syntax Tree (AST) parsing and analysing to instrument your code and produce new code. This way you gain confidence that you can use Ramda functions anywhere and your code will continue to work exactly the same as before.

In order promote point-free programming, ramda-loader enforces that you don't redeclare the names used by Ramda. This ensures you achieve a standardised codebase that anyone can understand just by looking at Ramda's documentation - less maintanance on your side and less documentation to write.

Example

Given this file:

var add10 = add(10)

var answer = pipe(
  add10,
  ifElse(
    equals(42),
    always('The answer to your Ramda import problems'),
    subtract(10)
  )
)

answer(32) // The answer to your Ramda import problems

it will automatically import all the Ramda functions found:

var R = __webpack_require__(1)
var add = R.add
var pipe = R.pipe
var ifElse = R.ifElse
var equals = R.equals
var always = R.always
var subtract = R.subtract
var __ = R.__

var add10 = add(10)

var answer = pipe(
	add10,
	ifElse(
	  equals(42),
	  always('The answer to your Ramda import problems'),
	  subtract(__, 10)
	)
)

answer(32) // The answer to your Ramda import problems

and with the debug=true this becomes:

var __ramdaDebugWrapper = __webpack_require__(1).fn;
var add = R.add
var pipe = R.pipe
var ifElse = R.ifElse
var equals = R.equals
var always = R.always
var subtract = R.subtract
var __ = R.__

var add10 = __ramdaDebugWrapper('../sample/src/index.js', 1, 15, 'add', add)(10);

var answer = __ramdaDebugWrapper('../sample/src/index.js', 3, 16, 'pipe', pipe)(add10, __ramdaDebugWrapper('../sample/src/index.js', 5, 3, 'ifElse', ifElse)(__ramdaDebugWrapper('../sample/src/index.js', 6, 5, 'equals', equals)(42), __ramdaDebugWrapper('../sample/src/index.js', 7, 5, 'always', always)('The answer to your Ramda import problems'), __ramdaDebugWrapper('../sample/src/index.js', 8, 5, 'subtract', subtract)(__, 10)));

module.exports = answer;

Build

Install the dependencies, via:

$ npm install

then you can run:

$ npm run build

which will build the loader in the /dist folder.

Running The Test Suite

Install the dependencies (see Build)

Then you can run the tests by running (which also builds the loader):

$ npm test

Contributing:

Feel free to open issues to propose stuff and participate. Pull requests are also welcome.

Licence:

MIT