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

regexp-util

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regexp-util

utilities for generating regular expression

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
45K
decreased by-9.22%
Maintainers
1
Weekly downloads
 
Created
Source

regexp-util

npm build

utilities for generating regular expression

Changelog

Install

npm install regexp-util

Usage

import { charset } from 'regexp-util'

const regex = util
  .charset(['a', 'g']) // a ~ g
  .subtract(['c', 'e'])
  .toRegExp()

const aResult = 'a'.test(regex) //=> true
const dResult = 'd'.test(regex) //=> false

API

Base

declare abstract class Base {
  isEmpty(): boolean
  toString(flags?: string): string
  toRegExp(flags?: string): RegExp
}

Charset

declare type CharsetInput =
  | Charset
  | string // char
  | number // codepoint
  | [string, string] // char: start to end (inclusive)
  | [number, number] // codepoint: start to end (inclusive)

declare function charset(...inputs: CharsetInput[]): Charset

declare class Charset extends Base {
  constructor(...inputs: CharsetInput[])
  union(...inputs: CharsetInput[]): Charset
  subtract(...inputs: CharsetInput[]): Charset
  intersect(...inputs: CharsetInput[]): Charset
}

Development

# lint
pnpm run lint

# build
pnpm run build

# test
pnpm run test

License

MIT © Ika

Keywords

FAQs

Package last updated on 09 Jul 2023

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