From 64b455a5fef5861671eb32f3d31c61298a633043 Mon Sep 17 00:00:00 2001 From: Leland Miller Date: Wed, 12 Jul 2017 17:26:50 -0700 Subject: [PATCH] Upgrade dependencies --- package.json | 10 +++++----- src/base-signals.ts | 4 ++-- src/extended-signal.ts | 14 +++++++------- src/interfaces.ts | 8 ++------ src/signal.ts | 6 +++--- test/readme.spec.ts | 4 ++-- test/suites/filtered-suite.ts | 2 +- test/suites/mapped-suite.ts | 4 ++-- test/suites/merged-suite.ts | 2 +- test/suites/promisify-suite.ts | 4 ++-- test/suites/read-only-suite.ts | 2 +- tslint.json | 10 +++++----- 12 files changed, 33 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index 4c939e6..eb08041 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/base-signals.ts b/src/base-signals.ts index 1398402..8ad1b7b 100644 --- a/src/base-signals.ts +++ b/src/base-signals.ts @@ -17,7 +17,7 @@ export function filteredBase( export function mappedBase( baseSignal: BaseSignal, - transform: (payload: T) => U + transform: (payload: T) => U, ): BaseSignal { return { add(listener: Listener) { @@ -27,7 +27,7 @@ export function mappedBase( } export function mergedBase( - ...baseSignals: BaseSignal[] + ...baseSignals: BaseSignal[], ): BaseSignal { return { add(listener: Listener): SignalBinding { diff --git a/src/extended-signal.ts b/src/extended-signal.ts index 4eaa39d..38d06c2 100644 --- a/src/extended-signal.ts +++ b/src/extended-signal.ts @@ -10,29 +10,29 @@ import {promisifySignal} from './promisify-signal'; export class ExtendedSignal implements ReadableSignal { constructor(private _baseSignal: BaseSignal) {} - add(listener: Listener): SignalBinding { + public add(listener: Listener): SignalBinding { return this._baseSignal.add(listener); } - addOnce(listener: Listener): SignalBinding { + public addOnce(listener: Listener): SignalBinding { const binding = this._baseSignal.add(payload => { binding.detach(); listener(payload); }); return binding; } - filter(filter: FilterFunction): ReadableSignal { + public filter(filter: FilterFunction): ReadableSignal { return new ExtendedSignal(filteredBase(this._baseSignal, filter)); } - map(transform: (payload: T) => U): ReadableSignal { + public map(transform: (payload: T) => U): ReadableSignal { return new ExtendedSignal(mappedBase(this._baseSignal, transform)); } - merge(...signals: ReadableSignal[]): ReadableSignal { + public merge(...signals: ReadableSignal[]): ReadableSignal { return new ExtendedSignal(mergedBase(this._baseSignal, ...signals)); } - promisify(rejectSignal?: ReadableSignal): Promise { + public promisify(rejectSignal?: ReadableSignal): Promise { return promisifySignal(this._baseSignal, rejectSignal); } - readOnly(): ReadableSignal { + public readOnly(): ReadableSignal { return new ExtendedSignal(readOnlyBase(this._baseSignal)); } } diff --git a/src/interfaces.ts b/src/interfaces.ts index 3f9fe9b..afe68f5 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -1,10 +1,6 @@ -export interface Listener { - (payload: T): void; -} +export type Listener = (payload: T) => void; -export interface FilterFunction { - (payload: T): boolean; -} +export type FilterFunction = (payload: T) => boolean; export interface SignalBinding { detach(): void; diff --git a/src/signal.ts b/src/signal.ts index 9342a79..8deff6a 100644 --- a/src/signal.ts +++ b/src/signal.ts @@ -10,20 +10,20 @@ export class Signal extends ExtendedSignal implements WritableSignal { super(signalSource); this._signalSource = signalSource; } - dispatch(payload: T): void { + public dispatch(payload: T): void { this._signalSource.dispatch(payload); } } export class SignalSource implements BaseSignal { public _listeners = new Set<(payload: T) => void>(); - add(listener: Listener): SignalBinding { + public add(listener: Listener): 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)); } } diff --git a/test/readme.spec.ts b/test/readme.spec.ts index 109fb53..74c7093 100644 --- a/test/readme.spec.ts +++ b/test/readme.spec.ts @@ -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`; @@ -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(); }); diff --git a/test/suites/filtered-suite.ts b/test/suites/filtered-suite.ts index 562c6ff..c1eb00e 100644 --- a/test/suites/filtered-suite.ts +++ b/test/suites/filtered-suite.ts @@ -85,7 +85,7 @@ export function filteredSuite(prefix: string, createFilteredSignal: FilteredSign test('FilteredSignal should not leak', t => { const signal = new LeakDetectionSignal(); - let filteredSignal = createFilteredSignal(signal, () => true); + const filteredSignal = createFilteredSignal(signal, () => true); const binding = filteredSignal.add(() => { /* empty listener */ }); signal.dispatch(undefined); diff --git a/test/suites/mapped-suite.ts b/test/suites/mapped-suite.ts index e021cb1..5f11e6c 100644 --- a/test/suites/mapped-suite.ts +++ b/test/suites/mapped-suite.ts @@ -3,7 +3,7 @@ import {ReadableSignal, Signal} from '../../src'; import {LeakDetectionSignal} from '../lib/leak-detection-signal'; export type MappedSignalCreationFunction - = (baseSignal: ReadableSignal, transform: (payload: T) => U) => ReadableSignal; + = (baseSignal: ReadableSignal, transform: (payload: T) => U) => ReadableSignal; export function mappedSuite(prefix: string, createMappedSignal: MappedSignalCreationFunction) { test(`${prefix} should dispatch with a transformed payload`, t => { @@ -29,7 +29,7 @@ export function mappedSuite(prefix: string, createMappedSignal: MappedSignalCrea test('MappedSignal should not leak', t => { const signal = new LeakDetectionSignal(); - let mappedSignal = createMappedSignal(signal, () => true); + const mappedSignal = createMappedSignal(signal, () => true); const binding = mappedSignal.add(() => { /* empty listener */ }); signal.dispatch(undefined); diff --git a/test/suites/merged-suite.ts b/test/suites/merged-suite.ts index b7be9fb..e0599cb 100644 --- a/test/suites/merged-suite.ts +++ b/test/suites/merged-suite.ts @@ -37,7 +37,7 @@ export function mergedSuite(prefix: string, createMergedSignal: ReadableSignalCr test('MergedSignal should not leak', t => { const signal1 = new LeakDetectionSignal(); const signal2 = new LeakDetectionSignal(); - let mergedSignal = createMergedSignal(signal1, signal2); + const mergedSignal = createMergedSignal(signal1, signal2); const binding = mergedSignal.add(() => { /* empty listener */ }); signal1.dispatch(undefined); diff --git a/test/suites/promisify-suite.ts b/test/suites/promisify-suite.ts index d485dba..381296a 100644 --- a/test/suites/promisify-suite.ts +++ b/test/suites/promisify-suite.ts @@ -49,7 +49,7 @@ export function promisifySuite(prefix: string, promisifyFunction: PromisifyFunct const acceptSignal = new LeakDetectionSignal(); const rejectSignal = new LeakDetectionSignal(); - let promise = promisifyFunction(acceptSignal, rejectSignal); + const promise = promisifyFunction(acceptSignal, rejectSignal); promise.then(() => { /* empty callback */ }); acceptSignal.dispatch(undefined); @@ -63,7 +63,7 @@ export function promisifySuite(prefix: string, promisifyFunction: PromisifyFunct const acceptSignal = new LeakDetectionSignal(); const rejectSignal = new LeakDetectionSignal(); - let promise = promisifyFunction(acceptSignal, rejectSignal); + const promise = promisifyFunction(acceptSignal, rejectSignal); promise.catch(() => { /* used to suppress unhandled promise error */ }); rejectSignal.dispatch(undefined); diff --git a/test/suites/read-only-suite.ts b/test/suites/read-only-suite.ts index 5dc5923..d344653 100644 --- a/test/suites/read-only-suite.ts +++ b/test/suites/read-only-suite.ts @@ -41,7 +41,7 @@ export function readOnlySuite(prefix: string, createReadOnlySignal: ReadOnlySign test(`${prefix} should not leak`, t => { const signal = new LeakDetectionSignal(); - let readOnlySignal = createReadOnlySignal(signal); + const readOnlySignal = createReadOnlySignal(signal); const binding = readOnlySignal.add(() => { /* empty listener */ }); signal.dispatch(undefined); diff --git a/tslint.json b/tslint.json index 9aacdb3..de1e55e 100644 --- a/tslint.json +++ b/tslint.json @@ -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"] } }