docs(groupBy): fix examples
Fixes a few glitches so the examples are runnable.
This also includes stripping the type definitions since the example
code blocks specify `javascript`, and the other examples I've seen so
far don't seem to include these.
MODIFY
src/internal/operators/groupBy.ts
src/internal/operators/groupBy.ts
@@ -38,12 +38,7 @@ export function groupBy<T, K, R>(keySelector: (value: T) => K, elementSelector?:
* import { of } from 'rxjs';
* import { mergeMap, groupBy, reduce } from 'rxjs/operators';
*
- * interface Obj {
- * id: number,
- * name: string,
- * }
- *
- * of<Obj>(
+ * of(
* {id: 1, name: 'JavaScript'},
* {id: 2, name: 'Parcel'},
* {id: 2, name: 'webpack'},
@@ -69,18 +64,21 @@ export function groupBy<T, K, R>(keySelector: (value: T) => K, elementSelector?:
*
* ```javascript
* import { of } from 'rxjs';
- * import { mergeMap, groupBy, map, reduce } from 'rxjs/operators';
+ * import { groupBy, map, mergeMap, reduce } from 'rxjs/operators';
*
- * of<Obj>(
+ * of(
* { id: 1, name: 'JavaScript' },
* { id: 2, name: 'Parcel' },
* { id: 2, name: 'webpack' },
- * {id: 1, name: 'TypeScript'}
+ * { id: 1, name: 'TypeScript' },
* { id: 3, name: 'TSLint' }
- * ).pipe(
+ * )
+ * .pipe(
* groupBy(p => p.id, p => p.name),
- * mergeMap( (group$) => group$.pipe(reduce((acc, cur) => [...acc, cur], ["" + group$.key]))),
- * map(arr => ({'id': parseInt(arr[0]), 'values': arr.slice(1)})),
+ * mergeMap(group$ =>
+ * group$.pipe(reduce((acc, cur) => [...acc, cur], [`${group$.key}`]))
+ * ),
+ * map(arr => ({ id: parseInt(arr[0], 10), values: arr.slice(1) }))
* )
* .subscribe(p => console.log(p));
*

docs(groupBy): fix examples (#4554)

Fixes a few glitches so the examples are runnable.

This also includes stripping the type definitions since the example
code blocks specify `javascript`, and the other examples I've seen so
far don't seem to include these.