@nxtedition/lib 26.8.7 → 27.0.0-alpha.0
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/app.js +1 -1
- package/couch.js +1 -1
- package/package.json +10 -48
- package/rxjs/auditMap.js +0 -111
- package/rxjs/auditMap.test.js +0 -64
- package/rxjs/combineMap.d.ts +0 -6
- package/rxjs/combineMap.js +0 -152
- package/rxjs/combineMap.test.js +0 -199
- package/rxjs/firstValueFrom.d.ts +0 -12
- package/rxjs/firstValueFrom.js +0 -18
- package/rxjs/lastValueFrom.js +0 -14
- package/rxjs/retry.js +0 -112
- package/rxjs/withAbortSignal.js +0 -31
- package/s3.js +0 -339
- package/timeline.js +0 -115
- package/util/template/index-common.d.ts +0 -67
- package/util/template/index-common.js +0 -226
- package/util/template/index-web.d.ts +0 -1
- package/util/template/index-web.js +0 -28
- package/util/template/index.d.ts +0 -1
- package/util/template/index.js +0 -26
- package/util/template/index.test.js +0 -94
- package/util/template/javascript.js +0 -692
- package/util/template/nextpressions.js +0 -600
- package/util/template/nextpressions.test.js +0 -165
- package/util/template/transform.js +0 -22
- package/util/template/transform.test.js +0 -16
- package/weakCache.d.ts +0 -4
- package/weakCache.js +0 -25
- package/yield.js +0 -103
package/app.js
CHANGED
|
@@ -21,7 +21,7 @@ import deepstream from '@nxtedition/deepstream.io-client-js'
|
|
|
21
21
|
import { createLogger } from './logger.js'
|
|
22
22
|
import nconf from 'nconf'
|
|
23
23
|
import { makeCouch } from './couch.js'
|
|
24
|
-
import { makeTemplateCompiler } from '
|
|
24
|
+
import { makeTemplateCompiler } from '@nxtedition/template'
|
|
25
25
|
import { makeDeepstream } from './deepstream.js'
|
|
26
26
|
import v8 from 'v8'
|
|
27
27
|
import * as rxjs from 'rxjs'
|
package/couch.js
CHANGED
|
@@ -2,7 +2,7 @@ import assert from 'node:assert'
|
|
|
2
2
|
import stream from 'node:stream'
|
|
3
3
|
import querystring from 'node:querystring'
|
|
4
4
|
import createError from 'http-errors'
|
|
5
|
-
import { makeWeakCache } from '
|
|
5
|
+
import { makeWeakCache } from '@nxtedition/weak-cache'
|
|
6
6
|
import { defaultDelay as delay } from './http.js'
|
|
7
7
|
import urljoin from 'url-join'
|
|
8
8
|
import { AbortError } from './errors.js'
|
package/package.json
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/lib",
|
|
3
|
-
"version": "
|
|
4
|
-
"license": "
|
|
3
|
+
"version": "27.0.0-alpha.0",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
5
|
"author": "Robert Nagy <robert.nagy@boffins.se>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
8
|
"index.d.ts",
|
|
9
9
|
"hash.js",
|
|
10
10
|
"ass.js",
|
|
11
|
-
"rxjs/*",
|
|
12
11
|
"util/*",
|
|
13
12
|
"cache.js",
|
|
14
13
|
"fixed-queue.js",
|
|
15
|
-
"http-client.js",
|
|
16
14
|
"subtract-ranges.js",
|
|
17
15
|
"serializers.js",
|
|
18
16
|
"platform.js",
|
|
19
17
|
"elasticsearch.js",
|
|
20
18
|
"merge-ranges.js",
|
|
21
19
|
"http.js",
|
|
22
|
-
"s3.js",
|
|
23
20
|
"time.js",
|
|
24
21
|
"mutex.js",
|
|
25
22
|
"deepstream.js",
|
|
@@ -33,8 +30,6 @@
|
|
|
33
30
|
"proxy.js",
|
|
34
31
|
"timers.js",
|
|
35
32
|
"trace.js",
|
|
36
|
-
"weakCache.js",
|
|
37
|
-
"weakCache.d.ts",
|
|
38
33
|
"couch.js",
|
|
39
34
|
"couch.d.ts",
|
|
40
35
|
"app.js",
|
|
@@ -43,57 +38,34 @@
|
|
|
43
38
|
"errors.d.ts",
|
|
44
39
|
"worker.js",
|
|
45
40
|
"stream.js",
|
|
46
|
-
"timeline.js",
|
|
47
41
|
"transcript.js",
|
|
48
42
|
"docker-secrets.js",
|
|
49
43
|
"wordwrap.js",
|
|
50
|
-
"under-pressure.js"
|
|
51
|
-
"yield.js"
|
|
44
|
+
"under-pressure.js"
|
|
52
45
|
],
|
|
53
46
|
"scripts": {
|
|
54
47
|
"test": "node --test-timeout 60000 --test",
|
|
55
|
-
"test:types": "tsd"
|
|
56
|
-
"prepare": "husky"
|
|
57
|
-
},
|
|
58
|
-
"lint-staged": {
|
|
59
|
-
"*.{js,jsx,md,ts}": [
|
|
60
|
-
"eslint",
|
|
61
|
-
"prettier --write"
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
|
-
"prettier": {
|
|
65
|
-
"printWidth": 100,
|
|
66
|
-
"semi": false,
|
|
67
|
-
"singleQuote": true
|
|
48
|
+
"test:types": "tsd"
|
|
68
49
|
},
|
|
69
50
|
"dependencies": {
|
|
70
|
-
"@aws-sdk/client-s3": "3.918.0",
|
|
71
51
|
"@elastic/elasticsearch": "^8.17.1",
|
|
72
52
|
"@elastic/transport": "^8.9.3",
|
|
73
53
|
"@nxtedition/nxt-undici": "^6.4.17",
|
|
74
54
|
"@nxtedition/sched": "^1.0.2",
|
|
75
|
-
"@
|
|
76
|
-
"
|
|
77
|
-
"astring": "^1.9.0",
|
|
78
|
-
"date-fns": "^4.1.0",
|
|
55
|
+
"@nxtedition/template": "^1.0.0-alpha.0",
|
|
56
|
+
"@nxtedition/weak-cache": "^1.0.0-alpha.0",
|
|
79
57
|
"diff": "5.2.0",
|
|
80
58
|
"fast-querystring": "^1.1.2",
|
|
81
|
-
"hasha": "^7.0.0",
|
|
82
59
|
"http-errors": "^2.0.0",
|
|
83
|
-
"json5": "^2.2.3",
|
|
84
60
|
"lodash": "^4.17.21",
|
|
85
61
|
"lru-cache": "^11.2.2",
|
|
86
62
|
"mime": "^4.0.7",
|
|
87
63
|
"mitata": "^1.0.34",
|
|
88
|
-
"moment-timezone": "^0.5.48",
|
|
89
64
|
"nconf": "^0.13.0",
|
|
90
65
|
"object-hash": "^3.0.0",
|
|
91
|
-
"p-queue": "^9.0.0",
|
|
92
66
|
"pino": "^10.1.0",
|
|
93
67
|
"qs": "^6.14.0",
|
|
94
68
|
"request-target": "^1.0.2",
|
|
95
|
-
"smpte-timecode": "^1.3.6",
|
|
96
|
-
"split-string": "^6.0.0",
|
|
97
69
|
"url-join": "^5.0.0",
|
|
98
70
|
"xuid": "^4.1.5",
|
|
99
71
|
"yocto-queue": "^1.2.1"
|
|
@@ -103,20 +75,9 @@
|
|
|
103
75
|
"@types/lodash": "^4.17.20",
|
|
104
76
|
"@types/node": "^24.9.1",
|
|
105
77
|
"canvas": "^3.1.0",
|
|
106
|
-
"eslint": "^9.38.0",
|
|
107
|
-
"eslint-config-prettier": "^10.1.8",
|
|
108
|
-
"eslint-config-standard": "^17.0.0",
|
|
109
|
-
"eslint-plugin-import": "^2.32.0",
|
|
110
|
-
"eslint-plugin-n": "^17.23.1",
|
|
111
|
-
"eslint-plugin-node": "^11.1.0",
|
|
112
|
-
"eslint-plugin-promise": "^7.2.1",
|
|
113
|
-
"husky": "^9.1.7",
|
|
114
|
-
"lint-staged": "^16.2.6",
|
|
115
|
-
"prettier": "^3.6.2",
|
|
116
78
|
"rxjs": "^7.8.2",
|
|
117
79
|
"tsd": "^0.33.0",
|
|
118
|
-
"typescript": "^5.9.3"
|
|
119
|
-
"typescript-eslint": "^8.46.2"
|
|
80
|
+
"typescript": "^5.9.3"
|
|
120
81
|
},
|
|
121
82
|
"peerDependencies": {
|
|
122
83
|
"@elastic/elasticsearch": "^8.6.0",
|
|
@@ -124,6 +85,7 @@
|
|
|
124
85
|
"@nxtedition/deepstream.io-client-js": ">=14.1.0",
|
|
125
86
|
"canvas": "^3.1.0",
|
|
126
87
|
"pino": ">=7.0.0",
|
|
127
|
-
"rxjs": "
|
|
128
|
-
}
|
|
88
|
+
"rxjs": "^7.0.0"
|
|
89
|
+
},
|
|
90
|
+
"gitHead": "7e4d71a9276d64d7cb8c39eaed681121903e16a4"
|
|
129
91
|
}
|
package/rxjs/auditMap.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { Observable, from } from 'rxjs'
|
|
2
|
-
|
|
3
|
-
function auditMapImpl(project) {
|
|
4
|
-
return new Observable((o) => {
|
|
5
|
-
let pendingValue = null
|
|
6
|
-
let hasPendingValue = false
|
|
7
|
-
let isComplete = false
|
|
8
|
-
let abortController = null
|
|
9
|
-
|
|
10
|
-
let innerSubscription = null
|
|
11
|
-
let outerSubscription = null
|
|
12
|
-
|
|
13
|
-
function _error(err) {
|
|
14
|
-
o.error(err)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function _innerComplete() {
|
|
18
|
-
innerSubscription = null
|
|
19
|
-
abortController = null
|
|
20
|
-
|
|
21
|
-
if (hasPendingValue) {
|
|
22
|
-
const value = pendingValue
|
|
23
|
-
pendingValue = null
|
|
24
|
-
hasPendingValue = false
|
|
25
|
-
_tryNext(value)
|
|
26
|
-
} else if (isComplete) {
|
|
27
|
-
o.complete()
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function _innerNext(val) {
|
|
32
|
-
o.next(val)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function _drain() {
|
|
36
|
-
if (!hasPendingValue) {
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
const value = pendingValue
|
|
40
|
-
pendingValue = null
|
|
41
|
-
hasPendingValue = false
|
|
42
|
-
return { value }
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function _tryNext(value) {
|
|
46
|
-
try {
|
|
47
|
-
const result = project(value, {
|
|
48
|
-
get signal() {
|
|
49
|
-
if (!abortController) {
|
|
50
|
-
abortController = new AbortController()
|
|
51
|
-
if (hasPendingValue) {
|
|
52
|
-
abortController.abort()
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return abortController.signal
|
|
56
|
-
},
|
|
57
|
-
_drain,
|
|
58
|
-
})
|
|
59
|
-
const observable = typeof result.then === 'function' ? from(result) : result
|
|
60
|
-
innerSubscription = observable.subscribe({
|
|
61
|
-
next: _innerNext,
|
|
62
|
-
error: _error,
|
|
63
|
-
complete: _innerComplete,
|
|
64
|
-
})
|
|
65
|
-
if (innerSubscription && innerSubscription.closed) {
|
|
66
|
-
innerSubscription = null
|
|
67
|
-
}
|
|
68
|
-
} catch (err) {
|
|
69
|
-
o.error(err)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function _next(value) {
|
|
74
|
-
if (innerSubscription) {
|
|
75
|
-
pendingValue = value
|
|
76
|
-
hasPendingValue = true
|
|
77
|
-
abortController?.abort()
|
|
78
|
-
} else {
|
|
79
|
-
_tryNext(value)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function _complete() {
|
|
84
|
-
isComplete = true
|
|
85
|
-
if (!innerSubscription) {
|
|
86
|
-
o.complete()
|
|
87
|
-
} else {
|
|
88
|
-
abortController?.abort()
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
outerSubscription = this.subscribe({
|
|
93
|
-
next: _next,
|
|
94
|
-
error: _error,
|
|
95
|
-
complete: _complete,
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
return () => {
|
|
99
|
-
if (innerSubscription) {
|
|
100
|
-
innerSubscription.unsubscribe()
|
|
101
|
-
}
|
|
102
|
-
outerSubscription.unsubscribe()
|
|
103
|
-
}
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
Observable.prototype.auditMap = auditMapImpl
|
|
108
|
-
|
|
109
|
-
export default function auditMap(project) {
|
|
110
|
-
return (o) => auditMapImpl.call(o, project)
|
|
111
|
-
}
|
package/rxjs/auditMap.test.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { test } from 'node:test'
|
|
2
|
-
import assert from 'node:assert'
|
|
3
|
-
import auditMap from './auditMap.js'
|
|
4
|
-
import * as rxjs from 'rxjs'
|
|
5
|
-
import tp from 'node:timers/promises'
|
|
6
|
-
|
|
7
|
-
test('auditMap sync', (t) => {
|
|
8
|
-
t.plan(1, { wait: true })
|
|
9
|
-
rxjs
|
|
10
|
-
.of(1, 2, 3)
|
|
11
|
-
.pipe(
|
|
12
|
-
auditMap((val) => rxjs.of(val * 2)),
|
|
13
|
-
rxjs.toArray(),
|
|
14
|
-
)
|
|
15
|
-
.subscribe((val) => {
|
|
16
|
-
t.assert.deepStrictEqual(val, [2, 4, 6])
|
|
17
|
-
})
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
test('auditMap async', (t) => {
|
|
21
|
-
t.plan(1, { wait: true })
|
|
22
|
-
rxjs
|
|
23
|
-
.of(1, 2, 3)
|
|
24
|
-
.pipe(
|
|
25
|
-
auditMap(async (val) => val * 2),
|
|
26
|
-
rxjs.toArray(),
|
|
27
|
-
)
|
|
28
|
-
.subscribe((val) => {
|
|
29
|
-
t.assert.deepStrictEqual(val, [2, 6])
|
|
30
|
-
})
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
test('auditMap drain', (t) => {
|
|
34
|
-
t.plan(1, { wait: true })
|
|
35
|
-
rxjs
|
|
36
|
-
.of(1, 2, 3)
|
|
37
|
-
.pipe(
|
|
38
|
-
auditMap(async (val, { _drain }) => {
|
|
39
|
-
await tp.setTimeout(1)
|
|
40
|
-
return _drain()?.value ?? val
|
|
41
|
-
}),
|
|
42
|
-
rxjs.toArray(),
|
|
43
|
-
)
|
|
44
|
-
.subscribe((val) => {
|
|
45
|
-
t.assert.deepStrictEqual(val, [3])
|
|
46
|
-
})
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
test('auditMap signal', (t) => {
|
|
50
|
-
t.plan(1, { wait: true })
|
|
51
|
-
rxjs
|
|
52
|
-
.of(1, 2, 3)
|
|
53
|
-
.pipe(
|
|
54
|
-
auditMap(async (val, { signal }) => {
|
|
55
|
-
await tp.setTimeout(1)
|
|
56
|
-
assert.strictEqual(signal.aborted, val === 1)
|
|
57
|
-
return val
|
|
58
|
-
}),
|
|
59
|
-
rxjs.toArray(),
|
|
60
|
-
)
|
|
61
|
-
.subscribe((val) => {
|
|
62
|
-
t.assert.deepStrictEqual(val, [1, 3])
|
|
63
|
-
})
|
|
64
|
-
})
|
package/rxjs/combineMap.d.ts
DELETED
package/rxjs/combineMap.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { Observable, from, throwError } from 'rxjs'
|
|
2
|
-
|
|
3
|
-
const EMPTY = Object.freeze([])
|
|
4
|
-
|
|
5
|
-
function combineMapImpl(project, equals = (a, b) => a === b) {
|
|
6
|
-
return new Observable((o) => {
|
|
7
|
-
let curr = EMPTY
|
|
8
|
-
let scheduled = false
|
|
9
|
-
let disposed = false
|
|
10
|
-
let dirty = false
|
|
11
|
-
let active = 0
|
|
12
|
-
let empty = 0
|
|
13
|
-
|
|
14
|
-
const _error = (err) => o.error(err)
|
|
15
|
-
|
|
16
|
-
function _update() {
|
|
17
|
-
scheduled = false
|
|
18
|
-
|
|
19
|
-
if (empty > 0) {
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (dirty) {
|
|
24
|
-
dirty = false
|
|
25
|
-
o.next(curr.map(({ value }) => value))
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (active === 0) {
|
|
29
|
-
o.complete()
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function update() {
|
|
34
|
-
if (!scheduled && !disposed) {
|
|
35
|
-
scheduled = true
|
|
36
|
-
queueMicrotask(_update)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
active += 1
|
|
41
|
-
const subscription = this.subscribe({
|
|
42
|
-
next(keys) {
|
|
43
|
-
keys = Array.isArray(keys) ? keys : EMPTY
|
|
44
|
-
|
|
45
|
-
// TODO (perf): Avoid array allocation & copy if nothing has updated.
|
|
46
|
-
const prev = curr
|
|
47
|
-
curr = new Array(keys.length)
|
|
48
|
-
|
|
49
|
-
const prevLen = prev.length
|
|
50
|
-
const currLen = curr.length
|
|
51
|
-
|
|
52
|
-
if (currLen !== prevLen || prev === EMPTY) {
|
|
53
|
-
dirty = true
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
for (let n = 0; n < currLen; ++n) {
|
|
57
|
-
const key = keys[n]
|
|
58
|
-
|
|
59
|
-
if (n < prevLen && prev[n] && equals(prev[n].key, key)) {
|
|
60
|
-
curr[n] = prev[n]
|
|
61
|
-
prev[n] = null
|
|
62
|
-
continue
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
dirty = true
|
|
66
|
-
|
|
67
|
-
// TODO (perf): Guess start index based on n, e.g. n - 1 and n + 1 to check if
|
|
68
|
-
// a key has simply been added or removed.
|
|
69
|
-
const i = prev.findIndex((entry) => entry && equals(entry.key, key))
|
|
70
|
-
|
|
71
|
-
if (i !== -1) {
|
|
72
|
-
curr[n] = prev[i]
|
|
73
|
-
prev[i] = null
|
|
74
|
-
} else {
|
|
75
|
-
let observable
|
|
76
|
-
try {
|
|
77
|
-
observable = from(project(keys[n]))
|
|
78
|
-
} catch (err) {
|
|
79
|
-
observable = throwError(() => err)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const entry = {
|
|
83
|
-
key,
|
|
84
|
-
value: EMPTY,
|
|
85
|
-
subscription: null,
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
empty += 1
|
|
89
|
-
entry.subscription = observable.subscribe({
|
|
90
|
-
next(value) {
|
|
91
|
-
if (entry.value === EMPTY) {
|
|
92
|
-
empty -= 1
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
entry.value = value
|
|
96
|
-
dirty = true
|
|
97
|
-
|
|
98
|
-
update()
|
|
99
|
-
},
|
|
100
|
-
error: _error,
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
active += 1
|
|
104
|
-
entry.subscription.add(() => {
|
|
105
|
-
active -= 1
|
|
106
|
-
|
|
107
|
-
if (entry.value === EMPTY) {
|
|
108
|
-
empty -= 1
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
update()
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
if (disposed) {
|
|
115
|
-
entry.subscription.unsubscribe()
|
|
116
|
-
} else {
|
|
117
|
-
curr[n] = entry
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// TODO (perf): start from index where prev[n] is not null.
|
|
123
|
-
for (let n = 0; n < prevLen; n++) {
|
|
124
|
-
prev[n]?.subscription?.unsubscribe()
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
update()
|
|
128
|
-
},
|
|
129
|
-
complete: () => {
|
|
130
|
-
active -= 1
|
|
131
|
-
update()
|
|
132
|
-
},
|
|
133
|
-
error: _error,
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
return () => {
|
|
137
|
-
disposed = true
|
|
138
|
-
|
|
139
|
-
for (const entry of curr) {
|
|
140
|
-
entry?.subscription?.unsubscribe()
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
subscription.unsubscribe()
|
|
144
|
-
}
|
|
145
|
-
})
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
Observable.prototype.combineMap = combineMapImpl
|
|
149
|
-
|
|
150
|
-
export default function combineMap(project, equals) {
|
|
151
|
-
return (o) => combineMapImpl.call(o, project, equals)
|
|
152
|
-
}
|
package/rxjs/combineMap.test.js
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { test } from 'node:test'
|
|
2
|
-
import combineMap from './combineMap.js'
|
|
3
|
-
import * as rxjs from 'rxjs'
|
|
4
|
-
|
|
5
|
-
test('combineMap sync', (t) => {
|
|
6
|
-
t.plan(1, { wait: true })
|
|
7
|
-
rxjs
|
|
8
|
-
.of([1, 2, 3])
|
|
9
|
-
.pipe(combineMap((val) => rxjs.of(val * 2)))
|
|
10
|
-
.subscribe((val) => {
|
|
11
|
-
t.assert.deepStrictEqual(val, [2, 4, 6])
|
|
12
|
-
})
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
test('combineMap async', (t) => {
|
|
16
|
-
t.plan(1, { wait: true })
|
|
17
|
-
rxjs
|
|
18
|
-
.of([1, 2, 3])
|
|
19
|
-
.pipe(combineMap(async (val) => val * 2))
|
|
20
|
-
.subscribe((val) => {
|
|
21
|
-
t.assert.deepStrictEqual(val, [2, 4, 6])
|
|
22
|
-
})
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
test('combineMap empty', (t) => {
|
|
26
|
-
t.plan(1, { wait: true })
|
|
27
|
-
rxjs
|
|
28
|
-
.of([])
|
|
29
|
-
.pipe(combineMap((val) => rxjs.of(val * 2)))
|
|
30
|
-
.subscribe((val) => {
|
|
31
|
-
t.assert.deepStrictEqual(val, [])
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
test('combineMap throw in resolver', (t) => {
|
|
36
|
-
t.plan(1, { wait: true })
|
|
37
|
-
const _err = new Error('asd')
|
|
38
|
-
rxjs
|
|
39
|
-
.of([1, 2, 3])
|
|
40
|
-
.pipe(
|
|
41
|
-
combineMap((val) => {
|
|
42
|
-
throw _err
|
|
43
|
-
}),
|
|
44
|
-
)
|
|
45
|
-
.subscribe({
|
|
46
|
-
error: (err) => {
|
|
47
|
-
t.assert.strictEqual(err, _err)
|
|
48
|
-
},
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
test('combineMap throw in source', (t) => {
|
|
53
|
-
t.plan(1, { wait: true })
|
|
54
|
-
const _err = new Error('asd')
|
|
55
|
-
rxjs
|
|
56
|
-
.throwError(() => _err)
|
|
57
|
-
.pipe(combineMap((val) => rxjs.of(val)))
|
|
58
|
-
.subscribe({
|
|
59
|
-
error: (err) => {
|
|
60
|
-
t.assert.strictEqual(err, _err)
|
|
61
|
-
},
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
test('combineMap bad resolve', (t) => {
|
|
66
|
-
t.plan(1, { wait: true })
|
|
67
|
-
rxjs
|
|
68
|
-
.of([1])
|
|
69
|
-
.pipe(combineMap((val) => val))
|
|
70
|
-
.subscribe({
|
|
71
|
-
error: () => {
|
|
72
|
-
t.assert.ok(true)
|
|
73
|
-
},
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
test('combineMap no change no tick', (t) => {
|
|
78
|
-
t.plan(1, { wait: true })
|
|
79
|
-
rxjs
|
|
80
|
-
.concat(
|
|
81
|
-
rxjs.timer(10).pipe(rxjs.map(() => [1, 2, 3])),
|
|
82
|
-
rxjs.timer(10).pipe(rxjs.map(() => [1, 2, 3])),
|
|
83
|
-
)
|
|
84
|
-
.pipe(combineMap((val) => rxjs.of(val * 2)))
|
|
85
|
-
.subscribe(() => {
|
|
86
|
-
t.assert.ok(true)
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
test('combineMap combine in single tick', (t) => {
|
|
91
|
-
t.plan(2, { wait: true })
|
|
92
|
-
rxjs
|
|
93
|
-
.concat(
|
|
94
|
-
rxjs.timer(10).pipe(rxjs.map(() => [1, 2, 3])),
|
|
95
|
-
rxjs.timer(10).pipe(rxjs.map(() => [4, 5, 6])),
|
|
96
|
-
)
|
|
97
|
-
.pipe(combineMap((val) => rxjs.from([val * 2, val * 2])))
|
|
98
|
-
.subscribe(() => {
|
|
99
|
-
t.assert.ok(true)
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
test('combineLatest completion', (t) => {
|
|
104
|
-
t.plan(1, { wait: true })
|
|
105
|
-
rxjs.combineLatest([1, 2, 3].map((x) => rxjs.of(x))).subscribe({
|
|
106
|
-
complete: () => {
|
|
107
|
-
t.assert.ok(true)
|
|
108
|
-
},
|
|
109
|
-
})
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
test('combineMap completion', (t) => {
|
|
113
|
-
t.plan(1, { wait: true })
|
|
114
|
-
rxjs
|
|
115
|
-
.of([1, 2, 3])
|
|
116
|
-
.pipe(combineMap((x) => rxjs.of(x)))
|
|
117
|
-
.subscribe({
|
|
118
|
-
complete: () => {
|
|
119
|
-
t.assert.ok(true)
|
|
120
|
-
},
|
|
121
|
-
})
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
test('combineLatest no completion', (t) => {
|
|
125
|
-
t.plan(1, { wait: true })
|
|
126
|
-
const subscription = rxjs
|
|
127
|
-
.combineLatest([1, 2, 3].map((x) => rxjs.timer(0, 1e3).pipe(rxjs.map(() => x))))
|
|
128
|
-
.subscribe({
|
|
129
|
-
next: () => {
|
|
130
|
-
t.assert.ok(true)
|
|
131
|
-
},
|
|
132
|
-
complete: () => {
|
|
133
|
-
t.assert.fail()
|
|
134
|
-
},
|
|
135
|
-
})
|
|
136
|
-
t.after(() => subscription.unsubscribe())
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
test('combineMap no completion', (t) => {
|
|
140
|
-
t.plan(1, { wait: true })
|
|
141
|
-
const subscription = rxjs
|
|
142
|
-
.of([1, 2, 3])
|
|
143
|
-
.pipe(combineMap((x) => rxjs.timer(0, 1e3).pipe(rxjs.map(() => x))))
|
|
144
|
-
.subscribe({
|
|
145
|
-
next: () => {
|
|
146
|
-
t.assert.ok(true)
|
|
147
|
-
},
|
|
148
|
-
complete: () => {
|
|
149
|
-
t.assert.fail()
|
|
150
|
-
},
|
|
151
|
-
})
|
|
152
|
-
t.after(() => subscription.unsubscribe())
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
test('combineLatest no value', (t) => {
|
|
156
|
-
t.plan(1, { wait: true })
|
|
157
|
-
rxjs.combineLatest([1, 2, 3].map((x) => rxjs.EMPTY)).subscribe({
|
|
158
|
-
complete: () => {
|
|
159
|
-
t.assert.ok(true)
|
|
160
|
-
},
|
|
161
|
-
})
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
test('combineMap no value', (t) => {
|
|
165
|
-
t.plan(1, { wait: true })
|
|
166
|
-
rxjs
|
|
167
|
-
.of([1, 2, 3])
|
|
168
|
-
.pipe(combineMap((x) => rxjs.EMPTY))
|
|
169
|
-
.subscribe({
|
|
170
|
-
complete: () => {
|
|
171
|
-
t.assert.ok(true)
|
|
172
|
-
},
|
|
173
|
-
})
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
test('combineMap object keys removed', (t) => {
|
|
177
|
-
t.plan(3, { wait: true })
|
|
178
|
-
const a = {}
|
|
179
|
-
const b = {}
|
|
180
|
-
const c = {}
|
|
181
|
-
|
|
182
|
-
let i = 0
|
|
183
|
-
rxjs
|
|
184
|
-
.concat(rxjs.of([a, b, c]), rxjs.of([a, b]).pipe(rxjs.delay(10)))
|
|
185
|
-
.pipe(combineMap((x) => rxjs.of(x)))
|
|
186
|
-
.subscribe({
|
|
187
|
-
next: (value) => {
|
|
188
|
-
if (i === 0) {
|
|
189
|
-
t.assert.deepStrictEqual(value, [a, b, c])
|
|
190
|
-
} else if (i === 1) {
|
|
191
|
-
t.assert.deepStrictEqual(value, [a, b])
|
|
192
|
-
}
|
|
193
|
-
i++
|
|
194
|
-
},
|
|
195
|
-
complete: () => {
|
|
196
|
-
t.assert.ok(true)
|
|
197
|
-
},
|
|
198
|
-
})
|
|
199
|
-
})
|
package/rxjs/firstValueFrom.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs'
|
|
2
|
-
|
|
3
|
-
interface FirstValueFromConfig<T> {
|
|
4
|
-
signal?: AbortSignal
|
|
5
|
-
timeout?: number
|
|
6
|
-
defaultValue?: T
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export default function firstValueFrom<T>(
|
|
10
|
-
source: Observable<T>,
|
|
11
|
-
config?: FirstValueFromConfig<T>,
|
|
12
|
-
): Promise<T>
|