Skip to content

Commit

Permalink
first line of business, remove this shit
Browse files Browse the repository at this point in the history
  • Loading branch information
stamat committed Jul 21, 2023
1 parent 185bb87 commit 1af13a8
Showing 1 changed file with 11 additions and 52 deletions.
63 changes: 11 additions & 52 deletions shortcodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,70 +35,29 @@ function Shortcodes(options) {
if (!window.hasOwnProperty('d0')) {
window.d0 = {};

window.d0.getClass = function(val) {
return Object.prototype.toString.call(val)
.match(/^\[object\s(.*)\]$/)[1];
};

window.d0.whatis = function(val) {

if (val === undefined)
return 'undefined';
if (val === null)
return 'null';

var type = typeof val;

if (type === 'object')
type = window.d0.getClass(val).toLowerCase();

if (type === 'number') {
if (val.toString().indexOf('.') > 0)
return 'float';
else
return 'integer';
}

return type;
};

window.d0.types = {
'undefined': -1,
'null': 0,
'boolean': 1,
'integer': 2,
'float': 3,
'string': 4,
'array': 5,
'object': 6,
'function': 7,
'regexp': 8,
'date': 9
};

window.d0.clone = function(o) {
var res = null;
var type = window.d0.types[window.d0.whatis(o)];
if(type === 6) {
let res = null;
if(typeof obj === 'object' && obj !== null) {
res = window.d0._cloneObject(o);
} else if(type === 5) {
res = window.d0._cloneArray(o);
} else {
res = o;
}
return res;
} else if(Array.isArray(o)) {
res = window.d0._cloneArray(o);
} else {
res = o;
}
return res;
};


window.d0._cloneObject = function(o) {
var res = {};
let res = {};
for(var i in o) {
res[i] = window.d0.clone(o[i]);
}
return res;
};

window.d0._cloneArray = function(a) {
var res = [];
let res = [];
for(var i = 0; i < a.length; i++) {
res[i] = window.d0.clone(a[i]);
}
Expand Down

0 comments on commit 1af13a8

Please sign in to comment.