Skip to content

Commit c173dd2

Browse files
authored
7.0.0 (#70)
* Update travis for new node version testing Version 7.0.0 setup * Added package-lock Updated some npm modules due to npm audit report Removed msngr.safe() Removed msngr.asyncify() * Build updates * Reverted grunt minor update as the minor update updates many dependencies that are major and breaking in super old versions of node. Revert npm audit fixes; they are just build dependencies and I went through them they are of no concern in our usage. * Cleaned up tiny bit more code Increased timeout on one weird test case (long explanation but it's fine for now) Added clean option to grunt / npm scripts * Minor tweaks * Update changelog notes
1 parent 0f95ead commit c173dd2

22 files changed

+1907
-366
lines changed

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ src
88
node_modules
99
CHANGELOG.md
1010
resources
11+
package-lock.json

.travis.yml

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
language: node_js
22
sudo: false
33
node_js:
4-
- "8.2"
5-
- "8.0"
6-
- "7.10"
7-
- "7.0"
8-
- "6.11"
9-
- "6.0"
10-
- "5.12"
11-
- "5.0"
12-
- "4.8"
13-
- "4.0"
4+
- "11.6.0"
5+
- "11.0.0"
6+
- "10.15.0"
7+
- "10.0.0"
8+
- "9.11.2"
9+
- "9.0.0"
10+
- "8.15.0"
11+
- "8.0.0"
12+
- "7.10.1"
13+
- "7.0.0"
14+
- "6.16.0"
15+
- "6.0.0"
16+
- "5.12.0"
17+
- "5.0.0"
18+
- "4.9.1"
19+
- "4.0.0"
1420
- "0.12"
1521
- "0.11"
1622
- "0.10"

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
# Changelog
22
This is a roll-up of all release notes in order of release
33

4+
## [Release 7.0.0 - January 11, 2019](https://github.com/KrisSiegel/msngr.js/releases/tag/7.0.0)
5+
This release is a new major version due to some API deprecation / removal. Beyond that the API is effectively unchanged and should continue to work unless you used undocumented features that were just removed :)
6+
7+
***Breaking changes***
8+
- Removed `msngr.asyncify`
9+
- Removed `msngr.safe`
10+
11+
***Misc changes***
12+
- Cleaned up dead code in build and testing scripts
13+
- `msngr.min.js` size decrease from 11.7kb to 11.1kb
14+
- Changed `npm test` behavior to no longer rebuild (only runs tests)
15+
- Added `npm run clean` to clean the current build
16+
- Added `package-lock.json` for better, reproducible builds
17+
418
## [Release 6.0.0 - July 28, 2017](https://github.com/KrisSiegel/msngr.js/releases/tag/6.0.0)
519
This release is a re-focusing on what makes msngr.js great. It removes the mache cache, the global configuration object and the universal networking to focus only on messaging and processing of messages. Additional, internal refactoring was also done to further shrink the filesize to a gzipped size of roughly 3kb.
620

Gruntfile.js

+7-57
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module.exports = (function(grunt) {
7676
tasks: {
7777
options: {
7878
filter: "include",
79-
tasks: ["build", "test"]
79+
tasks: ["build", "test", "clean"]
8080
}
8181
}
8282
}
@@ -214,65 +214,15 @@ module.exports = (function(grunt) {
214214
});
215215

216216
/*
217-
The reflective server simply accepts JSON, parses it and echos what it received
218-
back to the client. Pretty useful when testing sending and receiving data.
219-
*/
220-
grunt.registerTask("start-reflective-server", "Creates a test service with some dummy endpoints for testing", function() {
221-
var http = require("http");
222-
var server = http.createServer(function(request, response) {
223-
var body = "";
224-
request.on("data", function(chunk) {
225-
body = body + chunk;
226-
});
227-
228-
request.on("end", function() {
229-
var result = {
230-
method: request.method,
231-
headers: request.headers,
232-
path: request.url,
233-
body: body
234-
};
235-
236-
var headers = { };
237-
238-
try {
239-
var objBody = JSON.parse(body);
240-
if (objBody.headers != undefined && Object.keys(objBody.headers).length > 0) {
241-
for (var key in objBody.headers) {
242-
headers[key] = objBody.headers[key];
243-
}
244-
}
245-
246-
if (objBody.body != undefined) {
247-
result.body = objBody.body;
248-
}
249-
} catch (ex) {
250-
// Couldn't care less as opposed to the commonly misused "could care less"
251-
// in which you actually do care a little. No, I couldn't care less because
252-
// this error just means there are no commands to reflect :)
253-
}
254-
255-
if (headers["content-type"] === undefined) {
256-
headers["content-type"] = "application/json";
257-
}
258-
259-
response.writeHead(200, headers);
260-
response.end(JSON.stringify(result, null, 2));
261-
});
262-
});
263-
264-
server.listen("8009", "127.0.0.1", function(e) {
265-
console.log("Reflective http server started");
266-
});
267-
});
268-
269-
/*
270-
'build' and 'test' are roll-up tasks; they have specific descriptions and execute
217+
'build' and 'test' are rolled-up tasks; they have specific descriptions and execute
271218
multiple tasks each to accomplish their goals. These are the only intended tasks
272-
to be run by the developer.
219+
to be run by the developer.
220+
221+
build -> cleans then builds a new copy of `msngr.js` and `msngr.min.js`.
222+
test -> executes tests against the `msngr.js` and `msngr.min.js` rolled-up builds.
273223
*/
274224
grunt.registerTask("build", "Cleans, sets version and builds msngr.js", ["header:building", "clean", "verisionify", "concat", "uglify:minify", "setRunner"]);
275225

276-
grunt.registerTask("test", "Cleans, sets version, builds and runs mocha unit tests through node.js and phantom.js", ["build", "header:nodeTesting", "start-reflective-server", "mochaTest", "header:clientTesting", "mocha_phantomjs"]);
226+
grunt.registerTask("test", "Cleans, sets version, builds and runs mocha unit tests through node.js and phantom.js", ["header:nodeTesting", "mochaTest", "header:clientTesting", "mocha_phantomjs"]);
277227

278228
});

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014-2017 Kris Siegel
3+
Copyright (c) 2014-2018 Kris Siegel
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

