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

@handy-common-utils/misc-utils

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@handy-common-utils/misc-utils

Miscellaneous utilities

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
91
decreased by-20.87%
Maintainers
1
Weekly downloads
 
Created
Source

@handy-common-utils/misc-utils

Miscellaneous utilities

Version Downloads/week CI codecov

How to use

First add it as a dependency:

npm install @handy-common-utils/misc-utils

Then you can use it in the code:

import { shortBase64UrlFromUInt32 } from '@handy-common-utils/misc-utils';

const urlSafeBase64 = shortBase64UrlFromUInt32(12345);

API

@handy-common-utils/misc-utils

@handy-common-utils/misc-utils

Table of contents

Functions

Functions

base64FromUInt32

base64FromUInt32<T>(ui32): Exclude<T, number> | string

Encode an unsigned 32-bit integer into BASE64 string.

Type parameters
NameType
Textends undefined | null | number
Parameters
NameTypeDescription
ui32TA 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.
Returns

Exclude<T, number> | string

BASE64 string representing the integer input, or the original input if it is null or undefined.


base64UrlFromUInt32

base64UrlFromUInt32<T>(ui32, replacements?): Exclude<T, number> | string

Encode an unsigned 32-bit integer into URL/path safe BASE64 string.

Type parameters
NameType
Textends undefined | null | number
Parameters
NameTypeDefault valueDescription
ui32TundefinedA 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.
replacementsstring'_-='A string containing replacement characters for "/", "+", and "=". If omitted, default value of '_-=' would be used.
Returns

Exclude<T, number> | string

URL/path safe BASE64 string representing the integer input, or the original input if it is null or undefined.


shortBase64FromUInt32

shortBase64FromUInt32<T>(ui32): Exclude<T, number> | string

Encode an unsigned 32-bit integer into BASE64 string without trailing '='.

Type parameters
NameType
Textends undefined | null | number
Parameters
NameTypeDescription
ui32TA 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.
Returns

Exclude<T, number> | string

BASE64 string without trailing '=' representing the integer input, or the original input if it is null or undefined.


shortBase64UrlFromUInt32

shortBase64UrlFromUInt32<T>(ui32, replacements?): Exclude<T, number> | string

Encode an unsigned 32-bit integer into URL/path safe BASE64 string without trailling '='.

Type parameters
NameType
Textends undefined | null | number
Parameters
NameTypeDefault valueDescription
ui32TundefinedA 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.
replacementsstring'_-'A string containing replacement characters for "/" and "+". If omitted, default value of '_-' would be used.
Returns

Exclude<T, number> | string

URL/path safe BASE64 string without trailing '=' representing the integer input, or the original input if it is null or undefined.


urlSafe

urlSafe<T>(base64Input, replacements?): T

Make a "normal" (BASE64) string URL/path safe.

Type parameters
NameType
Textends undefined | null | string
Parameters
NameTypeDefault valueDescription
base64InputTundefinedA (BASE64) string which could be null or undefined.
replacementsstring'_-='A string containing replacement characters for "/", "+", and "=". If omitted, default value of '_-=' would be used.
Returns

T

URL/path safe version of the (BASE64) input string, or the original input if it is null or undefined.

Keywords

FAQs

Package last updated on 25 Dec 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc