Skip to content

Commit 11d9843

Browse files
committed
apply prettier format
1 parent 8b8c07c commit 11d9843

File tree

7 files changed

+137
-164
lines changed

7 files changed

+137
-164
lines changed

karma.conf.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,17 @@ module.exports = config => {
1414
var configuration = {
1515
client: {
1616
mocha: {
17-
timeout : 5000
17+
timeout: 5000
1818
}
1919
},
2020
basePath: "",
21-
frameworks: [
22-
"mocha",
23-
"sinon-chai",
24-
"es6-shim"
25-
],
21+
frameworks: ["mocha", "sinon-chai", "es6-shim"],
2622
files: [
2723
{ pattern: "node_modules/reflect-metadata/Reflect.js", include: true },
2824
{ pattern: "node_modules/bluebird/js/browser/bluebird.js", include: true },
2925
{ pattern: "node_modules/easeljs/lib/easeljs.js", include: true },
3026
{ pattern: "./test/index.ts", include: true },
31-
{ pattern: '**/*.map', served: true, included: false, watched: true }
27+
{ pattern: "**/*.map", served: true, included: false, watched: true }
3228
],
3329
preprocessors: {
3430
"./test/index.ts": ["webpack"],
@@ -50,13 +46,9 @@ module.exports = config => {
5046
"karma-coverage-istanbul-reporter"
5147
],
5248
mime: {
53-
"text/x-typescript": ["ts","tsx"]
49+
"text/x-typescript": ["ts", "tsx"]
5450
},
55-
reporters: (
56-
config.singleRun ?
57-
["dots", "mocha", "coverage-istanbul"] :
58-
["dots", "mocha"]
59-
),
51+
reporters: config.singleRun ? ["dots", "mocha", "coverage-istanbul"] : ["dots", "mocha"],
6052
coverageIstanbulReporter: {
6153
reports: ["html", "lcov", "lcovonly", "text-summary"],
6254
dir: "coverage",

static/scripts/cache-polyfill.js

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -16,87 +16,87 @@
1616
*/
1717

1818
(function() {
19-
var nativeAddAll = Cache.prototype.addAll;
20-
var userAgent = navigator.userAgent.match(/(Firefox|Chrome)\/(\d+\.)/);
19+
var nativeAddAll = Cache.prototype.addAll;
20+
var userAgent = navigator.userAgent.match(/(Firefox|Chrome)\/(\d+\.)/);
2121

22-
// Has nice behavior of `var` which everyone hates
23-
if (userAgent) {
24-
var agent = userAgent[1];
25-
var version = parseInt(userAgent[2]);
26-
}
22+
// Has nice behavior of `var` which everyone hates
23+
if (userAgent) {
24+
var agent = userAgent[1];
25+
var version = parseInt(userAgent[2]);
26+
}
2727

28-
if (nativeAddAll && (!userAgent || (agent === "Firefox" && version >= 46) || (agent === "Chrome" && version >= 50))) {
29-
return;
30-
}
28+
if (nativeAddAll && (!userAgent || (agent === "Firefox" && version >= 46) || (agent === "Chrome" && version >= 50))) {
29+
return;
30+
}
3131

32-
Cache.prototype.addAll = function addAll(requests) {
33-
var cache = this;
32+
Cache.prototype.addAll = function addAll(requests) {
33+
var cache = this;
3434

35-
// Since DOMExceptions are not constructable:
36-
function NetworkError(message) {
37-
this.name = "NetworkError";
38-
this.code = 19;
39-
this.message = message;
40-
}
35+
// Since DOMExceptions are not constructable:
36+
function NetworkError(message) {
37+
this.name = "NetworkError";
38+
this.code = 19;
39+
this.message = message;
40+
}
4141

42-
NetworkError.prototype = Object.create(Error.prototype);
42+
NetworkError.prototype = Object.create(Error.prototype);
4343

44-
return Promise.resolve()
45-
.then(function() {
46-
if (arguments.length < 1) throw new TypeError();
44+
return Promise.resolve()
45+
.then(function() {
46+
if (arguments.length < 1) throw new TypeError();
4747

48-
// Simulate sequence<(Request or USVString)> binding:
49-
var sequence = [];
48+
// Simulate sequence<(Request or USVString)> binding:
49+
var sequence = [];
5050

51-
requests = requests.map(function(request) {
52-
if (request instanceof Request) {
53-
return request;
54-
} else {
55-
return String(request); // may throw TypeError
56-
}
57-
});
51+
requests = requests.map(function(request) {
52+
if (request instanceof Request) {
53+
return request;
54+
} else {
55+
return String(request); // may throw TypeError
56+
}
57+
});
5858

59-
return Promise.all(
60-
requests.map(function(request) {
61-
if (typeof request === "string") {
62-
request = new Request(request);
63-
}
59+
return Promise.all(
60+
requests.map(function(request) {
61+
if (typeof request === "string") {
62+
request = new Request(request);
63+
}
6464

65-
var scheme = new URL(request.url).protocol;
65+
var scheme = new URL(request.url).protocol;
6666

67-
if (scheme !== "http:" && scheme !== "https:") {
68-
throw new NetworkError("Invalid scheme");
69-
}
67+
if (scheme !== "http:" && scheme !== "https:") {
68+
throw new NetworkError("Invalid scheme");
69+
}
7070

71-
return fetch(request.clone());
72-
})
73-
);
74-
})
75-
.then(function(responses) {
76-
// If some of the responses has not OK-eish status,
77-
// then whole operation should reject
78-
if (
79-
responses.some(function(response) {
80-
return !response.ok;
81-
})
82-
) {
83-
throw new NetworkError("Incorrect response status");
84-
}
71+
return fetch(request.clone());
72+
})
73+
);
74+
})
75+
.then(function(responses) {
76+
// If some of the responses has not OK-eish status,
77+
// then whole operation should reject
78+
if (
79+
responses.some(function(response) {
80+
return !response.ok;
81+
})
82+
) {
83+
throw new NetworkError("Incorrect response status");
84+
}
8585

86-
// TODO: check that requests don't overwrite one another
87-
// (don't think this is possible to polyfill due to opaque responses)
88-
return Promise.all(
89-
responses.map(function(response, i) {
90-
return cache.put(requests[i], response);
91-
})
92-
);
93-
})
94-
.then(function() {
95-
return undefined;
96-
});
97-
};
86+
// TODO: check that requests don't overwrite one another
87+
// (don't think this is possible to polyfill due to opaque responses)
88+
return Promise.all(
89+
responses.map(function(response, i) {
90+
return cache.put(requests[i], response);
91+
})
92+
);
93+
})
94+
.then(function() {
95+
return undefined;
96+
});
97+
};
9898

99-
Cache.prototype.add = function add(request) {
100-
return this.addAll([request]);
101-
};
99+
Cache.prototype.add = function add(request) {
100+
return this.addAll([request]);
101+
};
102102
})();

static/service-worker.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,53 @@ var CACHE_VERSION = "app-v1";
44
var CACHE_FILES = ["index.html"];
55

66
self.addEventListener("install", function(event) {
7-
event.waitUntil(
8-
caches.open(CACHE_VERSION).then(function(cache) {
9-
console.log("Opened cache");
10-
return cache.addAll(CACHE_FILES);
11-
})
12-
);
7+
event.waitUntil(
8+
caches.open(CACHE_VERSION).then(function(cache) {
9+
console.log("Opened cache");
10+
return cache.addAll(CACHE_FILES);
11+
})
12+
);
1313
});
1414

1515
self.addEventListener("activate", function(event) {
16-
event.waitUntil(
17-
caches.keys().then(function(keys) {
18-
return Promise.all(
19-
keys.map(function(key, i) {
20-
if (key !== CACHE_VERSION) {
21-
return caches.delete(keys[i]);
22-
}
23-
})
24-
);
16+
event.waitUntil(
17+
caches.keys().then(function(keys) {
18+
return Promise.all(
19+
keys.map(function(key, i) {
20+
if (key !== CACHE_VERSION) {
21+
return caches.delete(keys[i]);
22+
}
2523
})
26-
);
24+
);
25+
})
26+
);
2727
});
2828

2929
self.addEventListener("fetch", function(event) {
30-
event.respondWith(
31-
caches.match(event.request).then(function(res) {
32-
if (res) {
33-
return res;
34-
}
35-
requestBackend(event);
36-
})
37-
);
30+
event.respondWith(
31+
caches.match(event.request).then(function(res) {
32+
if (res) {
33+
return res;
34+
}
35+
requestBackend(event);
36+
})
37+
);
3838
});
3939

4040
function requestBackend(event) {
41-
var url = event.request.clone();
42-
return fetch(url).then(function(res) {
43-
//if not a valid response send the error
44-
if (!res || res.status !== 200 || res.type !== "basic") {
45-
return res;
46-
}
41+
var url = event.request.clone();
42+
return fetch(url).then(function(res) {
43+
//if not a valid response send the error
44+
if (!res || res.status !== 200 || res.type !== "basic") {
45+
return res;
46+
}
4747

48-
var response = res.clone();
48+
var response = res.clone();
4949

50-
caches.open(CACHE_VERSION).then(function(cache) {
51-
cache.put(event.request, response);
52-
});
53-
54-
return res;
50+
caches.open(CACHE_VERSION).then(function(cache) {
51+
cache.put(event.request, response);
5552
});
53+
54+
return res;
55+
});
5656
}

tslint.example.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"extends": [
3-
"./tslint.json"
4-
],
2+
"extends": ["./tslint.json"],
53
"rules": {
64
"no-implicit-dependencies": [true, "dev"],
75
"no-reference": false,

tslint.test.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"extends": [
3-
"./tslint.json"
4-
],
2+
"extends": ["./tslint.json"],
53
"rules": {
64
"no-implicit-dependencies": [true, "dev"],
75
"no-reference": false,

webpack.config.js

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ const path = require("path");
33
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
44

55
module.exports = env => {
6-
76
if (!env) env = { production: false, karma: false };
87

98
let mode = env.production ? "production" : "development";
109
let tsconfig = !env.karma ? "tsconfig.json" : "tsconfig.test.json";
1110
let output = env.production ? "dist" : "dist-test";
12-
let filename = env.karma ? "[name].[hash].js" : (env.production ? "robotlegs-createjs.min.js" : "robotlegs-createjs.js");
11+
let filename = env.karma ? "[name].[hash].js" : env.production ? "robotlegs-createjs.min.js" : "robotlegs-createjs.js";
1312

1413
return {
1514
mode: mode,
@@ -35,9 +34,7 @@ module.exports = env => {
3534
loader: "ts-loader?configFile=" + tsconfig
3635
},
3736
{
38-
test: ((env.production) /* disable this loader for production builds */
39-
? /^$/
40-
: /^.*(src).*\.ts$/),
37+
test: env.production /* disable this loader for production builds */ ? /^$/ : /^.*(src).*\.ts$/,
4138
loader: "istanbul-instrumenter-loader",
4239
query: {
4340
embedSource: true
@@ -47,34 +44,27 @@ module.exports = env => {
4744
]
4845
},
4946

50-
plugins: (
51-
(env.production)
52-
? []
53-
: [ new webpack.SourceMapDevToolPlugin({ test: /\.ts$/i }) ]
54-
),
47+
plugins: env.production ? [] : [new webpack.SourceMapDevToolPlugin({ test: /\.ts$/i })],
5548

56-
optimization:
57-
(env.production)
58-
? {
59-
concatenateModules: true,
60-
minimize: true,
61-
minimizer: [
62-
new UglifyJsPlugin({
63-
cache: true,
64-
parallel: 4,
65-
uglifyOptions: {
66-
output: {
67-
comments: false
68-
}
49+
optimization: env.production
50+
? {
51+
concatenateModules: true,
52+
minimize: true,
53+
minimizer: [
54+
new UglifyJsPlugin({
55+
cache: true,
56+
parallel: 4,
57+
uglifyOptions: {
58+
output: {
59+
comments: false
6960
}
70-
})
71-
]
72-
}
73-
: {}
74-
,
75-
61+
}
62+
})
63+
]
64+
}
65+
: {},
7666
resolve: {
7767
extensions: [".ts", ".js", ".json"]
7868
}
79-
}
69+
};
8070
};

0 commit comments

Comments
 (0)