New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@gilbarbara/helpers

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gilbarbara/helpers - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

2

esm/arrays.d.ts

@@ -15,3 +15,3 @@ import { SortFunction } from './types';

*/
export declare function sortByPrimitive<T extends number | boolean>(key?: string, descending?: boolean): SortFunction<T>;
export declare function sortByPrimitive<T extends number | boolean>(key?: string, descending?: boolean): SortFunction;
/**

@@ -18,0 +18,0 @@ * Basic sort comparator

@@ -23,2 +23,6 @@ import { LoggerOptions, UniqueOptions } from './types';

/**
* Returns the value or null
*/
export declare function nullify<T>(value: T): NonNullable<T> | null;
/**
* Return a unique string

@@ -25,0 +29,0 @@ */

@@ -119,2 +119,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

/**
* Returns the value or null
*/
export function nullify(value) {
return value !== null && value !== void 0 ? value : null;
}
/**
* Return a unique string

@@ -121,0 +127,0 @@ */

@@ -1,27 +0,37 @@

import { InvertKeyValue, PlainObject, QueryStringFormatOptions } from './types';
import { AnyObject, InvertKeyValue, NarrowPlainObject, QueryStringFormatOptions } from './types';
/**
* Remove properties from an object
*/
export declare function blacklist<T extends PlainObject, K extends keyof T>(input: T, ...filter: K[]): Omit<T, K>;
export declare function blacklist<T extends AnyObject, K extends keyof T>(input: T & NarrowPlainObject<T>, ...filter: K[]): Omit<T, K>;
/**
* Get a nested property inside an object or array
*/
export declare function getNestedProperty<T extends AnyObject>(input: T, path: string): any;
/**
* Invert object key and value
*/
export declare function invertKeys<T extends PlainObject>(input: T): InvertKeyValue<T>;
export declare function invertKeys<T extends AnyObject>(input: T & NarrowPlainObject<T>): InvertKeyValue<T>;
/**
* Set the key as the value
*/
export declare function keyMirror<T extends PlainObject>(input: T): {
export declare function keyMirror<T extends AnyObject>(input: T & NarrowPlainObject<T>): {
[K in keyof T]: K;
};
/**
* Convert an object to an array of objects
*/
export declare function objectToArray<T extends AnyObject>(input: T & NarrowPlainObject<T>, includeOnly?: string): {
[x: string]: any;
}[];
/**
* Stringify a shallow object into a query string
*/
export declare function queryStringFormat(input: PlainObject, options?: QueryStringFormatOptions): string;
export declare function queryStringFormat<T extends AnyObject>(input: T & NarrowPlainObject<T>, options?: QueryStringFormatOptions): string;
/**
* Parse a query string
*/
export declare function queryStringParse(input: string): PlainObject<string>;
export declare function queryStringParse(input: string): AnyObject<string>;
/**
* Sort object keys
*/
export declare function sortObjectKeys(input: PlainObject): PlainObject<any>;
export declare function sortObjectKeys<T extends AnyObject>(input: T & NarrowPlainObject<T>): AnyObject<any>;

@@ -26,2 +26,32 @@ import is from 'is-lite';

/**
* Get a nested property inside an object or array
*/
export function getNestedProperty(input, path) {
if ((!is.plainObject(input) && !is.array(input)) || !path) {
return input;
}
var segments = path.split('.');
var length = segments.length;
var output = input;
var _loop_1 = function (idx) {
var currentSegment = segments[idx];
var remainingSegments = segments.slice(idx + 1);
if (currentSegment === '+' && is.array(output) && remainingSegments.length === 1) {
return { value: output.map(function (d) { return d[remainingSegments.join('.')]; }) };
}
try {
output = output[currentSegment];
}
catch (_a) {
// skip
}
};
for (var idx = 0; idx < length; idx++) {
var state_1 = _loop_1(idx);
if (typeof state_1 === "object")
return state_1.value;
}
return output;
}
/**
* Invert object key and value

@@ -59,2 +89,20 @@ */

/**
* Convert an object to an array of objects
*/
export function objectToArray(input, includeOnly) {
if (!is.plainObject(input)) {
throw new TypeError('Expected an object');
}
return Object.entries(input)
.filter(function (_a) {
var value = _a[1];
return (includeOnly ? typeof value === "" + includeOnly : true);
}) // eslint-disable-line valid-typeof
.map(function (_a) {
var _b;
var key = _a[0], value = _a[1];
return (_b = {}, _b[key] = value, _b);
});
}
/**
* Stringify a shallow object into a query string

@@ -61,0 +109,0 @@ */

@@ -25,18 +25,18 @@ /**

*/
export declare function removeEmptyTags(input?: string): string;
export declare function removeEmptyTags(input: string): string;
/**
* Remove non-printable ASCII characters
*/
export declare function removeNonPrintableCharacters(input?: string): string;
export declare function removeNonPrintableCharacters(input: string): string;
/**
* Remove HTML tags
*/
export declare function removeTags(input?: string): string;
export declare function removeTags(input: string): string;
/**
* Remove whitespace
*/
export declare function removeWhitespace(input?: string): string;
export declare function removeWhitespace(input: string): string;
/**
* Format string to slug
*/
export declare function slugify(input?: string): string;
export declare function slugify(input: string): string;

@@ -135,3 +135,2 @@ import is from 'is-lite';

export function removeEmptyTags(input) {
if (input === void 0) { input = ''; }
return input.replace(/<[^/>][^>]*>\s*<\/[^>]+>/gi, '');

@@ -143,3 +142,2 @@ }

export function removeNonPrintableCharacters(input) {
if (input === void 0) { input = ''; }
return is.string(input) ? input.replace(/[^\u00C0-\u00FF\x20-\x7E´˜ˆ]+/g, '') : input;

@@ -151,3 +149,2 @@ }

export function removeTags(input) {
if (input === void 0) { input = ''; }
return input.replace(/(<([^>]+)>)/gi, '');

@@ -159,3 +156,2 @@ }

export function removeWhitespace(input) {
if (input === void 0) { input = ''; }
return input.replace(/\r\n|\r|\n|\t/g, '').replace(/[ ]+/g, ' ');

@@ -167,3 +163,2 @@ }

export function slugify(input) {
if (input === void 0) { input = ''; }
return removeAccents(input)

@@ -170,0 +165,0 @@ .replace(/[\u0300-\u036f]/g, '')

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

export declare type PlainObject<T = any> = Record<string, T>;
export declare type AnyObject<T = any> = Record<string, T>;
export declare type NarrowPlainObject<T> = Exclude<T, any[] | ((...args: any[]) => any)>;
export declare type HttpMethods = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
export declare type Primitive = bigint | boolean | null | number | string | symbol | undefined;
export interface CorsOptions {

@@ -30,3 +32,3 @@ headers?: string[];

body?: any;
headers?: PlainObject<string>;
headers?: AnyObject<string>;
method?: HttpMethods;

@@ -38,5 +40,5 @@ }

}
export interface SortFunction<T = string> {
(left: PlainObject, right: PlainObject): number;
(left: T, right: T): number;
export interface SortFunction {
<T = AnyObject>(left: T & NarrowPlainObject<T>, right: T & NarrowPlainObject<T>): number;
<T = string>(left: T, right: T): number;
}

@@ -43,0 +45,0 @@ export interface TimeSinceOptions {

@@ -15,3 +15,3 @@ import { SortFunction } from './types';

*/
export declare function sortByPrimitive<T extends number | boolean>(key?: string, descending?: boolean): SortFunction<T>;
export declare function sortByPrimitive<T extends number | boolean>(key?: string, descending?: boolean): SortFunction;
/**

@@ -18,0 +18,0 @@ * Basic sort comparator

@@ -23,2 +23,6 @@ import { LoggerOptions, UniqueOptions } from './types';

/**
* Returns the value or null
*/
export declare function nullify<T>(value: T): NonNullable<T> | null;
/**
* Return a unique string

@@ -25,0 +29,0 @@ */

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.uuid = exports.unique = exports.noop = exports.logger = exports.isRequired = exports.isJSON = exports.copyToClipboard = void 0;
exports.uuid = exports.unique = exports.nullify = exports.noop = exports.logger = exports.isRequired = exports.isJSON = exports.copyToClipboard = void 0;
var numbers_1 = require("./numbers");

@@ -128,2 +128,9 @@ /**

/**
* Returns the value or null
*/
function nullify(value) {
return value !== null && value !== void 0 ? value : null;
}
exports.nullify = nullify;
/**
* Return a unique string

@@ -130,0 +137,0 @@ */

@@ -1,27 +0,37 @@

import { InvertKeyValue, PlainObject, QueryStringFormatOptions } from './types';
import { AnyObject, InvertKeyValue, NarrowPlainObject, QueryStringFormatOptions } from './types';
/**
* Remove properties from an object
*/
export declare function blacklist<T extends PlainObject, K extends keyof T>(input: T, ...filter: K[]): Omit<T, K>;
export declare function blacklist<T extends AnyObject, K extends keyof T>(input: T & NarrowPlainObject<T>, ...filter: K[]): Omit<T, K>;
/**
* Get a nested property inside an object or array
*/
export declare function getNestedProperty<T extends AnyObject>(input: T, path: string): any;
/**
* Invert object key and value
*/
export declare function invertKeys<T extends PlainObject>(input: T): InvertKeyValue<T>;
export declare function invertKeys<T extends AnyObject>(input: T & NarrowPlainObject<T>): InvertKeyValue<T>;
/**
* Set the key as the value
*/
export declare function keyMirror<T extends PlainObject>(input: T): {
export declare function keyMirror<T extends AnyObject>(input: T & NarrowPlainObject<T>): {
[K in keyof T]: K;
};
/**
* Convert an object to an array of objects
*/
export declare function objectToArray<T extends AnyObject>(input: T & NarrowPlainObject<T>, includeOnly?: string): {
[x: string]: any;
}[];
/**
* Stringify a shallow object into a query string
*/
export declare function queryStringFormat(input: PlainObject, options?: QueryStringFormatOptions): string;
export declare function queryStringFormat<T extends AnyObject>(input: T & NarrowPlainObject<T>, options?: QueryStringFormatOptions): string;
/**
* Parse a query string
*/
export declare function queryStringParse(input: string): PlainObject<string>;
export declare function queryStringParse(input: string): AnyObject<string>;
/**
* Sort object keys
*/
export declare function sortObjectKeys(input: PlainObject): PlainObject<any>;
export declare function sortObjectKeys<T extends AnyObject>(input: T & NarrowPlainObject<T>): AnyObject<any>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sortObjectKeys = exports.queryStringParse = exports.queryStringFormat = exports.keyMirror = exports.invertKeys = exports.blacklist = void 0;
exports.sortObjectKeys = exports.queryStringParse = exports.queryStringFormat = exports.objectToArray = exports.keyMirror = exports.invertKeys = exports.getNestedProperty = exports.blacklist = void 0;
var is_lite_1 = require("is-lite");

@@ -30,2 +30,33 @@ /**

/**
* Get a nested property inside an object or array
*/
function getNestedProperty(input, path) {
if ((!is_lite_1.default.plainObject(input) && !is_lite_1.default.array(input)) || !path) {
return input;
}
var segments = path.split('.');
var length = segments.length;
var output = input;
var _loop_1 = function (idx) {
var currentSegment = segments[idx];
var remainingSegments = segments.slice(idx + 1);
if (currentSegment === '+' && is_lite_1.default.array(output) && remainingSegments.length === 1) {
return { value: output.map(function (d) { return d[remainingSegments.join('.')]; }) };
}
try {
output = output[currentSegment];
}
catch (_a) {
// skip
}
};
for (var idx = 0; idx < length; idx++) {
var state_1 = _loop_1(idx);
if (typeof state_1 === "object")
return state_1.value;
}
return output;
}
exports.getNestedProperty = getNestedProperty;
/**
* Invert object key and value

@@ -65,2 +96,21 @@ */

/**
* Convert an object to an array of objects
*/
function objectToArray(input, includeOnly) {
if (!is_lite_1.default.plainObject(input)) {
throw new TypeError('Expected an object');
}
return Object.entries(input)
.filter(function (_a) {
var value = _a[1];
return (includeOnly ? typeof value === "" + includeOnly : true);
}) // eslint-disable-line valid-typeof
.map(function (_a) {
var _b;
var key = _a[0], value = _a[1];
return (_b = {}, _b[key] = value, _b);
});
}
exports.objectToArray = objectToArray;
/**
* Stringify a shallow object into a query string

@@ -67,0 +117,0 @@ */

@@ -25,18 +25,18 @@ /**

*/
export declare function removeEmptyTags(input?: string): string;
export declare function removeEmptyTags(input: string): string;
/**
* Remove non-printable ASCII characters
*/
export declare function removeNonPrintableCharacters(input?: string): string;
export declare function removeNonPrintableCharacters(input: string): string;
/**
* Remove HTML tags
*/
export declare function removeTags(input?: string): string;
export declare function removeTags(input: string): string;
/**
* Remove whitespace
*/
export declare function removeWhitespace(input?: string): string;
export declare function removeWhitespace(input: string): string;
/**
* Format string to slug
*/
export declare function slugify(input?: string): string;
export declare function slugify(input: string): string;

@@ -144,3 +144,2 @@ "use strict";

function removeEmptyTags(input) {
if (input === void 0) { input = ''; }
return input.replace(/<[^/>][^>]*>\s*<\/[^>]+>/gi, '');

@@ -153,3 +152,2 @@ }

function removeNonPrintableCharacters(input) {
if (input === void 0) { input = ''; }
return is_lite_1.default.string(input) ? input.replace(/[^\u00C0-\u00FF\x20-\x7E´˜ˆ]+/g, '') : input;

@@ -162,3 +160,2 @@ }

function removeTags(input) {
if (input === void 0) { input = ''; }
return input.replace(/(<([^>]+)>)/gi, '');

@@ -171,3 +168,2 @@ }

function removeWhitespace(input) {
if (input === void 0) { input = ''; }
return input.replace(/\r\n|\r|\n|\t/g, '').replace(/[ ]+/g, ' ');

@@ -180,3 +176,2 @@ }

function slugify(input) {
if (input === void 0) { input = ''; }
return removeAccents(input)

@@ -183,0 +178,0 @@ .replace(/[\u0300-\u036f]/g, '')

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

export declare type PlainObject<T = any> = Record<string, T>;
export declare type AnyObject<T = any> = Record<string, T>;
export declare type NarrowPlainObject<T> = Exclude<T, any[] | ((...args: any[]) => any)>;
export declare type HttpMethods = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
export declare type Primitive = bigint | boolean | null | number | string | symbol | undefined;
export interface CorsOptions {

@@ -30,3 +32,3 @@ headers?: string[];

body?: any;
headers?: PlainObject<string>;
headers?: AnyObject<string>;
method?: HttpMethods;

@@ -38,5 +40,5 @@ }

}
export interface SortFunction<T = string> {
(left: PlainObject, right: PlainObject): number;
(left: T, right: T): number;
export interface SortFunction {
<T = AnyObject>(left: T & NarrowPlainObject<T>, right: T & NarrowPlainObject<T>): number;
<T = string>(left: T, right: T): number;
}

@@ -43,0 +45,0 @@ export interface TimeSinceOptions {

{
"name": "@gilbarbara/helpers",
"version": "0.2.0",
"version": "0.2.1",
"description": "Collection of useful functions",

@@ -5,0 +5,0 @@ "keywords": [

@@ -35,3 +35,3 @@ # @gilbarbara/helpers

interface SortFunction<T = string> {
(left: Record<string, any>, right: Record<string, any>): number;
(left: PlainObject, right: PlainObject): number;
(left: T, right: T): number;

@@ -75,3 +75,3 @@ }

interface SortFunction<T = string> {
(left: Record<string, any>, right: Record<string, any>): number;
(left: PlainObject, right: PlainObject): number;
(left: T, right: T): number;

@@ -121,3 +121,3 @@ }

body: string;
headers: Record<string, string>;
headers: PlainObject;
statusCode: number;

@@ -154,3 +154,3 @@ }

body?: any;
headers?: Record<string, any>;
headers?: PlainObject;
method?: HttpMethods;

@@ -219,8 +219,8 @@ }

**isJSON(input: string): boolean**
Check if a string is a valid JSON.
**isRequired(input?: string = 'parameter', type: Constructable = TypeError): void**
Throws an error of the Constructable type.
**isJSON(input: string): boolean**
Check if a string is a valid JSON.
<details>

@@ -257,2 +257,5 @@ <summary>Example</summary>

**nullify\<T>(value: T): T | null**
Returns the value or null.
**unique(length?: number = 8, options?: UniqueOptions): string**

@@ -297,12 +300,40 @@ Returns a random string.

**blacklist(input: Record<string, any>, ...filter)**
**blacklist\<T extends PlainObject, K extends keyof T>(input: T, ...filter: K[])**
Remove properties from an object.
**invertKeys(input: Record<string, any>)**
Invert object key and value
**getNestedProperty(input: PlainObject | any[], path: string)**
Get a nested property inside an object or array.
**keyMirror(input: Record<string, any>)**
Set the key as the value
<details>
<summary>Example</summary>
**queryStringFormat(input: Record<string, any>, options?: QueryStringFormatOptions)**
```typescript
getNestedProperty({ children: { letters: ['a', 'b', 'c'] } }, 'children.letters');
// returns ['a', 'b', 'c']
getNestedProperty({ children: { letters: ['a', 'b', 'c'] } }, 'children.letters.1');
// returns 'b'
getNestedProperty([{ a: 5 }, { a: 7 }, { a: 10 }], '0.a');
// returns 5
```
You may also use a wildcard (+) to get multiple array values:
```typescript
getNestedProperty([{ a: 5 }, { a: 7 }, { a: 10 }], '+.a');
// returns [5, 7, 10]
getNestedProperty({ children: [{ a: 5 }, { a: 7 }, { a: 10 }] }, 'children.+.a');
// returns [5, 7, 10]
```
</details>
**invertKeys(input: PlainObject)**
Invert object key and value.
**keyMirror(input: PlainObject)**
Set the key as the value.
**objectToArray(input: PlainObject, includeOnly?: string): PlainObject[]**
Convert an object to an array of objects.
**queryStringFormat(input: PlainObject, options?: QueryStringFormatOptions)**
Stringify a shallow object into a query string.

@@ -325,3 +356,3 @@

**sortObjectKeys(input: Record<string, any>)**
**sortObjectKeys(input: PlainObject)**
Sort object keys

@@ -363,2 +394,2 @@

**slugify(input: string): string**
Format string to slug.
Format string to slug.

@@ -1,2 +0,2 @@

import { PlainObject, SortFunction } from './types';
import { AnyObject, NarrowPlainObject, SortFunction } from './types';

@@ -69,7 +69,10 @@ /**

if (descending) {
return <T extends PlainObject>(left: T, right: T) =>
return <T extends AnyObject>(
left: T & NarrowPlainObject<T>,
right: T & NarrowPlainObject<T>,
) =>
right[key].toLowerCase().localeCompare(left[key].toLowerCase(), undefined, compareOptions);
}
return <T extends PlainObject>(left: T, right: T) =>
return <T extends AnyObject>(left: T & NarrowPlainObject<T>, right: T & NarrowPlainObject<T>) =>
left[key].toLowerCase().localeCompare(right[key].toLowerCase(), undefined, compareOptions);

@@ -93,3 +96,3 @@ }

descending = false,
): SortFunction<T> {
): SortFunction {
const firstComparator = descending ? 1 : -1;

@@ -99,3 +102,6 @@ const secondComparator = descending ? -1 : 1;

if (key) {
return <P extends PlainObject>(left: P, right: P) => {
return <P extends AnyObject>(
left: P & NarrowPlainObject<P>,
right: P & NarrowPlainObject<P>,
) => {
if (left[key] === right[key]) {

@@ -102,0 +108,0 @@ return 0;

@@ -80,2 +80,9 @@ import { pad } from './numbers';

/**
* Returns the value or null
*/
export function nullify<T>(value: T) {
return value ?? null;
}
/**
* Return a unique string

@@ -82,0 +89,0 @@ */

import is from 'is-lite';
import { InvertKeyValue, PlainObject, QueryStringFormatOptions } from './types';
import { AnyObject, InvertKeyValue, NarrowPlainObject, QueryStringFormatOptions } from './types';

@@ -8,3 +8,6 @@ /**

*/
export function blacklist<T extends PlainObject, K extends keyof T>(input: T, ...filter: K[]) {
export function blacklist<T extends AnyObject, K extends keyof T>(
input: T & NarrowPlainObject<T>,
...filter: K[]
) {
if (!is.plainObject(input)) {

@@ -30,5 +33,37 @@ throw new TypeError('Expected an object');

/**
* Get a nested property inside an object or array
*/
export function getNestedProperty<T extends AnyObject>(input: T, path: string): any {
if ((!is.plainObject(input) && !is.array(input)) || !path) {
return input;
}
const segments = path.split('.');
const { length } = segments;
let output = input;
for (let idx = 0; idx < length; idx++) {
const currentSegment = segments[idx];
const remainingSegments = segments.slice(idx + 1);
if (currentSegment === '+' && is.array(output) && remainingSegments.length === 1) {
return output.map(d => d[remainingSegments.join('.')]);
}
try {
output = output[currentSegment] as any;
} catch {
// skip
}
}
return output;
}
/**
* Invert object key and value
*/
export function invertKeys<T extends PlainObject>(input: T): InvertKeyValue<T> {
export function invertKeys<T extends AnyObject>(
input: T & NarrowPlainObject<T>,
): InvertKeyValue<T> {
if (!is.plainObject(input)) {

@@ -51,3 +86,5 @@ throw new TypeError('Expected an object');

*/
export function keyMirror<T extends PlainObject>(input: T): { [K in keyof T]: K } {
export function keyMirror<T extends AnyObject>(
input: T & NarrowPlainObject<T>,
): { [K in keyof T]: K } {
if (!is.plainObject(input)) {

@@ -71,5 +108,24 @@ throw new TypeError('Expected an object');

/**
* Convert an object to an array of objects
*/
export function objectToArray<T extends AnyObject>(
input: T & NarrowPlainObject<T>,
includeOnly?: string,
) {
if (!is.plainObject(input)) {
throw new TypeError('Expected an object');
}
return Object.entries(input)
.filter(([, value]) => (includeOnly ? typeof value === `${includeOnly}` : true)) // eslint-disable-line valid-typeof
.map(([key, value]) => ({ [key]: value }));
}
/**
* Stringify a shallow object into a query string
*/
export function queryStringFormat(input: PlainObject, options: QueryStringFormatOptions = {}) {
export function queryStringFormat<T extends AnyObject>(
input: T & NarrowPlainObject<T>,
options: QueryStringFormatOptions = {},
) {
const { addPrefix = false, encodeValuesOnly = true, encoder = encodeURIComponent } = options;

@@ -108,3 +164,3 @@

*/
export function queryStringParse(input: string): PlainObject<string> {
export function queryStringParse(input: string): AnyObject<string> {
let search = input;

@@ -116,3 +172,3 @@

return search.split('&').reduce<PlainObject<string>>((acc, d) => {
return search.split('&').reduce<AnyObject<string>>((acc, d) => {
const [key, value] = d.split('=');

@@ -129,3 +185,3 @@

*/
export function sortObjectKeys(input: PlainObject) {
export function sortObjectKeys<T extends AnyObject>(input: T & NarrowPlainObject<T>) {
return Object.keys(input)

@@ -137,3 +193,3 @@ .sort()

return acc;
}, {} as PlainObject);
}, {} as AnyObject);
}

@@ -146,3 +146,3 @@ import is from 'is-lite';

*/
export function removeEmptyTags(input = '') {
export function removeEmptyTags(input: string) {
return input.replace(/<[^/>][^>]*>\s*<\/[^>]+>/gi, '');

@@ -154,3 +154,3 @@ }

*/
export function removeNonPrintableCharacters(input = '') {
export function removeNonPrintableCharacters(input: string) {
return is.string(input) ? input.replace(/[^\u00C0-\u00FF\x20-\x7E´˜ˆ]+/g, '') : input;

@@ -162,3 +162,3 @@ }

*/
export function removeTags(input = '') {
export function removeTags(input: string) {
return input.replace(/(<([^>]+)>)/gi, '');

@@ -170,3 +170,3 @@ }

*/
export function removeWhitespace(input = '') {
export function removeWhitespace(input: string) {
return input.replace(/\r\n|\r|\n|\t/g, '').replace(/[ ]+/g, ' ');

@@ -178,3 +178,3 @@ }

*/
export function slugify(input = '') {
export function slugify(input: string) {
return removeAccents(input)

@@ -181,0 +181,0 @@ .replace(/[\u0300-\u036f]/g, '')

@@ -1,4 +0,6 @@

export type PlainObject<T = any> = Record<string, T>;
export type AnyObject<T = any> = Record<string, T>;
export type NarrowPlainObject<T> = Exclude<T, any[] | ((...args: any[]) => any)>;
export type HttpMethods = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
export type Primitive = bigint | boolean | null | number | string | symbol | undefined;

@@ -36,3 +38,3 @@ export interface CorsOptions {

body?: any;
headers?: PlainObject<string>;
headers?: AnyObject<string>;
method?: HttpMethods;

@@ -46,5 +48,5 @@ }

export interface SortFunction<T = string> {
(left: PlainObject, right: PlainObject): number;
(left: T, right: T): number;
export interface SortFunction {
<T = AnyObject>(left: T & NarrowPlainObject<T>, right: T & NarrowPlainObject<T>): number;
<T = string>(left: T, right: T): number;
}

@@ -51,0 +53,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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