Perchance Methods

This is a list of Perchance methods (properties) that are usually used to manipulate the output, lists, and texts generated.

### `consumableList`

Creates a list which depletes and ensures unique returns. (see Unique Selections - consumableList)

```
list
    a
    b
    c

output
    [x = list.consumableList] [x] [x] [x]
    // output:
    // a b c (no more items in the consumable 'list' list)

```

### `createClone`

Creates a clone of a list.

```
list
    a
    b
    c

output
    [x = list.createClone, ""] [x.getRawListText]
    // output: list a b c

```

### `evaluateItem`

Evaluates the output and the variables. To know what "evaluate" means in Perchance, see Shorthand Lists.

```
list
    a
    b
    c

item
    [list] {0-10}

output
    [x = item.evaluateItem, ""] [x]
    // example output: a 4

```

### `futureTense`

Changes the word (if possible) to future tense.

```
verb
    fly

output
    [x = verb.selectOne] | [x.futureTense]
    // output: fly | will fly

```

### `getChildNames`

Gets the "Child" names on a list (used mostly in Hierarchical Lists)

```
list
    a
        aa
        ab
        ac
    b
        ba
    c
        ca

output
    [list.getChildNames.joinItems(", ")] | [list.a.getChildNames.joinItems(", ")]
    // output:
    // a, b, c | aa, ab, ac

```

### `getFunctionNames`

Get the function names in a list, or object.

```
object
    functionOne() => return;
    functionTwo() => return;
    propertyOne = "one"
    propertyTwo = "two"

output
    [object.getFunctionNames.joinItems(", ")]
    // output:
    // functionOne, functionTwo

```

### `getLength`

Gets the length of the list.

```
list
    a
        aa
        ab
        ac
        ad
    b
        ba
    c
        ca

output
    [list.getLength], [list.a.getLength]
    // output: 3, 4

```

### `getName`

Gets the name of the list

```
list
    a
        aa
        ab
        ac
        ad
    b
        ba
    c
        ca

output
    [list.getName], [list.a.getName]
    // output: list, a

```

### `getOdds`

Gets the odds of the selected item from a list.

```
animal
    pig
    cow
    chicken
    zebra
    crayfish
    jellyfish^0.5  // this item is HALF as likely as the others
    worm^2         // this item is TWICE as likely as the others

output
    [x = animal.selectOne] [x.getOdds]
    // output:
    // worm 2
    // jellyfish 0.5
    // pig 1

```

### `getParent`

Gets the parents on a hierarchical list.

```
list
    a
        aa
        ab
        ac
        ad
    b
        ba
    c
        ca

output
    [x = list.a], [x.getParent]

```
`list` has three children: `a, b,` and `c`. `a` has four children, `aa, ab, ac,` and `ad`. The parent of `list.a` is `list`, which is why the output is `a,b,c`.

NoteConsider this example:

```
 [x = list.a] // this will evaluate to {aa|ab|ac|ad} or 'list.a'

```

This is the normal behavior of hierarchical lists in which it evaluates the items **within** `list.a`. Now consider the following:

```
 [x.getParent] // this evaluates to {a|b|c} or 'list'

```

Using the `getParent` method to `x` or `list.a` it will evaluate either `a, b, or c` since the parent of `list.a` is `list`. Now to get the **parent** of the item in `list.a`, for example `aa`:

```
 [x.getName] // this will evaluate to 'a' since 'x' is an alias to 'list.a' and getName of 'list.a' is 'a'

```

We can use the `getName` method to get the *name* of the *parent* of `aa` which will be `a`, this is the actual parent, but it cannot be accessed as a list since it is only a string. To get the **parent** of `a`:

```
 [x.getParent.getName] // this will evaluate to 'list' since 'x' is an alias to 'list.a', getParent of 'list.a' is 'list' and getName of 'list' is 'list'

```

