JavaScript to add current Safari tab to a Links: project, adding a dated @tag

That is amazing @complexpoint ! Thank you!

I am trying to integrate it into my previous code, and I am making a mistake somewhere. Can you tell me where I am going wrong?

(() => {
    "use strict";

    // Rob Trew @2021

    // main :: IO ()
    const main = () => {
        const
            tabs = Application("Safari")
            .windows.at(0).tabs,
            dateString = taskPaperDateString(new Date())
            .slice(0, 10);

        return zipWith(
                name => link =>
                `- ${name} → ${link} @link(${dateString})`
            )(
                tabs.name()
            )(
                tabs.url()
            )
            .join("\n");
    };

    // --------------------- GENERIC ---------------------

    // iso8601Local :: Date -> String
    const iso8601Local = dte =>
        new Date(dte - (6E4 * dte.getTimezoneOffset()))
        .toISOString();

    // taskPaperDateString :: Date -> String
    const taskPaperDateString = dte => {
        const [d, t] = iso8601Local(dte).split("T");

        return [d, t.slice(0, 5)].join(" ");
    };

    // zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
    const zipWith = f =>
        // A list constructed by zipping with a
        // custom function, rather than with the
        // default tuple constructor.
        xs => ys => xs.map(
            (x, i) => f(x)(ys[i])
        ).slice(
            0, Math.min(xs.length, ys.length)
        );

function TaskPaperContext(editor, options) {
    const outline = editor.outline
    const project = outline.evaluateItemPath('project Links')[0]
    if (project == null) {
        project = outline.createItem('Links:')
        outline.root.insertChildrenBefore(project, outline.root.firstChild)
    }
        project.insertChildrenBefore(
            outline.createItem(options.url),
            project.firstChild
    )
}

Application('TaskPaper').documents[0].evaluate({
  script: TaskPaperContext.toString(),
  withOptions: { url: main },
  });
})();

Side question: which app do you use to debug JavaScript code?