Getting Timestamp of Most Recently Modified Macro

FWIW you could specify a list of UUIDs to skip at source:

Expand disclosure triangle to view JS source
(() => {
    "use strict";

    // A list of UUID strings to skip.
    const exclusions = [
        // e.g. as comma-separated strings:
        // "DD24A07A-C07B-4A67-A1E6-0DF8569C473D",
        // "4F71F3BC-4F46-48B2-805F-AEC8EA77E418"
    ];

    const main = () => {
        const
            km = Application("Keyboard Maestro"),
            macros = km.macros;

        return sortBy(
            flip(compare)
        )(
            zipWith3(
                u => t => k =>
                    exclusions.includes(u)
                        ? []
                        : [`${new Date(t).getTime()} -> ${u} -> ${k}`]
            )(
                macros.id()
            )(
                macros.modificationDate()
            )(
                macros.name()
            )
            .flat()
        )
        .join("\n");
    };


    // ------------------ GENERICS -------------------
    // https://github.com/RobTrew/prelude-jxa
    // ----------------- JS PRELUDE ------------------

    // compare :: a -> a -> Ordering
    const compare = a =>
        b => a < b
            ? -1
            : a > b ? 1 : 0;


    // flip :: (a -> b -> c) -> b -> a -> c
    const flip = op =>
    // The binary function op with
    // its arguments reversed.
        1 !== op.length
            ? (a, b) => op(b, a)
            : (a => b => op(b)(a));


    // sortBy :: (a -> a -> Ordering) -> [a] -> [a]
    const sortBy = f =>
    // A copy of xs sorted by the comparator function f.
        xs => xs.slice()
        .sort((a, b) => f(a)(b));


    // zipWith3 :: (a -> b -> c -> d) ->
    // [a] -> [b] -> [c] -> [d]
    const zipWith3 = f =>
        xs => ys => zs => Array.from({
            length: Math.min(
                ...[xs, ys, zs].map(x => x.length)
            )
        }, (_, i) => f(xs[i])(ys[i])(zs[i]));


    // MAIN --
    return main();
})();
3 Likes