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

@trackunit/shared-utils

Package Overview
Dependencies
Maintainers
3
Versions
183
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trackunit/shared-utils - npm Package Compare versions

Comparing version 0.0.48 to 0.0.49

55

index.cjs.js

@@ -211,2 +211,5 @@ 'use strict';

/* -------------------------------------------------------------------------- */
/* Filtering utilities */
/* -------------------------------------------------------------------------- */
/**

@@ -233,7 +236,36 @@ * Use with filter() to remove null and undefined from an array

/**
* Converts an object into an array of properly typed key-value pairs.
* This is a type-faithful alternative to Object.entries().
*
* Uses the `Object.entries()` to get an array of the object's key-value pairs,
* and then casts each key-value pair to `[keyof TObject, TObject[keyof TObject]]`
*
* See https://stackoverflow.com/a/76176570
*
* @param {TObject} object - The object to convert.
* @template TObject - The type of the object.
*/
const objectEntries = (object) =>
// eslint-disable-next-line local-rules/no-typescript-assertion, local-rules/prefer-custom-object-entries
Object.entries(object);
/**
* Converts an array of key-value pairs into an object.
* This is a type-faithful alternative to Object.fromEntries().
*
* @param {TEntries} entries - The array of key-value pairs to convert.
* @template TEntries - The type of the entries array.
*/
const objectFromEntries = (entries) => {
// eslint-disable-next-line local-rules/no-typescript-assertion, local-rules/prefer-custom-object-from-entries
return Object.fromEntries(entries);
};
/**
* Returns an array of the **correctly typed** keys of a given object.
* This is a type-faithful alternative to Object.keys().
*
* This function uses the `Object.keys()` method to get an array of the object's keys,
* and then casts each key to `keyof TObject` to ensure TypeScript understands the keys are of the correct type.
* Uses the `Object.keys()` to get an array of the object's keys,
* and then casts each key to `keyof TObject`
*
* See https://stackoverflow.com/a/76176570
*
* @template TObject - The type of the object.

@@ -244,5 +276,19 @@ * @param {TObject} object - The object to get the keys from.

const objectKeys = (object) => {
// eslint-disable-next-line local-rules/no-typescript-assertion
// eslint-disable-next-line local-rules/no-typescript-assertion, local-rules/prefer-custom-object-keys
return Object.keys(object).map(key => key);
};
/**
* Returns an array of the **correctly typed** values of a given object.
* This is a type-faithful alternative to Object.values().
*
* Uses the `Object.values()` to get an array of the object's values,
* and then casts each value to `TObject[keyof TObject]`
*
* @template TObject - The type of the object.
* @param {TObject} object - The object to get the values from.
* @returns {TObject[keyof TObject][]} An array of the values of the object.
*/
const objectValues = (object) =>
// eslint-disable-next-line local-rules/no-typescript-assertion, local-rules/prefer-custom-object-values
Object.values(object);

@@ -1036,3 +1082,6 @@ /** toggle whether a value is in an array or not */

exports.objNotEmpty = objNotEmpty;
exports.objectEntries = objectEntries;
exports.objectFromEntries = objectFromEntries;
exports.objectKeys = objectKeys;
exports.objectValues = objectValues;
exports.pick = pick;

@@ -1039,0 +1088,0 @@ exports.removeLeftPadding = removeLeftPadding;

@@ -207,2 +207,5 @@ var HoursAndMinutesFormat;

