Journal

Journal

The Journal collection

Constructor

new Journal()

Source:

Extends

Members

_source :Array

Source:
Inherited From:

The source data is, itself, a mapping of IDs to data objects

Type:

apps :Array

Source:
Inherited From:

An Array of application references which will be automatically updated when the collection content changes

Type:

directory :SidebarDirectory|null

Source:
Inherited From:

Return a reference to the SidebarDirectory application for this EntityCollection, or null if it has not yet been created.

Type:

entity :string

Source:
Inherited From:

Return a reference to the base Entity name which is contained within this EntityCollection.

Type:
  • string

entries

Source:
Inherited From:

Return an Array of all the entry values in the Collection

name :string

Source:
Inherited From:

The EntityCollection name

Type:
  • string

Methods

filter(condition) → {Array.<V>}

Source:
Inherited From:
See:
  • {Array#filter}

Filter the Collection, returning an Array of entries which match a functional condition.

Example
let c = new Collection([["a", "AA"], ["b", "AB"], ["c", "CC"]]);
let hasA = c.filters(entry => entry.slice(0) === "A");
Parameters:
Name Type Description
condition function

The functional condition to test

Returns:

An Array of matched values

Type
Array.<V>

find(condition) → {V|null}

Source:
Inherited From:
See:
  • {Array#find}

Find an entry in the Map using an functional condition.

Example
let c = new Collection([["a", "A"], ["b", "B"], ["c", "C"]]);
let a = c.find(entry => entry === "A");
Parameters:
Name Type Description
condition function

The functional condition to test

Returns:

The value, if found, otherwise null

Type
V | null

get(key, strict) → {V|null}

Source:
Inherited From:

Get an element from the Collection by its key.

Example
let c = new Collection([["a", "A"], ["b", "B"], ["c", "C"]]);
c.get("a"); // "A"
c.get("d"); // null
c.get("d", {strict: true}); // throws Error
Parameters:
Name Type Description
key string

The key of the entry to retrieve

strict boolean

Throw an Error if the requested id does not exist, otherwise return null. Default false

Returns:

The retrieved entry value, if the key exists, otherwise null

Type
V | null

getName(name, strict) → {Entity|null}

Source:
Inherited From:

Get an Entity from the EntityCollection by name

Parameters:
Name Type Description
name string

The name of the Entity to retrieve

strict boolean

Throw an Error if the requested id does not exist, otherwise return null. Default false.

Returns:

The retrieved Entity, if one was found, otherwise null;

Type
Entity | null

(async) importFromCollection(collection, entryId, updateDataopt, optionsopt) → {Promise.<Entity>}

Source:
Inherited From:

Import an Entity from a compendium collection, adding it to the current World.

Parameters:
Name Type Attributes Description
collection string

The name of the pack from which to import

entryId string

The ID of the compendium entry to import

updateData Object <optional>

Optional additional data used to modify the imported Entity before it is created

options Object <optional>

Optional arguments passed to the Entity.create method

Returns:

A Promise containing the imported Entity

Type
Promise.<Entity>

insert(entity)

Source:
Inherited From:

Add a new Entity to the EntityCollection, asserting that they are of the correct type.

Parameters:
Name Type Description
entity Entity

The entity instance to add to the collection

map(transformer) → {Array.<V>}

Source:
Inherited From:

Transform each element of the Collection into a new form, returning an Array of transformed values

Parameters:
Name Type Description
transformer function

The transformation function to apply to each entry value

Returns:

An Array of transformed values

Type
Array.<V>

reduce(evaluator, initial) → {any}

Source:
Inherited From:
See:
  • {Array#reduce}

Reduce the Collection by applying an evaluator function and accumulating entries

Example
let c = new Collection([["a", "A"], ["b", "B"], ["c", "C"]]);
let letters = c.reduce((s, l) => {
  return s + l;
}, ""); // "ABC"
Parameters:
Name Type Description
evaluator function

A function which mutates the accumulator each iteration

initial any

An initial value which accumulates with each iteration

Returns:

The accumulated result

Type
any

remove(id)

Source:
Inherited From:

Remove an Entity from the EntityCollection by its ID.

Parameters:
Name Type Description
id string

The entity ID which should be removed

render() → {this}

Source:
Inherited From:

Render any Applications associated with this EntityCollection

Returns:

A reference to the rendered EntityCollection

Type
this