Last active
March 6, 2018 18:10
-
-
Save williammustaffa/e586c288081612ae03b8ce53a73e4b29 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* "string".cuckalize(value) | |
* transform any word into a custom object | |
* | |
* @param {Any} v Variable value | |
* | |
* @return {Object} | |
*/ | |
String.prototype.cuckalize = function (v) { return this.split('').reverse().reduce((p, c) => ({ [c]: p }), v) }; | |
/** | |
* "String".encode_cuck(value) | |
* encode a string with a value | |
* | |
* @param {Any} v Variable value | |
* | |
* @return {Object} | |
*/ | |
String.prototype.encode_cuck = function (v) { return window[`c_${btoa(this)}`] = JSON.stringify(this.split('').reverse().reduce((p, c) => ({ [btoa(c)]: p }), btoa(v))); }; | |
/** | |
* "String".decode_cuck() | |
* decode the giving string | |
* | |
* @return {any} | |
*/ | |
String.prototype.decode_cuck = function () { return o = window[`c_${btoa(this)}`], o && atob(this.split('').reduce((p, c) => p[btoa(c)], JSON.parse(o))); }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment