avoidwork / keysort

Sorts an Array of Objects with SQL ORDER BY clause syntax

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in keysort.js

olofweb opened this issue · comments

commented

Sorry if my message is off topic because I'm new to Javascript.

I try to use your library (keysort.js). I installed laster npm version (1.0.1) but I get this error :

Uncaught TypeError: Cannot set property 'keysort' of undefined

I see that the last line of keysort.js is :

})(undefined);

If I change this to :

})(this);

I don't get the error.

What is the problem ?

Thank you

Hi,

What version of node are you using?

screen shot 2017-02-23 at 6 30 47 am

Hi,

The IFFE argument this can be problematic depending on the env, so I've made it browser/node aware.

To explain further, this doesn't exist if you are requiring the lib inside an arrow function, unless that arrow function is within a class function where a this does exist for binding; I ran into this a few years ago and modded most of my libs to use a ternary to pass window or global in lieu of this; this was before webpack was a thing.

commented

Thank you for the patch, now it works. And thank you for the explanation :)