bower.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "msngr.js",
33
"main": "msngr.min.js",
44
"description": "msngr.js is an asynchronous messaging library, written in JavaScript, for node and browser use",
5-
"version": "6.0.0",
5+
"version": "7.0.0",
66
"homepage": "https://github.com/KrisSiegel/msngr.js",
77
"authors": [
88
"Kris Siegel"
@@ -17,6 +17,7 @@
1717
"src",
1818
"node_modules",
1919
"CHANGELOG.md",
20-
"resources"
20+
"resources",
21+
"package-lock.json"
2122
]
2223
}

msngr.js

+13-93
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var msngr = msngr || (function () {
1818
};
1919

2020
// Built version of msngr.js for programatic access; this is auto generated
21-
external.version = "6.0.0";
21+
external.version = "7.0.0";
2222

2323
// Takes a function, executes it passing in the external and internal interfaces
2424
external.extend = function (fn) {
@@ -226,7 +226,7 @@ msngr.extend(function (external, internal) {
226226
Utils for handling and creating identifiers
227227
*/
228228

229-
msngr.extend(function (external, internal) {
229+
msngr.extend(function (external) {
230230
"use strict";
231231

232232
var atomicCount = 0;
@@ -302,11 +302,10 @@ msngr.extend(function (external, internal) {
302302
An implementation of the best-performing now() available
303303
*/
304304

305-
msngr.extend(function (external, internal) {
305+
msngr.extend(function (external) {
306306
"use strict";
307307

308308
var nowExec = undefined;
309-
var nowExecDebugLabel = "";
310309
var lastNow = undefined;
311310

312311
var nowPerformance = function() {
@@ -325,13 +324,10 @@ msngr.extend(function (external, internal) {
325324
if (nowExec === undefined) {
326325
if (typeof performance !== "undefined") {
327326
nowExec = nowPerformance;
328-
nowExecDebugLabel = "performance";
329327
} else if (typeof process !== "undefined") {
330328
nowExec = nowNode;
331-
nowExecDebugLabel = "node";
332329
} else {
333330
nowExec = nowLegacy;
334-
nowExecDebugLabel = "legacy";
335331
}
336332
}
337333
var now = nowExec();
@@ -344,44 +340,6 @@ msngr.extend(function (external, internal) {
344340

345341
});
346342

347-
/*
348-
./src/mutators/asyncify.js
349-
350-
Takes a synchronous method and makes it work asynchronously
351-
*/
352-
353-
msngr.extend(function (external, internal) {
354-
"use strict";
355-
356-
/*
357-
msngr.asyncify() accepts a single parameter and returns it with a new, async method.
358-
359-
fn -> the function, which should be synchronous, to add an async() method to.
360-
*/
361-
external.asyncify = function(fn) {
362-
if (external.is(fn).function) {
363-
fn.async = function () {
364-
var args = [].slice.call(arguments);
365-
var callback = args.pop();
366-
if (external.is(callback).function) {
367-
(function (a, c) {
368-
external.immediate(function () {
369-
try {
370-
c.apply(null, [null, fn.apply(null, a)]);
371-
} catch (e) {
372-
c.apply(null, [e, null]);
373-
}
374-
});
375-
}(args, callback));
376-
}
377-
};
378-
}
379-
380-
return fn;
381-
};
382-
383-
});
384-
385343
/*
386344
./src/mutators/copy.js
387345
@@ -399,10 +357,7 @@ msngr.extend(function (external, internal) {
399357

400358
// Mutable types that need to be specially handled
401359
copyHandlers[internal.types.date] = function (d) {
402-
var cdate = new Date();
403-
cdate.setTime(d.getTime());
404-
405-
return cdate;
360+
return new Date(d);
406361
};
407362

408363
copyHandlers[internal.types.object] = function (obj) {
@@ -562,41 +517,6 @@ msngr.extend(function (external, internal) {
562517

563518
});
564519

565-
/*
566-
./src/mutators/safe.js
567-
568-
Provides a safe way to access objects and functions
569-
*/
570-
571-
msngr.extend(function (external, internal) {
572-
"use strict";
573-
574-
/*
575-
msngr.safe() accepts 2 required parameters and 1 optional.
576-
577-
obj -> the object to inspect.
578-
path -> the json path to a specific property separated by dots; note that this will fail if an object key actually contains a dot.
579-
def (optional) -> the default value to return should the requested property not exist.
580-
*/
581-
external.safe = function (obj, path, def) {
582-
if (!external.is(obj).object || !external.is(path).string) {
583-
throw new Error("msngr.safe() - invalid parameters");
584-
}
585-
586-
var props = path.split(".");
587-
var position = obj, prop = undefined;
588-
while (prop = props.shift()) {
589-
position = position[prop];
590-
if (position === undefined) {
591-
break;
592-
}
593-
}
594-
595-
return (external.is(position).there) ? position : def;
596-
};
597-
598-
});
599-
600520
/*
601521
./src/messaging/executer.js
602522
@@ -721,8 +641,8 @@ msngr.extend(function (external, internal) {
721641
"use strict";
722642

723643
// Wait, why are you re-implementing the functionality of msngr.is().there?
724-
// Listen there boyscout. The memory indexer needs to be fast. Like very fast.
725-
// So this simplifies and imlpements only what we need. This is slightly faster.
644+
// Alright, here's the deal. The memory indexer needs to be fast. Like very fast.
645+
// So this simplifies and implements only what we need. This is slightly faster.
726646
var exists = function (input) {
727647
return (input !== undefined && input !== null);
728648
};
@@ -920,7 +840,7 @@ msngr.extend(function (external, internal) {
920840
var ids = payloadIndex.query(msg);
921841

922842
if (ids.length === 0) {
923-
return undefined;
843+
return;
924844
}
925845

926846
var payload = payloads[ids[0]];
@@ -961,7 +881,7 @@ msngr.extend(function (external, internal) {
961881
// Executes middlewares
962882
var executeMiddlewares = function (uses, payload, message, callback) {
963883
var middles = getMiddlewares(uses, payload, message);
964-
var execute = internal.executer(middles).series(function (result) {
884+
internal.executer(middles).series(function (result) {
965885
return callback(internal.merge.apply(this, [payload].concat(result)));
966886
});
967887
};
@@ -1119,10 +1039,10 @@ msngr.extend(function (external, internal) {
11191039
if (payload !== undefined) {
11201040
if (uses.length > 0 || forced.length > 0) {
11211041
settleMiddleware(uses, payload, msg, function (newPayload) {
1122-
explicitEmit([id], newPayload, undefined);
1042+
explicitEmit([id], newPayload);
11231043
});
11241044
} else {
1125-
explicitEmit([id], payload, undefined);
1045+
explicitEmit([id], payload);
11261046
}
11271047
}
11281048

@@ -1141,10 +1061,10 @@ msngr.extend(function (external, internal) {
11411061
if (payload !== undefined) {
11421062
if (uses.length > 0 || forced.length > 0) {
11431063
settleMiddleware(uses, payload, msg, function (newPayload) {
1144-
explicitEmit([id], newPayload, undefined);
1064+
explicitEmit([id], newPayload);
11451065
});
11461066
} else {
1147-
explicitEmit([id], payload, undefined);
1067+
explicitEmit([id], payload);
11481068
}
11491069
}
11501070

@@ -1267,7 +1187,7 @@ msngr.extend(function (external, internal) {
12671187
/*
12681188
module.exports.js
12691189
1270-
If we're running in a node.js.
1190+
If we're running in node.js.
12711191
*/
12721192
if (typeof module !== "undefined" && typeof module.exports !== "undefined") {
12731193
module.exports = msngr;

0 commit comments

Comments
 (0)