Skip to content

Commit 52c71b1

Browse files
committed
Primera version estable
1 parent 15d0d22 commit 52c71b1

File tree

8 files changed

+239
-0
lines changed

8 files changed

+239
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package-lock.json
2+
node_modules/

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package-lock.json
2+
node_modules/
3+
lib/

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Operaciones matemáticas Plus
2+
3+
## Instrucciones de instalación:
4+
5+
```
6+
npm install proyecto-2b-nodejs-ts
7+
```
8+
9+
## Instrucciones de uso
10+
11+
### Importar el módulo
12+
```
13+
En NodeJS
14+
var op = require('proyecto-2b-nodejs-ts');
15+
En Typescript
16+
import * as matematica from 'proyecto-2b-nodejs-ts';
17+
```
18+
### Sumas
19+
20+
```
21+
console.log(op.operacion('+', 1,1));
22+
// 2
23+
```
24+
25+
### Restas
26+
27+
```
28+
console.log(op.operacion('-', 1,1));
29+
// 0
30+
```
31+
32+
### Multiplicacion
33+
34+
```
35+
console.log(op.operacion('*', 1,1));
36+
// 1
37+
```
38+
39+
### Division
40+
41+
```
42+
console.log(op.operacion('/', 1,2));
43+
// 0.5
44+
```
45+
46+
### Es par
47+
48+
```
49+
console.log(op.esPar(2));
50+
// true
51+
52+
console.log(op.esPar(251));
53+
// false
54+
```

dist/index.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Comprobar numeros pares o no
3+
* @param numero Numero que vamos a comprobar si es par
4+
*/
5+
export declare function esPar(numero: number): boolean;
6+
/**
7+
* Haciendo uso de la libreria vieja adaptada a TS
8+
* @param tipo Tipo de operacion que puede ser suma, resta, multiplicacion o division
9+
* @param n1 Primer numero
10+
* @param n2 Segundo numero
11+
*/
12+
export declare function operacion(tipo: string, n1: number, n2: number): any;

dist/index.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
/**
4+
* Comprobar numeros pares o no
5+
* @param numero Numero que vamos a comprobar si es par
6+
*/
7+
function esPar(numero) {
8+
if (numero % 2 === 0) {
9+
return true;
10+
}
11+
return false;
12+
}
13+
exports.esPar = esPar;
14+
/**
15+
* Haciendo uso de la libreria vieja adaptada a TS
16+
* @param tipo Tipo de operacion que puede ser suma, resta, multiplicacion o division
17+
* @param n1 Primer numero
18+
* @param n2 Segundo numero
19+
*/
20+
function operacion(tipo, n1, n2) {
21+
var matematica = require('proyecto-1-matematicas');
22+
switch (tipo) {
23+
case '+': {
24+
return matematica.suma(n1, n2);
25+
}
26+
case '-': {
27+
return matematica.resta(n1, n2);
28+
}
29+
case '*': {
30+
return matematica.multiplicacion(n1, n2);
31+
}
32+
case '/': {
33+
return matematica.division(n1, n2);
34+
}
35+
default: {
36+
console.warn('Tipo incorrecto');
37+
return;
38+
}
39+
}
40+
}
41+
exports.operacion = operacion;

lib/index.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
3+
/**
4+
* Comprobar numeros pares o no
5+
* @param numero Numero que vamos a comprobar si es par
6+
*/
7+
export function esPar(numero: number) : boolean {
8+
if ( numero % 2 === 0) {
9+
return true;
10+
}
11+
return false;
12+
}
13+
14+
/**
15+
* Haciendo uso de la libreria vieja adaptada a TS
16+
* @param tipo Tipo de operacion que puede ser suma, resta, multiplicacion o division
17+
* @param n1 Primer numero
18+
* @param n2 Segundo numero
19+
*/
20+
export function operacion(tipo: string, n1: number, n2: number) {
21+
const matematica = require('proyecto-1-matematicas');
22+
switch(tipo) {
23+
case '+': {
24+
return matematica.suma(n1, n2);
25+
}
26+
case '-': {
27+
return matematica.resta(n1, n2);
28+
}
29+
case '*': {
30+
return matematica.multiplicacion(n1, n2);
31+
}
32+
case '/': {
33+
return matematica.division(n1, n2);
34+
}
35+
default: {
36+
console.warn('Tipo incorrecto');
37+
return;
38+
}
39+
}
40+
}

package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "proyecto-2b-nodejs-ts",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "./dist/index.js",
6+
"types": "./dist/index.d.ts",
7+
"scripts": {
8+
"test": "echo \"Error: no test specified\" && exit 1",
9+
"watch": "tsc -w"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/npm-js-ts-angular-modules-course/proyecto-2b-nodejs-ts.git"
14+
},
15+
"keywords": [],
16+
"author": "Anartz Mugika Ledo <mugan86@gmail.com>",
17+
"license": "MIT",
18+
"bugs": {
19+
"url": "https://github.com/npm-js-ts-angular-modules-course/proyecto-2b-nodejs-ts/issues"
20+
},
21+
"homepage": "https://github.com/npm-js-ts-angular-modules-course/proyecto-2b-nodejs-ts#readme",
22+
"dependencies": {
23+
"@types/node": "^11.9.0",
24+
"proyecto-1-matematicas": "github:npm-js-ts-angular-modules-course/proyecto-1-matematicas"
25+
}
26+
}

tsconfig.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"compilerOptions": {
3+
/* Basic Options */
4+
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
5+
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
6+
// "lib": [], /* Specify library files to be included in the compilation. */
7+
// "allowJs": true, /* Allow javascript files to be compiled. */
8+
// "checkJs": true, /* Report errors in .js files. */
9+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
10+
"declaration": true, /* Generates corresponding '.d.ts' file. */
11+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
12+
// "sourceMap": true, /* Generates corresponding '.map' file. */
13+
// "outFile": "./", /* Concatenate and emit output to single file. */
14+
"outDir": "./dist", /* Redirect output structure to the directory. */
15+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
16+
// "composite": true, /* Enable project compilation */
17+
// "removeComments": true, /* Do not emit comments to output. */
18+
// "noEmit": true, /* Do not emit outputs. */
19+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
20+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
21+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
22+
23+
/* Strict Type-Checking Options */
24+
"strict": true, /* Enable all strict type-checking options. */
25+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
26+
// "strictNullChecks": true, /* Enable strict null checks. */
27+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
28+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
29+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
30+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
31+
32+
/* Additional Checks */
33+
// "noUnusedLocals": true, /* Report errors on unused locals. */
34+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
35+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
36+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
37+
38+
/* Module Resolution Options */
39+
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
40+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
41+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
42+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
43+
// "typeRoots": [], /* List of folders to include type definitions from. */
44+
// "types": [], /* Type declaration files to be included in compilation. */
45+
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
46+
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
47+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
48+
49+
/* Source Map Options */
50+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
51+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
52+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
53+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
54+
55+
/* Experimental Options */
56+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
57+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
58+
},
59+
"include": ["lib"],
60+
"exclude": ["node_modules"]
61+
}

0 commit comments

Comments
 (0)