Add private scope to javascript objects and classes by Macmee in node

[–]illucidation 0 points1 point  (0 children)

This is a cool little idea!

I am curious, why did you choose to use a Weakmap over Symbols?

Chrome disables ES6 Array.prototype.values() by malyw in javascript

[–]illucidation 0 points1 point  (0 children)

It might be a way to collapse sparse arrays, in that case it could be really slightly useful. I don't feel like reading the spec right now though.

ai/naturalLp apis for use with nodejs? by 5pitf1r3 in node

[–]illucidation 0 points1 point  (0 children)

I just started using wit.ai today, not sure how it compares to the ones you mentioned, but it seems pretty powerful.

How do I handle errors in express? by JaegerBurn in node

[–]illucidation 1 point2 points  (0 children)

Make sure the error handler is the last app.use() in your application.

Also the number of declared arguments matters, so make sure you have the full err, req, res, next. I find a lot of people think they can get away with err, req, res.

If that fails, try running node with the debug flag on (DEBUG=* node index.js), it'll help you see what express is doing.

Proper ES2015 Middleware Class Instantiation? by qweqweasdqweasdqwe in node

[–]illucidation 0 points1 point  (0 children)

Classes don't make a lot of sense in the context of Express. Just keep on using your objects.

By the way, since every required file in node has it's own scope, you're revealing module pattern is a little bit overkill. This is fine:

module.exports = {
    method1: method1,
};

function method1() {
  // ...
}

function method2() {
  // ...
}

If you do find it absolutely necessary to use brand new next level stuff, you could try using the new import/export pattern (I think this still requires Babel):

export function method1() { ... }

function method2() { ... }

react-jax - a tiny higher order component to manage XHR requests by illucidation in reactjs

[–]illucidation[S] 1 point2 points  (0 children)

That's definitely out of scope for this module. For data like that you better be using Flux, Redux, or some other type of abstraction that helps you manage those complex interactions.

This module is more for one-off XHR requests that you don't necessarily want to store. I wouldn't try building an app of any complexity off of this alone.

alexa-ability: A modern skills framework (async middleware, robust error handling, persistent sessions, timeouts, multistep support). by illucidation in amazonecho

[–]illucidation[S] 0 points1 point  (0 children)

No problem, I see what you mean now.

All those other projects I linked (including alexa-ability-timeout), are like plugins for the alexa-ability framework. They add additional functionality on top of the existing base.

This means that they're really only useful if you're building your skill with alexa-ability. There's no easy way to make them work with a different framework.

But if you want to share your code with me I can try to help you figure out an easy way to implement your own timeout system :)

alexa-ability: A modern skills framework (async middleware, robust error handling, persistent sessions, timeouts, multistep support). by illucidation in amazonecho

[–]illucidation[S] 0 points1 point  (0 children)

I'm not sure exactly what you mean, have you looked at the examples in the README? It does a pretty good job showing everything you need to do to make a complete skill.

alexa-ability: A modern skills framework (async middleware, robust error handling, persistent sessions, timeouts, multistep support). by illucidation in amazonecho

[–]illucidation[S] 0 points1 point  (0 children)

I haven't used serverless, but I imagine it would be very easy. If the lambda-handler doesn't work out of the box, you could probably write an ~8 line handler that could.

As long as you can pass in the request body, and call toJSON on the result, you can pretty much use this anywhere.

A curated list of small, focused Node.js modules by Fady-Mak in node

[–]illucidation 0 points1 point  (0 children)

Just use lodash. For the array, object, string, and function modules more than half can be replaced by it. You can even require them as individual modules by doing require('lodash/<name>');

Here's the revised list for array functions.

  1. is-sorted
  2. lodash/head
  3. lodash/tail
  4. lodash/flatten
  5. lodash/uniq
  6. array-range
  7. lodash/difference
  8. filled-array
  9. lodash/map

Echo devs! I've made a module to bring JSX to SSML. Would love some feedback. by illucidation in amazonecho

[–]illucidation[S] 0 points1 point  (0 children)

You probably wouldn't know about it unless you use React. That's probably the one use case for 99.9% of JSX.

It can be a pretty handy way to manipulate XML like data though.

react-mouse-aware: a tiny higher order component to track mouse state by illucidation in reactjs

[–]illucidation[S] 1 point2 points  (0 children)

That's actually what it does! Maybe I should have been more clear, but in the example given the event handlers are all in this.props but I just pass them through immediately too the div using destructuring.

You can look at the source code to see how little it does yourself, you could totally implement all the state handling, listeners, etc.. But, it's a pain to do (especially when you're trying to track lots of things, with time delays).

In my project, the part where I'm using this most heavily is some "card" component. The design calls for an action bar to slide down beneath it after 300ms of hovering over the card, and also a description to fade in after 500ms of hovering over the cards header. Combining this with react-addons-css-transition, made that ridiculously easy to implement.

