-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
105 changed files
with
9,328 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
test.js | ||
package-lock.json | ||
node_modules/ | ||
lib/ | ||
documentation/ | ||
tsconfig.doc.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Cronometro | ||
Un cronometro que cuenta y descuenta | ||
|
||
## Instalación | ||
|
||
``` | ||
npm install proyecto-2c-crono | ||
``` | ||
|
||
## Uso | ||
|
||
### Contador | ||
``` | ||
const modulo = require('proyecto-2c-crono'); | ||
const cont = new modulo.Contador(2); | ||
var d = cont.start().subscribe( | ||
data => { | ||
console.log(data); | ||
if (data === 'FINISH') { | ||
d.unsubscribe(); | ||
} | ||
} | ||
); | ||
//Espera estos resultados | ||
00:00:00 | ||
00:00:01 | ||
FINISH | ||
``` | ||
|
||
### Descontador | ||
``` | ||
const modulo = require('proyecto-2c-crono'); | ||
const cont = new modulo.Descontador(4); | ||
var d = cont.start().subscribe( | ||
data => { | ||
console.log(data); | ||
if (data === 'FINISH') { | ||
d.unsubscribe(); | ||
} | ||
} | ||
);//Espera estos resultados | ||
00:00:04 | ||
00:00:03 | ||
00:00:02 | ||
00:00:01 | ||
FINISH | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Constantes de tiempo | ||
*/ | ||
export declare enum Tiempo { | ||
SG_MIN = 60, | ||
SG_HORA = 3600, | ||
HORAS_DIA = 24, | ||
SG_DIA = 86400 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Constantes de tiempo | ||
*/ | ||
var Tiempo; | ||
(function (Tiempo) { | ||
Tiempo[Tiempo["SG_MIN"] = 60] = "SG_MIN"; | ||
Tiempo[Tiempo["SG_HORA"] = 3600] = "SG_HORA"; | ||
Tiempo[Tiempo["HORAS_DIA"] = 24] = "HORAS_DIA"; | ||
Tiempo[Tiempo["SG_DIA"] = 86400] = "SG_DIA"; | ||
})(Tiempo = exports.Tiempo || (exports.Tiempo = {})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Cuenta de manera ascendente de 1 en 1 | ||
*/ | ||
export declare class Contador { | ||
/** | ||
* @ignore | ||
*/ | ||
valorLImite: number; | ||
/** | ||
* @ignore | ||
*/ | ||
constructor(limite?: number); | ||
/** | ||
* CUenta de 0 hasta el límite establecido | ||
*/ | ||
start(): import("../../../../../../../../Volumes/DATA/Udemy/Proyects/NPM-Projects-Course/nodets/proyecto-2c-crono/node_modules/rxjs/internal/Observable").Observable<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const interval_1 = require("rxjs/internal/observable/interval"); | ||
const map_1 = require("rxjs/internal/operators/map"); | ||
const conversion_1 = require("./conversion"); | ||
/** | ||
* Cuenta de manera ascendente de 1 en 1 | ||
*/ | ||
class Contador { | ||
/** | ||
* @ignore | ||
*/ | ||
constructor(limite = 5) { | ||
/** | ||
* @ignore | ||
*/ | ||
this.valorLImite = -1; | ||
this.valorLImite = limite; | ||
} | ||
/** | ||
* CUenta de 0 hasta el límite establecido | ||
*/ | ||
start() { | ||
return interval_1.interval(1000).pipe(map_1.map((sg) => { | ||
return conversion_1.convertirSgAFormatoReloj(sg, 1, this.valorLImite); | ||
})); | ||
} | ||
} | ||
exports.Contador = Contador; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Convierte los segundos en HH:MM:SS | ||
* @param sg Segundos del momento | ||
* @param tipo 1: COntador / 2: Descontador | ||
* @param limite Valor limite hasta el momento que funcionará | ||
*/ | ||
export declare function convertirSgAFormatoReloj(sg: number, tipo: number, limite: number): string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const constants_1 = require("./constants"); | ||
/** | ||
* Convierte los segundos en HH:MM:SS | ||
* @param sg Segundos del momento | ||
* @param tipo 1: COntador / 2: Descontador | ||
* @param limite Valor limite hasta el momento que funcionará | ||
*/ | ||
function convertirSgAFormatoReloj(sg, tipo, limite) { | ||
if (tipo === 1 && limite === sg || tipo === 2 && sg === 0) { | ||
return 'FINISH'; | ||
} | ||
// COnseguir el tiempo formateado para devolverlo | ||
// Horas | ||
const horas = Math.floor((sg % constants_1.Tiempo.SG_DIA) / constants_1.Tiempo.SG_HORA); | ||
// Minutos | ||
const minutos = Math.floor((sg % constants_1.Tiempo.SG_HORA) / constants_1.Tiempo.SG_MIN); | ||
// segundos | ||
const sgs = Math.floor((sg % constants_1.Tiempo.SG_MIN)); | ||
return adaptarAlReloj(horas, minutos, sgs); | ||
} | ||
exports.convertirSgAFormatoReloj = convertirSgAFormatoReloj; | ||
/** | ||
* @ignore | ||
*/ | ||
function adaptarAlReloj(horas, minutos, sg) { | ||
const h = darNumeroFormatoCorrecto(horas); | ||
const m = darNumeroFormatoCorrecto(minutos); | ||
const s = darNumeroFormatoCorrecto(sg); | ||
return `${h}:${m}:${s}`; | ||
} | ||
/** | ||
* @ignore | ||
*/ | ||
function darNumeroFormatoCorrecto(n) { | ||
return (n < 10) ? '0'.concat(String(n)) : String(n); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Descuenta de uno en uno desde el valor establecido hasta 0 | ||
*/ | ||
export declare class Descontador { | ||
/** | ||
* @ignore | ||
*/ | ||
valorInicial: number; | ||
/** | ||
* @ignore | ||
*/ | ||
constructor(valor?: number); | ||
/** | ||
* Va descontando del valor inicial introducido hasta 0 | ||
*/ | ||
start(): import("../../../../../../../../Volumes/DATA/Udemy/Proyects/NPM-Projects-Course/nodets/proyecto-2c-crono/node_modules/rxjs/internal/Observable").Observable<string>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const interval_1 = require("rxjs/internal/observable/interval"); | ||
const map_1 = require("rxjs/internal/operators/map"); | ||
const conversion_1 = require("./conversion"); | ||
/** | ||
* Descuenta de uno en uno desde el valor establecido hasta 0 | ||
*/ | ||
class Descontador { | ||
/** | ||
* @ignore | ||
*/ | ||
constructor(valor = 5) { | ||
/** | ||
* @ignore | ||
*/ | ||
this.valorInicial = -1; | ||
this.valorInicial = valor; | ||
} | ||
/** | ||
* Va descontando del valor inicial introducido hasta 0 | ||
*/ | ||
start() { | ||
return interval_1.interval(1000).pipe(map_1.map((sg) => { | ||
return conversion_1.convertirSgAFormatoReloj(this.valorInicial - sg, 2, this.valorInicial); | ||
})); | ||
} | ||
} | ||
exports.Descontador = Descontador; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './constants'; | ||
export * from './conversion'; | ||
export * from './contador'; | ||
export * from './descontador'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./constants")); | ||
__export(require("./conversion")); | ||
__export(require("./contador")); | ||
__export(require("./descontador")); |
Oops, something went wrong.