Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
ts-utily / Exports
▸ addDays(d
, days?
): Date
Adds specified number of days to a given Date object.
Name | Type | Default value | Description |
---|---|---|---|
d | Date | undefined | The Date object to which days are to be added. |
days | number | 1 | The number of days to be added. Defaults to 1 if not provided. |
Date
▸ arrayBufferToBase64(buffer
): string
Converts an ArrayBuffer to a Base64 string.
Name | Type | Description |
---|---|---|
buffer | Uint8Array | The ArrayBuffer to convert. |
string
▸ at<T
>(collection
, index
): undefined
| T
The function at
returns the element at the specified index in a collection, or undefined if the collection is empty or
the index is out of bounds.
Name |
---|
T |
Name | Type | Description |
---|---|---|
collection | undefined | null | T [] | The collection parameter is an array of type T[] , or it can be undefined or null . It represents the collection of elements from which we want to retrieve an element at a specific index. |
index | number | The index parameter is the position of the element you want to retrieve from the collection . It is a number that represents the index of the element in the array. |
undefined
| T
the element at the specified index in the collection. If the collection is empty or the index is out of range, it will return undefined.
▸ capitalize(str
): string
The capitalize
function takes a string as input and returns the same string with the first letter of each word
capitalized.
Name | Type | Description |
---|---|---|
str | undefined | null | string | The str parameter is a string that may be undefined or null . |
string
The capitalize
function returns a string.
▸ capitalizeFully(str
): string
The capitalizeFully
function takes a string as input and returns a new string with each word capitalized.
Name | Type | Description |
---|---|---|
str | undefined | null | string | The str parameter is a string that can also be undefined or null . |
string
The function capitalizeFully
returns a string.
▸ compare(s1
, s2
): number
The function "compare" compares two strings case-insensitively and returns -1 if the first string is smaller, 1 if the second string is smaller.
Name | Type | Description |
---|---|---|
s1 | string | The parameter s1 is a string that represents the first string to be compared. |
s2 | string | The parameter s2 is a string that represents the second string to be compared. |
number
a number. If s1
is lexicographically less than s2
(ignoring case), it returns -1. Otherwise, it returns 1.
▸ convertArrayBufferToUint8Array(arrayBuffer
): Uint8Array
Converts an ArrayBuffer to a Uint8Array.
Name | Type | Description |
---|---|---|
arrayBuffer | ArrayBuffer | The ArrayBuffer to be converted. |
Uint8Array
▸ convertArrayToRecord<T
>(array
, key
): Record
<string
, T
>
Converts an array to a record by using the specified key from each element.
Name | Description |
---|---|
T | The type of array elements. |
Name | Type | Description |
---|---|---|
array | T [] | The array to convert. |
key | keyof T | The key to use from each element. |
Record
<string
, T
>
▸ convertIndexSignaturesToMap<V
>(indexSignatures
): undefined
| Map
<string
, V
>
The function converts an object with index signatures to a Map.
Name |
---|
V |
Name | Type | Description |
---|---|---|
indexSignatures | undefined | { [p: string] : V ; } | An object that contains index signatures, where the keys are strings and the values can be of any type. |
undefined
| Map
<string
, V
>
a Map<string, V>
or undefined
.
▸ convertMapToIndexSignatures<V
>(map
): undefined
| { [p: string]
: V
; }
The function converts a Map object to an object with index signatures in TypeScript.
Name |
---|
V |
Name | Type | Description |
---|---|---|
map | undefined | Map <string , V > | A Map object that contains key-value pairs. |
undefined
| { [p: string]
: V
; }
an object with index signatures, where the keys are strings and the values are of type V. If the input map is undefined, the function returns undefined.
▸ convertRecordToArray<T
, K
>(record
): T
[]
Converts a record to an array of its values.
Name | Type | Description |
---|---|---|
T | T | The type of the record values. |
K | extends PropertyKey | The type of the record keys. |
Name | Type | Description |
---|---|---|
record | Record <K , T > | The record to convert. |
T
[]
▸ createArrayBufferFromString(string
): ArrayBuffer
Converts a string into an ArrayBuffer.
Name | Type | Description |
---|---|---|
string | string | The string to be converted. |
ArrayBuffer
▸ createBlobFromBase64AndMimeType(base64
, MIME_Type
): Blob
Create a Blob object from the given base64 string and MIME type.
Name | Type | Description |
---|---|---|
base64 | string | The base64 string. |
MIME_Type | MimeTypeEnum | The MIME type of the Blob. |
Blob
▸ createBlobFromSourceAndMimeType(blobParts
, MIME_Type
): Blob
Creates a Blob object from an array of blob parts and the MIME type.
Name | Type | Description |
---|---|---|
blobParts | BlobPart [] | The array of blob parts to be combined into a Blob object. |
MIME_Type | MimeTypeEnum | The MIME type for the Blob object. |
Blob
▸ createFileFromBase64AndMimeType(base64
, MIME_Type
, fileName
): File
Creates a file from a base64 encoded string and MIME type.
Name | Type | Description |
---|---|---|
base64 | string | The base64 encoded string representing the file. |
MIME_Type | MimeTypeEnum | The MIME type of the file. |
fileName | string | The name of the file. |
File
▸ createUint8ArrayFromBase64(base64
): Uint8Array
Converts a base64 string to a Uint8Array.
Name | Type | Description |
---|---|---|
base64 | string | The base64 string to convert. |
Uint8Array
The Uint8Array representing the base64 string.
▸ dateWith00Mins(date?
): Date
Sets the minutes, seconds, and milliseconds of the given date to 0. If no date is provided, the current date and time will be used.
Name | Type | Description |
---|---|---|
date? | number | Date | The date to modify. If not provided, the current date and time will be used. |
Date
The modified date.
▸ dayBetween(d1
, d2
): number
Calculates the number of days between two dates.
Name | Type | Description |
---|---|---|
d1 | Date | The first date. |
d2 | Date | The second date. |
number
The number of days between the two dates.
▸ deleteElementCollection<T
>(collection
, element
): T
[]
The deleteElementCollection
function removes an element from a collection if it exists, otherwise it returns the
original collection.
Name |
---|
T |
Name | Type | Description |
---|---|---|
collection | undefined | null | T [] | The collection parameter is an array of elements of type T , or it can be undefined or null . |
element | T | Readonly <T > | The element parameter represents the element that you want to delete from the collection . |
T
[]
an array of type T.
▸ equalsCollection<T
>(collection1
, collection2
): boolean
The function checks if two collections are equal by comparing their lengths and elements.
Name |
---|
T |
Name | Type | Description |
---|---|---|
collection1 | undefined | null | T [] | The collection1 parameter is an array of type T , or it can be undefined or null . |
collection2 | undefined | null | T [] | The collection2 parameter is a generic array (T[] ) or can be undefined or null . It represents the second collection that you want to compare with collection1 . |
boolean
a boolean value.
▸ fileIs(filename
, mimeType
): boolean
Checks if a file matches the specified filename and mimeType.
Name | Type | Description |
---|---|---|
filename | string | The name of the file. |
mimeType | MimeTypeEnum | The MIME type to match. |
boolean
Returns true
if the filename matches the MIME type, otherwise false
.
▸ findOrDefault<T
>(collection
, element
, defaultElement
): T
The findOrDefault
function searches for an element in a collection and returns it if found, otherwise it returns a
default element.
Name |
---|
T |
Name | Type | Description |
---|---|---|
collection | undefined | null | T [] | The collection parameter is an array of elements of type T , or it can be undefined or null . It represents the collection of elements in which we want to find a specific element. |
element | T | Readonly <T > | The element parameter represents the element that you want to find in the collection . |
defaultElement | T | Readonly <T > | The defaultElement parameter is the value that will be returned if the element is not found in the collection . |
T
a value of type T.
▸ get<T
>(collection
): T
[]
The get
function returns the input collection if it is not empty, otherwise it returns an empty array.
Name |
---|
T |
Name | Type | Description |
---|---|---|
collection | undefined | null | T [] | The collection parameter is of type T[] | undefined | null . This means it can accept an array of type T , or it can be undefined or null . |
T
[]
an array of type T.
▸ getDeltaTimeFromTwoDates(date1
, date2
): DeltaDateResult
Calculates the time difference between two dates and returns the result as an object containing the number of years, months, days, hours, minutes, and seconds.
Name | Type | Description |
---|---|---|
date1 | number | Date | The first date. |
date2 | number | Date | The second date. |
DeltaDateResult
▸ getExtensionFromFileName(fileName
): undefined
| string
Retrieves the file extension from a file name.
Name | Type | Description |
---|---|---|
fileName | string | The file name. |
undefined
| string
▸ getExtensionFromMimeType(mimeType
): string
Retrieves file extension from given MIME type
Name | Type | Description |
---|---|---|
mimeType | MimeTypeEnum | The MIME type of the file |
string
▸ getHoursAndMinutesFromDateAsString(d
, locales
, hour?
, minute?
): null
| string
Converts a given date or number into a string representation of hours and minutes.
Name | Type | Default value | Description |
---|---|---|---|
d | undefined | null | number | Date | undefined | The date or number to convert. |
locales | LocalesArgument | undefined | The locales argument for the toLocaleTimeString method. |
hour? | "numeric" | "2-digit" | "2-digit" | The format of the hour: "numeric" for a single digit, "2-digit" for a double digit. Default is "2-digit". |
minute? | "numeric" | "2-digit" | "2-digit" | The format of the minute: "numeric" for a single digit, "2-digit" for a double digit. Default is "2-digit". |
null
| string
The string representation of the hours and minutes, or null if the input is null or undefined.
▸ getMimeTypeFromExtension(extension
): string
Retrieves the MIME type from a file extension.
Name | Type | Description |
---|---|---|
extension | string | The file extension. |
string
▸ getNextDayOfWeekFromDate(date
, dayOfWeek
): Date
Gets the next occurrence of a specified day of the week from a given date.
Name | Type | Description |
---|---|---|
date | undefined | null | number | Date | The date from which to start searching. If not provided or invalid, the current date will be used. |
dayOfWeek | DayOfWeek | The day of the week to find the next occurrence of. |
Date
▸ getOrDefault<T
>(data
, defaultValue
): T
The getOrDefault
function returns the provided data if it is not null or undefined, otherwise it returns the provided
default value.
Name |
---|
T |
Name | Type | Description |
---|---|---|
data | T | The data parameter is the value that you want to check if it is null or undefined. |
defaultValue | T | The defaultValue parameter is the value that will be returned if the data parameter is null or undefined . |
T
The function getOrDefault
returns the value of data
if it is not null or undefined, otherwise it returns the value
of defaultValue
.
▸ getOrDefaultCollection<T
>(collection
, defaultList
): T
[]
The getOrDefaultCollection
function returns the provided collection if it is not empty, otherwise it returns the
default list.
Name |
---|
T |
Name | Type | Description |
---|---|---|
collection | undefined | null | T [] | The collection parameter is a variable that represents an array of elements of type T , or it can be undefined or null . |
defaultList | T [] | The defaultList parameter is an array of type T[] . It is the list that will be returned if the collection parameter is empty or undefined. |
T
[]
an array of type T.
▸ getOrDefaultString(string
, defaultValue?
): string
The getOrDefaultString
function returns a string value if it is not empty, otherwise it returns a default value.
Name | Type | Default value | Description |
---|---|---|---|
string | undefined | null | string | undefined | The string parameter is a string value that can be either a valid string, undefined , or null . |
defaultValue? | string | '' | The defaultValue parameter is a string that specifies the value to return if the string parameter is empty, undefined, or null. If no defaultValue is provided, it defaults to an empty string (''). |
string
The function getOrDefault
returns a string value.
▸ getTomorrow(d?
): Date
Returns tomorrow's date.
Name | Type | Description |
---|---|---|
d? | number | Date | Optional date to be used as the base. |
Date
▸ hoursBetween(d1
, d2
, withAbs?
): number
Calculates the number of hours between two given dates.
Name | Type | Default value | Description |
---|---|---|---|
d1 | Date | undefined | The first date. |
d2 | Date | undefined | The second date. |
withAbs? | boolean | true | Whether to return the absolute difference or not. |
number
The number of hours between the two dates.
▸ includes(string1
, string2
): boolean
The function checks if a given string contains another given string, ignoring case sensitivity.
Name | Type | Description |
---|---|---|
string1 | undefined | null | string | A string that can be undefined or null. |
string2 | undefined | null | string | The string2 parameter is a string that represents the substring that we want to check if it is present in string1 . |
boolean
The function includes
returns a boolean value.
▸ instantToDate(instant?
): Date
Converts the given instant to a Date object.
Name | Type | Description |
---|---|---|
instant? | string | Date | The instant to convert. If not provided, the current date and time is used. |
Date
Example
use
for convert Instant(like as java
object
)
to
javascript
date
▸ isAfter(d1
, d2
, matchOnlyForYearMonthDay?
): boolean
Checks if a given date is after another date.
Name | Type | Description |
---|---|---|
d1 | Date | The first date. |
d2 | Date | The second date. |
matchOnlyForYearMonthDay? | boolean | Optional parameter to match only up to year, month, and day. |
boolean
▸ isBefore(d1
, d2
, matchOnlyForYearMonthDay?
): boolean
Determines if the given date is before the reference date.
Name | Type | Description |
---|---|---|
d1 | Date | The date to compare. |
d2 | Date | The reference date. |
matchOnlyForYearMonthDay? | boolean | Optional flag to indicate if the dates should only match for year, month, and day. Defaults to false. |
boolean
▸ isBetween(dateToMatch
, start
, end
, matchOnlyForYearMonthDay?
): boolean
Checks if a given date falls between a start and end date.
Name | Type | Description |
---|---|---|
dateToMatch | Date | The date to check. |
start | Date | The start date. |
end | Date | The end date. |
matchOnlyForYearMonthDay? | boolean | (Optional) Specifies whether to only consider the year, month, and day when checking the date. Default is false. |
boolean
▸ isEmptyCollection<T
>(collection
): boolean
The function isEmptyCollection
checks if a collection is empty or not.
Name |
---|
T |
Name | Type | Description |
---|---|---|
collection | undefined | null | T [] | The collection parameter is a generic type T[] which represents an array of elements of type T . It can also be undefined or null . |
boolean
a boolean value indicating whether the collection is empty or not.
▸ isEmptyString(string
): boolean
The function checks if a string is empty, including cases where the string is undefined or null.
Name | Type | Description |
---|---|---|
string | undefined | null | string | The string parameter is of type string | undefined | null , which means it can accept a value of type string , undefined , or null . |
boolean
The function isEmpty
returns a boolean value.
▸ isEqual<T
>(...objects
): boolean
The isEqual
function checks if all the given objects are equal by comparing their JSON representations.
Name |
---|
T |
Name | Type | Description |
---|---|---|
...objects | T [] | The objects parameter is a rest parameter that allows you to pass in multiple objects of type T . The rest parameter syntax (...objects ) allows you to pass any number of arguments, which will be collected into an array called objects . |
boolean
The function isEqual
returns a boolean value.
▸ isNotEmptyCollection<T
>(collection
): boolean
The function isNotEmptyCollection
checks if a collection is not empty.
Name |
---|
T |
Name | Type | Description |
---|---|---|
collection | undefined | null | T [] | The collection parameter is of type T[] | undefined | null . This means it can accept an array of type T , or it can be undefined or null . |
boolean
The function isNotEmpty is returning a boolean value.
▸ isNotEmptyString(string
): boolean
The function isNotEmptyString
checks if a string is not empty.
Name | Type | Description |
---|---|---|
string | undefined | null | string | The parameter "string" is of type string and can also be undefined or null. |
boolean
The function isNotEmpty is returning a boolean value.
▸ isNumber<T
>(value
): boolean
The function isNumber
checks if a value is a number in TypeScript.
Name |
---|
T |
Name | Type | Description |
---|---|---|
value | T | The value parameter is the value that you want to check if it is a number. It can be of any type T . |
boolean
a boolean value.
▸ isString<T
>(obj
): boolean
The function isString
checks if an object is a string or an instance of the String class.
Name |
---|
T |
Name | Type | Description |
---|---|---|
obj | T | The obj parameter is a generic type T , which means it can be any type. |
boolean
a boolean value indicating whether the input object is a string or not.
▸ monthFromDate(date
, locales?
, month?
): string
Returns the month from a given date in the specified format.
Name | Type | Default value | Description |
---|---|---|---|
date | Date | undefined | The date from which to extract the month. |
locales? | LocalesArgument | 'default' | A string representing a BCP 47 language tag, or an array of such strings. |
month? | "numeric" | "2-digit" | "long" | "short" | "narrow" | "long" | The format in which to return the month. Possible values are: - "numeric": Returns the month as a digit (e.g. 1, 2, 3, ... 12). - "2-digit": Returns the month as a two-digit number with leading zero (e.g. 01, 02, 03, ... 12). - "long": Returns the full name of the month (e.g. January, February, ... December). - "short": Returns the abbreviated name of the month (e.g. Jan, Feb, ... Dec). - "narrow": Returns the narrow name of the month (e.g. J, F, ... D). - undefined or not provided: Returns the default long format. |
string
The month from the given date in the specified format.
▸ notPresent<T
>(...args
): boolean
The function notPresent
checks if any of the arguments passed to it are not present.
Name |
---|
T |
Name | Type | Description |
---|---|---|
...args | T [] | The args parameter is a rest parameter of type T[] , which means it can accept any number of arguments of type T . |
boolean
a boolean value.
▸ parzializeArray<T
>(array
, section
): undefined
| T
[][]
The function parzializeArray
takes an array and a section size as input and returns an array of arrays, where each
subarray contains a section of the original array.
Name |
---|
T |
Name | Type | Description |
---|---|---|
array | undefined | null | T [] | The array parameter is an array of elements of type T , or it can be undefined or null . |
section | number | The parameter "section" represents the size of each section or chunk that the array will be divided into. |
undefined
| T
[][]
an array of arrays of type T, or undefined.
▸ parzializeArrayByKeys<T
>(array
, keys
): undefined
| T
[][]
The function parzializeArrayByKeys
takes an array of objects and an array of keys, and returns a partially grouped
array based on the specified keys.
Name |
---|
T |
Name | Type | Description |
---|---|---|
array | undefined | null | T [] | The array parameter is an array of objects of type T , or it can be undefined or null . |
keys | keyof T [] | An array of keys that represent the properties of the objects in the array. |
undefined
| T
[][]
The function parzializeArrayByKeys
returns an array of arrays of type T
, or undefined
.
▸ percentage(value
, totalValue
): number
The function calculates the percentage of a value in relation to a total value.
Name | Type | Description |
---|---|---|
value | number | The value parameter represents the specific value that you want to calculate the percentage of. It is a number that you want to find the percentage of in relation to the totalValue. |
totalValue | number | The total value represents the maximum value or the total amount that you want to calculate the percentage of. |
number
a number, which is the calculated percentage value.
▸ populateTemplate(string
, placeholders
): undefined
| string
Replaces placeholders in a string with corresponding values from an array.
Name | Type | Description |
---|---|---|
string | undefined | string | The string containing placeholders. |
placeholders | any [] | An array of objects containing key-value pairs, where the key represents a placeholder and the value is the replacement value. |
undefined
| string
Example
populateTemplate('Replace my text {myReplacePlaceholder}', [{
name: 'Valery',
age: 20,
myReplacePlaceholder: 'test this'
}, {name: 'Marcus', age: 21}])
=>
Replace
my
text
test
this
▸ present<T
>(...args
): boolean
The present
function checks if all the arguments passed to it are not null or undefined.
Name |
---|
T |
Name | Type | Description |
---|---|---|
...args | T [] | args is a rest parameter of type T[]. It allows the function to accept any number of arguments of type T. |
boolean
a boolean value.
▸ removeDays(d
, days?
): Date
Removes the specified number of days from a given date.
Name | Type | Default value | Description |
---|---|---|---|
d | Date | undefined | The date to remove days from. |
days | number | 1 | The number of days to remove. Defaults to 1 if not provided. |
Date
▸ removeDuplicateByKey<T
>(collection
, key?
): T
[]
The function removeDuplicatesByKey
removes duplicate elements from a collection based on a specified key.
Name |
---|
T |
Name | Type | Description |
---|---|---|
collection | undefined | null | T [] | The collection parameter is an array of objects of type T . It can also be undefined or null . |
key? | keyof T | The key parameter is an optional parameter that specifies the property of the objects in the collection array that should be used as the key for removing duplicates. If key is not provided, the entire objects in the collection array will be compared for duplicates. |
T
[]
The function rimuoviDuplicatiByKey
returns an array of type T[]
.
▸ removeDuplicateByKeys<T
>(collection
, keys
): T
[]
The removeDuplicateByKeys
function removes duplicate elements from a collection based on specified keys.
Name |
---|
T |
Name | Type | Description |
---|---|---|
collection | undefined | null | T [] | The collection parameter is an array of objects of type T . It can also be undefined or null . |
keys | keyof T [] | The keys parameter is an array of keys that are used to determine uniqueness in the collection. Each element in the array represents a key in the objects of the collection. |
T
[]
an array of type T, which is the collection with duplicate elements removed based on the specified keys.
▸ removeNullOrUndefinedFieldsFromObject<T
>(value
): undefined
| T
The function removes fields with null or undefined values from an object.
Name |
---|
T |
Name | Type | Description |
---|---|---|
value | T | The value parameter is the object from which you want to remove fields that have null or undefined values. |
undefined
| T
either the input value T
or undefined
.
Example
example
of
usage: cleaning
object
before
store
into
DB(JSON
type colum
)
▸ removeWhiteSpace(str
): string
The removeWhiteSpace
function removes all white spaces from a given string.
Name | Type | Description |
---|---|---|
str | undefined | null | string | The str parameter is a string that can be either a valid string value, undefined , or null . |
string
a string with all whitespace characters removed.
▸ replaceAll(originalString
, occurrenceToReplace
, replaceWith
): string
The replaceAll
function replaces all occurrences of a specified string in a given string with another specified
string.
Name | Type | Description |
---|---|---|
originalString | string | The original string that you want to perform the replacement on. |
occurrenceToReplace | string | The occurrenceToReplace parameter is a string that represents the occurrence or pattern that you want to replace in the originalString . |
replaceWith | string | The replaceWith parameter is the string that will replace all occurrences of occurrenceToReplace in the originalString . |
string
The function replaceAll
returns a string.
▸ sameDate(d1
, d2
): boolean
Checks if two dates are the same (year, month, and day).
Name | Type | Description |
---|---|---|
d1 | Date | The first date to compare. |
d2 | Date | The second date to compare. |
boolean
▸ setTime(date
, time
): undefined
| Date
Sets the time portion of a given date.
Name | Type | Description |
---|---|---|
date | undefined | null | number | Date | The date object or timestamp to modify. |
time | string | The time string to set in the format 'HH:MM'. |
undefined
| Date
Throws
▸ sortByObjectValues<T
>(keys
, isAsc
): (a
: T
, b
: T
) => number
The function sortByObjectValues
sorts an array of objects based on the values of specified nested keys in ascending or
descending order.
Name | Type |
---|---|
T | extends object |
Name | Type | Description |
---|---|---|
keys | NestedKeyOf <T >[] | An array of keys that represent the nested properties of the objects being sorted. |
isAsc | boolean | The isAsc parameter is a boolean value that determines whether the sorting order should be ascending (true ) or descending (false ). |
fn
The function sortByObjectValues
returns a function that takes two objects a
and b
of type T
and returns a
number.
▸ (a
, b
): number
Name | Type |
---|---|
a | T |
b | T |
number
Example
example
of
usage: [{name: 'Amanda', age: 18}, {name: 'Victor', age: 18}].sort(sortByObjectValues(['name', 'age'], true))
Example
array.sort(sortByObjectValues(['ele1', 'ele2' 'eleN', ...], false))
▸ sortNumericString(a
, b
): number
The function sortNumericString
compares two numeric strings and returns a number indicating their relative order.
Name | Type | Description |
---|---|---|
a | string | The parameter "a" is a string representing the first numeric string to be compared. |
b | string | The parameter "b" is a string representing the second value to be compared. |
number
a number.
▸ ternaryOperator(condition
, s1
, s2
): string
The ternaryOperator
function returns s1
if condition
is true, otherwise it returns s2
.
Name | Type | Description |
---|---|---|
condition | boolean | A boolean value that represents the condition to be evaluated. If the condition is true, the function will return s1. If the condition is false, the function will return s2. |
s1 | string | The parameter s1 is a string that represents the value to be returned if the condition is true. |
s2 | string | The parameter s2 is a string that represents the value to be returned if the condition is false. |
string
The ternaryOperator function returns either s2 or s1 based on the value of the condition. If the condition is false, it returns s2. Otherwise, it returns s1.
▸ toBoolean(value
): boolean
The function toBoolean
converts a string value to a boolean value, considering various possible representations of
true like as 'true', '1' or 'y'.
Name | Type | Description |
---|---|---|
value | string | The value parameter is a string that represents a boolean value. |
boolean
a boolean value.
▸ toLocalDate(date
): string
Converts a Date object to a string representation of the local date. If the input date is null or undefined, an empty string is returned.
Name | Type | Description |
---|---|---|
date | undefined | null | Date | The date object to convert. |
string
The string representation of the local date.
▸ toLocalDateTime(date
, nowAsDefault?
): string
Converts a given Date
, number
, null
, or undefined
value to a localized string representation of the date and
time in "YYYY-MM-DDTHH:MM" format.
Name | Type | Default value | Description |
---|---|---|---|
date | undefined | null | number | Date | undefined | The value to be converted. |
nowAsDefault? | boolean | false | If true and date is not provided, the current date and time will be used as the default value. |
string
The localized string representation of the date and time. Returns 'N.d.' if date
is null
and nowAsDefault
is false
.
▸ toNumber<T
>(value
): number
The toNumber
function converts a value to a number, returning 0 if the value is not a valid number.
Name |
---|
T |
Name | Type | Description |
---|---|---|
value | T | The value parameter is of type T , which means it can be any type. It represents the value that needs to be converted to a number. |
number
a number.
▸ typizeBlobFromFileName(blob
, fileName
): undefined
| Blob
Converts a Blob to a specific Blob type based on the file name extension.
Name | Type | Description |
---|---|---|
blob | Blob | The Blob instance to be typed. |
fileName | string | The name of the file associated with the Blob. |
undefined
| Blob
FAQs
Typescript utils library
We found that ts-utily demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.