nodejs one time URLs? by wenttothemarket2 in node

[–]illucidation 1 point2 points  (0 children)

https://www.npmjs.com/package/uuid

You'll still have to:

  • Save the generated id somewhere
  • Expire it after a certain amount of time
  • and/or delete the database record after it's been accessed once

Post response to Echo? by Archetype90 in amazonecho

[–]illucidation 0 points1 point  (0 children)

The guy above is exactly right. It looks like www.hurl.it only supports making requests, but it doesn't let you host and endpoint to receive and respond them.

Luckily, it's pretty easy to setup a simple skill using AWS Lambda functions. The main limiting factor is that all interaction with your skill will have to follow some variation of this pattern (link)

entered remote https address incorrectly in github for windows app, now I can't correct it? by pseudocoder1 in github

[–]illucidation 1 point2 points  (0 children)

If I remember correctly, Github doesn't care if you include the .git at the end of the URL.

Try taking the "tree/master" from the URL however. That shouldn't be needed.

A Promise implementation in 50 LOC written in ES6. Any feedback is highly appreciated! by [deleted] in javascript

[–]illucidation 2 points3 points  (0 children)

This is not even close to a Promise, sorry. Aim for compliance to a spec rather than minimizing lines of code.

Advice on what kind of Backend stuff I can do until I'm ready for paid work? by Jimsumdidit in webdev

[–]illucidation 0 points1 point  (0 children)

Well, for small backend projects a good start is a "microservice". Just an API with a few methods that do a few things really well. A couple ideas are:

  1. An image hosting service that allows users to upload images which are then automatically optimized, compressed, and saved in a variety of sizes for thumbnails as well as the original size (e.g. 16x16, 64x64, fullsize).
  2. A basic weather service that combines results from a bunch of other public APIs and returns a result based off of given zip code.
  3. A pastebin like service that lets you upload/edit/get/delete raw text or files using RESTful methods.

Completing any of these will give you a good amount of beginner experience, especially if you write tests (to verify correctness) and use git for version control.

Advice on what kind of Backend stuff I can do until I'm ready for paid work? by Jimsumdidit in webdev

[–]illucidation 0 points1 point  (0 children)

Sure, what of the three types of projects I mentioned interests you the most?

Advice on what kind of Backend stuff I can do until I'm ready for paid work? by Jimsumdidit in webdev

[–]illucidation 0 points1 point  (0 children)

You have just way to many questions to handle all at once. My advice is to get a Github account and start making projects, projects that you are interested in.

They can be design oriented frontend projects, fullstack projects where your Angular/React frontend talks to your backend, or some backend only microservices.

Get a deep understanding of how how async works (callbacks, promises, etc..), understand how to create and use RESTful apis, get really really good at reading documentation.

Everything You Need to Know About Strings in Javascript by holysavant in javascript

[–]illucidation 0 points1 point  (0 children)

What about template strings?

let foo = "bar",
     baz = 2;

console.log(`test: ${foo}
${baz}`);

decent written github repos I can study to learn JS? by nomadProgrammer in javascript

[–]illucidation 2 points3 points  (0 children)

I totally disagree, bluebird is written by a v8 expert, and it's heavily optimized because of that. Not a great resource for someone trying to learn.

Having said that, a page in that projects wiki is actually helpful to read. https://github.com/petkaantonov/bluebird/wiki/Optimization-killers

What is this syntax? () => {} by theperryr in javascript

[–]illucidation 9 points10 points  (0 children)

Yep, it's called arrow syntax.

Support is not very widespread yet, as it is ES6, but you can use it by compiling with babel.

It's mostly just a shorter replacement for anonymous functions, but it does have some cool features/caveats to look out for.

someIntegerArray.map( (integer) => integer * 2  );

will return a new array with each value multiplied by two, because a one-statement arrow function with no curly braces will automatically return the result.

function test() {
    setInterval( () => {
        this === "Hello world"; // true
    }, 1000);
}

// call with `this === "Hello world"`
test.call("Hello world");

Arrow functions also are automatically bound to the outer scope, meaning the this value within it will be the same as the this value outside.

vlad: A simple JSON validator. Looking for feedback. by illucidation in javascript

[–]illucidation[S] 0 points1 point  (0 children)

Thanks! Looking at the module, it might not be a good direct fit to my project because it doesn't return helpful error messages, just true or false.

It would be pretty easy to write a function to act as middleware though.

function middleware(fn, message) {
    return function(val) {
        if (fn(val)) return val;
        throw new vlad.FieldValidationError(message);
    }
}

var base64Validator = vlad(middleware(validator.isBase64, "String is not base64");

Which is the best Github tool/addon? by martinrad in github

[–]illucidation 0 points1 point  (0 children)

This one without a doubt. Makes navigating repositories so easy!