Skip to content
This repository has been archived by the owner on Nov 10, 2019. It is now read-only.

ryardley/babel-plugin-pdsl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@pdsl/babel-plugin-pdsl

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

This aught to work but should be considered experimental for the time being until we have more tests around it.

Prerequisites

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 helper function calls in your code:

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))));

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published