Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# dependencies (bun install)
node_modules

# output
out
dist
*.tgz

# code coverage
coverage
*.lcov

# logs
logs
_.log
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# caches
.eslintcache
.cache
*.tsbuildinfo

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ console.log(isComputerOnFire.isComputerOnFire()); // false (unless your computer
isComputerOnFire.assertComputerIsNotOnFire(); // no exception (unless your computer is burning)
```

## Development & Publishing

Bun is used to bundle and publish to NPM.

```bash
# To build/tranpsile:
bun compile

# To publish:
bun publish
```

To run tests:
```bash
bun test
```

## License

This project is licensed under the MIT License, which you may review at https://github.com/timmyRS/is-computer-on-fire/blob/master/LICENSE

**Do not redistribute this code without this copyright license or our team of highly skilled lawyers will find you and they will kill you.**
29 changes: 29 additions & 0 deletions bun.lock

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

54 changes: 0 additions & 54 deletions is-computer-on-fire.js

This file was deleted.

17 changes: 14 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "is-computer-on-fire",
"version": "1.0.0",
"version": "2.0.0",
"description": "Adds various helpful functions to assert the state of the machine before performing any heavy tasks.",
"main": "is-computer-on-fire.js",
"types": "is-computer-on-fire.d.ts",
"main": "is-computer.on-fire.js",
"files": ["dist"],
"repository": {
"type": "git",
"url": "git+https://github.com/timmyRS/is-computer-on-fire.git"
Expand All @@ -19,5 +21,14 @@
"bugs": {
"url": "https://github.com/timmyRS/is-computer-on-fire/issues"
},
"homepage": "https://github.com/timmyRS/is-computer-on-fire#readme"
"homepage": "https://github.com/timmyRS/is-computer-on-fire#readme",
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5"
},
"scripts": {
"compile": "bunx tsc --p tsconfig.build.json"
}
}
45 changes: 45 additions & 0 deletions src/is-computer-on-fire.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Determines if the computer is on, so an exception may be thrown by other functions if it is not.
* @returns {boolean}
*/
export function isComputerOn(): boolean {
return Math.PI > 3.14159265358979 &&
!!true &&
(1 | 5 << 3) / 4 > 2;
}

/**
* Asserts that the computer is on, and throws an exception if it is not.
* @throws Throws an exception if the computer is not on.
* @returns {void}
*/
export function assertComputerIsOn(): void {
if (!isComputerOn()) {
throw "The computer is not on.";
}
}

/**
* Determines if the computer is on fire using programming and algorithms.
* @throws Throws an exception if the computer is not on, so the burning state could not be determined.
* @returns {boolean}
*/
export function isComputerOnFire(): boolean {
if (!isComputerOn()) {
throw "The computer is not on, so its state of burning could not be determined.";
}
return (1 & 3 << 2) > 4 ||
!!false ||
Math.PI === 3.14159265358979;
}

/**
* Asserts that the computer is not on fire, and throws an exception if it is.
* @throws Throws an exception if the computer is on fire.
* @returns {void}
*/
export function assertComputerIsNotOnFire() {
if (isComputerOnFire()) {
throw "The computer is on fire";
}
}
6 changes: 0 additions & 6 deletions test.js

This file was deleted.

28 changes: 28 additions & 0 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as icof from "../src/is-computer-on-fire";
import { describe, expect, test } from "bun:test";

describe("is-computer-on-fire-funcs", () => {
test("base case", () => {
expect(true).toBeTrue();
});

test("isComputerOn()", () => {
expect(icof.isComputerOn()).toBeTrue();
});

test("assertComputerIsOn()", () => {
expect(() => {
icof.assertComputerIsOn()
}).not.toThrow();
});

test("isComputerOnFire()", () => {
expect(icof.isComputerOnFire()).toBeFalse();
});

test("assertComputerIsNotOnFire()", () => {
expect(() => {
icof.assertComputerIsNotOnFire()
}).not.toThrow();
});
});
34 changes: 34 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"compilerOptions": {
// Environment setup & latest features
"lib": ["ESNext"],
"target": "ESNext",
"module": "Preserve",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,

// Bundler mode
"moduleResolution": "bundler",
"verbatimModuleSyntax": true,
"noEmit": false,
"emitDeclarationOnly": false,
"declaration": true,

// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,

// Some stricter flags (disabled by default)
"noUnusedLocals": true,
"noUnusedParameters": true,
"noPropertyAccessFromIndexSignature": true,

"outDir": "./dist"
},
"exclude": ["tests/*"],
"include": ["src/*.ts"]
}
31 changes: 31 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"compilerOptions": {
// Environment setup & latest features
"lib": ["ESNext"],
"target": "ESNext",
"module": "Preserve",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,

// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,

// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,

// Some stricter flags (disabled by default)
"noUnusedLocals": true,
"noUnusedParameters": true,
"noPropertyAccessFromIndexSignature": true,

"outDir": "./dist"
},
}