Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 39 lines (32 sloc) 822 Bytes
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var repl = require('repl');
var r = repl.start('> ');
var c = r.context;
c._load = function () {
c.Segment = require('./');
var segment = new c.Segment();
segment.useDefault();
c.segment = segment;
c.s = function () {
return c.segment.doSegment.apply(c.segment, arguments);
};
c.ss = function () {
var list = c.s.apply(null, arguments);
return list.map(function (v) { return v.w; }).join('/');
};
};
c.reload = function () {
var t = Date.now();
var dir = path.resolve(__dirname) + path.sep;
for (var i in require.cache) {
if (i.indexOf(dir) === 0) {
delete require.cache[i];
// console.log('delete %s', i);
}
}
c._load();
console.log('OK. (spent %sms)', Date.now() - t);
}
c._load();