Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@ditojs/utils

Package Overview
Dependencies
Maintainers
2
Versions
424
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ditojs/utils - npm Package Compare versions

Comparing version
2.78.0
to
2.79.0
+2
-2
package.json
{
"name": "@ditojs/utils",
"version": "2.78.0",
"version": "2.79.0",
"type": "module",

@@ -42,3 +42,3 @@ "description": "Dito.js Utility Functions – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",

},
"gitHead": "ede4c836e6b2bb5dfcc80e1614a3d85eb80b0efa"
"gitHead": "f87ce5ce121a30830776774cd447014afef5b8ec"
}

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

export * from './asCallback.js'
export * from './clone.js'

@@ -3,0 +2,0 @@ export * from './equals.js'

@@ -145,5 +145,12 @@ // Type definitions for Dito.js utils

// TODO: document groupBy
/**
* Groups items in a collection by a key returned from the callback function,
* or by a property name when a string is provided.
*/
export function groupBy<T, K extends keyof T>(
collection: T[] | Record<string, T>,
callback: K
): Record<string, T[]>
export function groupBy<T, K extends string | number | symbol>(
list: T[],
collection: T[] | Record<string, T>,
callback: (item: T) => K

@@ -221,6 +228,12 @@ ): Record<K, T[]>

* Creates an object composed of the object properties predicate returns
* truthy for.
* truthy for. When a string is provided, filters by the truthiness of that
* property on each value.
* @param object The source object.
* @param callback Callback invoked with three arguments: (value, key, item).
* @param callback Callback invoked with three arguments: (value, key, item),
* or a property name string to check for truthiness.
*/
export function pickBy<T extends Dictionary<any>, K extends keyof T[keyof T]>(
object: T,
callback: K
): Partial<T>
export function pickBy<T extends Dictionary<any>>(

@@ -236,2 +249,13 @@ object: T,

/**
* Maps the values of an object using a callback function, or extracts a
* property when a string is provided.
*/
export function mapValues<
T extends Dictionary<any>,
K extends keyof T[keyof T]
>(
object: T,
callback: K
): Record<keyof T, T[keyof T][K]>
export function mapValues<T extends Dictionary<any>, K>(

@@ -296,5 +320,9 @@ object: T,

strings: OrArrayOf<string>,
...values: Array<string>
...values: Array<any>
): string
/**
* Escapes special characters in a string for use in a regular expression.
*/
export function escapeRegexp(string: string): string
/**
* Returns the longest prefix string that is common to the supplied strings.

@@ -322,2 +350,7 @@ */

/**
* Determines whether the supplied string is a valid domain name.
* Supports internationalized domain names with punycode.
*/
export function isDomain(str: string): boolean
/**
* Determines whether the supplied string is a valid email address.

@@ -427,5 +460,34 @@ */

): string
/**
* Formats a date value as a string. If the value is not a Date,
* attempts to convert it to a Date first.
*/
export function formatDate(
value: any,
options?: {
/**
* @default 'en-US'
*/
locale?: string
/**
* @default true
*/
date?: boolean | DateFormat
/**
* @default true
*/
time?: boolean | TimeFormat
}
): string
/* -------------------------------- function -------------------------------- */
/**
* Logs a deprecation warning message to the console. Each unique message
* is only logged once.
*
* @param message The deprecation message to log.
*/
export function deprecate(message: string): void
/**
* Creates a debounced function that delays invoking func until after wait

@@ -680,2 +742,17 @@ * milliseconds have elapsed since the last time the debounced function was

/**
* Gets entries at a data path, supporting wildcards (* and **).
* Wildcard * matches direct children, ** matches recursively.
*
* @param obj The object to query.
* @param path The data path (supports wildcards).
* @param handleError Optional error handler called when path is invalid.
* @returns Object with normalized paths as keys and values at those paths.
*/
export function getEntriesAtDataPath(
obj: any,
path: OrArrayOf<string>,
handleError?: (obj: any, part: string, index: number) => any
): Record<string, any>
export function getValueAtDataPath(

@@ -691,2 +768,14 @@ obj: any,

/**
* Sets multiple values at data paths from an entries object.
*
* @param obj The object to modify.
* @param entries Object with data paths as keys and values to set.
* @returns The modified object.
*/
export function setDataPathEntries<O>(
obj: O,
entries: Record<string, any>
): O
export function setValueAtDataPath<O>(

@@ -698,2 +787,15 @@ obj: O,

/* --------------------------------- class ---------------------------------- */
/**
* Creates a mixin decorator that applies a mixin function to a class.
* Prevents duplicate application of the same mixin in the inheritance chain.
*
* @param mixinFunction Function that takes a class and returns a mixed class.
* @returns Decorator function that applies the mixin to a target class.
*/
export function mixin<T extends new (...args: any[]) => any>(
mixinFunction: (targetClass: T) => T
): (targetClass: T) => T
/* ---------------------------------- html ---------------------------------- */

@@ -700,0 +802,0 @@