├── .editorconfig ├── .eslintrc.json ├── .github └── workflows │ └── pr-check.yml ├── .gitignore ├── .prettierignore ├── .prettierrc ├── .vscode └── extensions.json ├── README.md ├── jest.config.js ├── jest.preset.js ├── nx.json ├── package-lock.json ├── package.json ├── packages ├── .gitkeep └── operators │ └── debug │ ├── .eslintrc.json │ ├── README.md │ ├── jest.config.js │ ├── package.json │ ├── src │ ├── index.ts │ └── lib │ │ ├── debug-config.ts │ │ ├── debug-logger.ts │ │ ├── global-debug-config.ts │ │ ├── operators-debug.spec.ts │ │ └── operators-debug.ts │ ├── tsconfig.json │ ├── tsconfig.lib.json │ └── tsconfig.spec.json ├── tools ├── generators │ └── .gitkeep └── tsconfig.tools.json ├── tsconfig.base.json └── workspace.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "ignorePatterns": ["**/*"], 4 | "plugins": ["@nrwl/nx"], 5 | "overrides": [ 6 | { 7 | "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], 8 | "rules": { 9 | "@nrwl/nx/enforce-module-boundaries": [ 10 | "error", 11 | { 12 | "enforceBuildableLibDependency": true, 13 | "allow": [], 14 | "depConstraints": [ 15 | { 16 | "sourceTag": "*", 17 | "onlyDependOnLibsWithTags": ["*"] 18 | } 19 | ] 20 | } 21 | ] 22 | } 23 | }, 24 | { 25 | "files": ["*.ts", "*.tsx"], 26 | "extends": ["plugin:@nrwl/nx/typescript"], 27 | "parserOptions": { 28 | "project": "./tsconfig.*?.json" 29 | }, 30 | "rules": {} 31 | }, 32 | { 33 | "files": ["*.js", "*.jsx"], 34 | "extends": ["plugin:@nrwl/nx/javascript"], 35 | "rules": {} 36 | } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /.github/workflows/pr-check.yml: -------------------------------------------------------------------------------- 1 | name: PR Status Check 2 | on: 3 | pull_request: 4 | branches: [main] 5 | jobs: 6 | run-unit-tests: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - uses: actions/setup-node@v1 11 | - run: npm install 12 | - run: npm run test -- --project=operators-debug 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | yarn-error.log 34 | testem.log 35 | /typings 36 | 37 | # System Files 38 | .DS_Store 39 | Thumbs.db 40 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Add files here to ignore them from prettier formatting 2 | 3 | /dist 4 | /coverage 5 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true 3 | } -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-vscode.vscode-typescript-tslint-plugin", 4 | "esbenp.prettier-vscode", 5 | "firsttris.vscode-jest-runner" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

RxJS Debug Operator 🐛

2 | 3 | --- 4 | 5 |

6 | 7 | 8 | 9 | 10 |

11 | 12 | --- 13 | 14 | We've all had occasions where we've felt the need to simply pipe a `tap(console.log)` to our Observables to get some insight into what is occuring at a certain time. 15 | 16 | This operator aims to reduce the amount of typing you'll have to do! 17 | 18 | ## Usage 19 | 20 | ### Installation 21 | 22 | Install the package: 23 | `npm install rxjs-debug-operator` 24 | 25 | ### Adding it to your code 26 | 27 | It's super simple to add and use: 28 | 29 | Use your prefered import method: 30 | 31 | ```js 32 | import { debug } from 'rxjs-debug-operator'; 33 | // OR 34 | const { debug } = require('rxjs-debug-operator'); 35 | ``` 36 | 37 | Then pipe it to your Observables: 38 | 39 | ```ts 40 | const obs$ = source.pipe(debug()); 41 | ``` 42 | 43 | You can add a label to help identify the Observable: 44 | 45 | ```ts 46 | const obs$ = source.pipe(debug('My Observable')); 47 | // OUTPUT 48 | // My Observable {value} 49 | ``` 50 | 51 | It even allows you to turn it off if you are in a production environment, or for any other reason you wouldn't want to log to the console: 52 | 53 | ```ts 54 | const obs$ = source.pipe(debug({ shouldIgnore: true })); 55 | ``` 56 | 57 | ### Examples 58 | 59 | We can use it on its own to simply log out values to the console 60 | 61 | ```ts 62 | const obs$ = of('my test value'); 63 | obs$.pipe(debug()).subscribe(); 64 | 65 | // OUTPUT: 66 | // my test value 67 | ``` 68 | 69 | We can add a label to the logs: 70 | 71 | ```ts 72 | const obs$ = of('my test value'); 73 | obs$.pipe(debug('Obserable A')).subscribe(); 74 | 75 | // OUTPUT: 76 | // Obserable A my test value 77 | 78 | // We can label it using the config object syntax: 79 | const obs$ = of('my test value'); 80 | obs$.pipe(debug({ label: 'Obserable A' })).subscribe(); 81 | 82 | // OUTPUT: 83 | // Obserable A my test value 84 | 85 | // However, if we add a label and custom notification handlers, 86 | // we will not get the label in the logs by default: 87 | const obs$ = of('my test value'); 88 | obs$ 89 | .pipe( 90 | debug({ 91 | label: 'Obserable A', 92 | next: (value) => console.log(value), 93 | }) 94 | ) 95 | .subscribe(); 96 | 97 | // OUTPUT: 98 | // my test value 99 | ``` 100 | 101 | We can also set up our own notification handlers if we prefer: 102 | 103 | ```ts 104 | const obs$ = of('my test value'); 105 | obs$ 106 | .pipe(debug({ next: (value) => console.log('my custom handler:', value) })) 107 | .subscribe(); 108 | 109 | // OUTPUT: 110 | // my custom handler: my test value 111 | 112 | const obs$ = throwError('uh oh'); 113 | obs$ 114 | .pipe(debug({ error: (value) => console.log('my error handler:', value) })) 115 | .subscribe(); 116 | 117 | // OUTPUT: 118 | // my error handler: uh oh 119 | 120 | const obs$ = of('my test value'); 121 | obs$ 122 | .pipe(debug({ complete: (value) => console.log('I completed') })) 123 | .subscribe(); 124 | 125 | // OUTPUT: 126 | // I completed 127 | ``` 128 | 129 | We can access the default logger for more flexibility: 130 | 131 | ```js 132 | const obs$ = of('my test value'); 133 | 134 | obs$ 135 | .pipe( 136 | debug((logger) => ({ 137 | next: (v) => logger.warn('Warning!', v), 138 | })) 139 | ) 140 | .subscribe(); 141 | 142 | // OUTPUT 143 | // WARN: Warning! my test value 144 | ``` 145 | 146 | ## Setting Global Config 147 | 148 | You can set some globals that make it more convenient to change: 149 | 150 | - the default logger 151 | - a global prefix to be appended to all logs 152 | - a global-level ignore flag 153 | 154 | ### Change the Default Logger 155 | 156 | You can change the default logger by creating an object that matches the `DebugLogger` interface, which can be seen below: 157 | 158 | ```ts 159 | export interface DebugLogger { 160 | log: (...args: unknown[]) => void; 161 | error: (...args: unknown[]) => void; 162 | warn?: (...args: unknown[]) => void; 163 | debug?: (...args: unknown[]) => void; 164 | info?: (...args: unknown[]) => void; 165 | } 166 | ``` 167 | 168 | Once you have created your new logger, you can set it to be used as the default logger using `setGlobalDebugConfig()` 169 | 170 | ```js 171 | setGlobalDebugConfig({ 172 | logger: myNewLogger, 173 | }); 174 | ``` 175 | 176 | Now all your `debug()` operators will use your new logger to log the values it receives. 177 | 178 | ### Adding a Global Prefix 179 | 180 | You can also add a string prefix to all your logs at a global level, which can be useful to help identify logs. 181 | 182 | ```js 183 | setGlobalDebugConfig({ 184 | prefix: 'My Prefix', 185 | }); 186 | ``` 187 | 188 | ### Setting whether to ignore logging 189 | 190 | You can also set whether all `debug()` should not log at the global level. This can be useful for turning it off in production environments. 191 | 192 | ```js 193 | setGlobalDebugConfig({ 194 | shouldIgnore: isProduction, 195 | }); 196 | ``` 197 | 198 | ### Example Winston Usage 199 | 200 | ```ts 201 | import { DebugLogger, setGlobalDebugConfig } from 'rxjs-debug-operator'; 202 | const winston = require('winston'); 203 | 204 | const sysLogger = winston.createLogger({ 205 | level: 'info', 206 | format: winston.format.json(), 207 | transports: [ 208 | // 209 | // - Write all logs with level `error` and below to `error.log` 210 | // - Write all logs with level `info` and below to `combined.log` 211 | // 212 | new winston.transports.File({ filename: 'error.log', level: 'error' }), 213 | new winston.transports.File({ filename: 'combined.log' }), 214 | ], 215 | }); 216 | 217 | const debugLogger: DebugLogger = { 218 | log: (v) => sysLogger.info(v), 219 | error: (e) => sysLogger.error(e), 220 | }; 221 | 222 | setGlobalDebugConfig({ logger: debugLogger }); 223 | 224 | const obs$ = of('my test value'); 225 | obs$.pipe(debug()).subscribe(); 226 | 227 | // OUTPUT 228 | // 'my test value' written to `combined.log` 229 | ``` 230 | 231 | ### **NOTES** 232 | 233 | **It should be noted that local config options passed to the `debug()` operator will take precedence over any global values** 234 | 235 | ## API 236 | 237 | ### Debug 238 | 239 | `debug(config?: Partial)` 240 | 241 | ### DebugOperatorConfig 242 | 243 | See the list of options available to configure the operator below 244 | 245 | | Option | Description | Type | Default | 246 | | -------------- | :----------------------------------------------------------------: | -------------------------- | --------------- | 247 | | `shouldIgnore` | Do not perform the Debug actions | `boolean` | `false` | 248 | | `label` | Add a label to the logs to help identify the Observable | `string` | `null` | 249 | | `next` | Action to perform when Observer receives a Next notification | `(value: T) => void` | `console.log` | 250 | | `error` | Action to perform when Observer receives an Error notification | `(value: unknown) => void` | `console.error` | 251 | | `complete` | Action to perform when Observer receives a Completion notification | `() => void` | `() => null` | 252 | 253 | ### Global Debug Config 254 | 255 | `setGlobalDebugConfig(config: Partial)` 256 | 257 | ### GlobalDebugConfig 258 | 259 | | Option | Description | Type | Default | 260 | | -------------- | :-----------------------------------------------------: | ------------- | --------- | 261 | | `shouldIgnore` | Do not perform the Debug actions | `boolean` | `false` | 262 | | `prefix` | Add a label to the logs to help identify the Observable | `string` | `null` | 263 | | `logger` | Logger to use to log values recieved by `debug()` | `DebugLogger` | `console` | 264 | 265 | ### DebugLogger 266 | 267 | | Option | Description | Type | Default | 268 | | -------- | :---------: | ------------------------------ | --------------- | 269 | | `log` | Basic log | `(...args: unknown[]) => void` | `console.log` | 270 | | `error` | Error log | `(...args: unknown[]) => void` | `console.error` | 271 | | `info?` | Info log | `(...args: unknown[]) => void` | `console.info` | 272 | | `warn?` | Warn log | `(...args: unknown[]) => void` | `console.warn` | 273 | | `debug?` | Debug log | `(...args: unknown[]) => void` | `console.debug` | 274 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | projects: ['/packages/operators/debug'], 3 | }; 4 | -------------------------------------------------------------------------------- /jest.preset.js: -------------------------------------------------------------------------------- 1 | const nxPreset = require('@nrwl/jest/preset'); 2 | 3 | module.exports = { ...nxPreset }; 4 | -------------------------------------------------------------------------------- /nx.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmScope": "rxjs-debug-operator", 3 | "affected": { "defaultBase": "origin/main" }, 4 | "implicitDependencies": { 5 | "workspace.json": "*", 6 | "package.json": { "dependencies": "*", "devDependencies": "*" }, 7 | "tsconfig.base.json": "*", 8 | "tslint.json": "*", 9 | ".eslintrc.json": "*", 10 | "nx.json": "*" 11 | }, 12 | "tasksRunnerOptions": { 13 | "default": { 14 | "runner": "@nrwl/nx-cloud", 15 | "options": { 16 | "cacheableOperations": ["build", "lint", "test", "e2e"], 17 | "accessToken": "N2MzNzU4ZTctZjc1ZC00NDc2LTgyYTktZWUxMjQwMGQyNGUwfHJlYWQtd3JpdGU=", 18 | "canTrackAnalytics": false, 19 | "showUsageWarnings": true 20 | } 21 | } 22 | }, 23 | "projects": { "operators-debug": { "tags": [] } }, 24 | "workspaceLayout": { "appsDir": "packages", "libsDir": "packages" } 25 | } 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rxjs-debug-operator", 3 | "version": "2.0.0", 4 | "license": "MIT", 5 | "keywords": [ 6 | "rxjs", 7 | "operator" 8 | ], 9 | "author": { 10 | "name": "Colum Ferry", 11 | "url": "https://columferry.co.uk" 12 | }, 13 | "scripts": { 14 | "nx": "nx", 15 | "start": "nx serve", 16 | "build": "nx build", 17 | "test": "nx test", 18 | "lint": "nx workspace-lint && nx lint", 19 | "e2e": "nx e2e", 20 | "affected:apps": "nx affected:apps", 21 | "affected:libs": "nx affected:libs", 22 | "affected:build": "nx affected:build", 23 | "affected:e2e": "nx affected:e2e", 24 | "affected:test": "nx affected:test", 25 | "affected:lint": "nx affected:lint", 26 | "affected:dep-graph": "nx affected:dep-graph", 27 | "affected": "nx affected", 28 | "format": "nx format:write", 29 | "format:write": "nx format:write", 30 | "format:check": "nx format:check", 31 | "update": "nx migrate latest", 32 | "workspace-generator": "nx workspace-generator", 33 | "dep-graph": "nx dep-graph", 34 | "help": "nx help" 35 | }, 36 | "private": true, 37 | "devDependencies": { 38 | "@nrwl/cli": "11.4.0", 39 | "@nrwl/eslint-plugin-nx": "11.4.0", 40 | "@nrwl/jest": "11.4.0", 41 | "@nrwl/linter": "11.4.0", 42 | "@nrwl/node": "11.4.0", 43 | "@nrwl/nx-cloud": "latest", 44 | "@nrwl/tao": "11.4.0", 45 | "@nrwl/workspace": "11.4.0", 46 | "@types/jest": "26.0.8", 47 | "@types/node": "12.12.38", 48 | "@typescript-eslint/eslint-plugin": "4.3.0", 49 | "@typescript-eslint/parser": "4.3.0", 50 | "dotenv": "6.2.0", 51 | "eslint": "7.10.0", 52 | "eslint-config-prettier": "6.0.0", 53 | "jest": "26.2.2", 54 | "prettier": "2.2.1", 55 | "ts-jest": "26.4.0", 56 | "ts-node": "9.1.1", 57 | "typescript": "4.0.7" 58 | }, 59 | "peerDependencies": { 60 | "rxjs": "^7.0.0" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /packages/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coly010/rxjs-debug-operator/2481e14774f942bb3d8096524eac4cb705a2541a/packages/.gitkeep -------------------------------------------------------------------------------- /packages/operators/debug/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["../../../.eslintrc.json"], 3 | "ignorePatterns": ["!**/*"], 4 | "rules": {} 5 | } 6 | -------------------------------------------------------------------------------- /packages/operators/debug/README.md: -------------------------------------------------------------------------------- 1 |

RxJS Debug Operator 🐛

2 | 3 | --- 4 | 5 |

6 | 7 | 8 | 9 | 10 |

11 | 12 | --- 13 | 14 | We've all had occasions where we've felt the need to simply pipe a `tap(console.log)` to our Observables to get some insight into what is occuring at a certain time. 15 | 16 | This operator aims to reduce the amount of typing you'll have to do! 17 | 18 | ## Usage 19 | 20 | ### Installation 21 | 22 | Install the package: 23 | `npm install rxjs-debug-operator` 24 | 25 | ### Adding it to your code 26 | 27 | It's super simple to add and use: 28 | 29 | Use your prefered import method: 30 | 31 | ```js 32 | import { debug } from 'rxjs-debug-operator'; 33 | // OR 34 | const { debug } = require('rxjs-debug-operator'); 35 | ``` 36 | 37 | Then pipe it to your Observables: 38 | 39 | ```ts 40 | const obs$ = source.pipe(debug()); 41 | ``` 42 | 43 | You can add a label to help identify the Observable: 44 | 45 | ```ts 46 | const obs$ = source.pipe(debug('My Observable')); 47 | // OUTPUT 48 | // My Observable {value} 49 | ``` 50 | 51 | It even allows you to turn it off if you are in a production environment, or for any other reason you wouldn't want to log to the console: 52 | 53 | ```ts 54 | const obs$ = source.pipe(debug({ shouldIgnore: true })); 55 | ``` 56 | 57 | ### Examples 58 | 59 | We can use it on its own to simply log out values to the console 60 | 61 | ```ts 62 | const obs$ = of('my test value'); 63 | obs$.pipe(debug()).subscribe(); 64 | 65 | // OUTPUT: 66 | // my test value 67 | ``` 68 | 69 | We can add a label to the logs: 70 | 71 | ```ts 72 | const obs$ = of('my test value'); 73 | obs$.pipe(debug('Obserable A')).subscribe(); 74 | 75 | // OUTPUT: 76 | // Obserable A my test value 77 | 78 | // We can label it using the config object syntax: 79 | const obs$ = of('my test value'); 80 | obs$.pipe(debug({ label: 'Obserable A' })).subscribe(); 81 | 82 | // OUTPUT: 83 | // Obserable A my test value 84 | 85 | // However, if we add a label and custom notification handlers, 86 | // we will not get the label in the logs by default: 87 | const obs$ = of('my test value'); 88 | obs$ 89 | .pipe( 90 | debug({ 91 | label: 'Obserable A', 92 | next: (value) => console.log(value), 93 | }) 94 | ) 95 | .subscribe(); 96 | 97 | // OUTPUT: 98 | // my test value 99 | ``` 100 | 101 | We can also set up our own notification handlers if we prefer: 102 | 103 | ```ts 104 | const obs$ = of('my test value'); 105 | obs$ 106 | .pipe(debug({ next: (value) => console.log('my custom handler:', value) })) 107 | .subscribe(); 108 | 109 | // OUTPUT: 110 | // my custom handler: my test value 111 | 112 | const obs$ = throwError('uh oh'); 113 | obs$ 114 | .pipe(debug({ error: (value) => console.log('my error handler:', value) })) 115 | .subscribe(); 116 | 117 | // OUTPUT: 118 | // my error handler: uh oh 119 | 120 | const obs$ = of('my test value'); 121 | obs$ 122 | .pipe(debug({ complete: (value) => console.log('I completed') })) 123 | .subscribe(); 124 | 125 | // OUTPUT: 126 | // I completed 127 | ``` 128 | 129 | We can access the default logger for more flexibility: 130 | 131 | ```js 132 | const obs$ = of('my test value'); 133 | 134 | obs$ 135 | .pipe( 136 | debug((logger) => ({ 137 | next: (v) => logger.warn('Warning!', v), 138 | })) 139 | ) 140 | .subscribe(); 141 | 142 | // OUTPUT 143 | // WARN: Warning! my test value 144 | ``` 145 | 146 | ## Setting Global Config 147 | 148 | You can set some globals that make it more convenient to change: 149 | 150 | - the default logger 151 | - a global prefix to be appended to all logs 152 | - a global-level ignore flag 153 | 154 | ### Change the Default Logger 155 | 156 | You can change the default logger by creating an object that matches the `DebugLogger` interface, which can be seen below: 157 | 158 | ```ts 159 | export interface DebugLogger { 160 | log: (...args: unknown[]) => void; 161 | error: (...args: unknown[]) => void; 162 | warn?: (...args: unknown[]) => void; 163 | debug?: (...args: unknown[]) => void; 164 | info?: (...args: unknown[]) => void; 165 | } 166 | ``` 167 | 168 | Once you have created your new logger, you can set it to be used as the default logger using `setGlobalDebugConfig()` 169 | 170 | ```js 171 | setGlobalDebugConfig({ 172 | logger: myNewLogger, 173 | }); 174 | ``` 175 | 176 | Now all your `debug()` operators will use your new logger to log the values it receives. 177 | 178 | ### Adding a Global Prefix 179 | 180 | You can also add a string prefix to all your logs at a global level, which can be useful to help identify logs. 181 | 182 | ```js 183 | setGlobalDebugConfig({ 184 | prefix: 'My Prefix', 185 | }); 186 | ``` 187 | 188 | ### Setting whether to ignore logging 189 | 190 | You can also set whether all `debug()` should not log at the global level. This can be useful for turning it off in production environments. 191 | 192 | ```js 193 | setGlobalDebugConfig({ 194 | shouldIgnore: isProduction, 195 | }); 196 | ``` 197 | 198 | ### Example Winston Usage 199 | 200 | ```ts 201 | import { DebugLogger, setGlobalDebugConfig } from 'rxjs-debug-operator'; 202 | const winston = require('winston'); 203 | 204 | const sysLogger = winston.createLogger({ 205 | level: 'info', 206 | format: winston.format.json(), 207 | transports: [ 208 | // 209 | // - Write all logs with level `error` and below to `error.log` 210 | // - Write all logs with level `info` and below to `combined.log` 211 | // 212 | new winston.transports.File({ filename: 'error.log', level: 'error' }), 213 | new winston.transports.File({ filename: 'combined.log' }), 214 | ], 215 | }); 216 | 217 | const debugLogger: DebugLogger = { 218 | log: (v) => sysLogger.info(v), 219 | error: (e) => sysLogger.error(e), 220 | }; 221 | 222 | setGlobalDebugConfig({ logger: debugLogger }); 223 | 224 | const obs$ = of('my test value'); 225 | obs$.pipe(debug()).subscribe(); 226 | 227 | // OUTPUT 228 | // 'my test value' written to `combined.log` 229 | ``` 230 | 231 | ### **NOTES** 232 | 233 | **It should be noted that local config options passed to the `debug()` operator will take precedence over any global values** 234 | 235 | ## API 236 | 237 | ### Debug 238 | 239 | `debug(config?: Partial)` 240 | 241 | ### DebugOperatorConfig 242 | 243 | See the list of options available to configure the operator below 244 | 245 | | Option | Description | Type | Default | 246 | | -------------- | :----------------------------------------------------------------: | -------------------------- | --------------- | 247 | | `shouldIgnore` | Do not perform the Debug actions | `boolean` | `false` | 248 | | `label` | Add a label to the logs to help identify the Observable | `string` | `null` | 249 | | `next` | Action to perform when Observer receives a Next notification | `(value: T) => void` | `console.log` | 250 | | `error` | Action to perform when Observer receives an Error notification | `(value: unknown) => void` | `console.error` | 251 | | `complete` | Action to perform when Observer receives a Completion notification | `() => void` | `() => null` | 252 | 253 | ### Global Debug Config 254 | 255 | `setGlobalDebugConfig(config: Partial)` 256 | 257 | ### GlobalDebugConfig 258 | 259 | | Option | Description | Type | Default | 260 | | -------------- | :-----------------------------------------------------: | ------------- | --------- | 261 | | `shouldIgnore` | Do not perform the Debug actions | `boolean` | `false` | 262 | | `prefix` | Add a label to the logs to help identify the Observable | `string` | `null` | 263 | | `logger` | Logger to use to log values recieved by `debug()` | `DebugLogger` | `console` | 264 | 265 | ### DebugLogger 266 | 267 | | Option | Description | Type | Default | 268 | | -------- | :---------: | ------------------------------ | --------------- | 269 | | `log` | Basic log | `(...args: unknown[]) => void` | `console.log` | 270 | | `error` | Error log | `(...args: unknown[]) => void` | `console.error` | 271 | | `info?` | Info log | `(...args: unknown[]) => void` | `console.info` | 272 | | `warn?` | Warn log | `(...args: unknown[]) => void` | `console.warn` | 273 | | `debug?` | Debug log | `(...args: unknown[]) => void` | `console.debug` | 274 | -------------------------------------------------------------------------------- /packages/operators/debug/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | displayName: 'operators-debug', 3 | preset: '../../../jest.preset.js', 4 | globals: { 5 | 'ts-jest': { 6 | tsConfig: '/tsconfig.spec.json', 7 | }, 8 | }, 9 | transform: { 10 | '^.+\\.[tj]sx?$': 'ts-jest', 11 | }, 12 | moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], 13 | coverageDirectory: '../../../coverage/packages/operators/debug', 14 | }; 15 | -------------------------------------------------------------------------------- /packages/operators/debug/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rxjs-debug-operator", 3 | "version": "2.0.0", 4 | "license": "MIT", 5 | "repository": { 6 | "url": "https://github.com/Coly010/rxjs-debug-operator" 7 | }, 8 | "keywords": [ 9 | "rxjs", 10 | "operator" 11 | ], 12 | "author": { 13 | "name": "Colum Ferry", 14 | "url": "https://columferry.co.uk" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/operators/debug/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './lib/debug-config'; 2 | export * from './lib/global-debug-config'; 3 | export * from './lib/debug-logger'; 4 | export * from './lib/operators-debug'; 5 | -------------------------------------------------------------------------------- /packages/operators/debug/src/lib/debug-config.ts: -------------------------------------------------------------------------------- 1 | import { Observer } from 'rxjs'; 2 | import { GLOBAL_CONFIG } from './global-debug-config'; 3 | 4 | export interface DebugOperatorConfig extends Omit, 'closed'> { 5 | shouldIgnore: boolean; 6 | label: string; 7 | next: (value: T) => void; 8 | error: (value: unknown) => void; 9 | complete: () => void; 10 | } 11 | 12 | export function createDefaultConfig( 13 | label: string = null 14 | ): DebugOperatorConfig { 15 | const { logger, prefix, shouldIgnore } = GLOBAL_CONFIG; 16 | 17 | if (!label && prefix) { 18 | label = prefix; 19 | } else if (label && prefix) { 20 | label = `${prefix} ${label}`; 21 | } 22 | 23 | return { 24 | shouldIgnore, 25 | label, 26 | next: label ? (v) => logger.log(label, v) : logger.log, 27 | error: label ? (e) => logger.error(label, e) : logger.error, 28 | complete: label ? () => logger.log(`${label} completed`) : () => null, 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /packages/operators/debug/src/lib/debug-logger.ts: -------------------------------------------------------------------------------- 1 | export interface DebugLogger { 2 | log: (...args: unknown[]) => void; 3 | error: (...args: unknown[]) => void; 4 | warn?: (...args: unknown[]) => void; 5 | debug?: (...args: unknown[]) => void; 6 | info?: (...args: unknown[]) => void; 7 | } 8 | 9 | export const defaultLogger: DebugLogger = { 10 | log: console.log, 11 | error: console.error, 12 | warn: console.warn, 13 | debug: console.debug, 14 | info: console.info, 15 | }; 16 | -------------------------------------------------------------------------------- /packages/operators/debug/src/lib/global-debug-config.ts: -------------------------------------------------------------------------------- 1 | import { DebugLogger, defaultLogger } from './debug-logger'; 2 | 3 | export interface GlobalDebugConfig { 4 | logger: DebugLogger; 5 | prefix: string; 6 | shouldIgnore: boolean; 7 | } 8 | 9 | export function createDefaultGlobalDebugConfig() { 10 | return { 11 | logger: defaultLogger, 12 | prefix: null, 13 | shouldIgnore: false, 14 | }; 15 | } 16 | 17 | export function setGlobalDebugConfig(config: Partial) { 18 | GLOBAL_CONFIG = { ...GLOBAL_CONFIG, ...config }; 19 | } 20 | 21 | /** 22 | * @private DO NOT USE DIRECTLY 23 | */ 24 | export let GLOBAL_CONFIG: GlobalDebugConfig = createDefaultGlobalDebugConfig(); 25 | -------------------------------------------------------------------------------- /packages/operators/debug/src/lib/operators-debug.spec.ts: -------------------------------------------------------------------------------- 1 | import { of, throwError } from 'rxjs'; 2 | import { DebugOperatorConfig } from './debug-config'; 3 | import { DebugLogger } from './debug-logger'; 4 | import { 5 | createDefaultGlobalDebugConfig, 6 | setGlobalDebugConfig, 7 | } from './global-debug-config'; 8 | import { debug } from './operators-debug'; 9 | 10 | describe('operators - debug', () => { 11 | let testLogger: DebugLogger; 12 | 13 | beforeEach(() => { 14 | console.log = jest.fn(); 15 | console.error = jest.fn(); 16 | 17 | testLogger = { 18 | log: console.log, 19 | error: console.error, 20 | }; 21 | 22 | setGlobalDebugConfig({ logger: testLogger }); 23 | }); 24 | 25 | describe('when shouldIgnore is false', () => { 26 | it('should log value to the console when next notification receieved', () => { 27 | // ARRANGE 28 | const obs$ = of('my test value'); 29 | 30 | // ACT 31 | obs$.pipe(debug()).subscribe(); 32 | 33 | // ASSERT 34 | expect(testLogger.log).toHaveBeenCalledWith('my test value'); 35 | }); 36 | 37 | it('should error value to the console when error notification receieved', () => { 38 | // ARRANGE 39 | const obs$ = throwError('my error value'); 40 | 41 | // ACT 42 | obs$.pipe(debug()).subscribe(); 43 | 44 | // ASSERT 45 | expect(testLogger.error).toHaveBeenCalledWith('my error value'); 46 | }); 47 | }); 48 | 49 | describe('when shouldIgnore is true', () => { 50 | it('should not log value to the console when next notification receieved', () => { 51 | // ARRANGE 52 | const obs$ = of('my test value'); 53 | 54 | // ACT 55 | obs$.pipe(debug({ shouldIgnore: true })).subscribe(); 56 | 57 | // ASSERT 58 | expect(console.log).not.toHaveBeenCalledWith('my test value'); 59 | }); 60 | 61 | it('should not error value to the console when error notification receieved', () => { 62 | // ARRANGE 63 | const obs$ = throwError('my error value'); 64 | 65 | // ACT 66 | obs$.pipe(debug({ shouldIgnore: true })).subscribe(); 67 | 68 | // ASSERT 69 | expect(console.error).not.toHaveBeenCalledWith('my error value'); 70 | }); 71 | }); 72 | 73 | describe('when custom handlers are used', () => { 74 | let config: Partial>; 75 | 76 | beforeEach( 77 | () => 78 | (config = { 79 | shouldIgnore: false, 80 | next: (value) => console.log('I received: ', value), 81 | error: (value) => console.error('I received: ', value), 82 | complete: () => console.log('I received a completion'), 83 | }) 84 | ); 85 | 86 | describe('and when shouldIgnore is false', () => { 87 | beforeEach(() => (config.shouldIgnore = false)); 88 | 89 | it('should log value to the console when next notification receieved', () => { 90 | // ARRANGE 91 | const obs$ = of('my test value'); 92 | 93 | // ACT 94 | obs$.pipe(debug(config)).subscribe(); 95 | 96 | // ASSERT 97 | expect(console.log).toHaveBeenCalledWith( 98 | 'I received: ', 99 | 'my test value' 100 | ); 101 | }); 102 | 103 | it('should error value to the console when error notification receieved', () => { 104 | // ARRANGE 105 | const obs$ = throwError('my error value'); 106 | 107 | // ACT 108 | obs$.pipe(debug(config)).subscribe(); 109 | 110 | // ASSERT 111 | expect(console.error).toHaveBeenCalledWith( 112 | 'I received: ', 113 | 'my error value' 114 | ); 115 | }); 116 | 117 | it('should log value to the console when complete notification receieved', () => { 118 | // ARRANGE 119 | const obs$ = of('my test value'); 120 | 121 | // ACT 122 | obs$.pipe(debug(config)).subscribe(); 123 | 124 | // ASSERT 125 | expect(console.log).toHaveBeenCalledTimes(2); 126 | expect(console.log).toHaveBeenNthCalledWith( 127 | 2, 128 | 'I received a completion' 129 | ); 130 | }); 131 | }); 132 | 133 | describe('and when shouldIgnore is true', () => { 134 | beforeEach(() => (config.shouldIgnore = true)); 135 | 136 | it('should log value to the console when next notification receieved', () => { 137 | // ARRANGE 138 | const obs$ = of('my test value'); 139 | 140 | // ACT 141 | obs$.pipe(debug(config)).subscribe(); 142 | 143 | // ASSERT 144 | expect(console.log).not.toHaveBeenCalledWith( 145 | 'I received: ', 146 | 'my test value' 147 | ); 148 | }); 149 | 150 | it('should error value to the console when error notification receieved', () => { 151 | // ARRANGE 152 | const obs$ = throwError('my error value'); 153 | 154 | // ACT 155 | obs$.pipe(debug(config)).subscribe(); 156 | 157 | // ASSERT 158 | expect(console.error).not.toHaveBeenCalledWith( 159 | 'I received: ', 160 | 'my error value' 161 | ); 162 | }); 163 | 164 | it('should log value to the console when complete notification receieved', () => { 165 | // ARRANGE 166 | const obs$ = of('my test value'); 167 | 168 | // ACT 169 | obs$.pipe(debug(config)).subscribe(); 170 | 171 | // ASSERT 172 | expect(console.log).not.toHaveBeenCalledTimes(2); 173 | expect(console.log).not.toHaveBeenNthCalledWith( 174 | 2, 175 | 'I received a completion' 176 | ); 177 | }); 178 | }); 179 | }); 180 | 181 | describe('when a mix of custom and default handlers are used', () => { 182 | let config: Partial>; 183 | 184 | beforeEach( 185 | () => 186 | (config = { 187 | shouldIgnore: false, 188 | next: (value) => console.log('I received: ', value), 189 | complete: () => console.log('I received a completion'), 190 | }) 191 | ); 192 | 193 | describe('and when shouldIgnore is false', () => { 194 | beforeEach(() => (config.shouldIgnore = false)); 195 | 196 | it('should log value to the console when next notification receieved', () => { 197 | // ARRANGE 198 | const obs$ = of('my test value'); 199 | 200 | // ACT 201 | obs$.pipe(debug(config)).subscribe(); 202 | 203 | // ASSERT 204 | expect(console.log).toHaveBeenCalledWith( 205 | 'I received: ', 206 | 'my test value' 207 | ); 208 | }); 209 | 210 | it('should error value to the console when error notification receieved', () => { 211 | // ARRANGE 212 | const obs$ = throwError('my error value'); 213 | 214 | // ACT 215 | obs$.pipe(debug(config)).subscribe(); 216 | 217 | // ASSERT 218 | expect(console.error).toHaveBeenCalledWith('my error value'); 219 | }); 220 | 221 | it('should log value to the console when complete notification receieved', () => { 222 | // ARRANGE 223 | const obs$ = of('my test value'); 224 | 225 | // ACT 226 | obs$.pipe(debug(config)).subscribe(); 227 | 228 | // ASSERT 229 | expect(console.log).toHaveBeenCalledTimes(2); 230 | expect(console.log).toHaveBeenNthCalledWith( 231 | 2, 232 | 'I received a completion' 233 | ); 234 | }); 235 | }); 236 | 237 | describe('and when shouldIgnore is true', () => { 238 | beforeEach(() => (config.shouldIgnore = true)); 239 | 240 | it('should not log value to the console when next notification receieved', () => { 241 | // ARRANGE 242 | const obs$ = of('my test value'); 243 | 244 | // ACT 245 | obs$.pipe(debug(config)).subscribe(); 246 | 247 | // ASSERT 248 | expect(console.log).not.toHaveBeenCalledWith( 249 | 'I received: ', 250 | 'my test value' 251 | ); 252 | }); 253 | 254 | it('should not error value to the console when error notification receieved', () => { 255 | // ARRANGE 256 | const obs$ = throwError('my error value'); 257 | 258 | // ACT 259 | obs$.pipe(debug(config)).subscribe(); 260 | 261 | // ASSERT 262 | expect(console.error).not.toHaveBeenCalledWith('my error value'); 263 | }); 264 | 265 | it('should not log value to the console when complete notification receieved', () => { 266 | // ARRANGE 267 | const obs$ = of('my test value'); 268 | 269 | // ACT 270 | obs$.pipe(debug(config)).subscribe(); 271 | 272 | // ASSERT 273 | expect(console.log).not.toHaveBeenCalledTimes(2); 274 | expect(console.log).not.toHaveBeenNthCalledWith( 275 | 2, 276 | 'I received a completion' 277 | ); 278 | }); 279 | }); 280 | }); 281 | 282 | describe('when a label is used', () => { 283 | describe('using a string param', () => { 284 | it('should log value to the console when next notification receieved with the label', () => { 285 | // ARRANGE 286 | const obs$ = of('my test value'); 287 | 288 | // ACT 289 | obs$.pipe(debug('Test Label')).subscribe(); 290 | 291 | // ASSERT 292 | expect(console.log).toHaveBeenCalledWith('Test Label', 'my test value'); 293 | }); 294 | 295 | it('should error value to the console when error notification receieved with the label', () => { 296 | // ARRANGE 297 | const obs$ = throwError('my error value'); 298 | 299 | // ACT 300 | obs$.pipe(debug('Test Label')).subscribe(); 301 | 302 | // ASSERT 303 | expect(console.error).toHaveBeenCalledWith( 304 | 'Test Label', 305 | 'my error value' 306 | ); 307 | }); 308 | }); 309 | 310 | describe('using the config object', () => { 311 | let config: Partial>; 312 | 313 | beforeEach( 314 | () => 315 | (config = { 316 | shouldIgnore: false, 317 | label: 'Test Label', 318 | }) 319 | ); 320 | 321 | describe('and when shouldIgnore is false', () => { 322 | beforeEach(() => (config.shouldIgnore = false)); 323 | 324 | it('should log value to the console when next notification receieved', () => { 325 | // ARRANGE 326 | const obs$ = of('my test value'); 327 | 328 | // ACT 329 | obs$.pipe(debug(config)).subscribe(); 330 | 331 | // ASSERT 332 | expect(console.log).toHaveBeenCalledWith( 333 | 'Test Label', 334 | 'my test value' 335 | ); 336 | }); 337 | 338 | it('should error value to the console when error notification receieved', () => { 339 | // ARRANGE 340 | const obs$ = throwError('my error value'); 341 | 342 | // ACT 343 | obs$.pipe(debug(config)).subscribe(); 344 | 345 | // ASSERT 346 | expect(console.error).toHaveBeenCalledWith( 347 | 'Test Label', 348 | 'my error value' 349 | ); 350 | }); 351 | 352 | it('should log value to the console when complete notification receieved', () => { 353 | // ARRANGE 354 | const obs$ = of('my test value'); 355 | 356 | // ACT 357 | obs$.pipe(debug(config)).subscribe(); 358 | 359 | // ASSERT 360 | expect(console.log).toHaveBeenCalledTimes(2); 361 | expect(console.log).toHaveBeenNthCalledWith( 362 | 2, 363 | 'Test Label completed' 364 | ); 365 | }); 366 | }); 367 | 368 | describe('and when shouldIgnore is true', () => { 369 | beforeEach(() => (config.shouldIgnore = true)); 370 | 371 | it('should not log value to the console when next notification receieved', () => { 372 | // ARRANGE 373 | const obs$ = of('my test value'); 374 | 375 | // ACT 376 | obs$.pipe(debug(config)).subscribe(); 377 | 378 | // ASSERT 379 | expect(console.log).not.toHaveBeenCalledWith( 380 | 'Test Label', 381 | 'my test value' 382 | ); 383 | }); 384 | 385 | it('should not error value to the console when error notification receieved', () => { 386 | // ARRANGE 387 | const obs$ = throwError('my error value'); 388 | 389 | // ACT 390 | obs$.pipe(debug(config)).subscribe(); 391 | 392 | // ASSERT 393 | expect(console.error).not.toHaveBeenCalledWith( 394 | 'Test Label', 395 | 'my error value' 396 | ); 397 | }); 398 | 399 | it('should not log value to the console when complete notification receieved', () => { 400 | // ARRANGE 401 | const obs$ = of('my test value'); 402 | 403 | // ACT 404 | obs$.pipe(debug(config)).subscribe(); 405 | 406 | // ASSERT 407 | expect(console.log).not.toHaveBeenCalledTimes(2); 408 | expect(console.log).not.toHaveBeenNthCalledWith( 409 | 2, 410 | 'Test Label completed' 411 | ); 412 | }); 413 | }); 414 | }); 415 | }); 416 | 417 | describe('when we change the global config', () => { 418 | describe('by setting a new logger', () => { 419 | beforeEach(() => { 420 | console.warn = jest.fn(); 421 | console.debug = jest.fn(); 422 | 423 | setGlobalDebugConfig({ 424 | logger: { 425 | log: console.warn, 426 | error: console.debug, 427 | }, 428 | }); 429 | }); 430 | 431 | it('should use the new logger to log the next notification', () => { 432 | // ARRANGE 433 | const obs$ = of('my test value'); 434 | 435 | // ACT 436 | obs$.pipe(debug()).subscribe(); 437 | 438 | // ASSERT 439 | expect(console.warn).toHaveBeenCalled(); 440 | expect(console.warn).toHaveBeenCalledWith('my test value'); 441 | }); 442 | 443 | it('should use the new logger to log the error notification', () => { 444 | // ARRANGE 445 | const obs$ = throwError('my error value'); 446 | 447 | // ACT 448 | obs$.pipe(debug()).subscribe(); 449 | 450 | // ASSERT 451 | expect(console.debug).toHaveBeenCalled(); 452 | expect(console.debug).toHaveBeenCalledWith('my error value'); 453 | }); 454 | 455 | it('should allow for local overwrites of global config', () => { 456 | // ARRANGE 457 | const obs$ = of('my test value'); 458 | 459 | // ACT 460 | obs$.pipe(debug({ next: console.log })).subscribe(); 461 | 462 | // ASSERT 463 | expect(console.log).toHaveBeenCalled(); 464 | expect(console.log).toHaveBeenCalledWith('my test value'); 465 | }); 466 | 467 | it('should allow usage of the global logger for local overwrites', () => { 468 | // ARRANGE 469 | const obs$ = of('my test value'); 470 | 471 | // ACT 472 | obs$ 473 | .pipe( 474 | debug((logger) => ({ 475 | next: () => logger.log('I changed this completely'), 476 | })) 477 | ) 478 | .subscribe(); 479 | 480 | // ASSERT 481 | expect(console.warn).toHaveBeenCalled(); 482 | expect(console.warn).toHaveBeenCalledWith('I changed this completely'); 483 | }); 484 | }); 485 | 486 | describe('by setting a prefix', () => { 487 | beforeEach(() => { 488 | setGlobalDebugConfig({ 489 | prefix: 'Test Prefix', 490 | }); 491 | }); 492 | 493 | it('should use the new prefix when logging the next notification', () => { 494 | // ARRANGE 495 | const obs$ = of('my test value'); 496 | 497 | // ACT 498 | obs$.pipe(debug()).subscribe(); 499 | 500 | // ASSERT 501 | expect(console.log).toHaveBeenCalled(); 502 | expect(console.log).toHaveBeenCalledWith( 503 | 'Test Prefix', 504 | 'my test value' 505 | ); 506 | }); 507 | 508 | it('should prepend the new prefix to a label when logging the next notification', () => { 509 | // ARRANGE 510 | const obs$ = of('my test value'); 511 | 512 | // ACT 513 | obs$.pipe(debug('my label')).subscribe(); 514 | 515 | // ASSERT 516 | expect(console.log).toHaveBeenCalled(); 517 | expect(console.log).toHaveBeenCalledWith( 518 | 'Test Prefix my label', 519 | 'my test value' 520 | ); 521 | }); 522 | }); 523 | 524 | describe('by setting a global shouldIgnore value', () => { 525 | beforeEach(() => { 526 | setGlobalDebugConfig({ 527 | ...createDefaultGlobalDebugConfig(), 528 | logger: testLogger, // Have to reset to get the Jest Mock 529 | shouldIgnore: true, 530 | }); 531 | }); 532 | 533 | it('should not log the next notification', () => { 534 | // ARRANGE 535 | const obs$ = of('my test value'); 536 | 537 | // ACT 538 | obs$.pipe(debug()).subscribe(); 539 | 540 | // ASSERT 541 | expect(console.log).not.toHaveBeenCalled(); 542 | expect(console.log).not.toHaveBeenCalledWith('my test value'); 543 | }); 544 | 545 | it('should allow local overwrite of global shouldIgnore', () => { 546 | // ARRANGE 547 | const obs$ = of('my test value'); 548 | 549 | // ACT 550 | obs$.pipe(debug({ shouldIgnore: false })).subscribe(); 551 | 552 | // ASSERT 553 | expect(console.log).toHaveBeenCalled(); 554 | expect(console.log).toHaveBeenCalledWith('my test value'); 555 | }); 556 | }); 557 | }); 558 | }); 559 | -------------------------------------------------------------------------------- /packages/operators/debug/src/lib/operators-debug.ts: -------------------------------------------------------------------------------- 1 | import { MonoTypeOperatorFunction, Observable } from 'rxjs'; 2 | import { tap } from 'rxjs/operators'; 3 | import { createDefaultConfig, DebugOperatorConfig } from './debug-config'; 4 | import { DebugLogger } from './debug-logger'; 5 | import { GLOBAL_CONFIG } from './global-debug-config'; 6 | 7 | /** 8 | * Used to help debug the observable as it receives notifications 9 | * 10 | * @param config The config to be used to set up the operator 11 | */ 12 | export function debug( 13 | config?: 14 | | Partial> 15 | | ((logger: DebugLogger) => Partial>) 16 | | string 17 | ): MonoTypeOperatorFunction { 18 | let mergedConfig: DebugOperatorConfig; 19 | 20 | if (typeof config === 'string') { 21 | mergedConfig = createDefaultConfig(config); 22 | } else if (typeof config === 'function') { 23 | mergedConfig = { 24 | ...createDefaultConfig(), 25 | ...config(GLOBAL_CONFIG.logger), 26 | }; 27 | } else { 28 | mergedConfig = { ...createDefaultConfig(config?.label), ...config }; 29 | } 30 | 31 | const { shouldIgnore, next, error, complete } = mergedConfig; 32 | 33 | return (source: Observable) => 34 | shouldIgnore ? source : source.pipe(tap(next, error, complete)); 35 | } 36 | -------------------------------------------------------------------------------- /packages/operators/debug/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../../tsconfig.base.json", 3 | "files": [], 4 | "include": [], 5 | "references": [ 6 | { 7 | "path": "./tsconfig.lib.json" 8 | }, 9 | { 10 | "path": "./tsconfig.spec.json" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /packages/operators/debug/tsconfig.lib.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "outDir": "../../../dist/out-tsc", 6 | "declaration": true, 7 | "types": ["node"] 8 | }, 9 | "exclude": ["**/*.spec.ts"], 10 | "include": ["**/*.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /packages/operators/debug/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../../dist/out-tsc", 5 | "module": "commonjs", 6 | "types": ["jest", "node"] 7 | }, 8 | "include": [ 9 | "**/*.spec.ts", 10 | "**/*.spec.tsx", 11 | "**/*.spec.js", 12 | "**/*.spec.jsx", 13 | "**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /tools/generators/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coly010/rxjs-debug-operator/2481e14774f942bb3d8096524eac4cb705a2541a/tools/generators/.gitkeep -------------------------------------------------------------------------------- /tools/tsconfig.tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "outDir": "../dist/out-tsc/tools", 5 | "rootDir": ".", 6 | "module": "commonjs", 7 | "target": "es5", 8 | "types": ["node"], 9 | "importHelpers": false 10 | }, 11 | "include": ["**/*.ts"] 12 | } 13 | -------------------------------------------------------------------------------- /tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "sourceMap": true, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "importHelpers": true, 11 | "target": "es2015", 12 | "module": "esnext", 13 | "lib": ["es2017", "dom"], 14 | "skipLibCheck": true, 15 | "skipDefaultLibCheck": true, 16 | "baseUrl": ".", 17 | "paths": { 18 | "@rxjs-debug-operator/operators/debug": [ 19 | "packages/operators/debug/src/index.ts" 20 | ], 21 | "something": ["packages/testing/src/index.ts"], 22 | "rxjs-debug-operator": ["packages/operators/debug/src/index.ts"] 23 | } 24 | }, 25 | "exclude": ["node_modules", "tmp"] 26 | } 27 | -------------------------------------------------------------------------------- /workspace.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "projects": { 4 | "operators-debug": { 5 | "root": "packages/operators/debug", 6 | "sourceRoot": "packages/operators/debug/src", 7 | "projectType": "library", 8 | "targets": { 9 | "lint": { 10 | "executor": "@nrwl/linter:eslint", 11 | "options": { 12 | "lintFilePatterns": [ 13 | "packages/operators/debug/**/*.ts" 14 | ] 15 | } 16 | }, 17 | "test": { 18 | "executor": "@nrwl/jest:jest", 19 | "outputs": [ 20 | "coverage/packages/operators/debug" 21 | ], 22 | "options": { 23 | "jestConfig": "packages/operators/debug/jest.config.js", 24 | "passWithNoTests": true 25 | } 26 | }, 27 | "build": { 28 | "executor": "@nrwl/node:package", 29 | "outputs": [ 30 | "{options.outputPath}" 31 | ], 32 | "options": { 33 | "outputPath": "dist/packages/operators/debug", 34 | "tsConfig": "packages/operators/debug/tsconfig.lib.json", 35 | "packageJson": "packages/operators/debug/package.json", 36 | "main": "packages/operators/debug/src/index.ts", 37 | "assets": [ 38 | "packages/operators/debug/*.md" 39 | ] 40 | } 41 | } 42 | } 43 | } 44 | }, 45 | "cli": { 46 | "defaultCollection": "@nrwl/workspace" 47 | } 48 | } --------------------------------------------------------------------------------