Skip to content

Commit

Permalink
Linted.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Apr 29, 2016
1 parent 74c79f0 commit 2864f07
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 137 deletions.
1 change: 0 additions & 1 deletion lib/common.js
@@ -1,7 +1,6 @@
/* Copyright (c) 2010-2015 Richard Rodger, MIT License */
'use strict'

var Util = require('util')
var _ = require('lodash')
var Jsonic = require('jsonic')
var Nid = require('nid')
Expand Down
12 changes: 0 additions & 12 deletions lib/plugins.js
Expand Up @@ -5,7 +5,6 @@ var Util = require('util')
var _ = require('lodash')
var Eraro = require('eraro')
var Parambulator = require('parambulator')
var Common = require('./common')
var Logging = require('./logging')

// Shortcuts
Expand Down Expand Up @@ -60,11 +59,6 @@ module.exports.register = function (so) {

meta = define_plugin(delegate, plugin, plugin_options)

// legacy api for service function
if (_.isFunction(meta)) {
meta = {service: meta}
}

plugin.name = meta.name || plugin.name
plugin.tag =
meta.tag ||
Expand Down Expand Up @@ -300,12 +294,6 @@ function make_delegate (instance, plugin) {
}

function define_plugin (delegate, plugin, options) {
// legacy plugins
if (plugin.init.length > 1) {
plugin.init_func_sig = plugin.init.toString().match(/^(.*)\n/)[1]
throw internals.error('unsupported_legacy_plugin', plugin)
}

var meta = plugin.init.call(delegate, options) || {}

meta = _.isString(meta) ? {name: meta} : meta
Expand Down
1 change: 0 additions & 1 deletion lib/transport.js
Expand Up @@ -60,7 +60,6 @@ exports.client = function () {
var args = arrayify(arguments)

self.ready(function () {

self.log.info.apply(self, _.flatten([
'client', args[0], args.slice(1)
]))
Expand Down
101 changes: 13 additions & 88 deletions seneca.js
Expand Up @@ -86,7 +86,7 @@ var internals = {
act_caller: false,

// Shorten all identifiers to 2 characters.
short_logs: false,
short_logs: false
},

// Enforce strict behaviours. Relax when backwards compatibility needed.
Expand Down Expand Up @@ -428,8 +428,6 @@ function make_seneca (initial_options) {
}

function api_export (key) {
var self = this

// Legacy aliases
if (key === 'util') {
key = 'basic'
Expand Down Expand Up @@ -818,16 +816,6 @@ function make_seneca (initial_options) {
return this
}

var handleClose = function () {
root.close(function (err) {
if (err) {
Common.console_error(err)
}

process.exit(err ? (err.exit === null ? 1 : err.exit) : 0)
})
}

// close seneca instance
// sets public seneca.closed property
function api_close (done) {
Expand Down Expand Up @@ -1173,7 +1161,8 @@ function make_seneca (initial_options) {

if (!loadingStarted) {
loadingQueue.push(execute_action, act_done)
} else {
}
else {
execute_action(act_done)
}
}
Expand Down Expand Up @@ -1222,40 +1211,6 @@ function make_seneca (initial_options) {
}
}

function callback_error (instance, err, actmeta, result, cb,
duration, callargs, prior_ctxt) {
actmeta = actmeta || {}

if (!err.seneca) {
err = internals.error(err, 'act_callback', _.extend(
{},
err.details,
{
message: err.message,
pattern: actmeta.pattern,
fn: actmeta.func,
cb: cb,
instance: instance.toString()
}))

result[0] = err
}

err.details = err.details || {}
err.details.plugin = err.details.plugin || {}

Logging.log_act_err(root, {
actid: callargs.id$ || callargs.actid$,
duration: duration
}, actmeta, callargs, prior_ctxt, err)

instance.emit('act-err', callargs, err, result[1])

if (so.errhandler) {
so.errhandler.call(instance, err)
}
}

// Check if actid has already been seen, and if action cache is active,
// then provide cached result, if any. Return true in this case.
function apply_actcache (instance, args, prior_ctxt, actcb) {
Expand Down Expand Up @@ -1299,9 +1254,6 @@ function make_seneca (initial_options) {

function act_make_delegate (instance, tx, callargs, actmeta, prior_ctxt) {
var delegate_args = {}
if (callargs.gate$ != null) {
delegate_args.ungate$ = !!callargs.gate$
}

var history_entry = _.clone(callargs.meta$)
history_entry.instance = instance.id
Expand Down Expand Up @@ -1493,10 +1445,15 @@ function make_seneca (initial_options) {
// as zig does not like sync
var sync = true
self.act(actargs, function (err, out) {
if (!done) {
return
}

if (sync) {
// TODO use process.nextTick?
setImmediate(done, err, out)
} else {
}
else {
done(err, out)
}
})
Expand All @@ -1515,18 +1472,16 @@ function make_seneca (initial_options) {
trace: options.zig.trace
})

dzig.start(function () {
var self = this
dzig.end()
})
dzig.start()

sd.end = function (cb) {
var self = this
if (loadingStarted) {
dzig.end(function () {
if (cb) return cb.apply(self, arguments)
})
} else {
}
else {
loadingQueue.push(function (done) {
dzig.end(function () {
if (cb) return cb.apply(self, arguments)
Expand All @@ -1536,6 +1491,7 @@ function make_seneca (initial_options) {
done()
})
}

return self
}

Expand Down Expand Up @@ -1584,18 +1540,6 @@ function make_seneca (initial_options) {
root[property] = method
}

// DEPRECATED
// for use with async
root.next_act = function () {
var si = this || root
var args = arrayify(arguments)

return function (next) {
args.push(next)
si.act.apply(si, args)
}
}

// Add builtin actions.
root.add({role: 'seneca', cmd: 'stats'}, action_seneca_stats)
root.add({role: 'seneca', cmd: 'close'}, action_seneca_close)
Expand Down Expand Up @@ -1665,25 +1609,6 @@ function make_seneca (initial_options) {
return root
}


// Utilities

function make_trace_act (opts) {
return function () {
var args = Array.prototype.slice.call(arguments, 0)
args.unshift(new Date().toISOString())

if (opts.stack) {
args.push(new Error('trace...').stack)
}

console.log(args.join('\t'))
}
}


// Declarations

// Private member variables of Seneca object.
function make_private () {
return {
Expand Down
2 changes: 0 additions & 2 deletions test/entity.test.js
Expand Up @@ -286,7 +286,6 @@ describe('entity', function () {

si.use('entity')
si.ready(function () {

assert.equal('$-/-/foo;id=;{c:3,d:4}',
si.make('foo', {a: 1, b: 2, c: 3, d: 4}).toString())

Expand Down Expand Up @@ -341,7 +340,6 @@ describe('entity', function () {
// NOTE: zone is NOT saved! by design!

si.ready(function () {

var x1, x2, x3

Async.series([
Expand Down
1 change: 0 additions & 1 deletion test/error.test.js
Expand Up @@ -27,7 +27,6 @@ describe('seneca-error', function () {
var si = make_seneca(ctxt)

si.ready(function () {

// ~~ CASE: fire-and-forget; err-logged
si.act('a:1')
// FIX: validate using act events
Expand Down
9 changes: 5 additions & 4 deletions test/plugin.test.js
@@ -1,7 +1,6 @@
/* Copyright (c) 2013-2015 Richard Rodger, MIT License */
'use strict'

var _ = require('lodash')
var Code = require('code')
var Lab = require('lab')
var Seneca = require('..')
Expand Down Expand Up @@ -49,7 +48,8 @@ describe('plugin', function () {
var e
try {
this.add(new Error())
} catch (err) {
}
catch (err) {
e = err
}
expect(e).to.exists()
Expand All @@ -59,7 +59,7 @@ describe('plugin', function () {

it('plugin-error-act', function (done) {
var si = Seneca({
log: 'silent',
log: 'silent'
})

si.on('error', done)
Expand Down Expand Up @@ -143,7 +143,8 @@ describe('plugin', function () {
var err
try {
si.export('not-an-export')
} catch (e) {
}
catch (e) {
err = e
}
expect('export_not_found').to.equal(err.code)
Expand Down
49 changes: 29 additions & 20 deletions test/seneca.test.js
Expand Up @@ -622,7 +622,7 @@ describe('seneca', function () {
}
self.init = function (options) {
this.add({ role: self.name, cmd: 'foo' }, function (args, cb) {
cb(null, { 'foo' : args.foo })
cb(null, { foo: args.foo })
})
}
}
Expand Down Expand Up @@ -1240,29 +1240,38 @@ describe('seneca', function () {
done()
})
}
})

function do_zig3 () {
si.options({ xzig: { trace: true } })
it('zig3', function (done) {
var si = Seneca(testopts)
var tmp = {bb: []}

var tmp = {bb: []}
si
.add('a:1', function (a, d) { d(0, {aa: a.aa}) })
.add('b:1', function (a, cb) {
tmp.bb.push(a.bb)
cb()
})
.start()
.fire('b:1,bb:1')
.fire('b:1,bb:2')
.end(function () {
setTimeout(function () {
assert.deepEqual({ bb: [ 1, 2 ] }, tmp)
done()
}, 100)
})
})

si
.add('b:1', function (a, cb) {
tmp.bb.push(a.bb)
cb()
})
it('zig4', function (done) {
var si = Seneca(testopts)

si
.start()
.fire('b:1,bb:1')
.fire('b:1,bb:2')
.end(function () {
setTimeout(function () {
assert.deepEqual({ bb: [ 1, 2 ] }, tmp)
do_zig4()
}, 10)
})
}
si
.add('a:1', function (a, d) { d(0, {aa: a.aa}) })
.act('a:1,aa:1', function (e, o) {
assert.equal(1, o.aa)
do_zig4()
})

function do_zig4 () {
si.options({xzig: {trace: true}})
Expand Down

0 comments on commit 2864f07

Please sign in to comment.