/* -------------------------------------------------------------------------- */
/* Filtering utilities */
/* -------------------------------------------------------------------------- */
/**

@@ -229,7 +232,36 @@ * Use with filter() to remove null and undefined from an array

/**
* Converts an object into an array of properly typed key-value pairs.
* This is a type-faithful alternative to Object.entries().
*
* Uses the `Object.entries()` to get an array of the object's key-value pairs,
* and then casts each key-value pair to `[keyof TObject, TObject[keyof TObject]]`
*
* See https://stackoverflow.com/a/76176570
*
* @param {TObject} object - The object to convert.
* @template TObject - The type of the object.
*/
const objectEntries = (object) =>
// eslint-disable-next-line local-rules/no-typescript-assertion, local-rules/prefer-custom-object-entries
Object.entries(object);
/**
* Converts an array of key-value pairs into an object.
* This is a type-faithful alternative to Object.fromEntries().
*
* @param {TEntries} entries - The array of key-value pairs to convert.
* @template TEntries - The type of the entries array.
*/
const objectFromEntries = (entries) => {
// eslint-disable-next-line local-rules/no-typescript-assertion, local-rules/prefer-custom-object-from-entries
return Object.fromEntries(entries);
};
/**
* Returns an array of the **correctly typed** keys of a given object.
* This is a type-faithful alternative to Object.keys().
*
* This function uses the `Object.keys()` method to get an array of the object's keys,
* and then casts each key to `keyof TObject` to ensure TypeScript understands the keys are of the correct type.
* Uses the `Object.keys()` to get an array of the object's keys,
* and then casts each key to `keyof TObject`
*
* See https://stackoverflow.com/a/76176570
*
* @template TObject - The type of the object.

@@ -240,5 +272,19 @@ * @param {TObject} object - The object to get the keys from.

const objectKeys = (object) => {
// eslint-disable-next-line local-rules/no-typescript-assertion
// eslint-disable-next-line local-rules/no-typescript-assertion, local-rules/prefer-custom-object-keys
return Object.keys(object).map(key => key);
};
/**
* Returns an array of the **correctly typed** values of a given object.
* This is a type-faithful alternative to Object.values().
*
* Uses the `Object.values()` to get an array of the object's values,
* and then casts each value to `TObject[keyof TObject]`
*
* @template TObject - The type of the object.
* @param {TObject} object - The object to get the values from.
* @returns {TObject[keyof TObject][]} An array of the values of the object.
*/
const objectValues = (object) =>
// eslint-disable-next-line local-rules/no-typescript-assertion, local-rules/prefer-custom-object-values
Object.values(object);

@@ -993,2 +1039,2 @@ /** toggle whether a value is in an array or not */

export { DateTimeFormat, HoursAndMinutesFormat, align, arrayLengthCompare, arrayNotEmpty, booleanCompare, capitalize, convertBlobToBase64, convertMetersToYards, convertYardsToMeters, dateCompare, deleteUndefinedKeys, difference, doNothing, ensureArray, enumFromValue, enumFromValueTypesafe, enumOrUndefinedFromValue, exhaustiveCheck, filterByMultiple, formatAddress, formatCoordinates, fuzzySearch, getDifferenceBetweenDates, getEndOfDay, getISOStringFromDate, getMultipleCoordinatesFromGeoJsonObject, getPointCoordinateFromGeoJsonObject, getResizedDimensions, getStartOfDay, groupBy, groupTinyDataToOthers, hourIntervals, intersection, isStringArrayEqual, isUUID, isValidImage, nonNullable, numberCompare, numberCompareUnknownAfterHighest, objNotEmpty, objectKeys, pick, removeLeftPadding, resizeBlob, resizeImage, size, stringCompare, stringCompareFromKey, stringNaturalCompare, titleCase, toID, toIDs, toUUID, toggle, trimIds, trimPath, truthy, unionArraysByKey };
export { DateTimeFormat, HoursAndMinutesFormat, align, arrayLengthCompare, arrayNotEmpty, booleanCompare, capitalize, convertBlobToBase64, convertMetersToYards, convertYardsToMeters, dateCompare, deleteUndefinedKeys, difference, doNothing, ensureArray, enumFromValue, enumFromValueTypesafe, enumOrUndefinedFromValue, exhaustiveCheck, filterByMultiple, formatAddress, formatCoordinates, fuzzySearch, getDifferenceBetweenDates, getEndOfDay, getISOStringFromDate, getMultipleCoordinatesFromGeoJsonObject, getPointCoordinateFromGeoJsonObject, getResizedDimensions, getStartOfDay, groupBy, groupTinyDataToOthers, hourIntervals, intersection, isStringArrayEqual, isUUID, isValidImage, nonNullable, numberCompare, numberCompareUnknownAfterHighest, objNotEmpty, objectEntries, objectFromEntries, objectKeys, objectValues, pick, removeLeftPadding, resizeBlob, resizeImage, size, stringCompare, stringCompareFromKey, stringNaturalCompare, titleCase, toID, toIDs, toUUID, toggle, trimIds, trimPath, truthy, unionArraysByKey };

