Publish your own packages to the world's most popular software ecosystem with npm Pro.Get started »

pdsl

4.1.0 • Public • Published

Predicate Domain Specific Language

An expressive declarative toolkit for composing predicates in TypeScript or JavaScript

import p from "pdsl";
 
const isSoftwareCreator = p`{
  name: string,
  age: > 16,
  occupation: "Engineer" | "Designer" | "Project Manager"
}`;
 
isSoftwareCreator(someone); // true | false
  • Intuitive
  • Expressive
  • Lightweight
  • No dependencies
  • Small bundle size
  • Fast

Build Status npm bundle size npm codecov

Predicate functions are just easier with PDSL

Creating predicate functions in JavaScript is often verbose, especially for checking the format of complex object types. We need predicate functions all the time when filtering an array, validating input, determining the type of an unknown object or creating guard conditions in TypeScript.

PDSL provides the developer a simple but powerful shorthand based on a combination of template strings and helper functions for defining predicate functions that makes it easy to understand intent. With pdsl we can easily visualize the expected input's structure and intent using it's intuitive predicate composition language.

Documentation

Read the docs

Install

npm i pdsl

DownloadsWeekly Downloads

79

Version

4.1.0

License

MIT

Unpacked Size

72.6 kB

Total Files

20

Last publish

Collaborators

  • avatar