Skip to main content

Core Utilities

Core utilities are a collection of platform-agnostic functions that can be used across all walkerOS environments. They provide standardized building blocks for data manipulation, validation, mapping, and more.

Installation

Import the core utilities directly from the @walkeros/core package:

Loading...

Data Manipulation

assign

assign<T, U>(target: T, source: U, options?): T & U merges two objects with advanced merging capabilities. It has special behavior for arrays: when merging, it concatenates arrays from both objects, removing duplicates.

Loading...

Path Operations

getByPath

getByPath(object: unknown, path: string, defaultValue?: unknown): unknown accesses nested properties using dot notation. Supports wildcard * for array iteration.

Loading...

setByPath

setByPath(object: WalkerOS.Event, path: string, value: unknown): WalkerOS.Event sets nested values using dot notation, returning a new object with the updated value.

Loading...

clone

clone<T>(original: T): T creates a deep copy of objects/arrays with circular reference handling.

Loading...

castValue

castValue(value: unknown): WalkerOS.PropertyType converts string values to appropriate types (number, boolean).

Loading...

Privacy & Security

anonymizeIP

anonymizeIP(ip: string): string anonymizes IPv4 addresses by setting the last octet to zero.

Loading...

Hashing

getId(length?: number): string generates random alphanumeric strings for unique identifiers.

Loading...

Event Processing

getMappingValue

getMappingValue(event: WalkerOS.Event, mapping: Mapping.Data, options?: Mapping.Options): Promise<WalkerOS.Property | undefined> extracts values from events using

mapping configurations.

Loading...

getMappingEvent

getMappingEvent(event: WalkerOS.PartialEvent, mapping?: Mapping.Rules): Promise<Mapping.Result> finds the appropriate mapping rule for an event.

Marketing & Analytics

getMarketingParameters

getMarketingParameters(url: URL, custom?: MarketingParameters): WalkerOS.Properties extracts UTM and click ID parameters from URLs.

Loading...

Type Validation

Type Checkers

A comprehensive set of type checking functions:

  • isString(value), isNumber(value), isBoolean(value)
  • isArray(value), isObject(value), isFunction(value)
  • isDefined(value), isSameType(a, b)
  • isPropertyType(value) - Checks if value is valid walkerOS property

Property Utilities

  • castToProperty(value) - Casts to valid property type
  • filterValues(object) - Filters object to valid properties only
  • isPropertyType(value) - Type guard for property validation

Request Handling

requestToData

requestToData(parameter: unknown): WalkerOS.AnyObject | undefined converts query strings to JavaScript objects with type casting.

Loading...

requestToParameter

requestToParameter(data: WalkerOS.AnyObject): string converts objects to URL-encoded query strings.

Loading...

User Agent Parsing

parseUserAgent

parseUserAgent(userAgent?: string): WalkerOS.User extracts browser, OS, and device information.

Loading...

Individual functions are also available:

  • getBrowser(userAgent) - Returns browser name
  • getBrowserVersion(userAgent) - Returns browser version
  • getOS(userAgent) - Returns operating system
  • getOSVersion(userAgent) - Returns OS version
  • getDeviceType(userAgent) - Returns 'Desktop', 'Tablet', or 'Mobile'

Error Handling

tryCatch

tryCatch(tryFn: Function, catchFn?: Function, finallyFn?: Function) wraps functions with error handling.

Loading...

tryCatchAsync

tryCatchAsync(tryFn: Function, catchFn?: Function, finallyFn?: Function) for async operations.

Loading...

Performance Optimization

debounce

debounce(fn: Function, wait?: number) delays function execution until after the wait time.

Loading...

throttle

throttle(fn: Function, wait?: number) limits function execution frequency.

Loading...

Utilities

trim

trim(str: string): string removes whitespace from string ends.

throwError

throwError(message: string) throws descriptive errors.

onLog

onLog(message: unknown, verbose?: boolean) provides consistent logging.

Loading...

Validation

validateEvent

validateEvent(obj: unknown, customContracts?: Schema.Contracts): WalkerOS.Event | never validates event structure and throws on invalid events.

validateProperty

Validates that values conform to walkerOS property types.

For platform-specific utilities, see:

💡 Need Professional Support?
Need professional support with your walkerOS implementation? Check out our services.