2

package.json
{
"name": "@trackunit/shared-utils",
"version": "0.0.48",
"version": "0.0.49",
"repository": "https://github.com/Trackunit/manager",

@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE.txt",

@@ -51,7 +51,51 @@ /**

/**
* Represents a type that makes all properties of a given type optional recursively.
* This is useful for creating types that can accept partial data structures,
* where some fields may be omitted.
*
* @template TObject - The original type whose properties should be made optional.
* @example
* // Usage:
* type PartialUser = DeepPartial<User>;
* const user: PartialUser = { name: 'John' }; // Only 'name' is required.
*/
export type DeepPartial<TObject> = TObject extends Record<PropertyKey, unknown> ? {
[Key in keyof TObject]?: DeepPartial<TObject[Key]>;
} : TObject;
type Entries<TObject> = {
[Key in keyof TObject]: [Key, TObject[Key]];
}[keyof TObject][];
type KeyValueTupleToObject<TEntries extends readonly (readonly [PropertyKey, unknown])[]> = {
[Key in TEntries[number] as Key[0]]: Key[1];
};
/**
* Converts an object into an array of properly typed key-value pairs.
* This is a type-faithful alternative to Object.entries().
*
* Uses the `Object.entries()` to get an array of the object's key-value pairs,
* and then casts each key-value pair to `[keyof TObject, TObject[keyof TObject]]`
*
* See https://stackoverflow.com/a/76176570
*
* @param {TObject} object - The object to convert.
* @template TObject - The type of the object.
*/
export declare const objectEntries: <TObject extends Record<PropertyKey, unknown>>(object: TObject) => Entries<TObject>;
/**
* Converts an array of key-value pairs into an object.
* This is a type-faithful alternative to Object.fromEntries().
*
* @param {TEntries} entries - The array of key-value pairs to convert.
* @template TEntries - The type of the entries array.
*/
export declare const objectFromEntries: <const TEntries extends readonly (readonly [PropertyKey, unknown])[]>(entries: TEntries) => KeyValueTupleToObject<TEntries>;
/**
* Returns an array of the **correctly typed** keys of a given object.
* This is a type-faithful alternative to Object.keys().
*
* This function uses the `Object.keys()` method to get an array of the object's keys,
* and then casts each key to `keyof TObject` to ensure TypeScript understands the keys are of the correct type.
* Uses the `Object.keys()` to get an array of the object's keys,
* and then casts each key to `keyof TObject`
*
* See https://stackoverflow.com/a/76176570
*
* @template TObject - The type of the object.

@@ -61,3 +105,15 @@ * @param {TObject} object - The object to get the keys from.

*/
export declare const objectKeys: <TObject extends object>(object: TObject) => (keyof TObject)[];
export declare const objectKeys: <TObject extends Record<PropertyKey, unknown>>(object: TObject) => (keyof TObject)[];
/**
* Returns an array of the **correctly typed** values of a given object.
* This is a type-faithful alternative to Object.values().
*
* Uses the `Object.values()` to get an array of the object's values,
* and then casts each value to `TObject[keyof TObject]`
*
* @template TObject - The type of the object.
* @param {TObject} object - The object to get the values from.
* @returns {TObject[keyof TObject][]} An array of the values of the object.
*/
export declare const objectValues: <TObject extends Record<PropertyKey, unknown>>(object: TObject) => TObject[keyof TObject][];
export {};
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