We can use the combination of `getParent` and `getName` where `getParent` evaluates to `list` and using `getName` will return `list`.
### `getPropertyKeys`

Gets the names (keys) of the properties on the list (object).

```
object
    functionOne() => return;
    functionTwo() => return;
    propertyOne = "one"
    propertyTwo = "two"

output
    [object.getPropertyKeys.joinItems(", ")]
    // output:
    // propertyOne, propertyTwo

```

### `getRawListText`

Gets the "Raw" list text of the list.

```
list
    a
        aa
        ab
        ac
        ad
    b
        ba
    c
        ca

output
    [list.getRawListText]
    // output:
    // list a aa aaa ab ac ad b ba c ca

```

### `getSelf`

Similar to `getChildNames`.

```
list
    a
        aa
        ab
        ac
    b
        ba
    c
        ca

output
    [list.getSelf.joinItems(", ")] | [list.a.getSelf.joinItems(", ")]
    // output:
    // a, b, c | aa, ab, ac

```

### `joinItems`

Joins the items in an array in a single line. (the list must be an array or has multiple selections i.e. `selectMany, selectAll, selectUnique, sumItems, getChildNames, getSelf, consumableList, getPropertyKeys, getFunctionNames`). (see Repeating Things).

```
list
    a
        aa
        ab
        ac
    b
        ba
    c
        ca

output
    [list.joinItems(", ")] | [list.a.joinItems(", ")]
    // output:
    // a, b, c | aa, ab, ac

```

### `lowerCase`

Lowercases the text.

```
animal
    Pig
    Cow
    Chicken
    Zebra
    Crayfish
    Jellyfish^0.5  // this item is HALF as likely as the others
    Worm^2         // this item is TWICE as likely as the others

output
    [x = animal.selectOne], [x.lowerCase]
    // output:
    // Worm worm

```

### `negativeForm`

Sets the verb to a negative form (if possible).

```
verb
    examine

output
    [x = verb.selectOne] | [x.negativeForm]
    // output: examine | does not examine

```

### `pastTense`

Sets the verb to a past tense (if possible).

```
verb
    mend

output
    [x = verb.selectOne] | [x.pastTense]
    // output: mend | mended

```

### `pluralForm`

Sets the noun to plural form (if possible).

```
noun
    biography

output
    [x = noun.selectOne] | [x.pluralForm]
    // output: biography | biographies

```

### `presentTense`

Sets the verb to present tense (if possible).

```
verb
    dry

output
    [x = verb.selectOne] | [x.presentTense]
    // output: dry | dries

```

### `replaceText`

Replaces the indicated text with the replacement text (matching is Case Sensitive).

```
text
    Hello World!

output
    [text] [text.replaceText("Hello", "Goodbye")]
    // output: Hello World! | Goodbye World!

```

### `selectAll`

Selects/Returns all the evaluated items in the list in one line and an array.

```
list
    a
        aa
            aaa
        ab
        ac
    b
        ba
    c
        ca

output
    [list.selectAll.joinItems(", ")] | [list.a.selectAll.joinItems(", ")]
    // output:
    // [a], [b], [c] | [aa], [ab], [ac]
    // where [a] = {aa|ab|ac}
    //       [b] = ba
    //       [c] = ca
    //       [aa] = aaa
    //       [ab] = ab
    //       [ac] = ac
    // example:
    // aa, ba, ca | aaa, ab, ac

```

### `selectMany`

Selects/Returns specified number of evaluated items with repetition in one line and an array. (see Repeating Things).

```
list
    a
        aa
            aaa
        ab
        ac
    b
        ba
    c
        ca

output
    [list.selectMany(3).joinItems(", ")] | [list.a.selectMany(3).joinItems(", ")]
    // output:
    // where [a] = {aa|ab|ac}
    //       [b] = ba
    //       [c] = ca
    //       [aa] = aaa
    //       [ab] = ab
    //       [ac] = ac
    // example:
    // aa, ba, ac | aaa, ab, aaa

```

