@blackglory/observe 0.2.1 → 0.3.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.
Files changed (31) hide show
  1. package/README.md +11 -4
  2. package/lib/index.d.ts +3 -2
  3. package/lib/index.js +3 -2
  4. package/lib/index.js.map +1 -1
  5. package/lib/observe-addtions-of-descendant-nodes.d.ts +2 -0
  6. package/lib/observe-addtions-of-descendant-nodes.js +7 -0
  7. package/lib/observe-addtions-of-descendant-nodes.js.map +1 -0
  8. package/lib/observe-mutations.d.ts +2 -0
  9. package/lib/{utils/from-mutation-observer.js → observe-mutations.js} +2 -2
  10. package/lib/observe-mutations.js.map +1 -0
  11. package/lib/observe-removals-of-descendant-nodes.d.ts +2 -0
  12. package/lib/observe-removals-of-descendant-nodes.js +7 -0
  13. package/lib/observe-removals-of-descendant-nodes.js.map +1 -0
  14. package/lib/observe-state-changes.js +1 -1
  15. package/lib/observe-state-changes.js.map +1 -1
  16. package/package.json +21 -21
  17. package/src/index.ts +3 -2
  18. package/src/observe-addtions-of-descendant-nodes.ts +14 -0
  19. package/src/{utils/from-mutation-observer.ts → observe-mutations.ts} +1 -1
  20. package/src/observe-removals-of-descendant-nodes.ts +14 -0
  21. package/src/observe-state-changes.ts +1 -0
  22. package/lib/observe-addtion-of-descendant-nodes.d.ts +0 -2
  23. package/lib/observe-addtion-of-descendant-nodes.js +0 -7
  24. package/lib/observe-addtion-of-descendant-nodes.js.map +0 -1
  25. package/lib/observe-removal-of-descendant-nodes.d.ts +0 -2
  26. package/lib/observe-removal-of-descendant-nodes.js +0 -7
  27. package/lib/observe-removal-of-descendant-nodes.js.map +0 -1
  28. package/lib/utils/from-mutation-observer.d.ts +0 -2
  29. package/lib/utils/from-mutation-observer.js.map +0 -1
  30. package/src/observe-addtion-of-descendant-nodes.ts +0 -18
  31. package/src/observe-removal-of-descendant-nodes.ts +0 -18
package/README.md CHANGED
@@ -19,12 +19,19 @@ function observeURLChanges(): Observable<void>
19
19
  function observeStateChanges(): Observable<void>
20
20
  ```
21
21
 
22
- ### observeAdditionOfDescendantNodes
22
+ ### observeAdditionsOfDescendantNodes
23
23
  ```ts
24
- function observeAdditionOfDescendantNodes(node: Node): Observable<Node[]>
24
+ function observeAdditionsOfDescendantNodes(node: Node): Observable<Node[]>
25
25
  ```
26
26
 
27
- ### observeRemovalOfDescendantNodes
27
+ ### observeRemovalsOfDescendantNodes
28
28
  ```ts
