Skip to content

Commit

Permalink
remove toString api and increment semver
Browse files Browse the repository at this point in the history
  • Loading branch information
ansuz committed Mar 1, 2017
1 parent 6accd62 commit 903e8ae
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
24 changes: 0 additions & 24 deletions hyperjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,6 @@
return e;
};

var indent = function (s, n, t) {
return Array(n + 1).fill('').join(t) + s;
};

var toString = Hyperjson.toString = function (hj, depth, tab) {
if (typeof(hj) === 'string') { return hj; }
var e = document.createElement(hj[0]);
for (var x in hj[1]) { e.setAttribute(x, hj[1][x]); }
tab = typeof(tab) === 'string'? tab : ' ';

depth = (depth || 0) + 1;
e.innerHTML = hj[2].map(function (c, i, L) {
if (typeof(c) === 'string') { return c; }
// don't mess with whitespace in PRE tags
if (hj[0] === 'PRE') { return toString(c, depth, tab); }
// if the next element is a string, don't mess with it
if (typeof(L[i+1]) === 'string') { return toString(c, depth, tab); }
var result = '\n' + indent(toString(c, depth, tab), depth, tab) +
'\n' + indent('', depth - 1, tab);
return result;
}).join('');
return e.outerHTML;
};

if (typeof(module) !== 'undefined' && module.exports) {
module.exports = Hyperjson;
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hyper-json",
"version": "1.3.0",
"version": "1.4.0",
"description": "an abstract datatype compatible with the hyperscript API",
"main": "hyperjson.js",
"scripts": {
Expand Down

0 comments on commit 903e8ae

Please sign in to comment.