library refactoring
This commit is contained in:
parent
084ebf3ee0
commit
47fd7856e2
11
bin/find.js
11
bin/find.js
@ -4,8 +4,7 @@
|
|||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
|
|
||||||
const vcd = require('../lib/index.js');
|
const lib = require('../lib/index.js');
|
||||||
const utils = require('../lib/utils');
|
|
||||||
|
|
||||||
const dir = './tmp/';
|
const dir = './tmp/';
|
||||||
|
|
||||||
@ -19,11 +18,11 @@ fs.readdir(dir).then(files => {
|
|||||||
|
|
||||||
const t0 = Date.now();
|
const t0 = Date.now();
|
||||||
|
|
||||||
let inst = vcd();
|
let inst = lib.parser();
|
||||||
|
|
||||||
const loads = utils.and();
|
const loads = lib.and();
|
||||||
const stores = utils.and();
|
const stores = lib.and();
|
||||||
const duration = utils.activity(10);
|
const duration = lib.activity(10);
|
||||||
|
|
||||||
inst.on('$enddefinitions', () => {
|
inst.on('$enddefinitions', () => {
|
||||||
// console.log(res);
|
// console.log(res);
|
||||||
|
18
lib/activity.js
Normal file
18
lib/activity.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = skip => {
|
||||||
|
let start = 0;
|
||||||
|
let stop = 0;
|
||||||
|
return {
|
||||||
|
on: time => {
|
||||||
|
if (time > skip) {
|
||||||
|
if (start == 0) {
|
||||||
|
start = time;
|
||||||
|
} else {
|
||||||
|
stop = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
time: () => stop - start
|
||||||
|
};
|
||||||
|
};
|
13
lib/index.js
Normal file
13
lib/index.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const pkg = require('../package.json');
|
||||||
|
const parser = require('./parser.js');
|
||||||
|
const and = require('./and.js');
|
||||||
|
const activity = require('./activity.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
version: pkg.version,
|
||||||
|
and: and,
|
||||||
|
activity: activity,
|
||||||
|
parser: parser
|
||||||
|
};
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
const EventEmitter = require('events').EventEmitter;
|
const EventEmitter = require('events').EventEmitter;
|
||||||
const pkg = require('../package.json');
|
|
||||||
let lib = require('bindings')('vcd.node');
|
let lib = require('bindings')('vcd.node');
|
||||||
|
|
||||||
module.exports = () => {
|
module.exports = () => {
|
||||||
@ -35,8 +34,6 @@ module.exports = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
s.version = pkg.version;
|
|
||||||
|
|
||||||
s.info = info;
|
s.info = info;
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const expect = require('chai').expect;
|
const expect = require('chai').expect;
|
||||||
const vcd = require('../lib/index.js');
|
const lib = require('../lib/index.js');
|
||||||
|
|
||||||
describe('basic', () => {
|
describe('basic', () => {
|
||||||
|
|
||||||
it('typeof vcd', done => {
|
it('typeof vcd', done => {
|
||||||
expect(vcd).to.be.an('function');
|
expect(lib.parser).to.be.an('function');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('typeof vcd instance', done => {
|
it('typeof vcd instance', done => {
|
||||||
expect(vcd()).to.be.an('object');
|
expect(lib.parser()).to.be.an('object');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fail: foo bar', done => {
|
it('fail: foo bar', done => {
|
||||||
const inst = vcd();
|
const inst = lib.parser();
|
||||||
expect(inst.write(Buffer.from(' foo bar ???'))).to.eq(true);
|
expect(inst.write(Buffer.from(' foo bar ???'))).to.eq(true);
|
||||||
expect(inst.info).to.deep.eq({
|
expect(inst.info).to.deep.eq({
|
||||||
path: [],
|
path: [],
|
||||||
@ -26,7 +26,7 @@ describe('basic', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('$comment', done => {
|
it('$comment', done => {
|
||||||
const inst = vcd();
|
const inst = lib.parser();
|
||||||
expect(inst.write(Buffer.from(
|
expect(inst.write(Buffer.from(
|
||||||
' \n $comment some text $end $comment more text $end ???'
|
' \n $comment some text $end $comment more text $end ???'
|
||||||
))).to.eq(true);
|
))).to.eq(true);
|
||||||
@ -38,7 +38,7 @@ describe('basic', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('$version', done => {
|
it('$version', done => {
|
||||||
const inst = vcd();
|
const inst = lib.parser();
|
||||||
expect(inst.write(`
|
expect(inst.write(`
|
||||||
$version Generated by VerilatedVcd $end
|
$version Generated by VerilatedVcd $end
|
||||||
$date Wed Sep 18 22:59:07 2019
|
$date Wed Sep 18 22:59:07 2019
|
||||||
|
Loading…
x
Reference in New Issue
Block a user