@nxtedition/lib 14.1.20 → 14.2.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/ass.js CHANGED
@@ -120,7 +120,7 @@ function formatASSTime(seconds) {
120
120
  (m === 0 ? '00' : m < 10 ? '0' + m : m) +
121
121
  ':' +
122
122
  (s === 0 ? '00' : s < 10 ? '0' + s : s) +
123
- ':' +
123
+ '.' +
124
124
  (cs === 0 ? '00' : cs < 10 ? '0' + cs : cs)
125
125
  )
126
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "14.1.20",
3
+ "version": "14.2.1",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "files": [
@@ -1,6 +1,5 @@
1
- const rxjs = require('rxjs')
2
1
  const rx = require('rxjs/operators')
3
- const { AbortError } = require('../errors')
2
+ const withAbortSignal = require('./withAbortSignal')
4
3
 
5
4
  module.exports = function firstValueFrom(x$, config) {
6
5
  const hasConfig = config && typeof config === 'object'
@@ -8,8 +7,7 @@ module.exports = function firstValueFrom(x$, config) {
8
7
  const timeout = hasConfig ? config.timeout : undefined
9
8
 
10
9
  if (signal) {
11
- x$ = signal.aborted ? rxjs.EMPTY : x$.pipe(rx.takeUntil(rxjs.fromEvent(signal, 'abort')))
12
- x$ = x$.pipe(rx.throwIfEmpty(() => new AbortError()))
10
+ x$ = x$.pipe(withAbortSignal(signal))
13
11
  }
14
12
 
15
13
  if (timeout) {
package/rxjs/index.js CHANGED
@@ -3,4 +3,5 @@ module.exports = {
3
3
  combineMap: require('./combineMap'),
4
4
  firstValueFrom: require('./firstValueFrom'),
5
5
  lastValueFrom: require('./lastValueFrom'),
6
+ withAbortSignal: require('./withAbortSignal'),
6
7
  }
@@ -0,0 +1,29 @@
1
+ const rxjs = require('rxjs')
2
+ const { AbortError } = require('../errors')
3
+
4
+ function withAbortSignal(signal) {
5
+ return new rxjs.Observable((o) => {
6
+ o.add(this.subscribe(o))
7
+
8
+ if (!signal) {
9
+ return
10
+ }
11
+
12
+ const onAbort = () => {
13
+ o.error(signal.reason ?? new AbortError())
14
+ }
15
+
16
+ if (signal.aborted) {
17
+ onAbort()
18
+ } else {
19
+ signal.addEventListener('abort', onAbort)
20
+ o.add(() => {
21
+ signal.removeEventListener('abort', onAbort)
22
+ })
23
+ }
24
+ })
25
+ }
26
+
27
+ rxjs.Observable.prototype.withAbortSignal = withAbortSignal
28
+
29
+ module.exports = (signal) => (o) => withAbortSignal.call(o, signal)