rxjs-poll 1.1.3 → 1.1.4
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 +197 -217
- package/dist/cjs/common/config.js +2 -2
- package/dist/cjs/common/config.js.map +1 -1
- package/dist/cjs/common/observables.js +2 -2
- package/dist/cjs/common/observables.js.map +1 -1
- package/dist/cjs/common/utils.js +7 -8
- package/dist/cjs/common/utils.js.map +1 -1
- package/dist/cjs/poll.js +1 -2
- package/dist/cjs/poll.js.map +1 -1
- package/package.json +103 -102
package/README.md
CHANGED
|
@@ -1,217 +1,197 @@
|
|
|
1
|
-
# RxJS Polling Operator
|
|
2
|
-
|
|
3
|
-
<a href="https://www.npmjs.com/package/rxjs-poll" target="_blank" rel="noopener noreferrer nofollow"><img alt="NPM Version" src="https://img.shields.io/npm/v/rxjs-poll"></a>
|
|
4
|
-
<a href="https://bundlephobia.com/package/rxjs-poll@latest" target="_blank" rel="noopener noreferrer nofollow"><img alt="NPM Bundle Size" src="https://img.shields.io/bundlephobia/minzip/rxjs-poll?label=gzip"></a>
|
|
5
|
-
<a href="https://github.com/mmustra/rxjs-poll/tree/main/tests" target="_blank" rel="noopener noreferrer nofollow"><img alt="Codecov" src="https://img.shields.io/codecov/c/gh/mmustra/rxjs-poll?token=H9R97BLFQI"></a>
|
|
6
|
-
<a href="https://github.com/mmustra/rxjs-poll/issues" target="_blank" rel="noopener noreferrer nofollow"><img alt="GitHub Issues or Pull Requests" src="https://img.shields.io/github/issues/mmustra/rxjs-poll"></a>
|
|
7
|
-
<a href="https://github.com/mmustra/rxjs-poll/commits/main" target="_blank" rel="noopener noreferrer nofollow"><img alt="GitHub last commit (branch)" src="https://img.shields.io/github/last-commit/mmustra/rxjs-poll/main?label=activity"></a>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- Two
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
- Background mode
|
|
17
|
-
- Consecutive
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
- Compatible with RxJS v7+
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
## Installation
|
|
24
|
-
|
|
25
|
-
```shell
|
|
26
|
-
npm install rxjs-poll --save
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
##
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
```typescript
|
|
200
|
-
interface PollState<T> {
|
|
201
|
-
polls: number; // current count of successful polls
|
|
202
|
-
retries: number; // current count of retries
|
|
203
|
-
consecutiveRetries: number; // current count of consecutive retries
|
|
204
|
-
value: T; // value emitted from the source
|
|
205
|
-
error: any | null; // "any" when retrying and "null" when polling
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// polls + retries = total attempts
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
## Credits
|
|
212
|
-
|
|
213
|
-
This library is inspired by the [rx-polling](https://github.com/jiayihu/rx-polling) that creates Observable for polling.
|
|
214
|
-
|
|
215
|
-
## License
|
|
216
|
-
|
|
217
|
-
[MIT](LICENSE)
|
|
1
|
+
# RxJS Polling Operator
|
|
2
|
+
|
|
3
|
+
<a href="https://www.npmjs.com/package/rxjs-poll" target="_blank" rel="noopener noreferrer nofollow"><img alt="NPM Version" src="https://img.shields.io/npm/v/rxjs-poll"></a>
|
|
4
|
+
<a href="https://bundlephobia.com/package/rxjs-poll@latest" target="_blank" rel="noopener noreferrer nofollow"><img alt="NPM Bundle Size" src="https://img.shields.io/bundlephobia/minzip/rxjs-poll?label=gzip"></a>
|
|
5
|
+
<a href="https://github.com/mmustra/rxjs-poll/tree/main/tests" target="_blank" rel="noopener noreferrer nofollow"><img alt="Codecov" src="https://img.shields.io/codecov/c/gh/mmustra/rxjs-poll?token=H9R97BLFQI"></a>
|
|
6
|
+
<a href="https://github.com/mmustra/rxjs-poll/issues" target="_blank" rel="noopener noreferrer nofollow"><img alt="GitHub Issues or Pull Requests" src="https://img.shields.io/github/issues/mmustra/rxjs-poll"></a>
|
|
7
|
+
<a href="https://github.com/mmustra/rxjs-poll/commits/main" target="_blank" rel="noopener noreferrer nofollow"><img alt="GitHub last commit (branch)" src="https://img.shields.io/github/last-commit/mmustra/rxjs-poll/main?label=activity"></a>
|
|
8
|
+
|
|
9
|
+
A flexible RxJS operator library that enables polling on any completed observable source with advanced configuration options.
|
|
10
|
+
|
|
11
|
+
## 🌟 Features
|
|
12
|
+
|
|
13
|
+
- **Two polling modes**: `repeat` and `interval` to suit different use cases
|
|
14
|
+
- **Flexible delay configuration**: Use static, random, or dynamic delay values
|
|
15
|
+
- **Custom backoff strategies**: Implement any delay/backoff logic you need
|
|
16
|
+
- **Background mode**: Automatically pause/resume polling based on page visibility (browser only)
|
|
17
|
+
- **Consecutive error handling**: Configure how retry attempts are managed
|
|
18
|
+
- **Input validation**: Guards against unexpected configuration values
|
|
19
|
+
- **Cross-platform**: Works in both browser and Node.js environments
|
|
20
|
+
- **Modern compatibility**: Compatible with RxJS v7+
|
|
21
|
+
- **Multiple module formats**: Supports CommonJS (CJS) and ES Modules (ESM)
|
|
22
|
+
|
|
23
|
+
## 📦 Installation
|
|
24
|
+
|
|
25
|
+
```shell
|
|
26
|
+
npm install rxjs-poll --save
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 🔄 How It Works
|
|
30
|
+
|
|
31
|
+
The emission(s) passes through until the source completes. Once the source completes, polling begins according to your configuration. Depending on the type: `repeat` mode waits for source to complete before polling again, while `interval` mode polls at fixed intervals, canceling ongoing operations. Error handling respects retry settings and consecutive rules.
|
|
32
|
+
|
|
33
|
+
## 📚 Usage Examples
|
|
34
|
+
|
|
35
|
+
### Default Configuration
|
|
36
|
+
|
|
37
|
+
[▶️ Live Demo](https://stackblitz.com/edit/rxjs-6nrm8l?devToolsHeight=100&file=index.ts)
|
|
38
|
+
|
|
39
|
+
Plug and play - just add the operator to your pipe and start polling.
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { poll } from 'rxjs-poll';
|
|
43
|
+
import { takeWhile } from 'rxjs';
|
|
44
|
+
|
|
45
|
+
request$
|
|
46
|
+
.pipe(
|
|
47
|
+
poll(), // Use default settings
|
|
48
|
+
takeWhile(({ length }) => length < 200, true)
|
|
49
|
+
)
|
|
50
|
+
.subscribe({ next: console.log });
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Custom Configuration
|
|
54
|
+
|
|
55
|
+
[▶️ Live Demo](https://stackblitz.com/edit/rxjs-obywba?devToolsHeight=100&file=index.ts)
|
|
56
|
+
|
|
57
|
+
Customize polling behavior with a configuration object:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { poll } from 'rxjs-poll';
|
|
61
|
+
import { takeWhile } from 'rxjs';
|
|
62
|
+
|
|
63
|
+
request$
|
|
64
|
+
.pipe(
|
|
65
|
+
poll({
|
|
66
|
+
type: 'interval', // Drops uncompleted source after delay
|
|
67
|
+
retries: Infinity, // Will never throw
|
|
68
|
+
delay: [1000, 2000], // Random delay between 1 and 2 seconds
|
|
69
|
+
}),
|
|
70
|
+
takeWhile(({ length }) => length < 200, true)
|
|
71
|
+
)
|
|
72
|
+
.subscribe({ next: console.log });
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Advanced Strategies
|
|
76
|
+
|
|
77
|
+
[▶️ Live Demo](https://stackblitz.com/edit/rxjs-awthuj?devtoolsheight=100&file=index.ts)
|
|
78
|
+
|
|
79
|
+
Implement complex polling strategies with dynamic delay functions:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { poll } from 'rxjs-poll';
|
|
83
|
+
import { takeWhile } from 'rxjs';
|
|
84
|
+
|
|
85
|
+
request$
|
|
86
|
+
.pipe(
|
|
87
|
+
poll({
|
|
88
|
+
retries: 6,
|
|
89
|
+
delay: ({ value, error, consecutiveRetries }) => {
|
|
90
|
+
const baseDelay = 1000;
|
|
91
|
+
|
|
92
|
+
if (error) {
|
|
93
|
+
// Exponential backoff strategy
|
|
94
|
+
// With 6 retries, throws after ~1min of consecutive errors
|
|
95
|
+
return Math.pow(2, consecutiveRetries - 1) * baseDelay;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Adaptive polling based on response data
|
|
99
|
+
return value.length < 100 ? baseDelay * 0.3 : baseDelay;
|
|
100
|
+
},
|
|
101
|
+
}),
|
|
102
|
+
takeWhile(({ length }) => length < 200, true)
|
|
103
|
+
)
|
|
104
|
+
.subscribe({ next: console.log });
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 📋 API Reference
|
|
108
|
+
|
|
109
|
+
### `poll(config?: PollConfig)`
|
|
110
|
+
|
|
111
|
+
Creates a polling operator that will begin polling once the source observable completes.
|
|
112
|
+
|
|
113
|
+
#### PollConfig
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
interface PollConfig {
|
|
117
|
+
/**
|
|
118
|
+
* Defines the polling behavior:
|
|
119
|
+
* - 'repeat': Polls after current source completes
|
|
120
|
+
* - 'interval': Polls in intervals, dropping any ongoing source operations
|
|
121
|
+
* @default 'repeat'
|
|
122
|
+
*/
|
|
123
|
+
type?: 'repeat' | 'interval';
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Delay between polls and retries in milliseconds
|
|
127
|
+
*
|
|
128
|
+
* Can be:
|
|
129
|
+
* - A static number (e.g., 1000 for 1 second)
|
|
130
|
+
* - An array with [min, max] for random delay
|
|
131
|
+
* - A function returning either of the above based on state
|
|
132
|
+
* @default 1000
|
|
133
|
+
*/
|
|
134
|
+
delay?:
|
|
135
|
+
| number
|
|
136
|
+
| [number, number]
|
|
137
|
+
| ((state: PollState) => number | [number, number]);
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Maximum number of retry attempts before throwing an error
|
|
141
|
+
* Use Infinity to keep retrying indefinitely
|
|
142
|
+
* @default 3
|
|
143
|
+
*/
|
|
144
|
+
retries?: number;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Controls how retries are counted:
|
|
148
|
+
* - true: Only consecutive errors count toward retry limit
|
|
149
|
+
* (resets counter on success)
|
|
150
|
+
* - false: All errors count toward retry limit regardless of
|
|
151
|
+
* successful responses between them
|
|
152
|
+
* @default true
|
|
153
|
+
*/
|
|
154
|
+
isConsecutiveRule?: boolean;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* [Browser only] Controls polling behavior when page isn't visible
|
|
158
|
+
* - true: Continue polling when tab/window isn't focused
|
|
159
|
+
* - false: Pause polling when tab/window loses focus, resume when focus returns
|
|
160
|
+
* @default false
|
|
161
|
+
*/
|
|
162
|
+
isBackgroundMode?: boolean;
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### PollState
|
|
167
|
+
|
|
168
|
+
State object passed to dynamic delay functions:
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
interface PollState<T> {
|
|
172
|
+
/** Number of successful poll operations */
|
|
173
|
+
polls: number;
|
|
174
|
+
|
|
175
|
+
/** Total number of retry attempts */
|
|
176
|
+
retries: number;
|
|
177
|
+
|
|
178
|
+
/** Number of consecutive retry attempts without success */
|
|
179
|
+
consecutiveRetries: number;
|
|
180
|
+
|
|
181
|
+
/** Latest value emitted from the source */
|
|
182
|
+
value: T;
|
|
183
|
+
|
|
184
|
+
/** Error object when retrying, null during normal polling */
|
|
185
|
+
error: any | null;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Note: polls + retries = total attempts
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## 🙌 Credits
|
|
192
|
+
|
|
193
|
+
This library is inspired by [rx-polling](https://github.com/jiayihu/rx-polling), which creates an Observable for polling.
|
|
194
|
+
|
|
195
|
+
## 📄 License
|
|
196
|
+
|
|
197
|
+
[MIT](LICENSE)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.controlConfig =
|
|
3
|
+
exports.controlConfig = void 0;
|
|
4
|
+
exports.normalizeConfig = normalizeConfig;
|
|
4
5
|
var utils_1 = require("./utils");
|
|
5
6
|
function normalizeConfig(config) {
|
|
6
7
|
var _a;
|
|
@@ -12,7 +13,6 @@ function normalizeConfig(config) {
|
|
|
12
13
|
isBackgroundMode: Boolean(config === null || config === void 0 ? void 0 : config.isBackgroundMode),
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
|
-
exports.normalizeConfig = normalizeConfig;
|
|
16
16
|
function delayProducer(delayFunc) {
|
|
17
17
|
return function (state) {
|
|
18
18
|
var delay = delayFunc(Object.assign({}, state));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/common/config.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/common/config.ts"],"names":[],"mappings":";;;AAEA,0CAQC;AAVD,iCAA8F;AAE9F,SAAgB,eAAe,CAAI,MAA4B;;IAC7D,OAAO;QACL,IAAI,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,mCAAI,qBAAa,CAAC,IAAI;QACxC,QAAQ,EAAE,IAAA,kBAAU,EAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC;QAClG,OAAO,EAAE,IAAA,uBAAe,EAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,EAAE,qBAAa,CAAC,OAAO,EAAE,KAAK,CAAC;QACvE,iBAAiB,EAAE,IAAA,aAAK,EAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,iBAAiB;QACrF,gBAAgB,EAAE,OAAO,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,gBAAgB,CAAC;KACpD,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAI,SAA2B;IACnD,OAAO,UAAC,KAAK;QACX,IAAM,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;QAClD,IAAM,eAAe,GAAG,IAAA,uBAAe,EAAC,KAAK,EAAE,qBAAa,CAAC,KAAK,CAAC,CAAC;QAEpE,OAAO,IAAA,oBAAY,EAAC,eAAe,CAAC,CAAC;IACvC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAI,KAAkC;IAC5D,IAAM,eAAe,GAAG,IAAA,uBAAe,EAAC,KAAK,EAAE,qBAAa,CAAC,KAAK,CAAC,CAAC;IAEpE,OAAO,cAAc,OAAA,IAAA,oBAAY,EAAC,eAAe,CAAC,EAA7B,CAA6B,CAAC;AACrD,CAAC;AAEY,QAAA,aAAa,GAA2B;IACnD,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,CAAC;IACV,iBAAiB,EAAE,IAAI;IACvB,gBAAgB,EAAE,KAAK;CACxB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.visibilityState$ = void 0;
|
|
4
|
+
exports.getPoller$ = getPoller$;
|
|
4
5
|
var rxjs_1 = require("rxjs");
|
|
5
6
|
var utils_1 = require("./utils");
|
|
6
7
|
exports.visibilityState$ = pageVisibility$().pipe((0, rxjs_1.shareReplay)({ bufferSize: 1, refCount: true }));
|
|
@@ -15,7 +16,6 @@ function getPoller$(type, source$, getDelay) {
|
|
|
15
16
|
}))
|
|
16
17
|
: dynamicInterval$(function () { return getDelay(lastValue); }).pipe((0, rxjs_1.switchMap)(function () { return completed$; }));
|
|
17
18
|
}
|
|
18
|
-
exports.getPoller$ = getPoller$;
|
|
19
19
|
function pageVisibility$() {
|
|
20
20
|
return (0, utils_1.isBrowser)() ? (0, rxjs_1.fromEvent)(document, 'visibilitychange').pipe((0, rxjs_1.startWith)(null), (0, rxjs_1.map)(utils_1.isDocumentVisible)) : (0, rxjs_1.of)(true);
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observables.js","sourceRoot":"","sources":["../../../src/common/observables.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"observables.js","sourceRoot":"","sources":["../../../src/common/observables.ts"],"names":[],"mappings":";;;AA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EAAE,cAAM,OAAA,IAAA,YAAK,EAAC,QAAQ,EAAE,CAAC,EAAjB,CAAiB;KAC/B,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/dist/cjs/common/utils.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.normalizeNumber = normalizeNumber;
|
|
4
|
+
exports.sampleNumber = sampleNumber;
|
|
5
|
+
exports.randomNumber = randomNumber;
|
|
6
|
+
exports.isFunction = isFunction;
|
|
7
|
+
exports.isNil = isNil;
|
|
8
|
+
exports.isBrowser = isBrowser;
|
|
9
|
+
exports.isDocumentVisible = isDocumentVisible;
|
|
4
10
|
function normalizeNumber(value, defaultValue, isFinite) {
|
|
5
11
|
if (defaultValue === void 0) { defaultValue = 0; }
|
|
6
12
|
if (isFinite === void 0) { isFinite = true; }
|
|
@@ -16,29 +22,22 @@ function normalizeNumber(value, defaultValue, isFinite) {
|
|
|
16
22
|
}
|
|
17
23
|
return Math.abs(singleValue);
|
|
18
24
|
}
|
|
19
|
-
exports.normalizeNumber = normalizeNumber;
|
|
20
25
|
function sampleNumber(value) {
|
|
21
26
|
return Array.isArray(value) ? randomNumber.apply(void 0, value) : value;
|
|
22
27
|
}
|
|
23
|
-
exports.sampleNumber = sampleNumber;
|
|
24
28
|
function randomNumber(min, max) {
|
|
25
29
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
26
30
|
}
|
|
27
|
-
exports.randomNumber = randomNumber;
|
|
28
31
|
function isFunction(value) {
|
|
29
32
|
return typeof value === 'function';
|
|
30
33
|
}
|
|
31
|
-
exports.isFunction = isFunction;
|
|
32
34
|
function isNil(value) {
|
|
33
35
|
return value == null;
|
|
34
36
|
}
|
|
35
|
-
exports.isNil = isNil;
|
|
36
37
|
function isBrowser() {
|
|
37
38
|
return typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
38
39
|
}
|
|
39
|
-
exports.isBrowser = isBrowser;
|
|
40
40
|
function isDocumentVisible() {
|
|
41
41
|
return !document.hidden;
|
|
42
42
|
}
|
|
43
|
-
exports.isDocumentVisible = isDocumentVisible;
|
|
44
43
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/common/utils.ts"],"names":[],"mappings":";;AAOA,0CAoBC;AAED,oCAEC;AAED,oCAEC;AAED,gCAEC;AAED,sBAGC;AAED,8BAEC;AAED,8CAEC;AA7CD,SAAgB,eAAe,CAC7B,KAAkC,EAClC,YAAgB,EAChB,QAAe;IADf,6BAAA,EAAA,gBAAgB;IAChB,yBAAA,EAAA,eAAe;IAEf,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,eAAe,CAAC,CAAC,EAAE,YAAY,CAAC,EAAhC,CAAgC,CAAW,CAAC;IACtE,CAAC;IAED,IAAI,WAAW,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,YAAY,CAAC;IAExC,IAAI,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;QAC9B,WAAW,GAAG,YAAY,CAAC;IAC7B,CAAC;IAED,IAAI,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC9C,WAAW,GAAG,YAAY,CAAC;IAC7B,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC;AAED,SAAgB,YAAY,CAAC,KAAsB;IACjD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,eAAI,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC;AAC/D,CAAC;AAED,SAAgB,YAAY,CAAC,GAAW,EAAE,GAAW;IACnD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AAC3D,CAAC;AAED,SAAgB,UAAU,CAAC,KAAU;IACnC,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;AACrC,CAAC;AAED,SAAgB,KAAK,CAAC,KAAU;IAE9B,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAED,SAAgB,SAAS;IACvB,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;AACjF,CAAC;AAED,SAAgB,iBAAiB;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;AAC1B,CAAC"}
|
package/dist/cjs/poll.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.poll =
|
|
3
|
+
exports.poll = poll;
|
|
4
4
|
var rxjs_1 = require("rxjs");
|
|
5
5
|
var config_1 = require("./common/config");
|
|
6
6
|
var observables_1 = require("./common/observables");
|
|
@@ -39,5 +39,4 @@ function poll(config) {
|
|
|
39
39
|
}));
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
exports.poll = poll;
|
|
43
42
|
//# sourceMappingURL=poll.js.map
|
package/dist/cjs/poll.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll.js","sourceRoot":"","sources":["../../src/poll.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"poll.js","sourceRoot":"","sources":["../../src/poll.ts"],"names":[],"mappings":";;AAiCA,oBA+CC;AAhFD,6BAAqG;AAErG,0CAAmF;AACnF,oDAAoE;AA8BpE,SAAgB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AAA,KAAK,EAAL,CAAK,CAAC,CAAC,CAAC,CAAC,IAAA,YAAK,EAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;oBACtF,CAAC;iBACF,CAAC,EACF,IAAA,UAAG,EAAC;oBACF,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC;oBACnB,KAAK,CAAC,kBAAkB,GAAG,CAAC,CAAC;gBAC/B,CAAC,CAAC,CACH;gBACH,CAAC,CAAC,YAAK;QAlBT,CAkBS,CACV,CACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,102 +1,103 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "rxjs-poll",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "RxJS operator for polling",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"rxjs",
|
|
7
|
-
"operator",
|
|
8
|
-
"poll",
|
|
9
|
-
"polling",
|
|
10
|
-
"long-polling",
|
|
11
|
-
"network",
|
|
12
|
-
"http",
|
|
13
|
-
"ajax"
|
|
14
|
-
],
|
|
15
|
-
"author": {
|
|
16
|
-
"name": "Marin Muštra",
|
|
17
|
-
"url": "https://www.linkedin.com/in/marin-mustra"
|
|
18
|
-
},
|
|
19
|
-
"license": "MIT",
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "https://github.com/mmustra/rxjs-poll.git"
|
|
23
|
-
},
|
|
24
|
-
"bugs": {
|
|
25
|
-
"url": "https://github.com/mmustra/rxjs-poll/issues"
|
|
26
|
-
},
|
|
27
|
-
"scripts": {
|
|
28
|
-
"release": "release-it",
|
|
29
|
-
"build": "npm run util:clean:dist && npm run build:esm && npm run build:cjs && npm run build:types && npm run util:packageJson",
|
|
30
|
-
"build:esm": "tsc -p ./ts-configs/tsconfig.esm.json",
|
|
31
|
-
"build:cjs": "tsc -p ./ts-configs/tsconfig.cjs.json",
|
|
32
|
-
"build:types": "tsc -p ./ts-configs/tsconfig.types.json",
|
|
33
|
-
"prepare": "is-ci || husky",
|
|
34
|
-
"prepublishOnly": "npm run build",
|
|
35
|
-
"test": "jest --verbose",
|
|
36
|
-
"test:coverage": "npm run util:clean:coverage && npm run test -- --collect-coverage",
|
|
37
|
-
"lint": "eslint ./src ./tests
|
|
38
|
-
"lint:fix": "npm run lint -- --fix",
|
|
39
|
-
"util:packageJson": "ts-node ./scripts/generate-package-json.ts",
|
|
40
|
-
"util:clean:dist": "
|
|
41
|
-
"util:clean:coverage": "
|
|
42
|
-
"util:commitlint": "commitlint",
|
|
43
|
-
"util:lint-staged": "lint-staged"
|
|
44
|
-
},
|
|
45
|
-
"main": "./dist/cjs/index.js",
|
|
46
|
-
"module": "./dist/esm/index.js",
|
|
47
|
-
"types": "./dist/types/index.d.ts",
|
|
48
|
-
"sideEffects": false,
|
|
49
|
-
"files": [
|
|
50
|
-
"dist/**/*"
|
|
51
|
-
],
|
|
52
|
-
"exports": {
|
|
53
|
-
".": {
|
|
54
|
-
"types": "./dist/types/index.d.ts",
|
|
55
|
-
"node": "./dist/cjs/index.js",
|
|
56
|
-
"require": "./dist/cjs/index.js",
|
|
57
|
-
"import": "./dist/esm/index.js",
|
|
58
|
-
"default": "./dist/esm/index.js"
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"lint-staged": {
|
|
62
|
-
"*.{js,ts}": [
|
|
63
|
-
"npm run lint:fix"
|
|
64
|
-
]
|
|
65
|
-
},
|
|
66
|
-
"peerDependencies": {
|
|
67
|
-
"rxjs": ">=7 || ^8.0.0-alpha.0 || ^8.0.0-beta.0 || ^8.0.0-rc.0"
|
|
68
|
-
},
|
|
69
|
-
"devDependencies": {
|
|
70
|
-
"@
|
|
71
|
-
"@commitlint/
|
|
72
|
-
"@commitlint/
|
|
73
|
-
"@
|
|
74
|
-
"@
|
|
75
|
-
"@types/
|
|
76
|
-
"@types/
|
|
77
|
-
"@
|
|
78
|
-
"@typescript-eslint/
|
|
79
|
-
"
|
|
80
|
-
"eslint": "^
|
|
81
|
-
"eslint-config-prettier": "^
|
|
82
|
-
"eslint-config-xo": "^0.
|
|
83
|
-
"eslint-config-xo-typescript": "^
|
|
84
|
-
"eslint-plugin-import": "^2.
|
|
85
|
-
"eslint-plugin-jest-formatting": "^3.1.0",
|
|
86
|
-
"eslint-plugin-prettier": "^5.1
|
|
87
|
-
"eslint-plugin-simple-import-sort": "^12.1.
|
|
88
|
-
"eslint-plugin-unused-imports": "^
|
|
89
|
-
"fs-extra": "^11.
|
|
90
|
-
"husky": "^9.
|
|
91
|
-
"is-ci": "^
|
|
92
|
-
"jest": "^
|
|
93
|
-
"jest-environment-jsdom": "^
|
|
94
|
-
"jest-environment-node": "^
|
|
95
|
-
"lint-staged": "^
|
|
96
|
-
"release-it": "^
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"ts-
|
|
100
|
-
"
|
|
101
|
-
|
|
102
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "rxjs-poll",
|
|
3
|
+
"version": "1.1.4",
|
|
4
|
+
"description": "RxJS operator for polling",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"rxjs",
|
|
7
|
+
"operator",
|
|
8
|
+
"poll",
|
|
9
|
+
"polling",
|
|
10
|
+
"long-polling",
|
|
11
|
+
"network",
|
|
12
|
+
"http",
|
|
13
|
+
"ajax"
|
|
14
|
+
],
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Marin Muštra",
|
|
17
|
+
"url": "https://www.linkedin.com/in/marin-mustra"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/mmustra/rxjs-poll.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/mmustra/rxjs-poll/issues"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"release": "release-it",
|
|
29
|
+
"build": "npm run util:clean:dist && npm run build:esm && npm run build:cjs && npm run build:types && npm run util:packageJson",
|
|
30
|
+
"build:esm": "tsc -p ./ts-configs/tsconfig.esm.json",
|
|
31
|
+
"build:cjs": "tsc -p ./ts-configs/tsconfig.cjs.json",
|
|
32
|
+
"build:types": "tsc -p ./ts-configs/tsconfig.types.json",
|
|
33
|
+
"prepare": "is-ci || husky",
|
|
34
|
+
"prepublishOnly": "npm run build",
|
|
35
|
+
"test": "jest --verbose",
|
|
36
|
+
"test:coverage": "npm run util:clean:coverage && npm run test -- --collect-coverage",
|
|
37
|
+
"lint": "eslint ./src ./tests",
|
|
38
|
+
"lint:fix": "npm run lint -- --fix",
|
|
39
|
+
"util:packageJson": "cross-env TS_NODE_PROJECT='./ts-configs/tsconfig.scripts.json' ts-node ./scripts/generate-package-json.ts",
|
|
40
|
+
"util:clean:dist": "rimraf ./dist --no-preserve-root --no-interactive",
|
|
41
|
+
"util:clean:coverage": "rimraf ./coverage --no-preserve-root --no-interactive",
|
|
42
|
+
"util:commitlint": "commitlint",
|
|
43
|
+
"util:lint-staged": "lint-staged"
|
|
44
|
+
},
|
|
45
|
+
"main": "./dist/cjs/index.js",
|
|
46
|
+
"module": "./dist/esm/index.js",
|
|
47
|
+
"types": "./dist/types/index.d.ts",
|
|
48
|
+
"sideEffects": false,
|
|
49
|
+
"files": [
|
|
50
|
+
"dist/**/*"
|
|
51
|
+
],
|
|
52
|
+
"exports": {
|
|
53
|
+
".": {
|
|
54
|
+
"types": "./dist/types/index.d.ts",
|
|
55
|
+
"node": "./dist/cjs/index.js",
|
|
56
|
+
"require": "./dist/cjs/index.js",
|
|
57
|
+
"import": "./dist/esm/index.js",
|
|
58
|
+
"default": "./dist/esm/index.js"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"lint-staged": {
|
|
62
|
+
"*.{js,ts}": [
|
|
63
|
+
"npm run lint:fix"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"rxjs": ">=7 || ^8.0.0-alpha.0 || ^8.0.0-beta.0 || ^8.0.0-rc.0"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@commitlint/cli": "^19.8.1",
|
|
71
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
72
|
+
"@commitlint/types": "^19.8.1",
|
|
73
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
74
|
+
"@types/fs-extra": "^11.0.4",
|
|
75
|
+
"@types/jest": "^29.5.14",
|
|
76
|
+
"@types/node": "^24.0.1",
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
|
78
|
+
"@typescript-eslint/parser": "^8.34.0",
|
|
79
|
+
"cross-env": "^7.0.3",
|
|
80
|
+
"eslint": "^9.29.0",
|
|
81
|
+
"eslint-config-prettier": "^10.1.5",
|
|
82
|
+
"eslint-config-xo": "^0.47.0",
|
|
83
|
+
"eslint-config-xo-typescript": "^8.0.1",
|
|
84
|
+
"eslint-plugin-import": "^2.31.0",
|
|
85
|
+
"eslint-plugin-jest-formatting": "^3.1.0",
|
|
86
|
+
"eslint-plugin-prettier": "^5.4.1",
|
|
87
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
88
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
89
|
+
"fs-extra": "^11.3.0",
|
|
90
|
+
"husky": "^9.1.7",
|
|
91
|
+
"is-ci": "^4.1.0",
|
|
92
|
+
"jest": "^30.0.0",
|
|
93
|
+
"jest-environment-jsdom": "^30.0.0",
|
|
94
|
+
"jest-environment-node": "^30.0.0",
|
|
95
|
+
"lint-staged": "^16.1.1",
|
|
96
|
+
"release-it": "^19.0.3",
|
|
97
|
+
"rimraf": "^6.0.1",
|
|
98
|
+
"rxjs": "^7.8.2",
|
|
99
|
+
"ts-jest": "^29.4.0",
|
|
100
|
+
"ts-node": "^10.9.2",
|
|
101
|
+
"typescript": "^5.8.3"
|
|
102
|
+
}
|
|
103
|
+
}
|