pronouny 0.1.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -34
- package/lib/cjs/index.d.ts +286 -241
- package/lib/cjs/index.js +515 -368
- package/lib/esm/index.d.ts +286 -241
- package/lib/esm/index.js +514 -367
- package/package.json +33 -33
package/README.md
CHANGED
|
@@ -1,54 +1,106 @@
|
|
|
1
1
|
# Pronouny
|
|
2
2
|
|
|
3
|
-
**Pronouny** is a typed library intended to make programmatically resolving English pronouns easier.
|
|
3
|
+
**Pronouny** is a typed library intended to make programmatically resolving English pronouns easier. \
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
To install, simply
|
|
7
|
+
To install, simply run `npm install pronouny`.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Usage
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
```ts
|
|
12
|
+
// Single import
|
|
13
|
+
import Pronouny from "pronouny";
|
|
14
|
+
|
|
15
|
+
// Create a new instance of Pronouny. All config is optional.
|
|
16
|
+
// Below are defaults.
|
|
17
|
+
const p = new Pronouny({
|
|
18
|
+
// Will default to failing quietly into "they".
|
|
19
|
+
failQuietly: true,
|
|
20
|
+
|
|
21
|
+
// Will default to only querying the first subject
|
|
22
|
+
// pronoun to limit scope. Set to "true" to force
|
|
23
|
+
// recursive search.
|
|
24
|
+
deepSearch: false,
|
|
25
|
+
|
|
26
|
+
// Will default to using random pronouns in arrays.
|
|
27
|
+
// Set to false to force using 0 index.
|
|
28
|
+
useRandom: true,
|
|
29
|
+
});
|
|
18
30
|
|
|
19
|
-
|
|
31
|
+
// Create a new Pronoun object using Pronouny.new()
|
|
32
|
+
const pronounZe: Pronoun = p.new(
|
|
33
|
+
{
|
|
34
|
+
subject: "ze",
|
|
35
|
+
object: "hir",
|
|
36
|
+
possessive: "hirs",
|
|
37
|
+
psAdjective: "hir",
|
|
38
|
+
reflexive: "hirself",
|
|
39
|
+
},
|
|
40
|
+
false
|
|
41
|
+
);
|
|
20
42
|
|
|
21
|
-
|
|
43
|
+
// .new() will automatically add new Pronouns to its
|
|
44
|
+
// validation map. however, if you want to do so manually,
|
|
45
|
+
// you can do it with Pronouny.add().
|
|
46
|
+
p.add(pronounZe);
|
|
22
47
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// Create a new instance of the Validate class
|
|
27
|
-
const pronounValidator = new Pronouny.Validate();
|
|
28
|
-
|
|
29
|
-
// Create a new Pronoun object for ze/hir pronouns
|
|
30
|
-
const pronounZe = new Pronouny.Pronoun({
|
|
31
|
-
subject: "ze",
|
|
32
|
-
object: "hir",
|
|
33
|
-
possessiveAdjective: "hir",
|
|
34
|
-
possessivePronoun: "hirs",
|
|
35
|
-
reflexive: "hirself",
|
|
36
|
-
});
|
|
48
|
+
// .remove() also works;
|
|
49
|
+
p.remove(p.resolve("I"));
|
|
50
|
+
// this deletes the "I" pronoun from the map.
|
|
37
51
|
|
|
38
|
-
//
|
|
39
|
-
|
|
52
|
+
// Methods are chainable and you can reach the Pronoun class.
|
|
53
|
+
p.add(pronounZe).set("he/they").use().subject();
|
|
54
|
+
// ^Pronouny ^PronounSet ^Pronoun ^string
|
|
40
55
|
|
|
41
|
-
//
|
|
56
|
+
// Instantiate a set of pronouns using Pronouny.set().
|
|
42
57
|
const vayne = {
|
|
43
|
-
username: vaynegarden,
|
|
44
|
-
pronouns:
|
|
58
|
+
username: "vaynegarden",
|
|
59
|
+
pronouns: p.set("she/ze/they"),
|
|
45
60
|
};
|
|
61
|
+
// from there, you can use `[PronounSet].use()` to get a random pronoun.
|
|
46
62
|
|
|
47
|
-
// Resolve the pronouns in your app
|
|
63
|
+
// Resolve the pronouns in your app by referencing the form
|
|
64
|
+
// that you need. There's `subject`, `object`, `possessive`,
|
|
65
|
+
// `psAdjective`, and `reflexive`.
|
|
48
66
|
console.log(
|
|
49
|
-
vayne.username
|
|
67
|
+
`${vayne.username} has updated ${vayne.pronouns.psAdjective()} status.`
|
|
50
68
|
);
|
|
51
|
-
//
|
|
69
|
+
// This returns "vaynegarden updated her status", "vaynegarden
|
|
52
70
|
// updated hir status", or "vaynegarden updated their status",
|
|
53
71
|
// selected randomly among the three.
|
|
54
72
|
```
|
|
73
|
+
|
|
74
|
+
## Changelog
|
|
75
|
+
|
|
76
|
+
### v0.3.1
|
|
77
|
+
|
|
78
|
+
- Added documentation.
|
|
79
|
+
- Reordered `failQuietly` and `useRandom` on `Pronoun`.
|
|
80
|
+
- Tested and fixed examples.
|
|
81
|
+
|
|
82
|
+
### v0.3.0
|
|
83
|
+
|
|
84
|
+
- Rewritten to consolidate functionality into a single default export `Pronouny`.
|
|
85
|
+
- Includes "we", "you", and "I" pronouns by default.
|
|
86
|
+
- Added a config object so you can decide on error handling globally.
|
|
87
|
+
- All methods are now chainable for ease of use.
|
|
88
|
+
|
|
89
|
+
### v0.2.0
|
|
90
|
+
|
|
91
|
+
- Now fails silently when trying to resolve pronouns that don't exist or indexing out of bounds.
|
|
92
|
+
- Implementation of `PronounSet` class changed to Set from Array to prevent duplicate pronouns.
|
|
93
|
+
- added `get()` method to `PronounSet` class to retrieve a random Pronoun object.
|
|
94
|
+
- Added `add()` and `remove()` on `PronounSet`
|
|
95
|
+
|
|
96
|
+
### v0.1.2
|
|
97
|
+
|
|
98
|
+
- Initial release.
|
|
99
|
+
|
|
100
|
+
## TODO
|
|
101
|
+
|
|
102
|
+
- [x] Consolidate implementation into one general-use class.
|
|
103
|
+
- [x] Add global configuration for pronoun use.
|
|
104
|
+
- [ ] Use more performant data structures.
|
|
105
|
+
- [ ] Cleaner error handling.
|
|
106
|
+
- [ ] Unique pronoun identifiers to allow for pronouns with the same first subject pronoun to have multiple forms.
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,247 +1,292 @@
|
|
|
1
|
+
/**# `Pronoun` class
|
|
2
|
+
* A private class to construct the methods for pronoun
|
|
3
|
+
* access. Use {@link Pronouny} to create and
|
|
4
|
+
* append pronouns to the main validator. You can directly
|
|
5
|
+
* fetch pronoun arrays with `sbj`, `obj`, `psv`, `psj`,
|
|
6
|
+
* and `rfx`.
|
|
7
|
+
*/
|
|
8
|
+
declare class Pronoun {
|
|
9
|
+
sbj: Array<string>;
|
|
10
|
+
obj: Array<string>;
|
|
11
|
+
psv: Array<string>;
|
|
12
|
+
psj: Array<string>;
|
|
13
|
+
rfx: Array<string>;
|
|
14
|
+
/** @constructor */
|
|
15
|
+
constructor(pronouns: {
|
|
16
|
+
subject: Array<string> | string;
|
|
17
|
+
object: Array<string> | string;
|
|
18
|
+
possessive: Array<string> | string;
|
|
19
|
+
psAdjective: Array<string> | string;
|
|
20
|
+
reflexive: Array<string> | string;
|
|
21
|
+
});
|
|
22
|
+
/**# Subject Getter
|
|
23
|
+
* Get a subject pronoun. By default, uses one at
|
|
24
|
+
* random and fails silently by using the last
|
|
25
|
+
* pronoun if you index out of bounds.
|
|
26
|
+
*
|
|
27
|
+
* @param index
|
|
28
|
+
* Get `index`th pronoun, if specified. Fails to
|
|
29
|
+
* last if out of bounds and failing quietly.
|
|
30
|
+
* Default is `-1`.
|
|
31
|
+
*
|
|
32
|
+
* @param useRandom
|
|
33
|
+
* Overrides default random use behavior.
|
|
34
|
+
* Default is `true`.
|
|
35
|
+
*
|
|
36
|
+
* @param failQuietly
|
|
37
|
+
* Overrides default quiet failure behavior.
|
|
38
|
+
* Default is `true`.
|
|
39
|
+
*/
|
|
40
|
+
subject(index?: number, useRandom?: boolean, failQuietly?: boolean): string;
|
|
41
|
+
/**# Object Getter
|
|
42
|
+
* Get an object pronoun. By default, uses one at
|
|
43
|
+
* random and fails silently by using the last
|
|
44
|
+
* pronoun if you index out of bounds.
|
|
45
|
+
*
|
|
46
|
+
* @param index
|
|
47
|
+
* Get `index`th pronoun, if specified. Fails to
|
|
48
|
+
* last if out of bounds and failing quietly.
|
|
49
|
+
* Default is `-1`.
|
|
50
|
+
*
|
|
51
|
+
* @param useRandom
|
|
52
|
+
* Overrides default random use behavior.
|
|
53
|
+
* Default is `true`.
|
|
54
|
+
*
|
|
55
|
+
* @param failQuietly
|
|
56
|
+
* Overrides default quiet failure behavior.
|
|
57
|
+
* Default is `true`.
|
|
58
|
+
*/
|
|
59
|
+
object(index?: number, useRandom?: boolean, failQuietly?: boolean): string;
|
|
60
|
+
/**# Possessive Getter
|
|
61
|
+
* Get a possessive pronoun. By default, uses one
|
|
62
|
+
* at random and fails silently by using the last
|
|
63
|
+
* pronoun if you index out of bounds.
|
|
64
|
+
*
|
|
65
|
+
* @param index
|
|
66
|
+
* Get `index`th pronoun, if specified. Fails to
|
|
67
|
+
* last if out of bounds and failing quietly.
|
|
68
|
+
* Default is `-1`.
|
|
69
|
+
*
|
|
70
|
+
* @param useRandom
|
|
71
|
+
* Overrides default random use behavior.
|
|
72
|
+
* Default is `true`.
|
|
73
|
+
*
|
|
74
|
+
* @param failQuietly
|
|
75
|
+
* Overrides default quiet failure behavior.
|
|
76
|
+
* Default is `true`.
|
|
77
|
+
*/
|
|
78
|
+
possessive(index?: number, useRandom?: boolean, failQuietly?: boolean): string;
|
|
79
|
+
/**# Possessive Adjective Getter
|
|
80
|
+
* Get a possessive adjective pronoun. By
|
|
81
|
+
* default, uses one at random and fails
|
|
82
|
+
* silently by using the last pronoun if you
|
|
83
|
+
* index out of bounds.
|
|
84
|
+
*
|
|
85
|
+
* @param index
|
|
86
|
+
* Get `index`th pronoun, if specified. Fails to
|
|
87
|
+
* last if out of bounds and failing quietly.
|
|
88
|
+
* Default is `-1`.
|
|
89
|
+
*
|
|
90
|
+
* @param useRandom
|
|
91
|
+
* Overrides default random use behavior.
|
|
92
|
+
* Default is `true`.
|
|
93
|
+
*
|
|
94
|
+
* @param failQuietly
|
|
95
|
+
* Overrides default quiet failure behavior.
|
|
96
|
+
* Default is `true`.
|
|
97
|
+
*/
|
|
98
|
+
psAdjective(index?: number, useRandom?: boolean, failQuietly?: boolean): string;
|
|
99
|
+
/**# Reflexive Getter
|
|
100
|
+
* Get a reflexive pronoun. By default, uses one
|
|
101
|
+
* at random and fails silently by using the last
|
|
102
|
+
* pronoun if you index out of bounds.
|
|
103
|
+
*
|
|
104
|
+
* @param index
|
|
105
|
+
* Get `index`th pronoun, if specified. Fails to
|
|
106
|
+
* last if out of bounds and failing quietly.
|
|
107
|
+
* Default is `-1`.
|
|
108
|
+
*
|
|
109
|
+
* @param useRandom
|
|
110
|
+
* Overrides default random use behavior.
|
|
111
|
+
* Default is `true`.
|
|
112
|
+
*
|
|
113
|
+
* @param failQuietly
|
|
114
|
+
* Overrides default quiet failure behavior.
|
|
115
|
+
* Default is `true`.
|
|
116
|
+
*/
|
|
117
|
+
reflexive(index?: number, useRandom?: boolean, failQuietly?: boolean): string;
|
|
118
|
+
}
|
|
119
|
+
/**# `PronounSet` class
|
|
120
|
+
* A private class to construct the methods on
|
|
121
|
+
* sets of pronouns. Use {@linkcode Pronouny.set()}
|
|
122
|
+
* to produce a PronounSet for an entity. You can
|
|
123
|
+
* add pronouns to a set using {@linkcode PronounSet.add()},
|
|
124
|
+
* remove them using {@linkcode PronounSet.remove()}
|
|
125
|
+
*/
|
|
126
|
+
declare class PronounSet {
|
|
127
|
+
pronouns: Set<Pronoun>;
|
|
128
|
+
resolver: Pronouny;
|
|
129
|
+
/** @constructor */
|
|
130
|
+
constructor(resolver: Pronouny, pronouns?: Set<Pronoun> | Array<Pronoun> | Set<string> | Array<string> | string);
|
|
131
|
+
/**# `.add()` to PronounSet
|
|
132
|
+
* Adds pronoun/s from a given Pronoun or strings
|
|
133
|
+
* (resolved using the {@linkcode Pronouny} instance
|
|
134
|
+
* used to create this PronounSet.)
|
|
135
|
+
*
|
|
136
|
+
* @param pronoun
|
|
137
|
+
* A string, Pronoun, or array of either, to be
|
|
138
|
+
* appended to the PronounSet.
|
|
139
|
+
*
|
|
140
|
+
* @param failQuietly
|
|
141
|
+
* Override default behavior to fail into 'they'.
|
|
142
|
+
*/
|
|
143
|
+
add(pronoun: string | Pronoun | Array<string> | Array<Pronoun>, failQuietly?: boolean | undefined): this;
|
|
144
|
+
/**# `.remove()` from PronounSet
|
|
145
|
+
* Remove pronoun/s from a given Pronoun or strings
|
|
146
|
+
* (resolved using the {@linkcode Pronouny} instance
|
|
147
|
+
* used to create this PronounSet.)
|
|
148
|
+
*
|
|
149
|
+
* @param pronoun
|
|
150
|
+
* A string, Pronoun, or array of either, to be
|
|
151
|
+
* appended to the PronounSet.
|
|
152
|
+
*
|
|
153
|
+
* @param failQuietly
|
|
154
|
+
* Override default behavior to fail into no removal.
|
|
155
|
+
*/
|
|
156
|
+
remove(set: PronounSet, pronoun: string | Pronoun | Array<string> | Array<Pronoun>, failQuietly?: boolean | undefined): this;
|
|
157
|
+
/**# `.use()` a PronounSet
|
|
158
|
+
* A method to retrieve one Pronoun at random. Use with
|
|
159
|
+
* {@link Pronoun|`Pronoun` methods} to get a specific
|
|
160
|
+
* form. You can also directly use {@link PronounSet.subject|`.subject()`},
|
|
161
|
+
* {@link PronounSet.object|`.object()`}, {@link PronounSet.possessive|`.possessive()`},
|
|
162
|
+
* {@link PronounSet.possessive|`.possessive()`}, or
|
|
163
|
+
* {@link PronounSet.reflexive|`.reflexive()`}. This is mostly
|
|
164
|
+
* here if you'd like to explicitly get a `Pronoun` instance
|
|
165
|
+
* from a `PronounSet`.
|
|
166
|
+
*
|
|
167
|
+
* @param index
|
|
168
|
+
* Retrieve `index`th pronoun from insertion.
|
|
169
|
+
*
|
|
170
|
+
* @param failQuietly
|
|
171
|
+
* Override default behavior to fail as per Pronouny config.
|
|
172
|
+
*
|
|
173
|
+
* @param useRandom
|
|
174
|
+
* Override default behavior to use random as per
|
|
175
|
+
* Pronouny config.
|
|
176
|
+
*/
|
|
177
|
+
use(index?: number, failQuietly?: boolean | undefined, useRandom?: boolean | undefined): Pronoun;
|
|
178
|
+
/**Retrieves a random subject pronoun. */
|
|
179
|
+
subject(index?: number, failQuietly?: boolean | undefined, useRandom?: boolean | undefined): string;
|
|
180
|
+
/**Retrieves a random object pronoun. */
|
|
181
|
+
object(index?: number, failQuietly?: boolean | undefined, useRandom?: boolean | undefined): string;
|
|
182
|
+
/**Retrieves a random possessive pronoun. */
|
|
183
|
+
possessive(index?: number, failQuietly?: boolean | undefined, useRandom?: boolean | undefined): string;
|
|
184
|
+
/**Retrieves a random possessive adjective pronoun. */
|
|
185
|
+
psAdjective(index?: number, failQuietly?: boolean | undefined, useRandom?: boolean | undefined): string;
|
|
186
|
+
/**Retrieves a random reflexive pronoun. */
|
|
187
|
+
reflexive(index?: number, failQuietly?: boolean | undefined, useRandom?: boolean | undefined): string;
|
|
188
|
+
}
|
|
189
|
+
/**# Config
|
|
190
|
+
* `failQuietly`: Controls various quiet failure states.
|
|
191
|
+
*
|
|
192
|
+
* `deepSearch`: Controls how deeply Pronouny will search
|
|
193
|
+
* for queries. By default, `string` parameters will
|
|
194
|
+
* only resolve using the first subject pronoun.
|
|
195
|
+
*
|
|
196
|
+
* `useRandom`: Controls whether random selection will be
|
|
197
|
+
* used. If false, it will default to 0. If failing
|
|
198
|
+
* quietly and indexing out of bounds, it will use the
|
|
199
|
+
* last item.
|
|
200
|
+
*/
|
|
201
|
+
type PronounyConfig = {
|
|
202
|
+
/**Controls various quiet failure states. */
|
|
203
|
+
failQuietly?: boolean;
|
|
204
|
+
/**Controls how deeply Pronouny will search for
|
|
205
|
+
* queries. By default, `string` parameters will
|
|
206
|
+
* only resolve using the first subject pronoun. */
|
|
207
|
+
deepSearch?: boolean;
|
|
208
|
+
/**Controls whether random selection will be used.
|
|
209
|
+
* If false, it will default to 0. If failing
|
|
210
|
+
* quietly and indexing out of bounds, it will
|
|
211
|
+
* use the last item. */
|
|
212
|
+
useRandom?: boolean;
|
|
213
|
+
};
|
|
1
214
|
/**# Pronouny
|
|
2
|
-
* A
|
|
215
|
+
* A typed library intended to make English pronoun
|
|
216
|
+
* resolution easy. Instantiate in your project using
|
|
217
|
+
* `new Pronouny()`, optionally passing in a
|
|
218
|
+
* {@link PronounyConfig|`PronounyConfig` object}.
|
|
219
|
+
*
|
|
220
|
+
* Once you have configured Pronouny, you may add new
|
|
221
|
+
* pronouns by using `new()` and passing in a set of
|
|
222
|
+
* pronouns. They are registered automatically. If you
|
|
223
|
+
* would like to register them manually, you can use
|
|
224
|
+
* `add()`. You can also `remove()` them if you would
|
|
225
|
+
* like to make them no longer valid.
|
|
226
|
+
*
|
|
227
|
+
* You can produce a {@linkcode PronounSet} by using
|
|
228
|
+
* `set()`. By passing in a string, it will
|
|
229
|
+
* automatically resolve each, using a delimiter if
|
|
230
|
+
* specified. From there, you can chain methods like
|
|
231
|
+
* `subject()` to retrieve a subject pronoun for use.
|
|
232
|
+
*
|
|
233
|
+
* If you would like to get a {@link Pronoun|`Pronoun` object}
|
|
234
|
+
* from a given text, you can use `resolve()`. Pass
|
|
235
|
+
* in a string and it will return the entire matched
|
|
236
|
+
* `Pronoun` object.
|
|
3
237
|
*/
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* methods:
|
|
13
|
-
* * `new`: takes in an object containing the required pronouns.
|
|
14
|
-
* * `sbj`: returns subject pronouns. (e.g., he, she, they)
|
|
15
|
-
* * `obj`: returns object pronouns. (e.g., him, her, them)
|
|
16
|
-
* * `psAdj`: returns possessive adjectives (e.g., his, her, their)
|
|
17
|
-
* * `psPrn`: returns possessive pronouns (e.g., his, hers, theirs)
|
|
18
|
-
* * `rfx`: returns reflexive pronouns (e.g., himself, herself, themself)
|
|
238
|
+
export default class Pronouny {
|
|
239
|
+
config: PronounyConfig;
|
|
240
|
+
resolveMap: Map<string, Pronoun>;
|
|
241
|
+
constructor(config?: PronounyConfig);
|
|
242
|
+
/**# `.resolve()` a Pronoun
|
|
243
|
+
* Returns a pronoun from a given string. Uses
|
|
244
|
+
* Pronouny's config to determine the depth of search.
|
|
245
|
+
* By default, only checks the first subject pronoun.
|
|
19
246
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
reflexive: Array<string>;
|
|
26
|
-
/**
|
|
27
|
-
* # Pronoun Constructor
|
|
28
|
-
* In order to construct a new `Pronoun`, you will need to pass in an
|
|
29
|
-
* object which contains at least one `subject` pronoun, one `object`
|
|
30
|
-
* pronoun, one `possessiveAdjective`, one `possessivePronoun`, and one
|
|
31
|
-
* `reflexive` pronoun. You may pass in a string (which will be
|
|
32
|
-
* automatically placed into an array of one) or an array.
|
|
33
|
-
*
|
|
34
|
-
* @param pronouns
|
|
35
|
-
*/
|
|
36
|
-
constructor(pronouns: {
|
|
37
|
-
subject: Array<string> | string;
|
|
38
|
-
object: Array<string> | string;
|
|
39
|
-
possessiveAdjective: Array<string> | string;
|
|
40
|
-
possessivePronoun: Array<string> | string;
|
|
41
|
-
reflexive: Array<string> | string;
|
|
42
|
-
});
|
|
43
|
-
/**## Subject Getter
|
|
44
|
-
* Retrieves a subject pronoun. If no index is provided, it will retrieve
|
|
45
|
-
* a random one from the array *(recommended)*.
|
|
46
|
-
*
|
|
47
|
-
* @throws if you index out of `subject` array length.
|
|
48
|
-
*
|
|
49
|
-
* @param index
|
|
50
|
-
* by default, selects randomly.
|
|
51
|
-
*
|
|
52
|
-
* @returns a string.
|
|
53
|
-
*/
|
|
54
|
-
sbj(index?: number): string;
|
|
55
|
-
/**## Object Getter
|
|
56
|
-
* Retrieves an object pronoun. If no index is provided, it will retrieve
|
|
57
|
-
* a random one from the array *(recommended)*.
|
|
58
|
-
*
|
|
59
|
-
* @throws if you index out of `object` array length.
|
|
60
|
-
*
|
|
61
|
-
* @param index
|
|
62
|
-
* by default, selects randomly.
|
|
63
|
-
*
|
|
64
|
-
* @returns a string.
|
|
65
|
-
*/
|
|
66
|
-
obj(index?: number): string;
|
|
67
|
-
/**## Possessive Adjective Getter
|
|
68
|
-
* Retrieves a possessive adjective pronoun. If no index is provided, it will retrieve
|
|
69
|
-
* a random one from the array *(recommended)*.
|
|
70
|
-
*
|
|
71
|
-
* @throws if you index out of `possessiveAdjective` array length.
|
|
72
|
-
*
|
|
73
|
-
* @param index
|
|
74
|
-
* by default, selects randomly.
|
|
75
|
-
*
|
|
76
|
-
* @returns a string.
|
|
77
|
-
*/
|
|
78
|
-
psAdj(index?: number): string;
|
|
79
|
-
/**## Possessive Pronoun Getter
|
|
80
|
-
* Retrieves a possessive pronoun. If no index is provided, it will retrieve
|
|
81
|
-
* a random one from the array *(recommended)*.
|
|
82
|
-
*
|
|
83
|
-
* @throws if you index out of `possessivePronoun` array length.
|
|
84
|
-
*
|
|
85
|
-
* @param index
|
|
86
|
-
* by default, selects randomly.
|
|
87
|
-
*
|
|
88
|
-
* @returns a string.
|
|
89
|
-
*/
|
|
90
|
-
psPrn(index?: number): string;
|
|
91
|
-
/**## Reflexive Pronoun Getter
|
|
92
|
-
* Retrieves a reflexive pronoun. If no index is provided, it will retrieve
|
|
93
|
-
* a random one from the array *(recommended)*.
|
|
94
|
-
*
|
|
95
|
-
* @throws if you index out of `reflexive` array length.
|
|
96
|
-
*
|
|
97
|
-
* @param index
|
|
98
|
-
* by default, selects randomly.
|
|
99
|
-
*
|
|
100
|
-
* @returns a string.
|
|
101
|
-
*/
|
|
102
|
-
rfx(index?: number): string;
|
|
103
|
-
/**# Pronoun Extension
|
|
104
|
-
* Extend the set of Pronouns with new pronouns. You may pass in a
|
|
105
|
-
* string or an array of strings.
|
|
106
|
-
*
|
|
107
|
-
* @param pronounType
|
|
108
|
-
* Denotes which type of pronoun to extend. Can be `subject`, `object`,
|
|
109
|
-
* `possessiveAdjective`, `possessivePronoun`, or `reflexive`.
|
|
110
|
-
*
|
|
111
|
-
* @param extensions
|
|
112
|
-
* A string or array of strings to extend the pronoun set with.
|
|
113
|
-
*/
|
|
114
|
-
extend(pronounType: "subject" | "object" | "possessiveAdjective" | "possessivePronoun" | "reflexive", extensions: string | Array<string>): void;
|
|
115
|
-
/**# Pronoun Removal
|
|
116
|
-
* Remove a pronoun from the set. You may pass in a string or
|
|
117
|
-
* an array of strings.
|
|
118
|
-
*
|
|
119
|
-
* @param pronounType
|
|
120
|
-
* Pronoun type to remove from. Can be `subject`, `object`,
|
|
121
|
-
* `possessiveAdjective`, `possessivePronoun`, or `reflexive`.
|
|
122
|
-
*
|
|
123
|
-
* @param removal
|
|
124
|
-
* Pronoun to remove from array. Can be a string or an array
|
|
125
|
-
* of strings.
|
|
126
|
-
*/
|
|
127
|
-
remove(pronounType: "subject" | "object" | "possessiveAdjective" | "possessivePronoun" | "reflexive", removal: string | Array<string>): void;
|
|
128
|
-
}
|
|
129
|
-
/**# Pronoun Sets
|
|
130
|
-
* A class intended to define pronouns on a person.
|
|
247
|
+
resolve(pronoun: string, deepSearch?: boolean | undefined): Pronoun;
|
|
248
|
+
/**# `.add()` an Unlisted Pronoun
|
|
249
|
+
* If you made a `.new()` Pronoun but disabled
|
|
250
|
+
* `autoAppend`, you can later append it back by
|
|
251
|
+
* using this method. Returns `Pronouny`.
|
|
131
252
|
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
* @param index
|
|
163
|
-
* Specifies the index in the `Pronoun`. Defaults to a random one *(recommended)*.
|
|
164
|
-
*
|
|
165
|
-
* @returns a string.
|
|
166
|
-
*/
|
|
167
|
-
use(type: "sbj" | "obj" | "psAdj" | "psPrn" | "rfx", pronounIndex?: number, index?: number | undefined): string;
|
|
168
|
-
}
|
|
169
|
-
/**# Validator Class
|
|
170
|
-
* Validates and checks if the pronoun specified is valid. You may extend or
|
|
171
|
-
* remove Pronouns specified using the `extend()` or `remove()` methods.
|
|
253
|
+
add(pronoun: Pronoun): this;
|
|
254
|
+
/**# `.remove()` a Pronoun
|
|
255
|
+
* Renders a given Pronoun invalid within this
|
|
256
|
+
* Pronouny instance. Returns `Pronouny`.
|
|
257
|
+
*/
|
|
258
|
+
remove(pronoun: Pronoun): this;
|
|
259
|
+
/**# Make a `.set()` of Pronouns
|
|
260
|
+
* Returns a {@linkcode PronounSet} from a given
|
|
261
|
+
* string or array of strings. You can specify the
|
|
262
|
+
* delimiter to be used. By default, it is `/`.
|
|
263
|
+
*/
|
|
264
|
+
set(pronouns: string | Array<string>, delimiter?: string): PronounSet;
|
|
265
|
+
/**# `.new()`
|
|
266
|
+
* Returns a new pronoun. Takes in an object with
|
|
267
|
+
* a subject, object, possessive, possessive adjective,
|
|
268
|
+
* and reflexive string/s, and returns the Pronoun.
|
|
269
|
+
* By default, appends the new `Pronoun` to the Pronouny
|
|
270
|
+
* `resolveMap`.
|
|
271
|
+
*
|
|
272
|
+
* @param pronouns
|
|
273
|
+
* Takes an object with the structure of a `Pronoun`,
|
|
274
|
+
* with `Array<string>` or a `string` for `subject`,
|
|
275
|
+
* `object`, `possessive`, `psAdjective`, and
|
|
276
|
+
* `reflexive`.
|
|
277
|
+
*
|
|
278
|
+
* @param autoAppend
|
|
279
|
+
* Will automatically add the new Pronoun to the
|
|
280
|
+
* Pronouny instance. If false, will just return a
|
|
281
|
+
* {@link Pronoun|`Pronoun` object} without registering.
|
|
282
|
+
* You may register it later with {@link Pronouny.add}.
|
|
172
283
|
*/
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
constructor();
|
|
181
|
-
/**# Pronoun Resolver
|
|
182
|
-
* Returns the Pronoun object for the given pronoun string. Will
|
|
183
|
-
* return `undefined` if the pronoun is not found.
|
|
184
|
-
*
|
|
185
|
-
* @param pronoun
|
|
186
|
-
* String to check for against `pronounsSet`.
|
|
187
|
-
*
|
|
188
|
-
* @returns a `Pronoun` object or `undefined`.
|
|
189
|
-
*/
|
|
190
|
-
resolvePronoun(pronoun: string): Pronoun | undefined;
|
|
191
|
-
/**# Strict Pronoun Resolver
|
|
192
|
-
* Only checks the string against the `strictIdentifier` (usually
|
|
193
|
-
* the first subject pronoun). Returns the Pronoun object for the
|
|
194
|
-
* given pronoun string. Will return `undefined` if the pronoun is
|
|
195
|
-
* not found.
|
|
196
|
-
*
|
|
197
|
-
* @param pronoun
|
|
198
|
-
* String to check for against `pronounsSet`.
|
|
199
|
-
*
|
|
200
|
-
* @returns a `Pronoun` object or `undefined`.
|
|
201
|
-
*/
|
|
202
|
-
resolvePronounStrict(pronoun: string): Pronoun | undefined;
|
|
203
|
-
/**# Pronoun Set Constructor
|
|
204
|
-
* Convenience method to build a `PronounSet` from a string or array of
|
|
205
|
-
* strings. You may specify a delimiter and resolution type.
|
|
206
|
-
*
|
|
207
|
-
* @param pronounString
|
|
208
|
-
* `string` or `Array<string>` to build the `PronounSet` from.
|
|
209
|
-
*
|
|
210
|
-
* @param delimiter
|
|
211
|
-
* delimiter to split the `pronounString` by.
|
|
212
|
-
*
|
|
213
|
-
* @param type
|
|
214
|
-
* determines the resolution type. `resolvePronoun` is recommended, though
|
|
215
|
-
* `resolvePronounStrict` will be faster if the format is well-defined.
|
|
216
|
-
*
|
|
217
|
-
* @returns a PronounSet.
|
|
218
|
-
*/
|
|
219
|
-
createSetFrom(pronounString: string | Array<string>, delimiter?: string, type?: "resolvePronoun" | "resolvePronounStrict"): PronounSet;
|
|
220
|
-
/**# Pronoun Extension
|
|
221
|
-
* Extend the set of Pronouns with new pronouns. You may pass in a
|
|
222
|
-
* string or an array of strings.
|
|
223
|
-
*
|
|
224
|
-
* @param strictIdentifier
|
|
225
|
-
* The strict identifier for the pronoun set. Usually the first subject pronoun.
|
|
226
|
-
*
|
|
227
|
-
* @param pronoun
|
|
228
|
-
* A `Pronoun` object to extend the set with.
|
|
229
|
-
*
|
|
230
|
-
* @returns a `Pronoun` object.
|
|
231
|
-
*/
|
|
232
|
-
extend(strictIdentifier: string, pronoun: Pronoun): void;
|
|
233
|
-
/**# Pronoun Removal
|
|
234
|
-
* Remove a `Pronoun` from the `pronounsSet` map. You may pass in a
|
|
235
|
-
* string or an array of strings.
|
|
236
|
-
*
|
|
237
|
-
* @param strictIdentifier
|
|
238
|
-
* The strict identifier for the pronoun set. Usually the first subject pronoun.
|
|
239
|
-
*
|
|
240
|
-
* @param pronoun
|
|
241
|
-
* A `Pronoun` object to extend the set with.
|
|
242
|
-
*
|
|
243
|
-
* @returns a `Pronoun` object.
|
|
244
|
-
*/
|
|
245
|
-
remove(strictIdentifier: string, pronoun: Pronoun): void;
|
|
246
|
-
}
|
|
284
|
+
new(pronouns: {
|
|
285
|
+
subject: Array<string> | string;
|
|
286
|
+
object: Array<string> | string;
|
|
287
|
+
possessive: Array<string> | string;
|
|
288
|
+
psAdjective: Array<string> | string;
|
|
289
|
+
reflexive: Array<string> | string;
|
|
290
|
+
}, autoAppend?: boolean): Pronoun;
|
|
247
291
|
}
|
|
292
|
+
export {};
|