typed-signals
Advanced tools
Comparing version 1.0.2 to 1.0.4
"use strict"; | ||
// CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/ | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
@@ -56,20 +59,13 @@ extendStatics(d, b); | ||
/** | ||
* Represents a connection of a callback to a signal. | ||
* Implementation of SignalConnection, for internal use only. | ||
*/ | ||
var SignalConnection = /** @class */ (function () { | ||
var SignalConnectionImpl = /** @class */ (function () { | ||
/** | ||
* Do not use manually. For internal use only. | ||
* | ||
* @param head The head link of the signal. | ||
* @param link The actual link of the connection. | ||
*/ | ||
function SignalConnection(head, link) { | ||
function SignalConnectionImpl(head, link) { | ||
this.link = link; | ||
} | ||
/** | ||
* Stop this connection from receiving further events permanently. | ||
* | ||
* @returns false if the connection has already been severed. | ||
*/ | ||
SignalConnection.prototype.disconnect = function () { | ||
SignalConnectionImpl.prototype.disconnect = function () { | ||
if (this.link !== null) { | ||
@@ -82,9 +78,6 @@ this.link.unlink(); | ||
}; | ||
Object.defineProperty(SignalConnection.prototype, "enabled", { | ||
Object.defineProperty(SignalConnectionImpl.prototype, "enabled", { | ||
get: function () { | ||
return this.link !== null && this.link.isEnabled(); | ||
}, | ||
/** | ||
* If set to false it prevents the handler from receiving the signals events. | ||
*/ | ||
set: function (enable) { | ||
@@ -97,5 +90,4 @@ if (this.link) | ||
}); | ||
return SignalConnection; | ||
return SignalConnectionImpl; | ||
}()); | ||
exports.SignalConnection = SignalConnection; | ||
/** | ||
@@ -156,3 +148,3 @@ * Represents a list of connections to a signal for easy disconnect. | ||
} | ||
return new SignalConnection(this.head, link); | ||
return new SignalConnectionImpl(this.head, link); | ||
}; | ||
@@ -159,0 +151,0 @@ /** |
{ | ||
"name": "typed-signals", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"description": "A type checked signal library for TypeScript (and JavaScript)", | ||
@@ -23,9 +23,8 @@ "keywords": [ | ||
"files": [ | ||
"dist/", | ||
"dist/src", | ||
"src/", | ||
"test/", | ||
"tsconfig.json" | ||
], | ||
"main": "dist/src/Signal.js", | ||
"types": "src/Signal.ts", | ||
"types": "dist/src/Signal.d.ts", | ||
"scripts": { | ||
@@ -46,2 +45,3 @@ "pretest": "tsc", | ||
"dist/test/**/*", | ||
"docs/**/*", | ||
"**/*.d.ts" | ||
@@ -55,15 +55,14 @@ ], | ||
"devDependencies": { | ||
"@types/chai": "^4.0.4", | ||
"@types/mocha": "^2.2.43", | ||
"@types/node": "^8.0.46", | ||
"awesome-typescript-loader": "^3.2.3", | ||
"chai": "^4.1.2", | ||
"coveralls": "^3.0.0", | ||
"mocha": "^4.0.1", | ||
"mocha-typescript": "^1.1.11", | ||
"nyc": "^11.2.1", | ||
"source-map-loader": "^0.2.2", | ||
"source-map-support": "^0.5.0", | ||
"typescript": "^2.5.3" | ||
"@types/chai": "^4.1.7", | ||
"@types/mocha": "^5.2.5", | ||
"@types/node": "^10.12.1", | ||
"awesome-typescript-loader": "^5.2.1", | ||
"chai": "^4.2.0", | ||
"coveralls": "^3.0.2", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.1.0", | ||
"source-map-loader": "^0.2.4", | ||
"source-map-support": "^0.5.9", | ||
"typescript": "^3.1.5" | ||
} | ||
} |
@@ -25,3 +25,3 @@ ![](https://lusito.github.io/typed-signals/typed_signals.png) | ||
- Liberal license: [CC0 Public Domain](http://creativecommons.org/publicdomain/zero/1.0/) | ||
- [Fully documented](https://lusito.github.io/typed-ecstasy/index.html) using TypeDoc | ||
- [Fully documented](https://lusito.github.io/typed-signals/index.html) using TypeDoc | ||
@@ -28,0 +28,0 @@ ### Installation via NPM |
@@ -42,3 +42,3 @@ // CC0 Public Domain: http://creativecommons.org/publicdomain/zero/1.0/ | ||
let link = new SignalLink(after, after.next, order); | ||
const link = new SignalLink(after, after.next, order); | ||
link.callback = callback; | ||
@@ -55,8 +55,23 @@ after.next = link; | ||
*/ | ||
export class SignalConnection { | ||
export interface SignalConnection { | ||
/** | ||
* Stop this connection from receiving further events permanently. | ||
* | ||
* @returns false if the connection has already been severed. | ||
*/ | ||
disconnect(): boolean; | ||
/** | ||
* If set to false it prevents the handler from receiving the signals events. | ||
*/ | ||
enabled: boolean; | ||
} | ||
/** | ||
* Implementation of SignalConnection, for internal use only. | ||
*/ | ||
class SignalConnectionImpl implements SignalConnection { | ||
private link: SignalLink | null; | ||
/** | ||
* Do not use manually. For internal use only. | ||
* | ||
* @param head The head link of the signal. | ||
@@ -69,7 +84,2 @@ * @param link The actual link of the connection. | ||
/** | ||
* Stop this connection from receiving further events permanently. | ||
* | ||
* @returns false if the connection has already been severed. | ||
*/ | ||
public disconnect(): boolean { | ||
@@ -85,5 +95,2 @@ if (this.link !== null) { | ||
/** | ||
* If set to false it prevents the handler from receiving the signals events. | ||
*/ | ||
public set enabled(enable: boolean) { | ||
@@ -116,3 +123,3 @@ if (this.link) | ||
public disconnectAll() { | ||
for (let connection of this.list) { | ||
for (const connection of this.list) { | ||
connection.disconnect(); | ||
@@ -144,3 +151,3 @@ } | ||
public constructor() { | ||
(this.emit as any) = this.emitInternal.bind(this); | ||
this.emit = this.emitInternal.bind(this); | ||
} | ||
@@ -155,3 +162,3 @@ | ||
public connect(callback: CB, order: number = 0): SignalConnection { | ||
let link = this.head.insert(callback, order); | ||
const link = this.head.insert(callback, order); | ||
if (this.emitDepth > 0) { | ||
@@ -161,3 +168,3 @@ this.hasNewLinks = true; | ||
} | ||
return new SignalConnection(this.head, link); | ||
return new SignalConnectionImpl(this.head, link); | ||
} | ||
@@ -191,3 +198,3 @@ | ||
if (link.isEnabled() && link.callback) { | ||
let result = link.callback.apply(null, args); | ||
const result = link.callback.apply(null, args); | ||
if (!collector.handleResult(result)) | ||
@@ -230,4 +237,4 @@ break; | ||
public constructor(signal: Signal<CB>) { | ||
let self = this; | ||
(this.emit as any) = function () { (signal as any).emitCollecting(self, arguments); }; | ||
const self = this; | ||
this.emit = function () { (signal as any).emitCollecting(self, arguments) } as any; | ||
} | ||
@@ -234,0 +241,0 @@ |
@@ -10,2 +10,3 @@ { | ||
"outDir": "./dist", | ||
"declaration": true, | ||
"strict": true, | ||
@@ -22,2 +23,2 @@ "noImplicitAny": true, | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11
45158
8
821