subscribable-things 2.0.1 → 2.0.5

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Christoph Guttandin
3
+ Copyright (c) 2022 Christoph Guttandin
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1 +1 @@
1
- {"version":3,"file":"wrap-subscribe-function.d.ts","sourceRoot":"","sources":["../../../src/factories/wrap-subscribe-function.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+D,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAEtH,eAAO,MAAM,2BAA2B,EAAE,6BAkBzC,CAAC"}
1
+ {"version":3,"file":"wrap-subscribe-function.d.ts","sourceRoot":"","sources":["../../../src/factories/wrap-subscribe-function.ts"],"names":[],"mappings":"AACA,OAAO,EAA+D,6BAA6B,EAAE,MAAM,UAAU,CAAC;AAEtH,eAAO,MAAM,2BAA2B,EAAE,6BAqBzC,CAAC"}
@@ -1,14 +1,17 @@
1
1
  export const createWrapSubscribeFunction = (patch, toObserver) => {
2
2
  const emptyFunction = () => { }; // tslint:disable-line:no-empty
3
+ const isNextFunction = (args) => typeof args[0] === 'function';
3
4
  return (innerSubscribe) => {
4
5
  const subscribe = ((...args) => {
5
- const unsubscribe = innerSubscribe(toObserver(...args));
6
+ const unsubscribe = innerSubscribe(isNextFunction(args) ? toObserver({ next: args[0] }) : toObserver(...args));
6
7
  if (unsubscribe !== undefined) {
7
8
  return unsubscribe;
8
9
  }
9
10
  return emptyFunction;
10
11
  });
11
- subscribe[Symbol.observable] = () => ({ subscribe: (...args) => ({ unsubscribe: subscribe(...args) }) });
12
+ subscribe[Symbol.observable] = () => ({
13
+ subscribe: (...args) => ({ unsubscribe: subscribe(...args) })
14
+ });
12
15
  return patch(subscribe);
13
16
  };
14
17
  };
@@ -1 +1 @@
1
- {"version":3,"file":"wrap-subscribe-function.js","sourceRoot":"","sources":["../../../src/factories/wrap-subscribe-function.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,2BAA2B,GAAkC,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE;IAC5F,MAAM,aAAa,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,+BAA+B;IAE/D,OAAO,CAAI,cAAqC,EAAE,EAAE;QAChD,MAAM,SAAS,GAA0B,CAAC,CAAC,GAAG,IAA4B,EAAE,EAAE;YAC1E,MAAM,WAAW,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;YAExD,IAAI,WAAW,KAAK,SAAS,EAAE;gBAC3B,OAAO,WAAW,CAAC;aACtB;YAED,OAAO,aAAa,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,IAA4B,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAEjI,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC,CAAC;AACN,CAAC,CAAC"}
1
+ {"version":3,"file":"wrap-subscribe-function.js","sourceRoot":"","sources":["../../../src/factories/wrap-subscribe-function.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,2BAA2B,GAAkC,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE;IAC5F,MAAM,aAAa,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,+BAA+B;IAC/D,MAAM,cAAc,GAAG,CAAI,IAA4B,EAAiC,EAAE,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC;IAEzH,OAAO,CAAI,cAAqC,EAAE,EAAE;QAChD,MAAM,SAAS,GAA0B,CAAC,CAAC,GAAG,IAA4B,EAAE,EAAE;YAC1E,MAAM,WAAW,GAAG,cAAc,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;YAE/G,IAAI,WAAW,KAAK,SAAS,EAAE;gBAC3B,OAAO,WAAW,CAAC;aACtB;YAED,OAAO,aAAa,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC;YAClC,SAAS,EAAE,CAAC,GAAG,IAA8C,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;SAC1G,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC,CAAC;AACN,CAAC,CAAC"}
@@ -1,3 +1,3 @@
1
- import { PartialObserver, Subscribable } from 'rxjs-interop';
2
- export declare type TObserverParameters<T> = Parameters<Subscribable<T>['subscribe']> | [PartialObserver<T>?];
1
+ import { Observer, Subscribable } from 'rxjs-interop';
2
+ export declare type TObserverParameters<T> = Parameters<Subscribable<T>['subscribe']> | [Observer<T>['next']];
3
3
  //# sourceMappingURL=observer-parameters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"observer-parameters.d.ts","sourceRoot":"","sources":["../../../src/types/observer-parameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG7D,oBAAY,mBAAmB,CAAC,CAAC,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"observer-parameters.d.ts","sourceRoot":"","sources":["../../../src/types/observer-parameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEtD,oBAAY,mBAAmB,CAAC,CAAC,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC"}
@@ -407,9 +407,9 @@
407
407
  };
408
408
  };
409
409
 
410
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
410
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
411
411
 
412
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
412
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
413
413
 
414
414
  var createVideoFrame = function createVideoFrame(emitNotSupportedError, wrapSubscribeFunction) {
415
415
  return function (videoElement) {
@@ -500,9 +500,19 @@
500
500
  var emptyFunction = function emptyFunction() {}; // tslint:disable-line:no-empty
501
501
 
502
502
 
503
+ var isNextFunction = function isNextFunction(args) {
504
+ return typeof args[0] === 'function';
505
+ };
506
+
503
507
  return function (innerSubscribe) {
504
508
  var _subscribe = function subscribe() {
505
- var unsubscribe = innerSubscribe(toObserver.apply(void 0, arguments));
509
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
510
+ args[_key] = arguments[_key];
511
+ }
512
+
513
+ var unsubscribe = innerSubscribe(isNextFunction(args) ? toObserver({
514
+ next: args[0]
515
+ }) : toObserver.apply(void 0, args));
506
516
 
507
517
  if (unsubscribe !== undefined) {
508
518
  return unsubscribe;
package/package.json CHANGED
@@ -15,33 +15,33 @@
15
15
  }
16
16
  ],
17
17
  "dependencies": {
18
- "@babel/runtime": "^7.16.0",
18
+ "@babel/runtime": "^7.16.7",
19
19
  "rxjs-interop": "^2.0.0",
20
20
  "tslib": "^2.3.1"
21
21
  },
22
22
  "description": "A collection of reactive wrappers for various browser APIs.",
23
23
  "devDependencies": {
24
- "@babel/core": "^7.16.0",
25
- "@babel/plugin-external-helpers": "^7.16.0",
26
- "@babel/plugin-transform-runtime": "^7.16.0",
27
- "@babel/preset-env": "^7.16.0",
28
- "@commitlint/cli": "^13.2.1",
29
- "@commitlint/config-angular": "^13.2.0",
24
+ "@babel/core": "^7.16.7",
25
+ "@babel/plugin-external-helpers": "^7.16.7",
26
+ "@babel/plugin-transform-runtime": "^7.16.7",
27
+ "@babel/preset-env": "^7.16.7",
28
+ "@commitlint/cli": "^16.0.1",
29
+ "@commitlint/config-angular": "^16.0.0",
30
30
  "@rollup/plugin-babel": "^5.3.0",
31
31
  "baconjs": "^3.0.17",
32
- "body-parser": "^1.19.0",
32
+ "body-parser": "^1.19.1",
33
33
  "callbag-basics": "^4.0.0",
34
34
  "chai": "^4.3.4",
35
35
  "commitizen": "^4.2.4",
36
36
  "cz-conventional-changelog": "^3.3.0",
37
37
  "eslint": "^7.32.0",
38
- "eslint-config-holy-grail": "^50.1.17",
38
+ "eslint-config-holy-grail": "^50.1.23",
39
39
  "grunt": "^1.4.1",
40
40
  "grunt-cli": "^1.4.3",
41
41
  "grunt-contrib-clean": "^2.0.0",
42
42
  "grunt-sh": "^0.2.0",
43
43
  "husky": "^7.0.4",
44
- "karma": "^6.3.7",
44
+ "karma": "^6.3.9",
45
45
  "karma-browserstack-launcher": "^1.6.0",
46
46
  "karma-chrome-launcher": "^3.1.0",
47
47
  "karma-firefox-launcher": "^2.1.2",
@@ -53,20 +53,20 @@
53
53
  "load-grunt-config": "^4.0.1",
54
54
  "midi-test": "^1.1.9",
55
55
  "mocha": "^9.1.3",
56
- "prettier": "^2.4.1",
57
- "pretty-quick": "^3.1.1",
58
- "rollup": "^2.59.0",
59
- "rxjs": "^7.4.0",
60
- "rxjs-for-await": "0.0.2",
56
+ "prettier": "^2.5.1",
57
+ "pretty-quick": "^3.1.3",
58
+ "rollup": "^2.62.0",
59
+ "rxjs": "^7.5.1",
60
+ "rxjs-for-await": "^1.0.0",
61
61
  "sinon": "^11.1.2",
62
62
  "sinon-chai": "^3.7.0",
63
63
  "spect": "^23.1.1",
64
64
  "ts-loader": "^9.2.6",
65
- "tsconfig-holy-grail": "^11.1.18",
65
+ "tsconfig-holy-grail": "^11.1.22",
66
66
  "tslint": "^6.1.3",
67
- "tslint-config-holy-grail": "^53.2.25",
68
- "typescript": "^4.4.4",
69
- "webpack": "^5.61.0",
67
+ "tslint-config-holy-grail": "^53.2.26",
68
+ "typescript": "^4.5.4",
69
+ "webpack": "^5.65.0",
70
70
  "xstream": "^11.14.0"
71
71
  },
72
72
  "files": [
@@ -95,5 +95,5 @@
95
95
  "test": "grunt lint && grunt test"
96
96
  },
97
97
  "types": "build/es2019/module.d.ts",
98
- "version": "2.0.1"
98
+ "version": "2.0.5"
99
99
  }
@@ -1,11 +1,13 @@
1
+ import { Observer, Subscribable } from 'rxjs-interop';
1
2
  import { TObserverParameters, TSubscribableThing, TSubscribeFunction, TWrapSubscribeFunctionFactory } from '../types';
2
3
 
3
4
  export const createWrapSubscribeFunction: TWrapSubscribeFunctionFactory = (patch, toObserver) => {
4
5
  const emptyFunction = () => {}; // tslint:disable-line:no-empty
6
+ const isNextFunction = <T>(args: TObserverParameters<T>): args is [Observer<T>['next']] => typeof args[0] === 'function';
5
7
 
6
8
  return <T>(innerSubscribe: TSubscribeFunction<T>) => {
7
9
  const subscribe = <TSubscribableThing<T>>((...args: TObserverParameters<T>) => {
8
- const unsubscribe = innerSubscribe(toObserver(...args));
10
+ const unsubscribe = innerSubscribe(isNextFunction(args) ? toObserver({ next: args[0] }) : toObserver(...args));
9
11
 
10
12
  if (unsubscribe !== undefined) {
11
13
  return unsubscribe;
@@ -14,7 +16,9 @@ export const createWrapSubscribeFunction: TWrapSubscribeFunctionFactory = (patch
14
16
  return emptyFunction;
15
17
  });
16
18
 
17
- subscribe[Symbol.observable] = () => ({ subscribe: (...args: TObserverParameters<T>) => ({ unsubscribe: subscribe(...args) }) });
19
+ subscribe[Symbol.observable] = () => ({
20
+ subscribe: (...args: Parameters<Subscribable<T>['subscribe']>) => ({ unsubscribe: subscribe(...args) })
21
+ });
18
22
 
19
23
  return patch(subscribe);
20
24
  };
@@ -1,4 +1,3 @@
1
- import { PartialObserver, Subscribable } from 'rxjs-interop';
1
+ import { Observer, Subscribable } from 'rxjs-interop';
2
2
 
3
- // @todo Using Parameters<T> only extracts the parameters of the first overload.
4
- export type TObserverParameters<T> = Parameters<Subscribable<T>['subscribe']> | [PartialObserver<T>?];
3
+ export type TObserverParameters<T> = Parameters<Subscribable<T>['subscribe']> | [Observer<T>['next']];