Aliasing Functions that Return (RMMV)

Hello everyone,

I'm working on a script and I'm a bit stuck when it comes to aliasing. If I wanted to alias a function that already has a return command, how would I go about doing so? Unless I'm misunderstanding something (likely) calling the aliased function inside the new function definition triggers the return command before any of my other commands can be called. I know there's a way around this, but I'm not sure what it is.

I want to alias DataManager.makeSaveContents. Can anyone point me in the right direction for how to make this alias?

I have tried a few things, and none of it worked. I can't post the code/error messages right now because I don't have it with me.

Thanks

I've moved this thread to Learning Javascript. Thank you.

alias a function that already has a return command, how would I go about doing so?
I want to alias DataManager.makeSaveContents. Can anyone point me in the right direction for how to make this alias?
Basically it's like this...
  1. store the returned value in a variable
  2. do whatever you want with/to that variable
  3. return that variable
Spoiler: Code
Code:
$saveExpansionData = {demoData:'hello world'};
var $ = {}:
$['DataManagar_makeSaveContents'] = DataManager.makeSaveContents;
DataManager.makeSaveContents = function() {
  var contents = $['DataManagar_makeSaveContents'].apply(this, arguments);
  contents.saveExpansionData  = $saveExpansionData;
  return contents;
};
$['DataManager.extractSaveContents'] = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
  $['DataManager.extractSaveContents'].apply(this, arguments);
  $saveExpansionData = contents.saveExpansionData;
};
Test Demo: Click Here to Download
Wouldn't just aliasing it with a function work?
JavaScript:
function newAlias(){return DataManager.makeSaveContents()};

Original thread: https://forums.rpgmakerweb.com/threads/aliasing-functions-that-return-rmmv.120173/