Skip to content

Commit

Permalink
Merge pull request #23 from RobotlegsJS/map
Browse files Browse the repository at this point in the history
Use Map object properly
  • Loading branch information
tiagoschenkel authored Nov 15, 2017
2 parents 7e55fd7 + c7a562e commit 485e4a4
Show file tree
Hide file tree
Showing 12 changed files with 861 additions and 233 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: node_js
node_js:
- stable
env:
- CODECLIMATE_REPO_TOKEN=1b3aa177194deaeceb778c50f17f975f7000517d10cd53937de6fae600918425
- CODECLIMATE_REPO_TOKEN=611584fd9f3548ccff1c929361b6f63e199ff57f326c7e4427231db871665ec1
- CODECLIMATE_API_HOST=https://codebeat.co/webhooks/code_coverage CODECLIMATE_REPO_TOKEN=f8670689-0731-4631-aa9a-5561931884ba
before_install:
- export CHROME_BIN=chromium-browser
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

## RobotlegsJS-Pixi-SignalMediator 0.1.0

### v0.1.0
### [v0.1.0](https://github.com/RobotlegsJS/RobotlegsJS-Pixi-SignalMediator/releases/tag/0.1.0) - 2017-11-15

- Update @robotlegsjs/pixi to version 0.1.0 (see #16).

Expand All @@ -30,6 +30,8 @@

- Add Pull Request Template (see #22).

- Use Map object properly (see #23).

- Update dev dependencies to latest version.

## RobotlegsJS-Pixi-SignalMediator 0.0.1
Expand Down
136 changes: 70 additions & 66 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,80 @@ process.env.NODE_ENV = 'test';

const webpack = require("webpack");
const path = require("path");
const webpackConfig = require('./webpack.config.js')({isTest: true});
const webpackConfig = require('./webpack.config.js')({ isTest: true });

delete webpackConfig.entry;

module.exports = function (config) {
let frameworks = [
"mocha",
"chai",
"sinon",
"es6-shim"
];

var configuration = {
basePath: "",
frameworks: [
"mocha",
"chai",
"sinon",
"es6-shim"
],
files: [
"./test/**/**/**.test.ts",
{
pattern: '**/*.map',
served: true,
included: false,
watched: true
}
],
preprocessors: {
"./**/**/**/**.ts": ["sourcemap"],
"./test/**/**/**.test.ts": ["webpack"]
},
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
plugins: [
"karma-webpack",
"karma-sourcemap-writer",
"karma-sourcemap-loader",
"karma-remap-istanbul",
"karma-mocha-reporter",
"karma-mocha",
"karma-chai",
"karma-sinon",
"karma-es6-shim",
"karma-coverage"
],
reporters: (config.singleRun
? ["dots", "mocha", "coverage"]
: ["dots", "mocha"]),
coverageReporter: {
dir: "coverage",
reporters: [
{type: 'html', subdir: 'report-html'},
{type: 'lcov', subdir: 'report-lcov'}
],
instrumenterOptions: {
istanbul: {noCompact: true}
}
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome']
};
let plugins = [
"karma-webpack",
"karma-sourcemap-writer",
"karma-sourcemap-loader",
"karma-mocha-reporter",
"karma-mocha",
"karma-chai",
"karma-sinon",
"karma-es6-shim",
"karma-remap-istanbul",
"karma-coverage-istanbul-reporter"
];

if (process.env.TRAVIS) {
configuration.browsers = ['PhantomJS'];
configuration.plugins.push("karma-phantomjs-launcher");
} else {
configuration.browsers = ['Chrome'];
configuration.plugins.push("karma-chrome-launcher");
}
module.exports = function(config) {

config.set(configuration);
var configuration = {
basePath: "",
frameworks: frameworks,
files: [
{ pattern: "node_modules/reflect-metadata/Reflect.js", include: true },
{ pattern: "node_modules/bluebird/js/browser/bluebird.js", include: true },
{ pattern: "./test/**/**/**.test.ts", include: true },
{ pattern: '**/*.map', served: true, included: false, watched: true }
],
preprocessors: {
"./**/**/**/**.ts": ["sourcemap"],
"./test/**/**/**.test.ts": ["webpack"]
},
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
plugins: plugins,
reporters: (
config.singleRun ?
["dots", "mocha", "coverage-istanbul"] :
["dots", "mocha"]
),
coverageIstanbulReporter: {
reports: ["html", "lcov", "lcovonly", "text-summary"],
dir: "coverage",
fixWebpackSourcePaths: true,
"report-config": {
html: {
subdir: "html-report"
}
}
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: [],
browserNoActivityTimeout: 50000
};

if (process.env.TRAVIS) {
configuration.browsers = ['PhantomJS'];
configuration.plugins.push("karma-phantomjs-launcher");
} else {
configuration.browsers = ['PhantomJS'];
configuration.plugins.push("karma-phantomjs-launcher");
}

config.set(configuration);
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"scripts": {
"test": "nyc mocha",
"karma": "karma start",
"test": "karma start --single-run",
"mocha": "nyc mocha",
"autoformat": "prettier --config .prettierrc --write {src,test}/**/*.ts",
"tslint-check": "tslint-config-prettier-check ./tslint.json",
"clean-up": "rm -rf .nyc_output && rm -rf coverage && rm -rf lib",
Expand Down Expand Up @@ -80,6 +80,7 @@
"karma-chai-sinon": "^0.1.5",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.1",
"karma-coverage-istanbul-reporter": "^1.3.0",
"karma-es6-shim": "^1.0.0",
"karma-jasmine": "^1.1.0",
"karma-mocha": "^1.3.0",
Expand Down
16 changes: 7 additions & 9 deletions src/robotlegs/bender/extensions/signalMediator/impl/SignalMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ export class SignalMap implements ISignalMap {
this.storeSignalHandler(signal, handler);
}

public removeFromSignal(signal: any, handler: Function): void {
public removeFromSignal(signal: ISignal, handler: Function): void {
signal.remove(handler);

if (
this._handlersBySignal[signal] == null ||
this._handlersBySignal[signal].length === 0
!this._handlersBySignal.has(signal) ||
this._handlersBySignal.get(signal).length === 0
) {
return;
}

let handlerIndex = this._handlersBySignal[signal].indexOf(handler);
let handlerIndex = this._handlersBySignal.get(signal).indexOf(handler);

if (handlerIndex > -1) {
this._handlersBySignal[signal].splice(handlerIndex, 1);
this._handlersBySignal.get(signal).splice(handlerIndex, 1);
}
}

Expand All @@ -65,16 +65,14 @@ export class SignalMap implements ISignalMap {
);

this._handlersBySignal.clear();

this._handlersBySignal = new Map();
}

/*============================================================================*/
/* Protected Functions */
/*============================================================================*/

protected storeSignalHandler(signal: any, handler: Function): void {
if (this._handlersBySignal.get(signal) == null) {
protected storeSignalHandler(signal: ISignal, handler: Function): void {
if (!this._handlersBySignal.has(signal)) {
this._handlersBySignal.set(signal, [handler]);
} else {
this._handlersBySignal.get(signal).push(handler);
Expand Down
3 changes: 2 additions & 1 deletion test/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------

import "reflect-metadata";
/// <reference types="mocha" />

import "bluebird/js/browser/bluebird";
import "es6-symbol/implement";
import "es6-map/implement";
Loading

0 comments on commit 485e4a4

Please sign in to comment.