forked from osdio/react-native-html-render
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
50 lines (42 loc) · 1017 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var htmlparser = require('./lib/htmlparser2')
var fs = require('fs')
var htmlParse = require('./lib/htmlParse')
var data = fs.readFileSync('./example/test.html', {
encoding: 'utf-8'
})
console.log(data);
var opts = {
recognizeSelfClosing: true,
lowerCaseAttributeNames: true,
lowerCaseTags: true,
decodeEntities: true
}
//var parser = new htmlparser.Parser({
// onopentag: function (name) {
// console.log('openTag:');
// console.log(name);
// },
//
// ontext: function (text) {
// console.log('text:');
// console.log(text);
// },
//
// onclosetag: function (name) {
// console.log('closeTag:');
// console.log(name);
// },
//
// onend: function () {
// console.log('end');
// }
//}, opts)
//
//parser.write(data)
//parser.end()
var startTime = new Date().getTime()
htmlParse(data, function (data) {
var endTime = new Date().getTime()
var usedTime = endTime - startTime
console.log(usedTime + 'ms');
})