Socket
Socket
Sign inDemoInstall

@handy-common-utils/misc-utils

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 1.3.0

dist/array.d.ts

46

dist/index.d.ts

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

/**
* Make a "normal" (BASE64) string URL/path safe.
* @param base64Input A (BASE64) string which could be null or undefined.
* @param replacements A string containing replacement characters for "/", "+", and "=".
* If omitted, default value of '_-=' would be used.
* @returns URL/path safe version of the (BASE64) input string, or the original input if it is null or undefined.
*/
export declare function urlSafe<T extends string | undefined | null>(base64Input: T, replacements?: string): T;
/**
* Encode an unsigned 32-bit integer into BASE64 string.
* @param ui32 A 32-bit integer number which could also be null or undefined.
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer.
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32)
* @returns BASE64 string representing the integer input, or the original input if it is null or undefined.
*/
export declare function base64FromUInt32<T extends number | undefined | null>(ui32: T): Exclude<T, number> | string;
/**
* Encode an unsigned 32-bit integer into BASE64 string without trailing '='.
* @param ui32 A 32-bit integer number which could also be null or undefined.
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer.
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32)
* @returns BASE64 string without trailing '=' representing the integer input, or the original input if it is null or undefined.
*/
export declare function shortBase64FromUInt32<T extends number | undefined | null>(ui32: T): Exclude<T, number> | string;
/**
* Encode an unsigned 32-bit integer into URL/path safe BASE64 string.
* @param ui32 A 32-bit integer number which could also be null or undefined.
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer.
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32)
* @param replacements A string containing replacement characters for "/", "+", and "=".
* If omitted, default value of '_-=' would be used.
* @returns URL/path safe BASE64 string representing the integer input, or the original input if it is null or undefined.
*/
export declare function base64UrlFromUInt32<T extends number | undefined | null>(ui32: T, replacements?: string): Exclude<T, number> | string;
/**
* Encode an unsigned 32-bit integer into URL/path safe BASE64 string without trailling '='.
* @param ui32 A 32-bit integer number which could also be null or undefined.
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer.
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32)
* @param replacements A string containing replacement characters for "/" and "+".
* If omitted, default value of '_-' would be used.
* @returns URL/path safe BASE64 string without trailing '=' representing the integer input, or the original input if it is null or undefined.
*/
export declare function shortBase64UrlFromUInt32<T extends number | undefined | null>(ui32: T, replacements?: string): Exclude<T, number> | string;
export * from './codec';
export * from './line-logger';

@@ -49,2 +6,3 @@ export * from './stringify-replacer';

