[Pkg-javascript-commits] [ltx] 445/469: remove Element.toJSON

Jonas Smedegaard dr at jones.dk
Wed Aug 31 13:03:37 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository ltx.

commit ca43c4202121c80b0637376ada3d8c8deb012d93
Author: Sonny Piers <sonny at fastmail.net>
Date:   Mon Apr 4 10:56:36 2016 +0200

    remove Element.toJSON
---
 benchmarks/index.js   |  2 +-
 benchmarks/parsers.js |  5 +++++
 lib/Element.js        | 10 ----------
 lib/parsers/sax-js.js |  1 -
 test/element-test.js  | 10 ----------
 5 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/benchmarks/index.js b/benchmarks/index.js
index 9d8b85a..f0945bb 100644
--- a/benchmarks/index.js
+++ b/benchmarks/index.js
@@ -13,7 +13,7 @@ readdir(__dirname).forEach(function (file) {
     console.log(event.target.toString())
   })
   .on('complete', function () {
-    console.log('Fastest is ' + this.filter('fastest').map('name'))
+    console.log('Fastest is "' + this.filter('fastest').map('name') + '"')
   })
   .run({'async': false})
   console.log('\n')
diff --git a/benchmarks/parsers.js b/benchmarks/parsers.js
index 9a1f385..48a74e2 100644
--- a/benchmarks/parsers.js
+++ b/benchmarks/parsers.js
@@ -1,5 +1,10 @@
 'use strict'
 
+/*
+ * benchmark the parsing speed of the supported backends
+ * difference with parse.js benchmark is that this doesn't use ltx at all
+*/
+
 var benchmark = require('benchmark')
 var node_xml = require('node-xml')
 var libxml = require('libxmljs')
diff --git a/lib/Element.js b/lib/Element.js
index 73f6b19..7dce18b 100644
--- a/lib/Element.js
+++ b/lib/Element.js
@@ -318,16 +318,6 @@ Element.prototype.toString = function () {
   return s
 }
 
-Element.prototype.toJSON = function () {
-  return {
-    name: this.name,
-    attrs: this.attrs,
-    children: this.children.map(function (child) {
-      return child && child.toJSON ? child.toJSON() : child
-    })
-  }
-}
-
 Element.prototype._addChildren = function (writer) {
   writer('>')
   for (var i = 0; i < this.children.length; i++) {
diff --git a/lib/parsers/sax-js.js b/lib/parsers/sax-js.js
index b2c4f0c..7ace9ca 100644
--- a/lib/parsers/sax-js.js
+++ b/lib/parsers/sax-js.js
@@ -24,7 +24,6 @@ var SaxSaxjs = module.exports = function SaxSaxjs () {
   this.parser.onerror = function (e) {
     that.emit('error', e)
   }
-// TODO: other events, esp. entityDecl (billion laughs!)
 }
 
 inherits(SaxSaxjs, EventEmitter)
diff --git a/test/element-test.js b/test/element-test.js
index b33db92..9ce87bc 100644
--- a/test/element-test.js
+++ b/test/element-test.js
@@ -82,16 +82,6 @@ vows.describe('Element').addBatch({
     'serialize with integer text': function () {
       var e = new Element('e').t(1000)
       assert.equal(e.getText(), 1000)
-    },
-    'serialize to json': function () {
-      var e = new Element('e', { foo: 23, bar: 0, nil: null }).c('f').t(1000).up()
-      assert.deepEqual(e.toJSON(), {
-        name: 'e',
-        attrs: { foo: 23, bar: 0, nil: null },
-        children: [
-          { name: 'f', attrs: {}, children: [1000] }
-        ]
-      })
     }
   },
   'remove': {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git



More information about the Pkg-javascript-commits mailing list