Skip to content

Commit 2713380

Browse files
tetsuharuohzekikwonoj
authored andcommitted
refactor(audit): rename from 'inspect' to 'audit'
BREAKING CHANGE: `inspect` operator is renamed to `audit`
1 parent 3319a80 commit 2713380

File tree

6 files changed

+45
-45
lines changed

6 files changed

+45
-45
lines changed

doc/operators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ There are operators for different purposes, and they may be categorized as: crea
166166
- [`filter`](../class/es6/Observable.js~Observable.html#instance-method-filter)
167167
- [`first`](../class/es6/Observable.js~Observable.html#instance-method-first)
168168
- [`ignoreElements`](../class/es6/Observable.js~Observable.html#instance-method-ignoreElements)
169-
- [`inspect`](../class/es6/Observable.js~Observable.html#instance-method-inspect)
169+
- [`audit`](../class/es6/Observable.js~Observable.html#instance-method-audit)
170170
- [`inspectTime`](../class/es6/Observable.js~Observable.html#instance-method-inspectTime)
171171
- [`last`](../class/es6/Observable.js~Observable.html#instance-method-last)
172172
- [`sample`](../class/es6/Observable.js~Observable.html#instance-method-sample)

spec/operators/inspect-spec.ts renamed to spec/operators/audit-spec.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {DoneSignature} from '../helpers/test-helper';
44

55
const Observable = Rx.Observable;
66

7-
/** @test {inspect} */
8-
describe('Observable.prototype.inspect', () => {
9-
asDiagram('inspect')('should emit the last value in each time window', () => {
7+
/** @test {audit} */
8+
describe('Observable.prototype.audit', () => {
9+
asDiagram('audit')('should emit the last value in each time window', () => {
1010
const e1 = hot('-a-xy-----b--x--cxxx-|');
1111
const e1subs = '^ !';
1212
const e2 = cold( '----| ');
@@ -15,7 +15,7 @@ describe('Observable.prototype.inspect', () => {
1515
' ^ ! '];
1616
const expected = '-----y--------x-----x|';
1717

18-
const result = e1.inspect(() => e2);
18+
const result = e1.audit(() => e2);
1919

2020
expectObservable(result).toBe(expected);
2121
expectSubscriptions(e1.subscriptions).toBe(e1subs);
@@ -31,14 +31,14 @@ describe('Observable.prototype.inspect', () => {
3131
' ^ ! '];
3232
const expected = '-----a--------b-----c|';
3333

34-
const result = e1.inspect(() => e2);
34+
const result = e1.audit(() => e2);
3535

3636
expectObservable(result).toBe(expected);
3737
expectSubscriptions(e1.subscriptions).toBe(e1subs);
3838
expectSubscriptions(e2.subscriptions).toBe(e2subs);
3939
});
4040

41-
it('should inspect with duration Observable using next to close the duration', () => {
41+
it('should audit with duration Observable using next to close the duration', () => {
4242
const e1 = hot('-a-xy-----b--x--cxxx-|');
4343
const e1subs = '^ !';
4444
const e2 = cold( '----x-y-z ');
@@ -47,7 +47,7 @@ describe('Observable.prototype.inspect', () => {
4747
' ^ ! '];
4848
const expected = '-----y--------x-----x|';
4949

50-
const result = e1.inspect(() => e2);
50+
const result = e1.audit(() => e2);
5151

5252
expectObservable(result).toBe(expected);
5353
expectSubscriptions(e1.subscriptions).toBe(e1subs);
@@ -64,7 +64,7 @@ describe('Observable.prototype.inspect', () => {
6464
' ^! '];
6565
const expected = '------y-----z-- ';
6666

67-
const result = e1.inspect(() => e2);
67+
const result = e1.audit(() => e2);
6868

6969
expectObservable(result, unsub).toBe(expected);
7070
expectSubscriptions(e1.subscriptions).toBe(e1subs);
@@ -83,7 +83,7 @@ describe('Observable.prototype.inspect', () => {
8383

8484
const result = e1
8585
.mergeMap((x: string) => Observable.of(x))
86-
.inspect(() => e2)
86+
.audit(() => e2)
8787
.mergeMap((x: string) => Observable.of(x));
8888

8989
expectObservable(result, unsub).toBe(expected);
@@ -102,7 +102,7 @@ describe('Observable.prototype.inspect', () => {
102102
' ^!'];
103103
const expected = '-----f-----f-----f-----f-|';
104104

105-
const result = e1.inspect(() => e2);
105+
const result = e1.audit(() => e2);
106106

107107
expectObservable(result).toBe(expected);
108108
expectSubscriptions(e1.subscriptions).toBe(e1subs);
@@ -115,7 +115,7 @@ describe('Observable.prototype.inspect', () => {
115115
const e2 = cold('|');
116116
const expected = 'abcdefabcdefabcdefabcdefa|';
117117

118-
const result = e1.inspect(() => e2);
118+
const result = e1.audit(() => e2);
119119

120120
expectObservable(result).toBe(expected);
121121
expectSubscriptions(e1.subscriptions).toBe(e1subs);
@@ -128,7 +128,7 @@ describe('Observable.prototype.inspect', () => {
128128
const e2subs = ' ^ !';
129129
const expected = '-----------------------------|';
130130

131-
const result = e1.inspect(() => e2);
131+
const result = e1.audit(() => e2);
132132

133133
expectObservable(result).toBe(expected);
134134
expectSubscriptions(e1.subscriptions).toBe(e1subs);
@@ -142,7 +142,7 @@ describe('Observable.prototype.inspect', () => {
142142
const e2subs = ' ^ !';
143143
const expected = '-----------------------------#';
144144

145-
const result = e1.inspect(() => e2);
145+
const result = e1.audit(() => e2);
146146

147147
expectObservable(result).toBe(expected);
148148
expectSubscriptions(e1.subscriptions).toBe(e1subs);
@@ -156,14 +156,14 @@ describe('Observable.prototype.inspect', () => {
156156
const e2subs = ' (^!) ';
157157
const expected = '----(-#) ';
158158

159-
const result = e1.inspect(() => e2);
159+
const result = e1.audit(() => e2);
160160

161161
expectObservable(result).toBe(expected);
162162
expectSubscriptions(e1.subscriptions).toBe(e1subs);
163163
expectSubscriptions(e2.subscriptions).toBe(e2subs);
164164
});
165165

166-
it('should inspect using durations of constying lengths', () => {
166+
it('should audit using durations of constying lengths', () => {
167167
const e1 = hot('abcdefabcdabcdefghabca| ');
168168
const e1subs = '^ ! ';
169169
const e2 = [cold('-----| '),
@@ -179,7 +179,7 @@ describe('Observable.prototype.inspect', () => {
179179
const expected = '-----f---d-------h--c-| ';
180180

181181
let i = 0;
182-
const result = e1.inspect(() => e2[i++]);
182+
const result = e1.audit(() => e2[i++]);
183183

184184
expectObservable(result).toBe(expected);
185185
expectSubscriptions(e1.subscriptions).toBe(e1subs);
@@ -200,7 +200,7 @@ describe('Observable.prototype.inspect', () => {
200200
const expected = '-----f---d-------# ';
201201

202202
let i = 0;
203-
const result = e1.inspect(() => e2[i++]);
203+
const result = e1.audit(() => e2[i++]);
204204

205205
expectObservable(result).toBe(expected);
206206
expectSubscriptions(e1.subscriptions).toBe(e1subs);
@@ -220,7 +220,7 @@ describe('Observable.prototype.inspect', () => {
220220
const expected = '-----f---d# ';
221221

222222
let i = 0;
223-
const result = e1.inspect(() => {
223+
const result = e1.audit(() => {
224224
if (i === 2) {
225225
throw 'error';
226226
}
@@ -240,7 +240,7 @@ describe('Observable.prototype.inspect', () => {
240240
const expected = '-----|';
241241
function durationSelector() { return cold('-----|'); }
242242

243-
expectObservable(e1.inspect(durationSelector)).toBe(expected);
243+
expectObservable(e1.audit(durationSelector)).toBe(expected);
244244
expectSubscriptions(e1.subscriptions).toBe(subs);
245245
});
246246

@@ -250,7 +250,7 @@ describe('Observable.prototype.inspect', () => {
250250
const expected = '-----#';
251251
function durationSelector() { return cold('-----|'); }
252252

253-
expectObservable(e1.inspect(durationSelector)).toBe(expected);
253+
expectObservable(e1.audit(durationSelector)).toBe(expected);
254254
expectSubscriptions(e1.subscriptions).toBe(subs);
255255
});
256256

@@ -260,7 +260,7 @@ describe('Observable.prototype.inspect', () => {
260260
const expected = '|';
261261
function durationSelector() { return cold('-----|'); }
262262

263-
expectObservable(e1.inspect(durationSelector)).toBe(expected);
263+
expectObservable(e1.audit(durationSelector)).toBe(expected);
264264
expectSubscriptions(e1.subscriptions).toBe(subs);
265265
});
266266

@@ -270,7 +270,7 @@ describe('Observable.prototype.inspect', () => {
270270
const expected = '-';
271271
function durationSelector() { return cold('-----|'); }
272272

273-
expectObservable(e1.inspect(durationSelector)).toBe(expected);
273+
expectObservable(e1.audit(durationSelector)).toBe(expected);
274274
expectSubscriptions(e1.subscriptions).toBe(subs);
275275
});
276276

@@ -280,15 +280,15 @@ describe('Observable.prototype.inspect', () => {
280280
const expected = '#';
281281
function durationSelector() { return cold('-----|'); }
282282

283-
expectObservable(e1.inspect(durationSelector)).toBe(expected);
283+
expectObservable(e1.audit(durationSelector)).toBe(expected);
284284
expectSubscriptions(e1.subscriptions).toBe(subs);
285285
});
286286

287-
it('should inspect by promise resolves', (done: DoneSignature) => {
287+
it('should audit by promise resolves', (done: DoneSignature) => {
288288
const e1 = Observable.interval(10).take(5);
289289
const expected = [0, 1, 2, 3];
290290

291-
e1.inspect(() => {
291+
e1.audit(() => {
292292
return new Promise((resolve: any) => { resolve(42); });
293293
}).subscribe(
294294
(x: number) => {
@@ -308,7 +308,7 @@ describe('Observable.prototype.inspect', () => {
308308
const expected = [0, 1, 2];
309309
const error = new Error('error');
310310

311-
e1.inspect((x: number) => {
311+
e1.audit((x: number) => {
312312
if (x === 3) {
313313
return new Promise((resolve: any, reject: any) => { reject(error); });
314314
} else {

src/Rx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ import './add/operator/finally';
5959
import './add/operator/first';
6060
import './add/operator/groupBy';
6161
import './add/operator/ignoreElements';
62-
import './add/operator/inspect';
62+
import './add/operator/audit';
6363
import './add/operator/inspectTime';
6464
import './add/operator/last';
6565
import './add/operator/let';

src/add/operator/audit.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {Observable} from '../../Observable';
2+
import {audit, AuditSignature} from '../../operator/audit';
3+
4+
Observable.prototype.audit = audit;
5+
6+
declare module '../../Observable' {
7+
interface Observable<T> {
8+
audit: AuditSignature<T>;
9+
}
10+
}

src/add/operator/inspect.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/operator/inspect.ts renamed to src/operator/audit.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ import {subscribeToResult} from '../util/subscribeToResult';
1111
/**
1212
* @param durationSelector
1313
* @return {Observable<R>|WebSocketSubject<T>|Observable<T>}
14-
* @method inspect
14+
* @method audit
1515
* @owner Observable
1616
*/
17-
export function inspect<T>(durationSelector: (value: T) => SubscribableOrPromise<any>): Observable<T> {
18-
return this.lift(new InspectOperator(durationSelector));
17+
export function audit<T>(durationSelector: (value: T) => SubscribableOrPromise<any>): Observable<T> {
18+
return this.lift(new AuditOperator(durationSelector));
1919
}
2020

21-
export interface InspectSignature<T> {
21+
export interface AuditSignature<T> {
2222
(durationSelector: (value: T) => SubscribableOrPromise<any>): Observable<T>;
2323
}
2424

25-
class InspectOperator<T> implements Operator<T, T> {
25+
class AuditOperator<T> implements Operator<T, T> {
2626
constructor(private durationSelector: (value: T) => SubscribableOrPromise<any>) {
2727
}
2828

2929
call(subscriber: Subscriber<T>): Subscriber<T> {
30-
return new InspectSubscriber<T, T>(subscriber, this.durationSelector);
30+
return new AuditSubscriber<T, T>(subscriber, this.durationSelector);
3131
}
3232
}
3333

34-
class InspectSubscriber<T, R> extends OuterSubscriber<T, R> {
34+
class AuditSubscriber<T, R> extends OuterSubscriber<T, R> {
3535

3636
private value: T;
3737
private hasValue: boolean = false;

0 commit comments

Comments
 (0)