Skip to content

Commit

Permalink
1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
WarstekHUN committed Aug 2, 2023
1 parent 8ce883d commit 5eb8e6d
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Publish

on:
release:
types: [published]
push:
branches: [main, master]

jobs:
publish:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package",
"name": "typescript-npm-package-template",
"version": "1.0.1",
"name": "@warstekhun/typescript-npm-package-template",
"version": "1.0.2",
"description": "Typescript NPM package template that is ready for NPM and Github Packages publish.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand All @@ -22,7 +22,7 @@
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\"",
"format:fix": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"comver": "node tools/versionManager.js",
"prepublishOnly": "npm run build && npm run package"
"release": "npm run package"
},
"files": [
"dist"
Expand Down
66 changes: 33 additions & 33 deletions src/Num.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
export class Num {
value: number

constructor(n: number) {
this.value = n
}

val(): number {
return this.value
}

add(n2: Num): Num {
this.value += n2.val()
return this
}

toString(): string {
return this.val().toString()
}

static addAll(numArr: Array<Num>): Num {
return new Num(numArr.map((n) => n.val()).reduce((a, b) => a + b, 0))
}
value: number;

constructor(n: number) {
this.value = n;
}

/***
* Go to TypeScript's official website https://www.typescriptlang.org/docs/handbook/typescript-from-scratch.html to read more.
*
* The following text is copied from
* https://github.com/microsoft/TypeScript-New-Handbook/blob/master/intros/TypeScript%20for%20the%20New%20Programmer.md
* and is under the MIT License
*/

/*

val(): number {
return this.value;
}

add(n2: Num): Num {
this.value += n2.val();
return this;
}

toString(): string {
return this.val().toString();
}

static addAll(numArr: Array<Num>): Num {
return new Num(numArr.map((n) => n.val()).reduce((a, b) => a + b, 0));
}
}

/***
* Go to TypeScript's official website https://www.typescriptlang.org/docs/handbook/typescript-from-scratch.html to read more.
*
* The following text is copied from
* https://github.com/microsoft/TypeScript-New-Handbook/blob/master/intros/TypeScript%20for%20the%20New%20Programmer.md
* and is under the MIT License
*/

/*
* TypeScript for the New Programmer
* What is JavaScript?
Expand Down Expand Up @@ -174,4 +174,4 @@ export class Num {
The way you sort a list in TypeScript is the same way you sort a list in JavaScript.
If you find a resource that does use TypeScript, that's great too, but don't limit yourself to thinking you need TypeScript-specific answers for everyday questions about how to accomplish runtime tasks.
*/
*/
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { Num } from './Num'
import { Num } from "./Num";

export { Num }
export { Num };
20 changes: 10 additions & 10 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Num } from '../src/index'
import { Num } from "../src/index";

test('add', () => {
expect(new Num(5).add(new Num(6)).val()).toBe(11)
})
test("add", () => {
expect(new Num(5).add(new Num(6)).val()).toBe(11);
});

test('toString', () => {
expect(new Num(5).toString()).toBe('5')
})
test("toString", () => {
expect(new Num(5).toString()).toBe("5");
});

test('addAll', () => {
expect(Num.addAll([new Num(5), new Num(2), new Num(13)]).val()).toBe(20)
})
test("addAll", () => {
expect(Num.addAll([new Num(5), new Num(2), new Num(13)]).val()).toBe(20);
});

0 comments on commit 5eb8e6d

Please sign in to comment.