Skip to content

Instantly share code, notes, and snippets.

View Hoff97's full-sized avatar
🚕

Frithjof Winkelmann Hoff97

🚕
View GitHub Profile
@Hoff97
Hoff97 / observable.js
Created September 16, 2018 13:56
Very simple observable implementation
function Observable(observe) {
this.map = f => {
return new Observable(cb => {
this.observe(x => {
cb(f(x));
});
});
}
this.flatMap = f => {
@Hoff97
Hoff97 / JSONE.js
Last active September 24, 2020 03:54
Special JSON object that is able to convert Objects with their methods and also converts cyclic objects.
//Erweiterte JSON, die auch spezielle Objekte parst und zu JSON umwandelt:
//Objekte, die sich selbst enthalten
//Objekte, die Funktionen enthalten
var JSONE = {};
JSONE.to = {};
JSONE.to.removeCycle = function(obj,already = [],lvl = 1,path="PATH#obj"){
if(typeof obj === "object")
{
for(var i in already)
{
@Hoff97
Hoff97 / main.js
Created November 17, 2013 21:46
JSON but with function de- and encoding. Just use jsonWF to make a JSON string and objWF to make a Object from a JSON string. All methods will remain.
function jsonWF(obj)
{
inject(obj,"funcConvert","self");
var ret = JSON.stringify(obj,funcStringify);
cleanProb(obj,"funcConvert");
return ret;
}
function objWF(str)
{
@Hoff97
Hoff97 / gist:7146111
Created October 24, 2013 22:18
Simple to use Ajax Object.
function AjaxRequest(_file, _readyFunction, _parameters) //A Ajax request wich sends parameter with POST
{
var file = _file;
var readyFunction = _readyFunction;
var parameters = _parameters;
this.send = function()
{
var xmlhttp;
if (window.XMLHttpRequest)