Hacker News new | ask | show | jobs
by karmakaze 2486 days ago
Well looking at the left (Tasklemon) and right (Node.js) in the example, I'm wondering what it take to make them be the same thing. Off the top of my head something like:

#!/usr/local/bin/tasklemon stdlib

  home.children().forEach(child => {
    if (child.extension === 'tmp') child.delete();
  });
where 'stdlib' in a tasklemon config dir has the preamble:

  const fs = require('fs');
  const os = require('os');
  const path = require('path');
  
  const home = {
    children: function() {
      const homeDir = os.homedir();
      fs.readdirSync(homeDir).map((file) => {
        return {
          extension: path.parse(file).ext,
          delete: function() {
            const absPath = path.join(homeDir, file);
            fs.unlinkSync(absPath);
          },
        };
      });
    },
  };
So basically each 'feature' of Tasklemon is just a nice DSL for js/ts.

And for handing async callbacks, run the contents of the script in an async function so you can await values anywhere rather than have to pass in callbacks.

1 comments

I'm not sure what your point is; of course, you can write JS on top of Node that exposes its functionality with a nice API: that's exactly what Tasklemon is!

Did the intro maybe give you the impression that TL was built standalone, instead of on Node?