export * from './http-status';
export * from './array';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.shortBase64UrlFromUInt32 = exports.base64UrlFromUInt32 = exports.shortBase64FromUInt32 = exports.base64FromUInt32 = exports.urlSafe = void 0;
const tslib_1 = require("tslib");
/**
* Make a "normal" (BASE64) string URL/path safe.
* @param base64Input A (BASE64) string which could be null or undefined.
* @param replacements A string containing replacement characters for "/", "+", and "=".
* If omitted, default value of '_-=' would be used.
* @returns URL/path safe version of the (BASE64) input string, or the original input if it is null or undefined.
*/
function urlSafe(base64Input, replacements = '_-=') {
if (base64Input == null) {
return base64Input;
}
return base64Input.replace(/\//g, replacements.charAt(0))
.replace(/\+/g, replacements.charAt(1))
.replace(/=/g, replacements.charAt(2));
}
exports.urlSafe = urlSafe;
/**
* Encode an unsigned 32-bit integer into BASE64 string.
* @param ui32 A 32-bit integer number which could also be null or undefined.
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer.
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32)
* @returns BASE64 string representing the integer input, or the original input if it is null or undefined.
*/
function base64FromUInt32(ui32) {
if (ui32 == null) {
return ui32;
}
const buf = Buffer.allocUnsafe(4);
buf.writeUInt32BE(ui32, 0);
return buf.toString('base64');
}
exports.base64FromUInt32 = base64FromUInt32;
/**
* Encode an unsigned 32-bit integer into BASE64 string without trailing '='.
* @param ui32 A 32-bit integer number which could also be null or undefined.
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer.
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32)
* @returns BASE64 string without trailing '=' representing the integer input, or the original input if it is null or undefined.
*/
function shortBase64FromUInt32(ui32) {
if (ui32 == null) {
return ui32;
}
return base64FromUInt32(ui32).replace(/=+$/, '');
}
exports.shortBase64FromUInt32 = shortBase64FromUInt32;
/**
* Encode an unsigned 32-bit integer into URL/path safe BASE64 string.
* @param ui32 A 32-bit integer number which could also be null or undefined.
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer.
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32)
* @param replacements A string containing replacement characters for "/", "+", and "=".
* If omitted, default value of '_-=' would be used.
* @returns URL/path safe BASE64 string representing the integer input, or the original input if it is null or undefined.
*/
function base64UrlFromUInt32(ui32, replacements = '_-=') {
return urlSafe(base64FromUInt32(ui32), replacements);
}
exports.base64UrlFromUInt32 = base64UrlFromUInt32;
/**
* Encode an unsigned 32-bit integer into URL/path safe BASE64 string without trailling '='.
* @param ui32 A 32-bit integer number which could also be null or undefined.
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer.
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32)
* @param replacements A string containing replacement characters for "/" and "+".
* If omitted, default value of '_-' would be used.
* @returns URL/path safe BASE64 string without trailing '=' representing the integer input, or the original input if it is null or undefined.
*/
function shortBase64UrlFromUInt32(ui32, replacements = '_-') {
return urlSafe(shortBase64FromUInt32(ui32), replacements);
}
exports.shortBase64UrlFromUInt32 = shortBase64UrlFromUInt32;
tslib_1.__exportStar(require("./codec"), exports);
tslib_1.__exportStar(require("./line-logger"), exports);

@@ -81,1 +9,2 @@ tslib_1.__exportStar(require("./stringify-replacer"), exports);

tslib_1.__exportStar(require("./http-status"), exports);
tslib_1.__exportStar(require("./array"), exports);

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

/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
Object.defineProperty(exports, "__esModule", { value: true });

@@ -8,0 +7,0 @@ exports.consoleLike = exports.consoleWithColour = exports.consoleWithoutColour = exports.LineLogger = void 0;

{
"name": "@handy-common-utils/misc-utils",
"version": "1.2.0",
"version": "1.3.0",
"description": "Miscellaneous utilities",

@@ -5,0 +5,0 @@ "scripts": {

@@ -147,2 +147,4 @@ # @handy-common-utils/misc-utils

- [array](#modulesarraymd)
- [codec](#modulescodecmd)
- [http-status](#moduleshttp_statusmd)

@@ -521,134 +523,39 @@ - [index](#modulesindexmd)

<a name="moduleshttp_statusmd"></a>
<a name="modulesarraymd"></a>
### Module: http-status
### Module: array
#### Enumerations
#### Functions
- [HttpStatusCode](#enumshttp_statushttpstatuscodemd)
##### distributeRoundRobin
#### Variables
▸ **distributeRoundRobin**<`T`\>(`array`, `groups`): `T`[][]
##### HttpStatusMessage
Distributes an array into a number of groups in a round robin fashion.
This function has been tuned for performance.
• `Const` **HttpStatusMessage**: `Object`
###### Type parameters
Some (not all) HTTP status messages matching their codes
| Name |
| :------ |
| `T` |
###### Type declaration
###### Parameters
| Name | Type |
| :------ | :------ |
| `200` | `string` |
| `201` | `string` |
| `202` | `string` |
| `204` | `string` |
| `301` | `string` |
| `302` | `string` |
| `303` | `string` |
| `307` | `string` |
| `308` | `string` |
| `400` | `string` |
| `401` | `string` |
| `403` | `string` |
| `404` | `string` |
| `405` | `string` |
| `408` | `string` |
| `409` | `string` |
| `429` | `string` |
| `500` | `string` |
| `501` | `string` |
| `502` | `string` |
| `503` | `string` |
| `504` | `string` |
| Name | Type | Description |
| :------ | :------ | :------ |
| `array` | `T`[] | The input array |
| `groups` | `number` | Number of groups the elements in the input array need to be distributed into. |
###### Returns
<a name="modulesindexmd"></a>
`T`[][]
### Module: index
The result as an array of arrays which each represents a group
#### References
##### ConsoleLineLogger
<a name="modulescodecmd"></a>
Re-exports [ConsoleLineLogger](#consolelinelogger)
### Module: codec
___
##### HttpStatusCode
Re-exports [HttpStatusCode](#enumshttp_statushttpstatuscodemd)
___
##### HttpStatusMessage
Re-exports [HttpStatusMessage](http_status.md#httpstatusmessage)
___
##### LineLogger
Re-exports [LineLogger](#classesline_loggerlineloggermd)
___
##### PathAwareReplacer
Re-exports [PathAwareReplacer](#pathawarereplacer)
___
##### consoleLike
Re-exports [consoleLike](#consolelike)
___
##### consoleWithColour
Re-exports [consoleWithColour](#consolewithcolour)
___
##### consoleWithoutColour
Re-exports [consoleWithoutColour](#consolewithoutcolour)
___
##### mask
Re-exports [mask](#mask)
___
##### maskAll
Re-exports [maskAll](#maskall)
___
##### maskEmail
Re-exports [maskEmail](#maskemail)
___
##### maskFullName
Re-exports [maskFullName](#maskfullname)
___
##### pathAwareReplacer
Re-exports [pathAwareReplacer](#pathawarereplacer-1)
___
##### pathBasedReplacer
Re-exports [pathBasedReplacer](#pathbasedreplacer)
#### Functions

@@ -788,2 +695,171 @@

<a name="moduleshttp_statusmd"></a>
### Module: http-status
#### Enumerations
- [HttpStatusCode](#enumshttp_statushttpstatuscodemd)
#### Variables
##### HttpStatusMessage
• `Const` **HttpStatusMessage**: `Object`
Some (not all) HTTP status messages matching their codes
###### Type declaration
| Name | Type |
| :------ | :------ |
| `200` | `string` |
| `201` | `string` |
| `202` | `string` |
| `204` | `string` |
| `301` | `string` |
| `302` | `string` |
| `303` | `string` |
| `307` | `string` |
| `308` | `string` |
| `400` | `string` |
| `401` | `string` |
| `403` | `string` |
| `404` | `string` |
| `405` | `string` |
| `408` | `string` |
| `409` | `string` |
| `429` | `string` |
| `500` | `string` |
| `501` | `string` |
| `502` | `string` |
| `503` | `string` |
| `504` | `string` |
<a name="modulesindexmd"></a>
### Module: index
#### References
##### ConsoleLineLogger
Re-exports [ConsoleLineLogger](#consolelinelogger)
___
##### HttpStatusCode
Re-exports [HttpStatusCode](#enumshttp_statushttpstatuscodemd)
___
##### HttpStatusMessage
Re-exports [HttpStatusMessage](http_status.md#httpstatusmessage)
___
##### LineLogger
Re-exports [LineLogger](#classesline_loggerlineloggermd)
___
##### PathAwareReplacer
Re-exports [PathAwareReplacer](#pathawarereplacer)
___
##### base64FromUInt32
Re-exports [base64FromUInt32](#base64fromuint32)
___
##### base64UrlFromUInt32
Re-exports [base64UrlFromUInt32](#base64urlfromuint32)
___
##### consoleLike
Re-exports [consoleLike](#consolelike)
___
##### consoleWithColour
Re-exports [consoleWithColour](#consolewithcolour)
___
##### consoleWithoutColour
Re-exports [consoleWithoutColour](#consolewithoutcolour)
___
##### distributeRoundRobin
Re-exports [distributeRoundRobin](#distributeroundrobin)
___
##### mask
Re-exports [mask](#mask)
___
##### maskAll
Re-exports [maskAll](#maskall)
___
##### maskEmail
Re-exports [maskEmail](#maskemail)
___
##### maskFullName
Re-exports [maskFullName](#maskfullname)
___
##### pathAwareReplacer
Re-exports [pathAwareReplacer](#pathawarereplacer-1)
___
##### pathBasedReplacer
Re-exports [pathBasedReplacer](#pathbasedreplacer)
___
##### shortBase64FromUInt32
Re-exports [shortBase64FromUInt32](#shortbase64fromuint32)
___
##### shortBase64UrlFromUInt32
Re-exports [shortBase64UrlFromUInt32](#shortbase64urlfromuint32)
___
##### urlSafe
Re-exports [urlSafe](#urlsafe)
<a name="modulesline_loggermd"></a>

@@ -790,0 +866,0 @@

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc