now ready for use

This commit is contained in:
Philipp Kunz 2016-05-21 20:33:13 +02:00
parent ef20c00999
commit 00d9ad0af1
6 changed files with 83 additions and 15 deletions

2
dist/index.d.ts vendored
View File

@ -1,2 +1,2 @@
export declare let start: (moduleStringArg: string) => void; export declare let start: (moduleNameArg: string, loaderLengthArg?: number) => void;
export declare let stop: () => void; export declare let stop: () => void;

43
dist/index.js vendored
View File

@ -6,13 +6,46 @@ var rl = readline.createInterface({
input: process.stdin, input: process.stdin,
output: process.stdout output: process.stdout
}); });
exports.start = function (moduleStringArg) { var moduleName;
rl.write('Delete me!'); var loaderLength;
setTimeout(function () { var frameCounter = 0;
var makeFrame = function () {
var resultString = "["
+ "/".green.repeat(frameCounter)
+ " ".repeat(loaderLength - frameCounter)
+ "]"
+ " starting "
+ moduleName.cyan;
if (frameCounter == loaderLength) {
frameCounter = 0;
}
else {
frameCounter++;
}
return resultString;
};
var abort = true;
var logEarly = function () {
rl.write(null, { ctrl: true, name: 'u' }); rl.write(null, { ctrl: true, name: 'u' });
}, 1000); rl.write(makeFrame());
setTimeout(function () {
if (!abort) {
logEarly();
}
}, 200);
};
// exports
exports.start = function (moduleNameArg, loaderLengthArg) {
if (loaderLengthArg === void 0) { loaderLengthArg = 10; }
abort = false;
moduleName = moduleNameArg;
loaderLength = loaderLengthArg;
logEarly();
}; };
exports.stop = function () { exports.stop = function () {
abort = true;
rl.write(null, { ctrl: true, name: 'u' });
rl.close();
}; };
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw2Q0FBNkM7QUFDN0MsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFDO0FBQy9CLElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQztBQUVuQyxJQUFNLEVBQUUsR0FBRyxRQUFRLEN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1ha2VGcmFtZSgpKTtcclxuICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKXtcclxuICAgICAgICBpZighYWJvcnQpe1xyXG4gICAgICAgICAgICBsb2dFYXJseSgpO1xyXG4gICAgICAgIH1cclxuICAgIH0sMjAwKTtcclxufTtcclxuXHJcblxyXG4vLyBleHBvcnRzXHJcbmV4cG9ydCBsZXQgc3RhcnQgPSBmdW5jdGlvbihtb2R1bGVOYW1lQXJnOnN0cmluZyxsb2FkZXJMZW5ndGhBcmc6bnVtYmVyID0gMTApe1xyXG4gICAgYWJvcnQgPSBmYWxzZTtcclxuICAgIG1vZHVsZU5hbWUgPSBtb2R1bGVOYW1lQXJnO1xyXG4gICAgbG9hZGVyTGVuZ3RoID0gbG9hZGVyTGVuZ3RoQXJnO1xyXG4gICAgbG9nRWFybHkoKTtcclxufTtcclxuXHJcbmV4cG9ydCBsZXQgc3RvcCA9IGZ1bmN0aW9uKCl7XHJcbiAgICBhYm9ydCA9IHRydWU7XHJcbiAgICBybC53cml0ZShudWxsLCB7Y3RybDogdHJ1ZSwgbmFtZTogJ3UnfSk7XHJcbiAgICBybC5jbG9zZSgpO1xyXG59O1xyXG5cclxuIl19

View File

@ -20,7 +20,7 @@
}, },
"homepage": "https://github.com/pushrocks/early#readme", "homepage": "https://github.com/pushrocks/early#readme",
"devDependencies": { "devDependencies": {
"npmts": "^5.1.8" "npmts": "^5.1.9"
}, },
"dependencies": { "dependencies": {
"colors": "^1.1.2" "colors": "^1.1.2"

View File

@ -4,7 +4,7 @@ var early = require("../dist/index.js");
describe("early", function () { describe("early", function () {
it(".start()", function (done) { it(".start()", function (done) {
this.timeout(10000); this.timeout(10000);
early.start("early test"); early.start("early");
setTimeout(done, 5000); setTimeout(done, 5000);
}); });
it(".stop()", function () { it(".stop()", function () {
@ -12,4 +12,4 @@ describe("early", function () {
}); });
}); });
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3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xyXG59KSJdfQ==

View File

@ -4,7 +4,7 @@ import early = require("../dist/index.js");
describe("early",function(){ describe("early",function(){
it(".start()",function(done){ it(".start()",function(done){
this.timeout(10000); this.timeout(10000);
early.start("early test"); early.start("early");
setTimeout(done,5000); setTimeout(done,5000);
}); });
it(".stop()",function(){ it(".stop()",function(){

View File

@ -7,14 +7,49 @@ const rl = readline.createInterface({
output: process.stdout output: process.stdout
}); });
export let start = function(moduleStringArg:string){ let moduleName:string;
rl.write('Delete me!'); let loaderLength:number;
setTimeout(function(){ let frameCounter:number = 0;
let makeFrame = ():string => {
let resultString:string = "["
+ "/".green.repeat(frameCounter)
+ " ".repeat(loaderLength - frameCounter)
+ "]"
+ " starting "
+ moduleName.cyan;
if(frameCounter == loaderLength){
frameCounter = 0;
} else {
frameCounter++;
}
return resultString;
};
let abort:boolean = true;
let logEarly = () => {
rl.write(null, {ctrl: true, name: 'u'}); rl.write(null, {ctrl: true, name: 'u'});
},1000); rl.write(makeFrame());
setTimeout(function(){
if(!abort){
logEarly();
}
},200);
};
// exports
export let start = function(moduleNameArg:string,loaderLengthArg:number = 10){
abort = false;
moduleName = moduleNameArg;
loaderLength = loaderLengthArg;
logEarly();
}; };
export let stop = function(){ export let stop = function(){
abort = true;
rl.write(null, {ctrl: true, name: 'u'});
rl.close();
}; };