Skip to content

moxie.core.utils.Basic

Davit Barbakadze edited this page Aug 5, 2017 · 1 revision

Important! This page is auto-generated from the comments in the source files. All changes will be overwritten! If you are looking to contribute, modify the comment in the corresponding source file instead.

Module: moxie.core.utils.Basic

Table of Contents

Methods

typeOf(o) static

Gets the true type of the built-in object (better version of typeof).

Arguments

  • o Object
    Object to check.

Extends the specified object with another object(s).

Arguments

  • target Object
    Object to extend.
  • [obj] Object
    Multiple objects to extend with.

Extends the specified object with another object(s), but only if the property exists in the target.

Arguments

  • target Object
    Object to extend.
  • [obj] Object
    Multiple objects to extend with.

A way to inherit one class from another in a consisstent way (more or less)

Arguments

  • child Function

  • parent Function

Executes the callback function for each item in array/object. If you return false in the callback it will break the loop.

Arguments

  • obj Object
    Object to iterate.
  • callback Function
    Callback function to execute for each item.

isEmptyObj(o) static

Checks if object is empty.

Arguments

  • o Object
    Object to check.

Recieve an array of functions (usually async) to call in sequence, each function receives a callback as first argument that it should call, when it completes. Finally, after everything is complete, main callback is called. Passing truthy value to the callback as a first argument will interrupt the sequence and invoke main callback immediately.

Arguments

  • queue Array
    Array of functions to call in sequence
  • cb Function
    Main callback that is called in the end, or in case of error

Recieve an array of functions (usually async) to call in parallel, each function receives a callback as first argument that it should call, when it completes. After everything is complete, main callback is called. Passing truthy value to the callback as a first argument will interrupt the process and invoke main callback immediately.

Arguments

  • queue Array
    Array of functions to call in sequence
  • cb Function
    Main callback that is called in the end, or in case of erro

Find an element in array and return it's index if present, otherwise return -1.

Arguments

  • needle Mixed
    Element to find
  • array Array

toArray(obj) static

Forces anything into an array.

Arguments

  • obj Object
    Object with length field.

guid(prefix) static

Generates an unique ID. The only way a user would be able to get the same ID is if the two persons at the same exact millisecond manage to get the same 5 random numbers between 0-65535; it also uses a counter so each ID is guaranteed to be unique for the given page. It is more probable for the earth to be hit with an asteroid.

Arguments

  • prefix String
    to prepend (by default 'o' will be prepended).

trim(str) static

Trims white spaces around the string

Arguments

  • str String

Parses the specified size string into a byte value. For example 10kb becomes 10240.

Arguments

  • size String/Number
    String to parse or number to just pass through.