Function Composition helper function

I'm not sure of there is a proposal for this. Would it make sense to have a compose helper function on Function or its prototype? I often come across situations where I have to nest function calls to pass data. I was thinking along the lines of mapping of functions, like arrays.
Code like this

const objectInvert = (obj) => {
  return Object.fromEntries(
    Object.entries(obj).map(entry => entry.reverse())
  );
}

can be converted to

const objectInvert = Function.compose(
  Object.entries,
  (entries) => entries.map(entry => entry.reverse()),
  Object.fromEntries,
);

Here's a very rough polyfill for Function.compose.

Function.compose = function(...args) {
  return (input) => {
    return args.reduce((acc, fn) => {
      return fn(acc);
    }, input);
  }
}

Alternatively, on the prototype

Function.prototype.compose = function(fn) {
  const currentFn = this;
  return (...args) => {
    return fn(currentFn(...args));
  }
}

and we can do things like this --

function add(a, b) {
  return a + b;
}
const square = el => el => el ** 2;
const sumSquare = add.compose(square);

Would compose like this make sense? Or would this only work with explicit currying support?
Feedback welcome! Thanks!

You may be interested in https://github.com/tc39/proposal-pipeline-operator :

const objectInvert = (obj) => {
    return obj
        |> Object.entries
        |> (entries => entries.map(entry => entry.reverse())
        |> Object.fromEntries;
}

Thanks for the reply! I didn't know about that. Seems like that I wanted. :)

say i'm debugging unfamiliar code written by someone else in moderately-complex io-application (e.g. ingest-and-map 100mb csv into sql.js via web-workers).

while trying to pinpoint source of bug through 1000 lines of io-code, i run across something like this:

const objectInvert = (obj) => {
    return obj
        |> Object.entries
        |> (entries => entries.map(entry => entry.reverse())
        |> Object.fromEntries;
}

// or this

const objectInvert = Function.compose(
    Object.entries,
    (entries) => entries.map(entry => entry.reverse()),
    Object.fromEntries,
);

if there was bug in either of above examples, could any of you have easily figured it out?

i would say the original "ugly" vanilla-js code is in fact easier-to-reason and debug in real-world javascript io-scenarios:

const objectInvert = (obj) => {
    return Object.fromEntries(
      Object.entries(obj).map(entry => entry.reverse())
    );
}