StructureJS

0.15.2

A class based utility library for building modular and scalable web platform applications. Features opt-in classes and utilities which provide a solid foundation and toolset to build your next project.

Util Class

Defined in: ts/util/Util.ts:1
Module: util
Parent Module: StructureJS

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

Index

Show:

Properties

Methods

Properties

_idCounter Int private static

Defined in ts/util/Util.ts:12

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 ts/util/Util.ts:311

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 ts/util/Util.ts:129

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 ts/util/Util.ts:257

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 ts/util/Util.ts:56

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 ts/util/Util.ts:215

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 ts/util/Util.ts:100

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 ts/util/Util.ts:190

Converts a string or number to a boolean.

Parameters:

Returns:

Example:

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

 Util.toBoolean(0);
 // false

 Util.toBoolean(undefined);
 // false

unique
(
  • list
)
Array protected

Defined in ts/util/Util.ts:349

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 ts/util/Util.ts:27

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