Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

expressive-ts

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expressive-ts

A functional programming library designed to simplify building complex regular expressions

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-72%
Maintainers
1
Weekly downloads
 
Created
Source

Expressive-ts Logo

Build Status Badge

expressive-ts is a functional programming library designed to simplify building complex regular expressions.

Expressive-ts

Table of contents

  • Installation
  • Why?
  • Usage
  • Documentation
  • Prior Art

Installation

npm install fp-ts expressive-ts

or

yarn add fp-ts expressive-ts

Note: fp-ts is a peer dependency of expressive-ts

Why?

The expressive nature of the expressive-ts API makes it incredibly easy to understand the purpose of an otherwise cryptic regular expression. Function composition is a core component of the API. By composing together the various functions provided by expressive-ts, extremely complex regular expressions can be built easily.

Usage

Lets imagine that we would like to recognize and validate a basic URL. Here's how it would look using expressive-ts.

import { pipe } from 'fp-ts/lib/function'
import * as E from 'expressive-ts/lib/Expression'

const expression = pipe(
  E.compile, // expressions always begin with a call to `compile`
  E.startOfInput,
  E.string('http'),
  E.maybe('s'),
  E.string('://'),
  E.maybe('www.'),
  E.anythingBut(' '),
  E.endOfInput,
  E.toRegex
)

assert.strictEqual(expression.test('https://www.google.com'), true)
assert.strictEqual(expression.test('https://google.com'), true)
assert.strictEqual(expression.test('http://google.com'), true)
assert.strictEqual(expression.test('http:/google.com'), false)
assert.strictEqual(expression.test('http://goog le.com'), false)

Documentation

Prior Art

Keywords

FAQs

Package last updated on 18 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc