Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
loosely
Advanced tools
Readme
Smart input masks for regexes
Try it out! (powered by codesandbox.io)
You are probably already using regular expressions to validate user input. Leverage those existing patterns to help users format their input instead of showing them error messages.
Loosely parses a regex into a graph. Each node in the graph has a set of characters that it accepts. Each time the user types a character, the graph is searched to see if the text represents a path through the graph. If a node only accepts one character, the search is allowed to insert that character into the input. This allows required parts of the mask to be inserted automatically while the user is typing. If no nodes accept a character, the search is allowed to remove it from the input. This allows a user's personal formatting preferences to be gracefully ignored. The result is a robust input experience that adapts to the data as it changes.
npm install --save loosely
Construct a Mask
instance from a regular expression.
const { Mask } = require('loosely');
const mask = new Mask(/\d \(\d{3}\) \d{3}-\d{4}/);
Filter input as the user is typing into a DOM input.
const input = document.querySelector('#phone');
mask.watch(input);
filter(text)
returns a string that at least partially matches the mask.
validate(text)
determines if the text completely matches the mask.
sample()
returns a random string that matches the mask.
const text = mask.filter('1-800-555-1234');
// 1 (800) 555-1234
mask.validate(text);
// true
mask.sample()
// 8 (693) 906-1454
Filter a regular expression from right to left.
const { ReverseMask } = require('loosely');
const mask = new ReverseMask(/(\d{1,3},)*\d{1,3}/);
const text = mask.filter('12345');
// 12,345
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.
FAQs
Text loosely based on input
The npm package loosely receives a total of 311 weekly downloads. As such, loosely popularity was classified as not popular.
We found that loosely demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.