Echo JS 0.11.0

<~>

tracker1 comments

tracker1 3346 days ago. link 1 point
I really wish that there was more effort to get the underlying data for Moment into the browsers, so the likes of moment itself could be *much* smaller...
tracker1 3346 days ago. link 1 point
because `require('stream').Through` pretty much does everything through2 does...

    new Transform({
      objectMode: true,
      transform(chunk, enc, cb) {},
      flush(cb) {}
    });

Is there something through2 inherently does that this doesn't?

The internals provide... I mean, you can either inherit from the template streams, or you can use streams that actually serve a purpose..  Readable handles backpressure by default, not sure why you'd want from2 or through2 ... end-of-stream comes down to knowing when to listen for 'end' (readable/through) and 'finish' (writable).

pump actually seems to serve a purpose... as does the likes of split2, and others... but the most basic readable/transform/writable bases are covered in the box, and it's really better to use them than bring in potentially a bunch of extra dependencies.
tracker1 3348 days ago. link 1 point
Also, don't roll your own CSV library, there's a couple decent ones already... ymmv, but there's a lot of edge cases to CSV parsing, and you will probably come across some issues if you aren't very careful.
tracker1 3348 days ago. link 1 point
Grr.. please don't use the modules the article mentions... use the built in, extensible streams...

    import { Readable, Writeable, Transform, Duplex } from 'stream';

All you have to do is implement the minimal override in your own version.. for example...

    import { Tranform } from 'stream';

    // relies on split2 being run before this filter
    export default class FileOutputSettingsFilter extends Tranform {
      __line = 0;

      constructor(options) {
        super({ objectMode: true });
      }

      _tranform = (chunk, enc, cb) => {
        const line = ++this.__line;
        if (line > 3) return cb(null, chunk);
        if (line = 2) this.emit('fileOutputSettings', chunk);
        cb();
      }
    }

This lets me pluck the second line of input from a file, while passing everything after the third line through... in the case above, there is some prefixed data before CSV data at the top of the file.

It's easy enough to create readable/writeable streams as well... I have a few that will output to Message Queue services, or logging, etc.
tracker1 3350 days ago. link 1 point
Yeah, I was really interested in Aphrodite, but react-jss just seems slightly better in terms of a solution.  It renders to style tag(s), so you can do media queries, and you can invert nesting similar to sass/less, so it's not bad.. remembering to quote css properties is the only hard part (similar to inline)... you get classes to set on your rendered components, similar to aphrodite (iirc), and it goes well enough.
tracker1 3354 days ago. link 1 point
Very cool... would love to see a jest version of this...
tracker1 3354 days ago. link 1 point
I've either gone with Sass (via webpack/require) per component, or with JSS (my preference lately)... react-jss works pretty well, and I can always start with inline, change to jss as I go.  Some things are a bit awkward starting out, but it's easier to share configs and common settings with JSS.  My only complaint is the library is a little heavy.
tracker1 3356 days ago. link 1 point
I haven't not used babel in some while now... even for smaller, personal bits... though not always via webpack.
tracker1 3356 days ago. link 1 point
My favorite, and really useful for batch processing scripts, is `--expose-gc` which allows you to use `global.gc()` in your processing script after each item (or N items), keeping your total memory use lower.  It's not a good thing for service processes (generally), but for long-running workers, can keep you from experiencing large GCs in the middle of the run, or from inflating the memory use on a system that's shared for other processing scripts.
[more]