# Util Class

Defined in: `js/util/Util.js:9`
Module: util
Parent Module: StructureJS

A Utility class that has several static methods to assist in development.

## Index

Show: Inherited Protected Private Deprecated

### Properties

- _idCounter static

### Methods

- applyMixins static
- clone static
- debounce static
- deletePropertyFromObject static
- getName static
- renamePropertyOnObject static
- toBoolean static
- unique
- uniqueId static

## Properties

### `_idCounter` Int private static

Defined in `js/util/Util.js:321`

Keeps track of the count for the uniqueId method.

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

## Methods

### `applyMixins`
(

- `derivedCtor`
- `baseCtors`

)
public static

Defined in `js/util/Util.js:268`

TODO: YUIDoc_comment

#### Parameters:

- `derivedCtor` Any
- `baseCtors` Any

#### Example:

               class Flies {
                   fly() {
                       alert('Is it a bird? Is it a plane?');
                   }
               }

               class Climbs {
                   climb() {
                       alert('My spider-sense is tingling.');
                   }
               }

               class HorseflyWoman implements Climbs, Flies {
                   climb: () => void;
                   fly: () => void;
               }

               Util.applyMixins(HorseflyWoman, [Climbs, Flies]);

### `clone`
(

- `obj`

)
Any public static

Defined in `js/util/Util.js:122`

Makes a clone of an object.

#### Parameters:

- `obj` Object

  The object you to clone.

#### Returns:

Any:

Returns a clone object of the one passed in.

#### Example:

     let cloneOfObject = Util.clone(obj);

### `debounce`
(

- `callback`
- `wait`
- `immediate`
- `callbackScope`

)
public static

Defined in `js/util/Util.js:229`

Creates and returns a new debounced version of the passed function which will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked.

#### Parameters:

- `callback` Function

  The function that should be executed.

- `wait` Number

  Milliseconds to elapsed before invoking the callback.

- `immediate` Boolean

  Pass true for the immediate parameter to cause debounce to trigger the function on the leading instead of the trailing edge of the wait interval. Useful in circumstances like preventing accidental double-clicks on a "submit" button from firing a second time.

- `callbackScope` Any

  The scope of the callback function that should be executed.

#### Example:

     Util.debounce(this._onBreakpointChange, 250, false, this);

### `deletePropertyFromObject`
(

- `object`
- `value`

)
Any public static

Defined in `js/util/Util.js:47`

Removes a list of properties from an object.

#### Parameters:

- `object` Object

  The object you want to remove properties from.

- `value` String | Array.

  A property name or an array of property names you want to remove from the object.

#### Returns:

Any:

Returns the object passed in without the removed the properties.

#### Example:

     let obj = { name: 'Robert', gender: 'male', phone: '555-555-5555' }

     Util.deletePropertyFromObject(obj, ['phone', 'gender']);

     // { name: 'Robert' }

### `getName`
(

- `classObject`

)
String static

Defined in `js/util/Util.js:189`

Returns the name of the function/object passed in.

#### Parameters:

- `classObject` Any

#### Returns:

String:

Returns the name of the function or object.

#### Example:

     let someClass = new SomeClass();
     Util.getName(someClass);            // 'SomeClass'

     Util.getName(function Test(){});    // 'Test'
     Util.getName(function (){});        // 'anonymous'

### `renamePropertyOnObject`
(

- `object`
- `oldName`
- `newName`

)
Any public static

Defined in `js/util/Util.js:97`

Renames a property name on an object.

#### Parameters:

- `object` Object

  The object you want to rename properties from.

- `oldName` String
- `newName` String

#### Returns:

Any:

Returns the object passed in renamed properties.

#### Example:

     let obj = { name: 'Robert', gender: 'male', phone: '555-555-5555' }

     Util.renamePropertyOnObject(obj, 'gender', 'sex');

     // { name: 'Robert', sex: 'male', phone: '555-555-5555' }

### `toBoolean`
(

- `strNum`

)
Boolean public static

Defined in `js/util/Util.js:167`

Converts a string or number to a boolean.

#### Parameters:

- `strNum` String | Number

#### Returns:

Boolean:

#### Example:

     Util.toBoolean("TRUE");
     // true

     Util.toBoolean(0);
     // false

     Util.toBoolean(undefined);
     // false

### `unique`
(

- `list`

)
Array protected

Defined in `js/util/Util.js:304`

Returns a new array with duplicates removed.

#### Parameters:

- `list` Array.

  The array you want to use to generate the unique array.

#### Returns:

Array:

Returns a new array list of unique items.

### `uniqueId`
(

- `[prefix]`

)
Init | String public static

Defined in `js/util/Util.js:22`

Generates a unique ID. If a prefix is passed in, the value will be appended to it.

#### Parameters:

- `[prefix]` String optional

  The string value used for the prefix.

#### Returns:

Init | String:

Returns the unique identifier.

#### Example:

     let property = Util.uniqueId();
     // 1

     let property = Util.uniqueId('prefixName_');
     // prefixName_1

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index