https://github.com/mathiasbynens/tpyo
A small script that enables you to make typos in JavaScript property names. Powered by ES2015 proxies + Levenshtein string distance.
https://github.com/mathiasbynens/tpyo
Last synced: 6 months ago
JSON representation
A small script that enables you to make typos in JavaScript property names. Powered by ES2015 proxies + Levenshtein string distance.
- Host: GitHub
- URL: https://github.com/mathiasbynens/tpyo
- Owner: mathiasbynens
- License: mit
- Created: 2013-11-27T23:01:12.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2021-04-19T20:53:11.000Z (over 4 years ago)
- Last Synced: 2025-03-04T09:34:35.333Z (10 months ago)
- Language: JavaScript
- Homepage: https://mths.be/tpyo
- Size: 15.6 KB
- Stars: 207
- Watchers: 6
- Forks: 6
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT.txt
Awesome Lists containing this project
- awesome-es2015-proxy - tpyo
README
# tpyo [](https://travis-ci.org/mathiasbynens/tpyo)
Ever wanted to use `Math.SQUIRTLE` instead of `Math.SQRT2`? Think `Function.prototype.apple` looks shinier than `apply`? Or do you prefer `Array.prototype.faReech` over `forEach`? Look no further — _tpyo_’s got your back.
_tpyo_ (pronounced _‘typo’_) is the result of combining the power of ES2015 proxies with [Levenshtein string distance](https://github.com/gf3/Levenshtein). It’s a small script that enables you to make typos in JavaScript property names.
## Installation
Via [npm](https://www.npmjs.com/):
```bash
npm install tpyo
```
In [Node.js](https://nodejs.org/) v6+:
```js
const tpyo = require('tpyo');
```
## Examples
```js
const array = tpyo(['a', 'b', 'c']);
array.lnegth;
// → `3`
array.tosTr1ng();
// → `'a,b,c'`
array.rap((item) => item + item);
// → `['aa', 'bb', 'cc']`
array.poop();
// → `'cc'`
array.shit();
// → `'aa'`
const object = tpyo({
name: 'Leeroy Jenkins',
awesome: true
});
object.naem;
// → `'Leeroy Jenkins'`
object.awsum;
// → `true`
const math = tpyo(Math);
math.PIE;
// → `3.141592653589793`
math.squrt(4);
// → `2`
```
For more examples, [see the tests](https://github.com/mathiasbynens/tpyo/blob/master/tests/tests.js). [More examples welcome :)](https://github.com/mathiasbynens/tpyo/issues/1)
## Should I use this?
**Nope.** It’s just a fun example of what’s possible with ECMAScript 2015 proxies.
## Acknowledgements
* Kudos to @gf3, whose [excellent implementation of the Levenshtein string difference algorithm](http://gf3.github.com/Levenshtein/) is being used in _tpyo_.
* Shout-out to `-ot`. ♥
## Author
| [](https://twitter.com/mathias "Follow @mathias on Twitter") |
|---|
| [Mathias Bynens](https://mathiasbynens.be/) |
## License
_tpyo_ is available under the [MIT](https://mths.be/mit) license.