Skip to content

Instantly share code, notes, and snippets.

@19h
Last active December 14, 2015 00:38
Show Gist options
  • Select an option

  • Save 19h/4999900 to your computer and use it in GitHub Desktop.

Select an option

Save 19h/4999900 to your computer and use it in GitHub Desktop.
The intermediate data control format implements a non directly interpretable / evaluable intermediate language supposed for the delivery of data in an directly execution context. That is, every instance pushes arguments onto the function stack, the last entity of a lines' call is the function onto which the stack is being applied. The intermedia…
// The immediate data control format
l = console.log;
dcf = {
// settings:
reverse: false,
stringify: function ( a, b ) {
return (!(a instanceof Array) && (a=[a])),
(b && ("$"+(dcf.reverse?a.reverse():a).map(function(v){
return JSON.stringify(v instanceof RegExp ? v.toString() : v).split("$").join("\u0240");
}).join("$")+"$"+JSON.stringify((typeof b == "function" && "("+b.toString().split(" ").join("").split("\n").join("")+")") || b) ));
},
parse: function ( a ) {
return !(a instanceof Array) && (
(a.split("\r\n").length > 1)
? (a=a.split("\r\n"))
: (a.split("\n").length > 1)
? (a=a.split("\n"))
: (a=[a])
), a.map(function (v) {
a = v.split("$").filter(function (v) { return !!v || v != "" }).map(function(v){
return v.split("\u0240").join("$")
}),
b = a.pop();
return [(dcf.reverse?a.reverse():a), b]
}).map(function (v) {
return [v[0].map(JSON.parse), v[1]];
}).map(function (v) {
return new Function ("return " + JSON.parse(v[1]) + ".apply(this, " + JSON.stringify(v[0]) + ")")
})[0]
}
}
v = dcf.stringify(["Kenan", "Sulayman", 23, {
"Integer": 2,
"Float": 1.2,
"Double": 1.232332323232E2
}], function(){
return arguments.length
});
// '$"Kenan"$"Sulayman"$23${"Integer":2,"Float":1.2,"Double":123.2332323232}$"(function () {return arguments.length;})"'
console.log(dcf.parse(v).toString(), v);
console.log(v = "Kenan Sulayman".split("").map(function (v) {
return String.fromCharCode(v.charCodeAt(0) + 1);
}).join(""), v.split("").map(function (v) {
return String.fromCharCode(v.charCodeAt(0) - 1);
}).join(""))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment