Skip to content

Commit

Permalink
Put boolean constants in their own file.
Browse files Browse the repository at this point in the history
  • Loading branch information
quacksouls committed Sep 14, 2022
1 parent 3fe84a2 commit 9993f21
Show file tree
Hide file tree
Showing 20 changed files with 242 additions and 58 deletions.
38 changes: 38 additions & 0 deletions 01/lib/constant.bool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (C) 2022 Duck McSouls
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

// Boolean values.

/**
* A boolean indicating that we want to enable a feature.
*/
export const ENABLE = true;

/**
* A boolean indicating that we want to disable a feature.
*/
export const DISABLE = !ENABLE;

/**
* A boolean indicating success or true.
*/
export const SUCCESS = true;

/**
* A boolean indicating failure or false; the opposite of success.
*/
export const FAILURE = !SUCCESS;
5 changes: 1 addition & 4 deletions 01/lib/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// A class and various utility functions related to network.

import { home } from "/lib/constant.js";
import { FAILURE, SUCCESS } from "/lib/constant.bool.js";
import { assert, filter_pserv } from "/lib/util.js";

/**
Expand Down Expand Up @@ -59,8 +60,6 @@ export class Graph {
* false otherwise or the edge is already in the graph.
*/
add_edge(u, v) {
const SUCCESS = true;
const FAILURE = !SUCCESS;
// Already have the edge.
if (this.has_edge(u, v)) {
return FAILURE;
Expand Down Expand Up @@ -95,8 +94,6 @@ export class Graph {
* false otherwise or the node already exists in the graph.
*/
add_node(v) {
const SUCCESS = true;
const FAILURE = !SUCCESS;
if (this.has_node(v)) {
return FAILURE;
}
Expand Down
38 changes: 38 additions & 0 deletions 05/lib/constant.bool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (C) 2022 Duck McSouls
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

// Boolean values.

/**
* A boolean indicating that we want to enable a feature.
*/
export const ENABLE = true;

/**
* A boolean indicating that we want to disable a feature.
*/
export const DISABLE = !ENABLE;

/**
* A boolean indicating success or true.
*/
export const SUCCESS = true;

/**
* A boolean indicating failure or false; the opposite of success.
*/
export const FAILURE = !SUCCESS;
5 changes: 1 addition & 4 deletions 05/lib/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// A class and various utility functions related to network.

import { home } from "/lib/constant.js";
import { FAILURE, SUCCESS } from "/lib/constant.bool.js";
import { assert, filter_pserv } from "/lib/util.js";

/**
Expand Down Expand Up @@ -59,8 +60,6 @@ export class Graph {
* false otherwise or the edge is already in the graph.
*/
add_edge(u, v) {
const SUCCESS = true;
const FAILURE = !SUCCESS;
// Already have the edge.
if (this.has_edge(u, v)) {
return FAILURE;
Expand Down Expand Up @@ -95,8 +94,6 @@ export class Graph {
* false otherwise or the node already exists in the graph.
*/
add_node(v) {
const SUCCESS = true;
const FAILURE = !SUCCESS;
if (this.has_node(v)) {
return FAILURE;
}
Expand Down
3 changes: 1 addition & 2 deletions 05/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import { home, script } from "/lib/constant.js";
import { FAILURE, SUCCESS } from "/lib/constant.bool.js";
import { assert } from "/lib/util.js";

/**
Expand Down Expand Up @@ -149,8 +150,6 @@ export class Server {
*/
async deploy(target) {
assert(target.length > 0);
const SUCCESS = true;
const FAILURE = !SUCCESS;
const targ = this.#ns.getServer(target);
// No root access on either servers.
if (!this.has_root_access()) {
Expand Down
38 changes: 38 additions & 0 deletions 06/lib/constant.bool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (C) 2022 Duck McSouls
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

// Boolean values.

/**
* A boolean indicating that we want to enable a feature.
*/
export const ENABLE = true;

/**
* A boolean indicating that we want to disable a feature.
*/
export const DISABLE = !ENABLE;

/**
* A boolean indicating success or true.
*/
export const SUCCESS = true;

/**
* A boolean indicating failure or false; the opposite of success.
*/
export const FAILURE = !SUCCESS;
5 changes: 1 addition & 4 deletions 06/lib/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// A class and various utility functions related to network.

import { home } from "/lib/constant.js";
import { FAILURE, SUCCESS } from "/lib/constant.bool.js";
import { assert, filter_pserv } from "/lib/util.js";

/**
Expand Down Expand Up @@ -59,8 +60,6 @@ export class Graph {
* false otherwise or the edge is already in the graph.
*/
add_edge(u, v) {
const SUCCESS = true;
const FAILURE = !SUCCESS;
// Already have the edge.
if (this.has_edge(u, v)) {
return FAILURE;
Expand Down Expand Up @@ -95,8 +94,6 @@ export class Graph {
* false otherwise or the node already exists in the graph.
*/
add_node(v) {
const SUCCESS = true;
const FAILURE = !SUCCESS;
if (this.has_node(v)) {
return FAILURE;
}
Expand Down
3 changes: 1 addition & 2 deletions 06/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import { home, script } from "/lib/constant.js";
import { FAILURE, SUCCESS } from "/lib/constant.bool.js";
import { assert } from "/lib/util.js";

/**
Expand Down Expand Up @@ -149,8 +150,6 @@ export class Server {
*/
async deploy(target) {
assert(target.length > 0);
const SUCCESS = true;
const FAILURE = !SUCCESS;
const targ = this.#ns.getServer(target);
// No root access on either servers.
if (!this.has_root_access()) {
Expand Down
38 changes: 38 additions & 0 deletions 07/lib/constant.bool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (C) 2022 Duck McSouls
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

// Boolean values.

/**
* A boolean indicating that we want to enable a feature.
*/
export const ENABLE = true;

/**
* A boolean indicating that we want to disable a feature.
*/
export const DISABLE = !ENABLE;

/**
* A boolean indicating success or true.
*/
export const SUCCESS = true;

/**
* A boolean indicating failure or false; the opposite of success.
*/
export const FAILURE = !SUCCESS;
5 changes: 1 addition & 4 deletions 07/lib/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// A class and various utility functions related to network.

import { home } from "/lib/constant.js";
import { FAILURE, SUCCESS } from "/lib/constant.bool.js";
import { assert, filter_pserv } from "/lib/util.js";

/**
Expand Down Expand Up @@ -59,8 +60,6 @@ export class Graph {
* false otherwise or the edge is already in the graph.
*/
add_edge(u, v) {
const SUCCESS = true;
const FAILURE = !SUCCESS;
// Already have the edge.
if (this.has_edge(u, v)) {
return FAILURE;
Expand Down Expand Up @@ -95,8 +94,6 @@ export class Graph {
* false otherwise or the node already exists in the graph.
*/
add_node(v) {
const SUCCESS = true;
const FAILURE = !SUCCESS;
if (this.has_node(v)) {
return FAILURE;
}
Expand Down
3 changes: 1 addition & 2 deletions 07/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import { home, script } from "/lib/constant.js";
import { FAILURE, SUCCESS } from "/lib/constant.bool.js";
import { assert } from "/lib/util.js";

/**
Expand Down Expand Up @@ -157,8 +158,6 @@ export class Server {
*/
async deploy(target) {
assert(target.length > 0);
const SUCCESS = true;
const FAILURE = !SUCCESS;
const targ = this.#ns.getServer(target);
// No root access on either servers.
if (!this.has_root_access()) {
Expand Down
38 changes: 38 additions & 0 deletions 08/lib/constant.bool.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (C) 2022 Duck McSouls
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

// Boolean values.

/**
* A boolean indicating that we want to enable a feature.
*/
export const ENABLE = true;

/**
* A boolean indicating that we want to disable a feature.
*/
export const DISABLE = !ENABLE;

/**
* A boolean indicating success or true.
*/
export const SUCCESS = true;

/**
* A boolean indicating failure or false; the opposite of success.
*/
export const FAILURE = !SUCCESS;
5 changes: 1 addition & 4 deletions 08/lib/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// A class and various utility functions related to network.

import { home } from "/lib/constant.js";
import { FAILURE, SUCCESS } from "/lib/constant.bool.js";
import { assert, filter_pserv } from "/lib/util.js";

/**
Expand Down Expand Up @@ -59,8 +60,6 @@ export class Graph {
* false otherwise or the edge is already in the graph.
*/
add_edge(u, v) {
const SUCCESS = true;
const FAILURE = !SUCCESS;
// Already have the edge.
if (this.has_edge(u, v)) {
return FAILURE;
Expand Down Expand Up @@ -95,8 +94,6 @@ export class Graph {
* false otherwise or the node already exists in the graph.
*/
add_node(v) {
const SUCCESS = true;
const FAILURE = !SUCCESS;
if (this.has_node(v)) {
return FAILURE;
}
Expand Down
3 changes: 1 addition & 2 deletions 08/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import { home, script } from "/lib/constant.js";
import { FAILURE, SUCCESS } from "/lib/constant.bool.js";
import { assert } from "/lib/util.js";

/**
Expand Down Expand Up @@ -157,8 +158,6 @@ export class Server {
*/
async deploy(target) {
assert(target.length > 0);
const SUCCESS = true;
const FAILURE = !SUCCESS;
const targ = this.#ns.getServer(target);
// No root access on either servers.
if (!this.has_root_access()) {
Expand Down
Loading

0 comments on commit 9993f21

Please sign in to comment.