Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
lelandmiller committed Jul 13, 2017
1 parent 50d51d6 commit 64b455a
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 37 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"@types/tape": "^4.2.30",
"erasmus": "^0.1.0",
"faucet": "0.0.1",
"nyc": "^11.0.2",
"nyc": "^11.0.3",
"rimraf": "^2.6.1",
"tape": "^4.6.3",
"ts-node": "^3.1.0",
"tslint": "^3.13.3",
"typescript": "2.2.2"
"tape": "^4.7.0",
"ts-node": "^3.2.0",
"tslint": "^5.5.0",
"typescript": "2.4.1"
},
"scripts": {
"lint": "tslint --project ./tsconfig.json",
Expand Down
4 changes: 2 additions & 2 deletions src/base-signals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function filteredBase<T>(

export function mappedBase<T, U>(
baseSignal: BaseSignal<T>,
transform: (payload: T) => U
transform: (payload: T) => U,
): BaseSignal<U> {
return {
add(listener: Listener<U>) {
Expand All @@ -27,7 +27,7 @@ export function mappedBase<T, U>(
}

export function mergedBase<T>(
...baseSignals: BaseSignal<T>[]
...baseSignals: BaseSignal<T>[],
): BaseSignal<T> {
return {
add(listener: Listener<T>): SignalBinding {
Expand Down
14 changes: 7 additions & 7 deletions src/extended-signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ import {promisifySignal} from './promisify-signal';

export class ExtendedSignal<T> implements ReadableSignal<T> {
constructor(private _baseSignal: BaseSignal<T>) {}
add(listener: Listener<T>): SignalBinding {
public add(listener: Listener<T>): SignalBinding {
return this._baseSignal.add(listener);
}
addOnce(listener: Listener<T>): SignalBinding {
public addOnce(listener: Listener<T>): SignalBinding {
const binding = this._baseSignal.add(payload => {
binding.detach();
listener(payload);
});
return binding;
}
filter(filter: FilterFunction<T>): ReadableSignal<T> {
public filter(filter: FilterFunction<T>): ReadableSignal<T> {
return new ExtendedSignal(filteredBase(this._baseSignal, filter));
}
map<U>(transform: (payload: T) => U): ReadableSignal<U> {
public map<U>(transform: (payload: T) => U): ReadableSignal<U> {
return new ExtendedSignal(mappedBase(this._baseSignal, transform));
}
merge<U>(...signals: ReadableSignal<U>[]): ReadableSignal<T|U> {
public merge<U>(...signals: ReadableSignal<U>[]): ReadableSignal<T|U> {
return new ExtendedSignal(mergedBase<T|U>(this._baseSignal, ...signals));
}
promisify(rejectSignal?: ReadableSignal<Error>): Promise<T> {
public promisify(rejectSignal?: ReadableSignal<Error>): Promise<T> {
return promisifySignal(this._baseSignal, rejectSignal);
}
readOnly(): ReadableSignal<T> {
public readOnly(): ReadableSignal<T> {
return new ExtendedSignal(readOnlyBase(this._baseSignal));
}
}
8 changes: 2 additions & 6 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
export interface Listener<T> {
(payload: T): void;
}
export type Listener<T> = (payload: T) => void;

export interface FilterFunction<T> {
(payload: T): boolean;
}
export type FilterFunction<T> = (payload: T) => boolean;

export interface SignalBinding {
detach(): void;
Expand Down
6 changes: 3 additions & 3 deletions src/signal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ export class Signal<T> extends ExtendedSignal<T> implements WritableSignal<T> {
super(signalSource);
this._signalSource = signalSource;
}
dispatch(payload: T): void {
public dispatch(payload: T): void {
this._signalSource.dispatch(payload);
}
}

export class SignalSource<T> implements BaseSignal<T> {
public _listeners = new Set<(payload: T) => void>();
add(listener: Listener<T>): SignalBinding {
public add(listener: Listener<T>): SignalBinding {
this._listeners.add(listener);
return {
detach: () => this._listeners.delete(listener),
};
}
dispatch(payload: T): void {
public dispatch(payload: T): void {
this._listeners.forEach(callback => callback.call(undefined, payload));
}
}
4 changes: 2 additions & 2 deletions test/readme.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* installed dependencies.
*/
import test = require('tape');
import * as signals from '../src/index';
import { extractCode } from 'erasmus';
import * as fs from 'fs';
import * as signals from '../src/index';
import rimraf = require('rimraf');

const outPath = `${__dirname}/generated-readme-examples`;
Expand Down Expand Up @@ -80,7 +80,7 @@ test(`ensure all exports are at least mentioned in an example (does not capture
t.equals(
unusedExports.length,
0,
`${unusedExports.join(', ')} were not used in example code blocks`
`${unusedExports.join(', ')} were not used in example code blocks`,
);
t.end();
});
2 changes: 1 addition & 1 deletion test/suites/filtered-suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function filteredSuite(prefix: string, createFilteredSignal: FilteredSign

test('FilteredSignal should not leak', t => {
const signal = new LeakDetectionSignal<void>();
let filteredSignal = createFilteredSignal(signal, () => true);
const filteredSignal = createFilteredSignal(signal, () => true);

const binding = filteredSignal.add(() => { /* empty listener */ });
signal.dispatch(undefined);
Expand Down
4 changes: 2 additions & 2 deletions test/suites/mapped-suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {ReadableSignal, Signal} from '../../src';
import {LeakDetectionSignal} from '../lib/leak-detection-signal';

export type MappedSignalCreationFunction
= <T, U>(baseSignal: ReadableSignal<T>, transform: (payload: T) => U) => ReadableSignal<T>;
= <T, U>(baseSignal: ReadableSignal<T>, transform: (payload: T) => U) => ReadableSignal<U>;

export function mappedSuite(prefix: string, createMappedSignal: MappedSignalCreationFunction) {
test(`${prefix} should dispatch with a transformed payload`, t => {
Expand All @@ -29,7 +29,7 @@ export function mappedSuite(prefix: string, createMappedSignal: MappedSignalCrea

test('MappedSignal should not leak', t => {
const signal = new LeakDetectionSignal<void>();
let mappedSignal = createMappedSignal(signal, () => true);
const mappedSignal = createMappedSignal(signal, () => true);

const binding = mappedSignal.add(() => { /* empty listener */ });
signal.dispatch(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/suites/merged-suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function mergedSuite(prefix: string, createMergedSignal: ReadableSignalCr
test('MergedSignal should not leak', t => {
const signal1 = new LeakDetectionSignal<void>();
const signal2 = new LeakDetectionSignal<void>();
let mergedSignal = createMergedSignal(signal1, signal2);
const mergedSignal = createMergedSignal(signal1, signal2);

const binding = mergedSignal.add(() => { /* empty listener */ });
signal1.dispatch(undefined);
Expand Down
4 changes: 2 additions & 2 deletions test/suites/promisify-suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function promisifySuite(prefix: string, promisifyFunction: PromisifyFunct
const acceptSignal = new LeakDetectionSignal<void>();
const rejectSignal = new LeakDetectionSignal<void>();

let promise = promisifyFunction(acceptSignal, rejectSignal);
const promise = promisifyFunction(acceptSignal, rejectSignal);
promise.then(() => { /* empty callback */ });

acceptSignal.dispatch(undefined);
Expand All @@ -63,7 +63,7 @@ export function promisifySuite(prefix: string, promisifyFunction: PromisifyFunct
const acceptSignal = new LeakDetectionSignal<void>();
const rejectSignal = new LeakDetectionSignal<void>();

let promise = promisifyFunction(acceptSignal, rejectSignal);
const promise = promisifyFunction(acceptSignal, rejectSignal);
promise.catch(() => { /* used to suppress unhandled promise error */ });

rejectSignal.dispatch(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/suites/read-only-suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function readOnlySuite(prefix: string, createReadOnlySignal: ReadOnlySign

test(`${prefix} should not leak`, t => {
const signal = new LeakDetectionSignal<void>();
let readOnlySignal = createReadOnlySignal(signal);
const readOnlySignal = createReadOnlySignal(signal);

const binding = readOnlySignal.add(() => { /* empty listener */ });
signal.dispatch(undefined);
Expand Down
10 changes: 5 additions & 5 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"extends": ["tslint:latest"],
"extends": ["tslint:recommended"],
"rules": {
"array-type": [true, "array"],
"arrow-parens": [true, "ban-single-arg-parens"],
"interface-name": [false],
"max-classes-per-file": [false],
"quotemark": [true, "single"],
"member-access": false,
"interface-name": false,
"ordered-imports": [true, "alphabetize", "check-groups"],
"switch-default": false,
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"]
}
}

0 comments on commit 64b455a

Please sign in to comment.