Skip to content

Commit

Permalink
Final removal iterate() from utility module
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Oct 8, 2017
1 parent e036b4a commit 453af6d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
13 changes: 0 additions & 13 deletions lib/iterate.js

This file was deleted.

22 changes: 12 additions & 10 deletions lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const path = require("path"),
etag = require("tiny-etag"),
middleware = require(path.join(__dirname, "middleware.js")),
regex = require(path.join(__dirname, "regex.js")),
iterate = require(path.join(__dirname, "iterate.js")),
passport = require("passport"),
jwt = require("passport-jwt"),
BasicStrategy = require("passport-http").BasicStrategy,
Expand Down Expand Up @@ -611,12 +610,15 @@ function bootstrap (obj) {
}

// Setting routes
iterate(obj.config.routes, (routes, method) => {
retsu.each(Reflect.ownKeys(obj.config.routes), k => {
const method = k,
routes = obj.config.routes[method];

if (method === "coap") {
if (obj.coap !== null) {
iterate(routes, (fn, event) => {
obj.log(`COAP event handler: '${event}'`, "debug");
obj.coap.on(event, (req, res) => fn(req, res, obj.coap, obj));
retsu.each(Reflect.ownKeys(routes), i => {
obj.log(`COAP event handler: '${i}'`, "debug");
obj.coap.on(i, (req, res) => routes[i](req, res, obj.coap, obj));
});
}
} else if (method === "socket") {
Expand All @@ -630,11 +632,11 @@ function bootstrap (obj) {
});
}
} else {
iterate(routes, (arg, route) => {
if (typeof arg === "function") {
obj[method](route, (...args) => arg(...args));
retsu.each(Reflect.ownKeys(routes), i => {
if (typeof routes[i] === "function") {
obj[method](i, (...args) => routes[i](...args));
} else {
obj[method](route, (req, res) => res.send(arg));
obj[method](i, (req, res) => res.send(routes[i]));
}
});
}
Expand Down Expand Up @@ -744,7 +746,7 @@ function hypermedia (server, req, rep, headers) {
}
}

iterate(rep.data, i => {
retsu.each(rep.data, i => {
if (i instanceof Object) {
marshal(i, "item", req.parsed.pathname.replace(regex.trailing_slash, "").replace(regex.leading, ""));
} else {
Expand Down

0 comments on commit 453af6d

Please sign in to comment.