# Global

##

### Methods

#### _extend()

  Extend function from jQuery 3

#### copy(target)

  Clone the properties of an object and its children (deep copy)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `target` | Object | Object to copy

  ##### Returns:

  Type
    Object

  ##### Example

      clonedObject = copy(target)

#### debounce(callback [, threshold] [, immediate])

  Debounce

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `callback` | function |  |  |
  `threshold` | Number | <optional> | 100 |
  `immediate` | Boolean | <optional> |  |

  ##### Returns:

  Type
    function

  ##### Example

      debouncedFunction = debounce( myFunction, 200 )

#### defer()

  Deferred promise

  ##### Returns:

  - a promise with a resolve and reject function
  Type
    Promise

  ##### Example

      let dfd = defer()

      // To resolve:
      dfd.resolve()

      // To reject:
      dfd.reject()

#### distance(latitude1, longitude1, latitude2, longitude2)

  Compute the distance (in km) between 2 coordinates

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `latitude1` | Number |
  `longitude1` | Number |
  `latitude2` | Number |
  `longitude2` | Number |

  ##### Returns:

  Type
    Number

#### extend(target, sources)

  Merge the properties of an object and its children (deep merge) with others objects. It doesn't modify the target object.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `target` | Object |  | Object to merge
  `sources` | Object | <repeatable> | All other arguments are objects

  ##### Returns:

  Type
    Object

  ##### Example

      extendedObject = extend(target, obj1, obj2)

#### getValue($input)

  Get the value of a form field (get from jQuery)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `$input` | HTMLElement |

  ##### Returns:

  - the value of the form field
  Type
    String | Number

  ##### Example

      value = getValue( $input )

#### hasLocalStorage()

  Check if the localstorage is available.

  ##### Returns:

  Type
    Boolean

  ##### Example

      hasStorage = hasLocalStorage();

#### sequence(promisesArray)

  Create a sequential list of promises (which resolves one after another)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `promisesArray` | Array.<Promise> |

  ##### Returns:

  Type
    Promise

  ##### Example

      prom = sequence( arrayOfPromise )

#### throttle(callback [, limit])

  Throttle

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `callback` | function |  |  |
  `limit` | Number | <optional> | 100 |

  ##### Returns:

  Type
    function

  ##### Example

      throttledFunction = throttle( cbFunction, 200 )

#### wait( [waitFor])

  Return a promise and wait for 'waitFor' millisecond to resolve it. If 'waitFor' < 0 => wait for an animation frame

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `waitFor` | Number | String | <optional> | -1 | Number in ms or 'idle'

  ##### Returns:

  - a promise with a .kill() function to cancel the waiting
  Type
    Promise

  ##### Example

      // Wait for an animation frame (using requestAnimationFrame)
      wait().then( ... )

      // Wait for 500ms
      wait( 500 ).then( ... )

      // Wait for an idle state
      wait( 'idle' ).then( ... )

      // To be able to cancel the waiting, don't chain .then() directly on wait()
      promise = wait( 500 )
      promise.then( ... )
      promise.kill()

#### Search results