### `selectOne`

Selects/Returns **one** evaluated item from the list.

```
list
    a
        aa
            aaa
        ab
        ac
    b
        ba
    c
        ca

output
    [list.selectOne]
    // output:
    // {[a]|[b]|[c]}
    // where [a] = {[aa]|ab|ac}
    //       [b] = ba
    //       [c] = ca
    //       [aa] = aaa
    // example:
    // aaa
    // ba
    // ac
    // ca

```

### `selectUnique`

Selects/Returns specified number of evaluated items **without** repetition (like a `consumableList`) in one line and an array. (see Repeating Things).

```
list
    a
        aa
            aaa
        ab
        ac
    b
        ba
    c
        ca

output
    [list.selectUnique(3).joinItems(", ")] | [list.a.selectUnique(3).joinItems(", ")]
    // output:
    // where [a] = {aa|ab|ac}
    //       [b] = ba
    //       [c] = ca
    //       [aa] = aaa
    //       [ab] = ab
    //       [ac] = ac
    // example:
    // ca, aa, ba | aaa, ab, ad

```

### `sentenceCase`

Sets the text to have capitalized first letter just like sentences.

```
text
    the quick brown fox jumps over the lazy dog. hello world.

output
    [text] <br> [text.sentenceCase]
    // output:
    // the quick brown fox jumps over the lazy dog. hello world.
    // The quick brown fox jumps over the lazy dog. Hello world.

```

### `singularForm`

Sets the noun to be in singular form (if possible).

```
noun
    discoveries

output
    [x = noun.selectOne] | [x.singularForm]
    // output: discoveries | discovery

```

### `sumItems`

Gets the (possible) sum of items.

```
list
    a
        aa
            aaa
        ab
        ac
    b
        ba
    c
        ca

numbers
    1
    2
    3
    4

output
    [list.sumItems] | [numbers.sumItems]
    // output:
    // 0[a][b][c] | 10
    // where [a] = {aa|ab|ac}
    //       [b] = ba
    //       [c] = ca
    // example:
    // 0aabaca | 10

```

### `titleCase`

Capitalizes each word in the text like a title (for a better improved version of this checkout title-case-plugin).

```
text
    the quick brown fox jumps over the lazy dog. hello world.

output
    [text] <br> [text.titleCase]
    // output:
    // the quick brown fox jumps over the lazy dog. hello world.
    // The Quick Brown Fox Jumps Over The Lazy Dog. Hello World.

```

### `toLocaleString`

A Javascript property for Dates and Numbers, check this documentation for date, for number, for how to use the function.

```
text
    499.99

output
    [text] | [text.toLocaleString("en-US", { style: "currency", currency: "USD" })]
    // output:
    // 499.99 | $ 499.99

```

### `toString`

A Javascript property for converting types to string.

```
text
    10

output
    [text] [text+1] | [x = text.toString()] [x+1]
    // output:
    // 10 11 | 10 101

```

### `upperCase`

Uppercases the text

```
animal
    Pig
    Cow
    Chicken
    Zebra
    Crayfish
    Jellyfish^0.5  // this item is HALF as likely as the others
    Worm^2         // this item is TWICE as likely as the others

output
    [x = animal.selectOne], [x.upperCase]
    // output:
    // Worm WORM

```

### `valueOf`

Gets the value of the specified property or the 'evaluated' string of a list.

```
object
    functionOne() => return;
    functionTwo() => return;
    propertyOne = "one"
    propertyTwo = "two"

output
    [object.propertyOne.valueOf()] [object.propertyTwo.valueOf()]
    // output:
    // "one" "two"

```

Note

* You can use the conjugate-plugin for less common tenses like gerund, actor and infinitive.
* You might also like the plural-plugin, which allows you to add custom plurals, and the be-plugin, which automatically chooses is/are/was/were based on the preceding pronoun.