29
- function observeRemovalOfDescendantNodes(node: Node): Observable<Node[]>
29
+ function observeRemovalsOfDescendantNodes(node: Node): Observable<Node[]>
30
+ ```
31
+
32
+ ### observeMutations
33
+ ```ts
34
+ function observeMutations(
35
+ ...args: Parameters<MutationObserver['observe']>
36
+ ): Observable<MutationRecord[]>
30
37
  ```
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- export * from './observe-addtion-of-descendant-nodes.js';
2
- export * from './observe-removal-of-descendant-nodes.js';
3
1
  export * from './observe-state-changes.js';
4
2
  export * from './observe-url-changes.js';
3
+ export * from './observe-addtions-of-descendant-nodes.js';
4
+ export * from './observe-removals-of-descendant-nodes.js';
5
+ export * from './observe-mutations.js';
package/lib/index.js CHANGED
@@ -1,5 +1,6 @@
1
- export * from './observe-addtion-of-descendant-nodes.js';
2
- export * from './observe-removal-of-descendant-nodes.js';
3
1
  export * from './observe-state-changes.js';
4
2
  export * from './observe-url-changes.js';
3
+ export * from './observe-addtions-of-descendant-nodes.js';
4
+ export * from './observe-removals-of-descendant-nodes.js';
5
+ export * from './observe-mutations.js';
5
6
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAA;AACxD,cAAc,0CAA0C,CAAA;AACxD,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,2CAA2C,CAAA;AACzD,cAAc,2CAA2C,CAAA;AACzD,cAAc,wBAAwB,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { Observable } from 'rxjs';
2
+ export declare function observeAdditionsOfDescendantNodes(node: Node): Observable<Node[]>;
@@ -0,0 +1,7 @@
1
+ import { observeMutations } from './observe-mutations.js';
2
+ import { filter, map } from 'rxjs/operators';
3
+ import * as Iter from 'iterable-operator';
4
+ export function observeAdditionsOfDescendantNodes(node) {
5
+ return observeMutations(node, { childList: true, subtree: true }).pipe(map(records => Iter.toArray(Iter.flatMap(records, x => x.addedNodes))), filter(addedNodes => addedNodes.length > 0));
6
+ }
7
+ //# sourceMappingURL=observe-addtions-of-descendant-nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe-addtions-of-descendant-nodes.js","sourceRoot":"","sources":["../src/observe-addtions-of-descendant-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA;AAEzC,MAAM,UAAU,iCAAiC,CAAC,IAAU;IAC1D,OAAO,gBAAgB,CACrB,IAAI,EACJ,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CACnC,CAAC,IAAI,CACJ,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EACtE,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAC5C,CAAA;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Observable } from 'rxjs';
2
+ export declare function observeMutations(...args: Parameters<MutationObserver['observe']>): Observable<MutationRecord[]>;
@@ -1,9 +1,9 @@
1
1
  import { Observable } from 'rxjs';
2
- export function fromMutationObserver(...args) {
2
+ export function observeMutations(...args) {
3
3
  return new Observable(subscriber => {
4
4
  const observer = new MutationObserver(mutationList => subscriber.next(mutationList));
5
5
  observer.observe(...args);
6
6
  return () => observer.disconnect();
7
7
  });
8
8
  }
9
- //# sourceMappingURL=from-mutation-observer.js.map
9
+ //# sourceMappingURL=observe-mutations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe-mutations.js","sourceRoot":"","sources":["../src/observe-mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAEjC,MAAM,UAAU,gBAAgB,CAC9B,GAAG,IAA6C;IAEhD,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE;QACjC,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CACnC,YAAY,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAC9C,CAAA;QACD,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;QACzB,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Observable } from 'rxjs';
2
+ export declare function observeRemovalsOfDescendantNodes(node: Node): Observable<Node[]>;
@@ -0,0 +1,7 @@
1
+ import { observeMutations } from './observe-mutations.js';
2
+ import { filter, map } from 'rxjs/operators';
3
+ import * as Iter from 'iterable-operator';
4
+ export function observeRemovalsOfDescendantNodes(node) {
5
+ return observeMutations(node, { childList: true, subtree: true }).pipe(map(records => Iter.toArray(Iter.flatMap(records, x => x.removedNodes))), filter(removedNodes => removedNodes.length > 0));
6
+ }
7
+ //# sourceMappingURL=observe-removals-of-descendant-nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe-removals-of-descendant-nodes.js","sourceRoot":"","sources":["../src/observe-removals-of-descendant-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA;AAEzC,MAAM,UAAU,gCAAgC,CAAC,IAAU;IACzD,OAAO,gBAAgB,CACrB,IAAI,EACJ,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CACnC,CAAC,IAAI,CACJ,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EACxE,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAChD,CAAA;AACH,CAAC"}
@@ -5,7 +5,7 @@ const replaceStateHooks = new Set();
5
5
  let pushStateHookRegistered = false;
6
6
  let replaceStateHookRegistered = false;
7
7
  export function observeStateChanges() {
8
- return merge(observePushState(), observeReplaceState(), fromEvent(window, 'popstate')).pipe(map(_ => undefined));
8
+ return merge(observePushState(), observeReplaceState(), fromEvent(window, 'popstate'), fromEvent(window, 'hashchange')).pipe(map(_ => undefined));
9
9
  }
10
10
  function observePushState() {
11
11
  return new Observable(observer => {
@@ -1 +1 @@
1
- {"version":3,"file":"observe-state-changes.js","sourceRoot":"","sources":["../src/observe-state-changes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAC/D,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEpC,MAAM,cAA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
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "A module for observing things happening.",
5
5
  "keywords": [
6
6
  "DOM"
@@ -14,14 +14,14 @@
14
14
  "types": "lib/index.d.ts",
15
15
  "sideEffects": false,
16
16
  "engines": {
17
- "node": ">=16"
17
+ "node": ">=22"
18
18
  },
19
19
  "repository": "git@github.com:BlackGlory/observe.git",
20
20
  "author": "BlackGlory <woshenmedoubuzhidao@blackglory.me>",
21
21
  "license": "MIT",
22
22
  "scripts": {
23
23
  "prepare": "ts-patch install -s",
24
- "lint": "eslint --ext .js,.jsx,.ts,.tsx --quiet src __tests__",
24
+ "lint": "eslint --quiet src __tests__",
25
25
  "test": "vitest --run",
26
26
  "prepublishOnly": "run-s prepare clean build",
27
27
  "clean": "rimraf lib",
@@ -35,28 +35,28 @@
35
35
  }
36
36
  },
37
37
  "devDependencies": {
38
- "@blackglory/wait-for": "^0.7.1",
39
- "@commitlint/cli": "^17.4.4",
40
- "@commitlint/config-conventional": "^17.4.4",
41
- "@typescript-eslint/eslint-plugin": "^5.55.0",
42
- "@typescript-eslint/parser": "^5.55.0",
43
- "cross-env": "^7.0.3",
44
- "eslint": "^8.36.0",
38
+ "@blackglory/wait-for": "^0.8.4",
39
+ "@commitlint/cli": "^20.4.1",
40
+ "@commitlint/config-conventional": "^20.4.1",
41
+ "@eslint/js": "^10.0.1",
42
+ "cross-env": "^10.1.0",
43
+ "eslint": "^10.0.0",
45
44
  "husky": "^4.3.6",
46
- "jsdom": "^21.1.1",
45
+ "jsdom": "^28.1.0",
47
46
  "npm-run-all": "^4.1.5",
48
- "rimraf": "^3.0.2",
47
+ "rimraf": "^6.1.3",
49
48
  "standard-version": "^9.5.0",
50
- "ts-patch": "^2.1.0",
51
- "tslib": "^2.5.0",
52
- "typescript": "4.8",
53
- "typescript-transform-paths": "^3.4.6",
54
- "vite": "^4.2.0",
55
- "vite-tsconfig-paths": "^4.0.7",
56
- "vitest": "^0.29.3"
49
+ "ts-patch": "^3.3.0",
50
+ "tslib": "^2.8.1",
51
+ "typescript": "5.9.3",
52
+ "typescript-eslint": "^8.56.0",
53
+ "typescript-transform-paths": "^3.5.6",
54
+ "vite": "^7.3.1",
55
+ "vite-tsconfig-paths": "^6.1.1",
56
+ "vitest": "^4.0.18"
57
57
  },
58
58
  "dependencies": {
59
- "iterable-operator": "^4.0.3",
60
- "rxjs": "^7.8.0"
59
+ "iterable-operator": "^6.0.0",
60
+ "rxjs": "^7.8.2"
61
61
  }
62
62
  }
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
- export * from './observe-addtion-of-descendant-nodes.js'
2
- export * from './observe-removal-of-descendant-nodes.js'
3
1
  export * from './observe-state-changes.js'
4
2
  export * from './observe-url-changes.js'
3
+ export * from './observe-addtions-of-descendant-nodes.js'
4
+ export * from './observe-removals-of-descendant-nodes.js'
5
+ export * from './observe-mutations.js'
@@ -0,0 +1,14 @@
1
+ import { observeMutations } from './observe-mutations.js'
2
+ import { filter, map } from 'rxjs/operators'
3
+ import { Observable } from 'rxjs'
4
+ import * as Iter from 'iterable-operator'
5
+
6
+ export function observeAdditionsOfDescendantNodes(node: Node): Observable<Node[]> {
7
+ return observeMutations(
8
+ node
9
+ , { childList: true, subtree: true }
10
+ ).pipe(
11
+ map(records => Iter.toArray(Iter.flatMap(records, x => x.addedNodes)))
12
+ , filter(addedNodes => addedNodes.length > 0)
13
+ )
14
+ }
@@ -1,6 +1,6 @@
1
1
  import { Observable } from 'rxjs'
2
2
 
3
- export function fromMutationObserver(
3
+ export function observeMutations(
4
4
  ...args: Parameters<MutationObserver['observe']>
5
5
  ): Observable<MutationRecord[]> {
6
6
  return new Observable(subscriber => {
@@ -0,0 +1,14 @@
1
+ import { observeMutations } from './observe-mutations.js'
2
+ import { filter, map } from 'rxjs/operators'
3
+ import { Observable } from 'rxjs'
4
+ import * as Iter from 'iterable-operator'
5
+
6
+ export function observeRemovalsOfDescendantNodes(node: Node): Observable<Node[]> {
7
+ return observeMutations(
8
+ node
9
+ , { childList: true, subtree: true }
10
+ ).pipe(
11
+ map(records => Iter.toArray(Iter.flatMap(records, x => x.removedNodes)))
12
+ , filter(removedNodes => removedNodes.length > 0)
13
+ )
14
+ }
@@ -11,6 +11,7 @@ export function observeStateChanges(): Observable<void> {
11
11
  observePushState()
12
12
  , observeReplaceState()
13
13
  , fromEvent(window, 'popstate')
14
+ , fromEvent(window, 'hashchange')
14
15
  ).pipe(
15
16
  map(_ => undefined)
16
17
  )
@@ -1,2 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- export declare function observeAdditionOfDescendantNodes(node: Node): Observable<Node[]>;
@@ -1,7 +0,0 @@
1
- import { fromMutationObserver } from "./utils/from-mutation-observer.js";
2
- import { filter, map } from 'rxjs/operators';
3
- import * as Iter from 'iterable-operator';
4
- export function observeAdditionOfDescendantNodes(node) {
5
- return fromMutationObserver(node, { childList: true, subtree: true }).pipe(map(records => Iter.toArray(Iter.flatten(Iter.map(records, x => x.addedNodes)))), filter(addedNodes => addedNodes.length > 0));
6
- }
7
- //# sourceMappingURL=observe-addtion-of-descendant-nodes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"observe-addtion-of-descendant-nodes.js","sourceRoot":"","sources":["../src/observe-addtion-of-descendant-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,0CAAwC;AACvE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA;AAEzC,MAAM,UAAU,gCAAgC,CAAC,IAAU;IACzD,OAAO,oBAAoB,CACzB,IAAI,EACJ,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CACnC,CAAC,IAAI,CACJ,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CACzB,IAAI,CAAC,OAAO,CACV,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CACrC,CACF,CAAC,EACF,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAC5C,CAAA;AACH,CAAC"}
@@ -1,2 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- export declare function observeRemovalOfDescendantNodes(node: Node): Observable<Node[]>;
@@ -1,7 +0,0 @@
1
- import { fromMutationObserver } from "./utils/from-mutation-observer.js";
2
- import { filter, map } from 'rxjs/operators';
3
- import * as Iter from 'iterable-operator';
4
- export function observeRemovalOfDescendantNodes(node) {
5
- return fromMutationObserver(node, { childList: true, subtree: true }).pipe(map(records => Iter.toArray(Iter.flatten(Iter.map(records, x => x.removedNodes)))), filter(removedNodes => removedNodes.length > 0));
6
- }
7
- //# sourceMappingURL=observe-removal-of-descendant-nodes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"observe-removal-of-descendant-nodes.js","sourceRoot":"","sources":["../src/observe-removal-of-descendant-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,0CAAwC;AACvE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA;AAEzC,MAAM,UAAU,+BAA+B,CAAC,IAAU;IACxD,OAAO,oBAAoB,CACzB,IAAI,EACJ,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CACnC,CAAC,IAAI,CACJ,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CACzB,IAAI,CAAC,OAAO,CACV,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CACvC,CACF,CAAC,EACF,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAChD,CAAA;AACH,CAAC"}
@@ -1,2 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- export declare function fromMutationObserver(...args: Parameters<MutationObserver['observe']>): Observable<MutationRecord[]>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"from-mutation-observer.js","sourceRoot":"","sources":["../../src/utils/from-mutation-observer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAEjC,MAAM,UAAU,oBAAoB,CAClC,GAAG,IAA6C;IAEhD,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE;QACjC,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CACnC,YAAY,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAC9C,CAAA;QACD,QAAQ,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;QACzB,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,18 +0,0 @@
1
- import { fromMutationObserver } from '@utils/from-mutation-observer.js'
2
- import { filter, map } from 'rxjs/operators'
3
- import { Observable } from 'rxjs'
4
- import * as Iter from 'iterable-operator'
5
-
6
- export function observeAdditionOfDescendantNodes(node: Node): Observable<Node[]> {
7
- return fromMutationObserver(
8
- node
9
- , { childList: true, subtree: true }
10
- ).pipe(
11
- map(records => Iter.toArray(
12
- Iter.flatten<Node>(
13
- Iter.map(records, x => x.addedNodes)
14
- )
15
- ))
16
- , filter(addedNodes => addedNodes.length > 0)
17
- )
18
- }
@@ -1,18 +0,0 @@
1
- import { fromMutationObserver } from '@utils/from-mutation-observer.js'
2
- import { filter, map } from 'rxjs/operators'
3
- import { Observable } from 'rxjs'
4
- import * as Iter from 'iterable-operator'
5
-
6
- export function observeRemovalOfDescendantNodes(node: Node): Observable<Node[]> {
7
- return fromMutationObserver(
8
- node
9
- , { childList: true, subtree: true }
10
- ).pipe(
11
- map(records => Iter.toArray(
12
- Iter.flatten<Node>(
13
- Iter.map(records, x => x.removedNodes)
14
- )
15
- ))
16
- , filter(removedNodes => removedNodes.length > 0)
17
- )
18
- }