hormander / json-lzw

GNU General Public License v2.0
4 stars 2 forks source link

Angular file, undefined is not a function #3

Open madvas opened 9 years ago

madvas commented 9 years ago

There is a problem with angular file. On line 64 this.JSON.parse(json) throws error undefined is not a function . It should probably be only JSON.parse(json).

After I've tried it I encountered another error with this on line 134 this._indexOf.call -> undefined is not a function , because this means something else in recursiveAstBuilder function

gustavomazzoni commented 8 years ago

Yes, you are right. He created two closures inside pack function, recursiveAstBuilder and recursiveParser. So this is not associated to the jsonlzw object anymore, it's associated to window. To use the jsonlzw object inside the closures we need to assign it to a different variable like self, for example. Then replace the use of this inside the closures to self.

At line 75, add the following code:

var self = this;

Replace this to self inside the closures like:

var index = self._indexOf.call(dictionary.strings, item);
hormander commented 8 years ago

Hi Gustavo thank you for your interested about my software. Currently I'm working on other project (non javascript) If you send me your change, I apply it For curiosity, where do you use the my library?

PS: excuse me for my bad english

Il 22/07/2016 20:17, Gustavo Mazzoni ha scritto:

Yes, you are right. He created two closures inside |pack| function, |recursiveAstBuilder| and |recursiveParser|. So |this| is not associated to the jsonlzw object anymore, it's associated to window. To use the jsonlzw object inside the closures we need to assign it to a different variable like |self|, for example. Then replace the use of |this| inside the closures to |self|.

gustavomazzoni commented 8 years ago

Hi Marco,

I’ve forked your project and will send you a pull request with the changes I’ve made, ok?

I’m not using your library, actually. I needed some more features and decided to go with lz-string.

On 25 de jul de 2016, at 10:56, Marco notifications@github.com wrote:

Hi Gustavo thank you for your interested about my software. Currently I'm working on other project (non javascript) If you send me your change, I apply it For curiosity, where do you use the my library?

PS: excuse me for my bad english

Il 22/07/2016 20:17, Gustavo Mazzoni ha scritto:

Yes, you are right. He created two closures inside |pack| function, |recursiveAstBuilder| and |recursiveParser|. So |this| is not associated to the jsonlzw object anymore, it's associated to window. To use the jsonlzw object inside the closures we need to assign it to a different variable like |self|, for example. Then replace the use of |this| inside the closures to |self|.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hormander/json-lzw/issues/3#issuecomment-234959995, or mute the thread https://github.com/notifications/unsubscribe-auth/ABczA1D32sNeK-uo0j9y41wgJAqh51Unks5qZMCAgaJpZM4DK6is.

gustavomazzoni commented 8 years ago

Marco, just created the pull request with the changes. If you have any questions please do it.

hormander commented 8 years ago

Hello Gustavo, Thanks again, I apply now your patch Tomorrow, I'll update the files on the NPM and, if you want, I'll add your name

Best regards, m

Il 26/07/2016 16:55, Gustavo Mazzoni ha scritto:

Marco, just created the pull request with the changes. If you have any questions please do it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hormander/json-lzw/issues/3#issuecomment-235293980, or mute the thread https://github.com/notifications/unsubscribe-auth/AG5HSv4TTLc6vzzybRM9uYdQ-VvnVm15ks5qZh_zgaJpZM4DK6is.

gustavomazzoni commented 8 years ago

Hi Marco,

You're welcome! Happy to help. It will be a pleasure to have my name on it.

Best regards, Gustavo

Em ter, 26 de jul de 2016 às 12:49, Marco notifications@github.com escreveu:

Hello Gustavo, Thanks again, I apply now your patch Tomorrow, I'll update the files on the NPM and, if you want, I'll add your name

Best regards, m

Il 26/07/2016 16:55, Gustavo Mazzoni ha scritto:

Marco, just created the pull request with the changes. If you have any questions please do it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hormander/json-lzw/issues/3#issuecomment-235293980,

