Socket
Socket
Sign inDemoInstall

loosely

Package Overview
Dependencies
0
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    loosely

Text loosely based on input


Version published
Weekly downloads
584
decreased by-25.03%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Loosely🌱

Text loosely based on input

loosely-watch

Install

npm install --save loosely

Use

const { Mask } = require('loosely');

const mask = new Mask(/\d \(\d{3}\) \d{3}-\d{4}/);

const input = document.querySelector('#phone');

mask.watch(input);
// Filters the input value after every input event.

const text = mask.filter('1-800-555-1234');
// 1 (800) 555-1234

mask.validate(text);
// true

mask.sample()
// 8 (693) 906-1454

Limitations

Greed

The non-greedy operators are currently ignored. filter is non-greedy by default. An important behavior of filter is that it inserts static parts of the pattern automatically. Since static expressions can be repeated infinitely, it is not possible to be greedy without encountering infinite loops or enforcing artificial recursion limits. Choosing a path through the pattern with the smallest number of additions leads to an intuitive experience when filtering live input.

Assertions (TODO)

Assertions are currently treated as normal groups. Any overlapping expressions before a look-behind or after a look-ahead will produce invalid results. Negative assertions are also treated as normal groups without negation, so they will always produce invalid results. Please consider contributing any ideas or code you have for this feature.

Keywords

FAQs

Last updated on 06 May 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc