@pdsl/babel-plugin-pdsl

5.2.10 • Public • Published

@pdsl/babel-plugin-pdsl

This plugin speeds up pdsl in babelified codebases by pre-compiling p-expressions to predicate function definitions.

This should be considered experimental for the time being.

Prerequisites

Ensure you have pdsl installed in your project.

Installation

Install the plugin with yarn or npm.

yarn add --dev @pdsl/babel-plugin-pdsl
npm install -D @pdsl/babel-plugin-pdsl

Configuration

Add the plugin to your .bablerc:

{
  "plugins": ["@pdsl/babel-plugin-pdsl"]
}

NOTE: Ensure the plugin is placed before any module resolution plugins.

How this works

This plugin parses p-expressions and repaces them with function calls:

Input

import p from "pdsl";

const notNil = p`!(null|undefined)`;
const hasName = p`{name}`;
const isTrue = p`true`;
const hasNameWithFn = p`{name:${a => a.length > 10}}`;

Output

import { val, not, or, obj, entry, pred } from "pdsl/helpers";

const notNil = val(not(or(val(null), val(undefined))));
const hasName = val(obj("name"));
const isTrue = val(true);
const hasNameWithFn = val(obj(entry("name", pred(a => a.length > 10))));

Readme

Keywords

none

Package Sidebar

Install

npm i @pdsl/babel-plugin-pdsl

Weekly Downloads

25

Version

5.2.10

License

MIT

Unpacked Size

28.4 kB

Total Files

30

Last publish

Collaborators

  • ryardley