or mute the thread < https://github.com/notifications/unsubscribe-auth/AG5HSv4TTLc6vzzybRM9uYdQ-VvnVm15ks5qZh_zgaJpZM4DK6is .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hormander/json-lzw/issues/3#issuecomment-235312010, or mute the thread https://github.com/notifications/unsubscribe-auth/ABczA_STPiRLMK9wiMJfFqelz7Tb0WPHks5qZiySgaJpZM4DK6is .

hormander commented 8 years ago

Hi Gustavo,

I added your name on my npm project page (https://www.npmjs.com/package/json-lzw)

Best regards, m

Il 26/07/2016 18:06, Gustavo Mazzoni ha scritto:

Hi Marco,

You're welcome! Happy to help. It will be a pleasure to have my name on it.

Best regards, Gustavo

Em ter, 26 de jul de 2016 às 12:49, Marco notifications@github.com escreveu:

Hello Gustavo, Thanks again, I apply now your patch Tomorrow, I'll update the files on the NPM and, if you want, I'll add your name

Best regards, m

Il 26/07/2016 16:55, Gustavo Mazzoni ha scritto:

Marco, just created the pull request with the changes. If you have any questions please do it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub

https://github.com/hormander/json-lzw/issues/3#issuecomment-235293980,

or mute the thread <

https://github.com/notifications/unsubscribe-auth/AG5HSv4TTLc6vzzybRM9uYdQ-VvnVm15ks5qZh_zgaJpZM4DK6is

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hormander/json-lzw/issues/3#issuecomment-235312010, or mute the thread

https://github.com/notifications/unsubscribe-auth/ABczA_STPiRLMK9wiMJfFqelz7Tb0WPHks5qZiySgaJpZM4DK6is .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hormander/json-lzw/issues/3#issuecomment-235317708, or mute the thread https://github.com/notifications/unsubscribe-auth/AG5HSm6-05Ophubceu_M-thnl3Njaiczks5qZjCUgaJpZM4DK6is.

gustavomazzoni commented 8 years ago

Nice! Thanks!

On 27 de jul de 2016, at 06:59, Marco notifications@github.com wrote:

Hi Gustavo,

I added your name on my npm project page (https://www.npmjs.com/package/json-lzw)

Best regards, m

Il 26/07/2016 18:06, Gustavo Mazzoni ha scritto:

Hi Marco,

You're welcome! Happy to help. It will be a pleasure to have my name on it.

Best regards, Gustavo

Em ter, 26 de jul de 2016 às 12:49, Marco notifications@github.com escreveu:

Hello Gustavo, Thanks again, I apply now your patch Tomorrow, I'll update the files on the NPM and, if you want, I'll add your name

Best regards, m

Il 26/07/2016 16:55, Gustavo Mazzoni ha scritto:

Marco, just created the pull request with the changes. If you have any questions please do it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub

https://github.com/hormander/json-lzw/issues/3#issuecomment-235293980,

or mute the thread <

https://github.com/notifications/unsubscribe-auth/AG5HSv4TTLc6vzzybRM9uYdQ-VvnVm15ks5qZh_zgaJpZM4DK6is

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hormander/json-lzw/issues/3#issuecomment-235312010, or mute the thread

https://github.com/notifications/unsubscribe-auth/ABczA_STPiRLMK9wiMJfFqelz7Tb0WPHks5qZiySgaJpZM4DK6is .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hormander/json-lzw/issues/3#issuecomment-235317708, or mute the thread https://github.com/notifications/unsubscribe-auth/AG5HSm6-05Ophubceu_M-thnl3Njaiczks5qZjCUgaJpZM4DK6is.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hormander/json-lzw/issues/3#issuecomment-235541974, or mute the thread https://github.com/notifications/unsubscribe-auth/ABczA6Ut4jnuyI6_-JBRmLv8jwbN7Z-uks5qZywbgaJpZM4DK6is.