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

no-regex-utils

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

no-regex-utils - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

4

dist/index.d.ts

@@ -1,3 +0,3 @@

import { onlyNumbers } from "./manipulations";
import { onlyLetters, onlyNumbers } from "./manipulations";
import { isEmail, isIPv4, isUsername } from "./validations";
export { isEmail, isIPv4, isUsername, onlyNumbers };
export { isEmail, isIPv4, isUsername, onlyNumbers, onlyLetters };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.onlyNumbers = exports.isUsername = exports.isIPv4 = exports.isEmail = void 0;
exports.onlyLetters = exports.onlyNumbers = exports.isUsername = exports.isIPv4 = exports.isEmail = void 0;
const manipulations_1 = require("./manipulations");
Object.defineProperty(exports, "onlyLetters", { enumerable: true, get: function () { return manipulations_1.onlyLetters; } });
Object.defineProperty(exports, "onlyNumbers", { enumerable: true, get: function () { return manipulations_1.onlyNumbers; } });

@@ -6,0 +7,0 @@ const validations_1 = require("./validations");

export declare const onlyNumbers: (value: string) => string;
export interface IOnlyLettersOptions {
lowercase: boolean;
uppercase: boolean;
}
export declare const onlyLetters: (value: string, { lowercase, uppercase }: IOnlyLettersOptions) => string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.onlyNumbers = void 0;
const onlyNumbers = (value) => {
const regex = /\d+/g;
exports.onlyLetters = exports.onlyNumbers = void 0;
const applyRegex = (value, regex) => {
if (value && typeof value === "string") {
const numbersArray = value.match(regex);
return Array.isArray(numbersArray) ? numbersArray.join("") : "";
const valueArray = value.match(regex);
return Array.isArray(valueArray) ? valueArray.join("") : "";
}

@@ -14,2 +13,13 @@ else {

};
const onlyNumbers = (value) => {
const regex = /\d+/g;
return applyRegex(value, regex);
};
exports.onlyNumbers = onlyNumbers;
const onlyLetters = (value, { lowercase = true, uppercase = true }) => {
if (lowercase === false && uppercase === false)
return "";
const regex = new RegExp(`[${uppercase ? "A-Z" : ""}${lowercase ? "a-z" : ""}]+`, "g");
return applyRegex(value, regex);
};
exports.onlyLetters = onlyLetters;
export declare const isEmail: (value: string) => boolean;
export declare const isIPv4: (value: string) => boolean;
export declare const isUsername: ({ value, minLength, maxLength, underline, dash, }: {
value: string;
export interface IIsUsernameOptions {
minLength?: number;

@@ -9,2 +8,3 @@ maxLength?: number;

dash?: boolean;
}) => boolean;
}
export declare const isUsername: (value: string, { minLength, maxLength, underline, dash, }: IIsUsernameOptions) => boolean;

@@ -12,3 +12,3 @@ "use strict";

exports.isIPv4 = isIPv4;
const isUsername = ({ value, minLength = 3, maxLength = 16, underline = true, dash = true, }) => {
const isUsername = (value, { minLength = 3, maxLength = 16, underline = true, dash = true, }) => {
let regex = `^[a-z0-9${underline ? "_" : ""}${dash ? "-" : ""}]{${minLength},${maxLength}}$`;

@@ -15,0 +15,0 @@ return new RegExp(regex).test(value);

{
"name": "no-regex-utils",
"version": "0.4.0",
"version": "0.5.0",
"description": "No Regex Utils - Common regex functions",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -34,9 +34,10 @@ # NO Regex Utils

```javascript
NoRegex.isUsername({
value: "user_test", // required
minLength: 3, // optional, default: 3
maxLength: 16, // optional, default: 16
underline: true, // optional, default: true
dash: true, // optional, default: true
});
NoRegex.isUsername(
"user_test"
{
minLength: int, // optional, default: 3
maxLength: int, // optional, default: 16
underline: boolean, // optional, default: true
dash: boolean, // optional, default: true
}) // true;
```

@@ -52,2 +53,13 @@

> onlyLetters
```javascript
NoRegex.onlyLetters(
"lE123tterS123"
{
lowercase: boolean, // optional, default: true
uppercase: boolean, // optional, default: true
}) // 'lEtterS';
```
## Author

@@ -54,0 +66,0 @@

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