kareem 1.4.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +6 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -146,7 +146,7 @@ Kareem.prototype.execPost = function(name, context, args, options, callback) {
146
146
 
147
147
  if (firstError) {
148
148
  if (post.length === numArgs + 2) {
149
- post.apply(context, [firstError, null].concat(function(error) {
149
+ post.apply(context, [firstError].concat(newArgs).concat(function(error) {
150
150
  if (error) {
151
151
  firstError = error;
152
152
  }
@@ -209,14 +209,7 @@ Kareem.prototype.execPostSync = function(name, context) {
209
209
  function _handleWrapError(instance, error, name, context, args, options, callback) {
210
210
  if (options.useErrorHandlers) {
211
211
  var _options = { error: error };
212
- var newArgs = [];
213
- // Filter out trailing undefineds
214
- for (var i = args.length; i >= 0; --i) {
215
- if (newArgs.length > 0 || args[i] !== void 0) {
216
- newArgs.unshift(args[i]);
217
- }
218
- }
219
- return instance.execPost(name, context, newArgs, _options, function(error) {
212
+ return instance.execPost(name, context, args, _options, function(error) {
220
213
  return typeof callback === 'function' && callback(error);
221
214
  });
222
215
  } else {
@@ -257,10 +250,13 @@ Kareem.prototype.wrap = function(name, fn, context, args, options) {
257
250
  fn.apply(context, args.slice(0, end).concat(function() {
258
251
  var args = arguments;
259
252
  var argsWithoutError = Array.prototype.slice.call(arguments, 1);
253
+ if (options.nullResultByDefault && argsWithoutError.length === 0) {
254
+ argsWithoutError.push(null);
255
+ }
260
256
  if (arguments[0]) {
261
257
  // Assume error
262
258
  return _handleWrapError(_this, arguments[0], name, context,
263
- args, options, lastArg);
259
+ argsWithoutError, options, lastArg);
264
260
  } else {
265
261
  if (useLegacyPost && typeof lastArg === 'function') {
266
262
  lastArg.apply(context, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kareem",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "description": "Next-generation take on pre/post function hooks",
5
5
  "main": "index.js",
6
6
  "scripts": {