# Mixin: Common

## Common

Provides commonly used methods to most classes in ForerunnerDB.

Source:
  - Mixin.Common.js, line 31

### Methods

- (static) checksum(str) → {Number}
- (static) classIdentifier() → {String}
- (static) convertToFdb(obj)
- (static) debounce(id, callback, timeout)
- (static) decouple(data, copiesopt) → {*}
- (static) hash(obj) → {String}
- (static) instanceIdentifier() → {String}
- (static) isDropped() → {boolean}
- (static) jParse(data) → {Object}
- (static) logIdentifier() → {String}
- (static) make(val)
- (static) objectId(stropt) → {String}
- (static) store(key, valopt) → {*}
- (static) unStore(key) → {Common}

#### (static) checksum(str) → {Number}

Returns a checksum of a string.

##### Parameters:

Name | Type | Description
--- | --- | ---
`str` | String | The string to checksum.

Source:
  - Mixin.Common.js, line 342

##### Returns:

The checksum generated.

Type
  Number

#### (static) classIdentifier() → {String}

Returns a string describing the class this instance is derived from.

Source:
  - Mixin.Common.js, line 231

##### Returns:

Type
  String

#### (static) convertToFdb(obj)

Converts a query object with MongoDB dot notation syntax to Forerunner's object notation syntax.

##### Parameters:

Name | Type | Description
--- | --- | ---
`obj` | Object | The object to convert.

Source:
  - Mixin.Common.js, line 258

#### (static) debounce(id, callback, timeout)

Registers a timed callback that will overwrite itself if the same id is used within the timeout period. Useful for de-bouncing fast-calls.

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | An ID for the call (use the same one to debounce the same calls).
`callback` | function | The callback method to call on timeout.
`timeout` | Number | The timeout in milliseconds before the callback is called.

Source:
  - Mixin.Common.js, line 311

#### (static) decouple(data, copiesopt) → {*}

Returns a non-referenced version of the passed object / array.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`data` | Object |  | The object or array to return as a non-referenced version.
`copies` | Number | <optional> | Optional number of copies to produce. If specified, the return value will be an array of decoupled objects, each distinct from the other.

Source:
  - Mixin.Common.js, line 97

##### Returns:

Type
  *

#### (static) hash(obj) → {String}

Generates a unique hash for the passed object.

##### Parameters:

Name | Type | Description
--- | --- | ---
`obj` | Object | The object to generate a hash for.

Source:
  - Mixin.Common.js, line 174

##### Returns:

Type
  String

#### (static) instanceIdentifier() → {String}

Returns a string describing the instance by it's class name and instance object name.

Source:
  - Mixin.Common.js, line 240

##### Returns:

The instance identifier.

Type
  String

#### (static) isDropped() → {boolean}

Checks if the state is dropped.

Source:
  - Mixin.Common.js, line 296

##### Returns:

True when dropped, false otherwise.

Type
  boolean

#### (static) jParse(data) → {Object}

Parses and returns data from stringified version.

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | String | The stringified version of data to parse.

Source:
  - Mixin.Common.js, line 122

##### Returns:

The parsed JSON object from the data.

Type
  Object

#### (static) logIdentifier() → {String}

Returns a string used to denote a console log against this instance, consisting of the class identifier and instance identifier.

Source:
  - Mixin.Common.js, line 249

##### Returns:

The log identifier.

Type
  String

#### (static) make(val)

Generates a JSON serialisation-compatible object instance. After the instance has been passed through this method, it will be able to survive a JSON.stringify() and JSON.parse() cycle and still end up as an instance at the end. Further information about this process can be found in the ForerunnerDB wiki at: https://github.com/Irrelon/ForerunnerDB/wiki/Serialiser-&-Performance-Benchmarks

##### Parameters:

Name | Type | Description
--- | --- | ---
`val` | * | The object instance such as "new Date()" or "new RegExp()".

Source:
  - Mixin.Common.js, line 43

#### (static) objectId(stropt) → {String}

Generates a new 16-character hexadecimal unique ID or generates a new 16-character hexadecimal ID based on the passed string. Will always generate the same ID for the same string.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`str` | String | <optional> | A string to generate the ID from.

Source:
  - Mixin.Common.js, line 141

##### Returns:

Type
  String

#### (static) store(key, valopt) → {*}

Gets / sets data in the item store. The store can be used to set and retrieve data against a key. Useful for adding arbitrary key/value data to a collection / view etc and retrieving it later.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`key` | String | * |  | The key under which to store the passed value or retrieve the existing stored value.
`val` | * | <optional> | Optional value. If passed will overwrite the existing value stored against the specified key if one currently exists.

Source:
  - Mixin.Common.js, line 58

##### Returns:

Type
  *

#### (static) unStore(key) → {Common}

Removes a previously stored key/value pair from the item store, set previously by using the store() method.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | String | * | The key of the key/value pair to remove;

Source:
  - Mixin.Common.js, line 82

##### Returns:

Returns this for chaining.

Type
  Common

### Members

- (static) debug
- (static) jStringify

#### (static) debug

Sets debug flag for a particular type that can enable debug message output to the console if required.

Source:
  - Mixin.Common.js, line 191

#### (static) jStringify

Converts a JSON object into a stringified version.

Source:
  - Mixin.Common.js, line 131