You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Call `parse` with a string and a lang (see [Override the value for a one-time parsing](#override-the-value-for-a-one-time-parsing) for an alternative usage):
24
24
25
25
```javascript
26
-
constrpm=newReadPerMinute()
27
-
```
28
-
29
-
Call the `parse` method with a string and a lang (see [Override the value for a one-time parsing](#override-the-value-for-a-one-time-parsing) for an alternative usage):
30
-
31
-
```javascript
32
-
rpm.parse('Long text', 'en')
26
+
parse('Long text', 'en')
33
27
```
34
28
35
29
The `parse` function returns an object with the following properties:
@@ -66,7 +60,7 @@ If the lang is not listed or is undefined, the default value will be used instea
66
60
67
61
### Override all the values
68
62
69
-
You can specify an entire custom rates object in the constructor of an instance:
63
+
You can specify an entire custom rates object as the third parameter of `parse` or `isLangExist`:
70
64
71
65
```javascript
72
66
constcustomRates= {
@@ -76,19 +70,20 @@ const customRates = {
76
70
nl:234,
77
71
en:244,
78
72
}
79
-
constrpm=newReadPerMinute(customRates)
73
+
parse('Long text', 'en', customRates)
74
+
isLangExist('en', customRates)
80
75
```
81
76
82
-
**NOTE**: Set a `default` property in the object if you want the parsing to fallback to a specific value.
83
-
Otherwise, the static value will be used (`ReadPerMinute.rates.default`).
77
+
**NOTE**: Set a `default` property in the object if you want the parsing to fallback to a specific value.
78
+
Otherwise, the static value will be used (`rates.default`).
84
79
85
80
### Override the value for a one-time parsing
86
81
87
82
Simply pass the desired custom reading rate in words per minute instead of a language code:
88
83
89
84
```javascript
90
85
// For very fast readers: 425 words per minute.
91
-
rpm.parse('Long text', 425)
86
+
parse('Long text', 425)
92
87
```
93
88
94
89
**NOTE**: The custom reading rate must be greater than zero or the default value will be used.
* Rates from "How many words do we read per minute? A review and meta-analysis of reading rate" by Marc Brysbaert - Department of Experimental Psychology Ghent University
* @returns {{rate: number, words: number, time: number}} Object containing the estimated time, the number of words and the rate used in the calculation.
* Parses a string, counts the number the words and divides it by the lang rate to get an estimated reading time.
38
-
* The function returns an object containing the estimated time, the number of words and the rate used in the calculation.
39
-
* @param text {string} String to parse.
40
-
* @param langOrRate {string | number} Lang used to retrieve the reading rate, or a custom rate value.
41
-
* @returns {{rate: number, words: number, time: number}} Object containing the estimated time, the number of words and the rate used in the calculation.
0 commit comments