mathiasbynens / tpyo

A small script that enables you to make typos in JavaScript property names. Powered by ES2015 proxies + Levenshtein string distance.
https://mths.be/tpyo
MIT License
206 stars 6 forks source link

More examples? #1

Open mathiasbynens opened 10 years ago

mathiasbynens commented 10 years ago

Do your worst. Bonus points for horrible puns.

gulian commented 10 years ago

console.lol('oops'); ?

remeh commented 10 years ago

current = Dqte.noz;

mathiasbynens commented 10 years ago

@remeh That wouldn’t work, as only misspelled property names can be detected using proxies. tpyo(global).Dqte.noz (or tpyo(window).Dqte.noz in browser environments) could work though, as long as you don’t misspell global (or window).

hemanth commented 10 years ago

Here are few horrible puns I tried @mathiasbynens :

array.poop() // for pop()

array.goin() // for join()

array.shit() // for shift()

JSON.prase() // for parse()

Math.squrt() // for Math.sqrt()

Math.poo() // for Math.pow()

Object.evil // for Object.eval

String.bug // for String.big ? 

Happy to send a PR, if worthy.

gulian commented 10 years ago

Math.:poop:() ? Can you make it work ?

mathiasbynens commented 10 years ago

@hemanth Nice work! Object.eval is not a thing though, right? Anyway, that pull request would be very welcome. You could add these to the tests, and some to the README. Thanks in advance.

@gulian Sadly :poop: is not a valid unquoted property name, and even if it was, the Levenshtein distance algorithm wouldn’t be able to map it to anything you’d expect. :(

gulian commented 10 years ago

I'm so sad

console.:heart:() -> console.love() -> console.log() ...

Ok, I'm done.

gulian commented 10 years ago

capture decran 2013-11-29 a 11 19 54 capture decran 2013-11-29 a 11 20 03

(it's working ! :smile:)

hemanth commented 10 years ago

@mathiasbynens Object.eval is a valid thinge, but is obsolete and String.bug must be String.big but there is no String.big on node. So better I shall skip them?

mathiasbynens commented 10 years ago

Ah, you meant Object#eval (i.e. Object.prototype.eval) instead of Object.eval! I had never heard about that one either, though :) Pretty cool.

Also, Node does have String#big (although there is no such thing as String.big in any JS environment), so feel free to include it in the tests.

hemanth commented 10 years ago

@mathiasbynens Ah, that was some FF masala there with String#big

Just sent a PR :)