From fc9a371e09cfe82839aea48d26beb7748da7d63c Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Thu, 10 Oct 2024 19:23:09 -0400 Subject: [PATCH] dev: add more to NariMethodsFeature --- src/putility/src/features/NariMethodsFeature.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/putility/src/features/NariMethodsFeature.js b/src/putility/src/features/NariMethodsFeature.js index 7fcc71b4..ad761263 100644 --- a/src/putility/src/features/NariMethodsFeature.js +++ b/src/putility/src/features/NariMethodsFeature.js @@ -52,7 +52,14 @@ module.exports = { instance._.nariMethods[method_name] = bound_fn; instance[method_name] = async (...args) => { - const endArgsIndex = spec.positional.length; + const endArgsIndex = (() => { + if ( spec.firstarg_options ) { + if ( typeof args[0] === 'object' ) { + return 0; + } + } + return spec.positional.length; + })(); const posArgs = args.slice(0, endArgsIndex); const endArgs = args.slice(endArgsIndex); @@ -71,11 +78,15 @@ module.exports = { if ( typeof endArgs[0] === 'function' ) { callbacks.success = endArgs[0]; endArgs.shift(); + } else if ( options.success ) { + callbacks.success = options.success; } if ( typeof endArgs[0] === 'function' ) { callbacks.error = endArgs[0]; endArgs.shift(); + } else if ( options.error ) { + callbacks.error = options.error; } if ( spec.separate_options ) {