Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

seneca

Package Overview
Dependencies
Maintainers
2
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seneca - npm Package Compare versions

Comparing version 0.5.11 to 0.5.12

8

CHANGES.md
## 0.5.12:
* argsparser replaced with jsonic module
* added act_if convenience method
* deepextend can handle circular references
* argprops cleans $ args
## 0.5.11:

@@ -3,0 +11,0 @@

2

lib/entity.js

@@ -277,2 +277,4 @@ /* Copyright (c) 2010-2012 Richard Rodger */

}
// TOOD: convert entity objects into id refs
}

@@ -279,0 +281,0 @@

158

lib/seneca.js

@@ -5,3 +5,3 @@ /* Copyright (c) 2010-2013 Richard Rodger */

var VERSION = '0.5.11'
var VERSION = '0.5.12'

@@ -32,4 +32,7 @@ // FIX: nix this common thing!

var connect = require('connect')
var request = require('request')
var jsonic = require('jsonic')

@@ -44,3 +47,3 @@

var argsparser = require('./argsparser')
//var argsparser = require('./argsparser')

@@ -422,15 +425,18 @@

sd.add = function(args,paramspec,actfunc,actmeta) {
if( _.isFunction(paramspec) ) {
actmeta = actfunc || {}
actfunc = paramspec
paramspec = null
sd.add = function() {
var args = arrayify(arguments)
//console.log('sd.args',args)
var actmeta = args[args.length-1]
if( _.isFunction(actmeta) ) {
actmeta = {}
args.push(actmeta)
}
else {
actmeta = actmeta || {}
}
actmeta.plugin_nameref = nameref
actmeta.log = sd.log
self.add.call(sd,args,paramspec,actfunc,actmeta)
//console.log('sd.args.passed',args)
self.add.apply(sd,args)
}

@@ -1037,5 +1043,5 @@

var objstr = err ? JSON.stringify({error:''+err}) : safe_json_stringify(outobj)
var code = err ? (err.seneca && err.seneca.httpstatus ? err.seneca.httpstatus : 500) : obj.httpstatus$ ? obj.httpstatus$ : 200;
var code = err ? (err.seneca && err.seneca.httpstatus ? err.seneca.httpstatus : 500) : (obj && obj.httpstatus$) ? obj.httpstatus$ : 200;
var redirect = obj.redirect$ || (err && err.seneca.httpredirect)
var redirect = (obj ? obj.redirect$ : false) || (err && err.seneca.httpredirect)

@@ -1213,23 +1219,67 @@ if( redirect ) {

self.add = function(args,paramspec,actfunc,actmeta) {
var pb
// params: argstr,argobj,paramspec,actfunc,actmeta
self.add = function() {
var inargs = arrayify(arguments)
//console.log('inargs',inargs)
var args = inargs.shift()
if( _.isString( args) ) {
try {
var strargsobj = jsonic(args)
}
catch( e ) {
throw self.fail({code:'seneca/string-args-syntax-error',argstr:args,inargs:inargs})
}
// NOTE: second args is always interpreted as args object!
// to have a paramspec with string args, you need to say add("a:1",{b:2}, {a:"required$"}, ...
var argsobj = inargs.shift()
if( _.isFunction(argsobj) ) {
inargs.unshift(argsobj)
args = strargsobj
}
else if( _.isObject(argsobj) ) {
args = _.extend( {}, argsobj, strargsobj )
}
else throw self.fail({code:'seneca/args-must-be-object',args:argsobj,inargs:inargs})
}
else if( !_.isObject(args) ) {
throw self.fail({code:'seneca/args-must-be-object',args:argsobj,inargs:inargs})
}
var paramspec = inargs.shift()
var actfunc
var pm
if( _.isFunction(paramspec) ) {
actmeta = actfunc || {}
pm = null
actfunc = paramspec
}
else {
actmeta = actmeta || {}
if( _.isObject(paramspec) ) {
actmeta.parambulator = parambulator(paramspec)
}
else if( _.isObject(paramspec) ) {
pm = parambulator(paramspec)
actfunc = inargs.shift()
}
if( !_.isFunction(actfunc) ) {
throw self.fail({code:'seneca/actfunc_not_defined',args:args})
throw self.fail({code:'seneca/action-function-required',actfunc:actfunc,inargs:inargs})
}
if( !_.isObject(actmeta) || _.isFunction(actmeta) ) {
throw self.fail({code:'seneca/actmeta_not_object',args:args})
var actmeta = inargs.shift()
if( void 0 == actmeta ) {
actmeta = {}
}
else if( !_.isObject(actmeta) ) {
throw self.fail({code:'seneca/action-metadata-not-an-object',actmeta:actmeta,inargs:inargs})
}
if( paramspec ) {
actmeta.parambulator = pm
}
var instance = this && this.seneca ? this : self

@@ -1398,2 +1448,3 @@

$.stats.act.called++
actmeta.func.call(delegate,callargs,function(err){

@@ -1405,3 +1456,3 @@ var args = arrayify(arguments)

instance.log.error('act','err',actid,err.message,stackfirst(err) )
if( !err.seneca ) {

@@ -1413,3 +1464,3 @@ return instance.fail(err,cb)

}
}
}
else {

@@ -1421,3 +1472,3 @@ var emitargs = args.slice()

instance.emit.apply(instance,emitargs)
args[0] = null

@@ -1453,3 +1504,3 @@

var argsobj = _.isObject(orig[1]) ? orig[1] : {}
args = _.extend({},argsobj,argsparser.parse(orig[0]))
args = _.extend({},argsobj,jsonic(orig[0]))
}

@@ -1469,2 +1520,10 @@ catch( e ) {

self.act_if = function() {
if( _.isBoolean( arguments[0] ) ) {
if( !arguments[0] ) return;
return this.act.apply(this,arrayify(arguments).slice(1))
}
else throw this.fail({code:'act-if-no-boolean'})
}
self.act = function() {

@@ -1671,5 +1730,12 @@ var argscb = handle_act_args(arrayify(arguments))

function deepextend(tar) {
function deepextend() {
var args = arrayify(arguments)
args.unshift([])
return deepextend_impl.apply( this, args )
}
// TODO: can still fail if objects are too deeply complex - need a finite bound on recursion
function deepextend_impl(seen, tar) {
tar = _.clone(tar)
_.each(Array.prototype.slice.call(arguments, 1), function(src) {
_.each(Array.prototype.slice.call(arguments, 2), function(src) {
for (var p in src) {

@@ -1683,12 +1749,21 @@ var v = src[p]

// this also works for arrays - allows index-specific overides if object used - see test/common-test.js
// this also works for arrays - allows index-specific overrides if object used - see test/common-test.js
else if( _.isObject(v) ) {
tar[p] = _.isObject( tar[p] ) ? tar[p] : (_.isArray(v) ? [] : {})
if( v.entity$ ) {
tar[p] = v
}
else if( _.contains( seen, v ) ) {
tar[p] = v
}
else {
seen.push(v)
tar[p] = _.isObject( tar[p] ) ? tar[p] : (_.isArray(v) ? [] : {})
// for array/object mismatch, override completely
if( (_.isArray(v) && !_.isArray( tar[p] ) ) || (!_.isArray(v) && _.isArray( tar[p] ) ) ) {
tar[p] = src[p]
// for array/object mismatch, override completely
if( (_.isArray(v) && !_.isArray( tar[p] ) ) || (!_.isArray(v) && _.isArray( tar[p] ) ) ) {
tar[p] = src[p]
}
tar[p] = deepextend_impl( seen, tar[p], src[p] )
}
tar[p] = deepextend(tar[p],src[p])
}

@@ -1737,3 +1812,10 @@ else {

omits = _.isArray(omits) ? omits : _.isObject(omits) ? _.keys(omits) : _.isString(omits) ? omits.split(/\s*,\s*/) : ''+omits
return _.omit( deepextend( defaults, args, fixed ), omits )
// a little pre omit to avoid entities named in omits
var usedargs = _.omit( args, omits )
// don't support $ args
usedargs = clean(usedargs)
return _.omit( deepextend( defaults, usedargs, fixed ), omits )
}

@@ -1740,0 +1822,0 @@

@@ -14,3 +14,3 @@ {

],
"version": "0.5.11",
"version": "0.5.12",
"license": "MIT",

@@ -43,3 +43,4 @@ "homepage": "http://senecajs.org",

"pegjs": "~0.7.0",
"temp": "~0.5.0"
"temp": "~0.5.0",
"jsonic": "~0.1.0"
},

@@ -60,4 +61,7 @@ "main": "lib/seneca",

"scripts": {
"test": "mocha test/seneca.test.js"
"test": "node_modules/.bin/mocha test/*.test.js"
},
"devDependencies": {
"mocha": "~1.13.0"
}
}

@@ -16,3 +16,3 @@ # seneca - Node.js module

Current Version: 0.5.11
Current Version: 0.5.12

@@ -19,0 +19,0 @@ Tested on: node 0.10.6, 0.8.7

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc