Skip to content

Commit

Permalink
yo
Browse files Browse the repository at this point in the history
  • Loading branch information
tj-commits committed Nov 16, 2024
1 parent 364ff22 commit 1bcb88e
Show file tree
Hide file tree
Showing 7 changed files with 2,912 additions and 2,676 deletions.
74 changes: 49 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,29 @@ PNPM: `pnpm add falsejs`
Import it with require:

```javascript
const f = require("falsejs")
const falsejs = require("falsejs").default
```

Import it with import:

```javascript
import f from "falsejs"
import falsejs from "falsejs"
```

## Usage

`f.False` is a function that calculates the boolean value false and returns it. It takes three arguments.
`falsejs.False` is a function that calculates the boolean value false and returns it. It takes three arguments.

```
f.False(loggingEnabled?: "yes" | "no", shouldDoSomethingAsync?: "yes" | "no", shouldDoSomethingAsyncWithIsTenThousand?: "yes" | "no", disableAprilFoolsSideEffects?: "yes" | "no", definitelyDisableAprilFoolsSideEffects?: "yes" | "no", strictDisableAprilFoolsSideEffectsCheck?: "yes" | "no"): boolean | undefined;
function False(
loggingEnabled?: "yes" | "no",
shouldDoSomethingAsync?: "yes" | "no",
shouldDoSomethingAsyncWithIsTenThousand?: "yes" | "no",
disableAprilFoolsSideEffects?: "yes" | "no",
definitelyDisableAprilFoolsSideEffects?: "yes" | "no",
strictDisableAprilFoolsSideEffectsCheck?: "yes" | "no",
openRandomImageOfDofleWhenDone?: "yes" | "no"
): boolean
```

The first argument is `loggingEnabled`, which is whether to output useful and funny logs or not. This can be `"yes"` or `"no"`. Some logs may still be output even when you pass in `"no"`, because FalseJS uses other libraries that may log things without user consent. `"yes"` and `"no"` are basically `true` and `false`, except the whole reason you're calling the function is to get a boolean, so it wouldn't make sense to pass in a boolean.
Expand All @@ -51,31 +59,32 @@ The sixth argument, `openRandomImageOfDofleWhenDone`, can be `"yes"` or `"no"`.
## Example

```javascript
const f = require("falsejs")
const False = f.False("yes", "no", "no", "yes", "yes", "no", "no") // outputs a bunch of logs
const falsejs = require("falsejs").default
const falseValue = falsejs.False("yes", "no", "no", "yes", "yes", "no", "no") // outputs a bunch of logs

console.log(False) // outputs false
console.log(falseValue) // outputs false
```

## `isFalse` function

FalseJS also exports a function called `isFalse`, which returns true if the value is false, otherwise false. This can be used to test whether FalseJS worked and returned false (like it wouldn't, so there's no need to do that). `f.isFalse` just takes in a value and returns true if the value is false.
FalseJS also exports a function called `isFalse`, which returns true if the value is false, otherwise false. This can be used to test whether FalseJS worked and returned false (like it wouldn't, so there's no need to do that). `falsejs.isFalse` just takes in a value and returns true if the value is false.

It takes in too parameters, the value to check whether it is false, and `loggingEnabled` which can be `"yes"` or `"no"`.

Example:

```javascript
const f = require("falsejs")
const False = f.False("no", "no", "no")
const falsejs = require("falsejs").default
const falseValue = falsejs.False("no", "no", "no")
const trueValue = require("true-value")

console.log(f.isFalse(False)) // true
console.log(f.isFalse(false)) // probably true
console.log(f.isFalse(true)) // probably false
console.log(f.isFalse("hi")) // false
console.log(falsejs.isFalse(falseValue)) // true
console.log(falsejs.isFalse(false)) // probably true
console.log(falsejs.isFalse(trueValue)) // false
console.log(falsejs.isFalse("hi")) // false
```

`isFalse` can also be used as an alternative to running the `f.False` function and instead just passing a value that isn't false into the `f.isFalse` (actually there's no point doing that because `f.False` can output useful logs if you want it to and is safer and better while `f.isFalse` is definitely not just made to be used as a tool to get the value of false).
`falsejs.isFalse` can also be used as an alternative to running the `falsejs.False` function and instead just passing a value that isn't false into `falsejs.isFalse`.

## CLI

Expand Down Expand Up @@ -110,9 +119,9 @@ false
A jQuery plugin is also provided for FalseJS. Here is an example:

```javascript
const f = require("falsejs")
const falsejs = require("falsejs").default
global.jQuery = require("jquery")
f.injectIntojQuery()
falsejs.injectIntojQuery()

const $ = jQuery

Expand All @@ -127,16 +136,16 @@ Express middleware is also exported. Here is an example:

```javascript
const express = require("express")
const f = require("falsejs")
const falsejs = require("falsejs").default
const Bro = require("brototype")

const app = express()
const PORT = Bro(process).doYouEven("env.PORT") ? process.env.PORT : 3000

app.use(f.expressMiddleware)
app.use(falsejs.expressMiddleware)

app.get("/", (req, res) => {
res.send(req.isFalse(req.False())) // sends true to the client (except on april fools (because false is false (except on april fools (because the defualt parameters were set (which enables april fools side effects (so many parentheses (can we stop the parentheses (no? (dang it (im bored (this actually looks cool (im closing the parentheses now anyway (NO DONT KILL ME (whispers to self: ill have to figure out how to close the parentheses (*closes parentheses by surprise*))))))))))))))) haha! i got out!
res.send(req.isFalse(req.False())) // sends true to the client haha! i got out!
})

app.listen(PORT)
Expand All @@ -145,12 +154,14 @@ app.listen(PORT)
## April Fools Behavior

### **Not April Fools Day**

- **FalseJS will return** `false` by default.
- The flags `disableAprilFoolsSideEffects` and `definitelyDisableAprilFoolsSideEffects` **do not affect the behavior** of FalseJS. It behaves normally as it would on any non-April Fools' Day.
- However, if `strictDisableAprilFoolsSideEffectsCheck` is **not `no"`** and instead `"yes"` (by default it's `"yes"`), it will throw an error if these options are set to `"yes"`, because it's not April Fools' Day, and there are no side effects to disable.
- If `strictDisableAprilFoolsSideEffectsCheck` is set to **"no"**, FalseJS behaves normally without throwing an error, even if the side effect parameters are set to `"yes"`.

### **April Fools Day**

- **On April Fools' Day**, FalseJS **always returns `true`**, regardless of the state of the flags.
- **To prevent this behavior**, you must set both `disableAprilFoolsSideEffects` to `"yes"` and `definitelyDisableAprilFoolsSideEffects` to `"yes"` when you call FalsejS.
- If these flags are set to `"yes"`, FalseJS will return its expected behavior (return `false`), even on April Fools' Day.
Expand All @@ -160,18 +171,31 @@ app.listen(PORT)
This usage ensures that you will always get `false` whether it's April Fools or not and no errors.

```js
const f = require('falsejs')
const isAprilFools = require('is-april-fools')
const falsejs = require("falsejs").default
const isAprilFools = require("is-april-fools")
const disableAprilFoolsSideEffects = isAprilFools() ? "yes" : "no"

const falseValue = f.False("no", "no", "no"/*the first three options you can choose, for examples we set them all to "no"*/, disableAprilFoolsSideEffects, disableAprilFoolsSideEffects, "yes")
const falseValue = falsejs.False(
"no",
"no",
"no" /*the first three options you can choose, for examples we set them all to "no"*/,
disableAprilFoolsSideEffects,
disableAprilFoolsSideEffects,
"yes"
)

// or you can do this, but the above is better

const falseValue = f.False("no", "no", "no"/*the first three options you can choose, for examples we set them all to "no"*/, "yes", "yes", "no")
const falseValue = falsejs.False(
"no",
"no",
"no" /*the first three options you can choose, for examples we set them all to "no"*/,
"yes",
"yes",
"no"
)
```


## Related Projects

- [true-value](https://github.com/tj-commits/true-value) (the sister project)
Expand Down
4 changes: 2 additions & 2 deletions cli/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
#!/usr/bin/env node

const f = require("../index")
const f = require("../index").default

console.log(f.False("no", "no", "no", "yes", "yes", "no", "no")) // false
55 changes: 32 additions & 23 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
/**
* Returns false from the given parameters.
*
* @param {"yes"|"no"} loggingEnabled - Indicates whether logging should be enabled.
* @param {"yes"|"no"} shouldDoSomethingAsync - A pointless option that indicates whether something should be done asynchronously that just waits 200ms before saying "Did something async"
* @param {"yes"|"no"} shouldDoSomethingAsyncWithIsTenThousand - Indicates whether something should be done asynchronously when checking the self equality of 10,000 using the isTenThousand module (credits to james-work-account)
* @param {"yes"|"no"} disableAprilFoolsSideEffects - Indicates whether April Fools side effects should be disabled.
* @param {"yes"|"no"} definitelyDisableAprilFoolsSideEffects - Indicates whether April Fools side effects should be definitely disabled.
* @param {"yes"|"no"} strictDisableAprilFoolsSideEffectsCheck - Indicates whether strict checking for disabling April Fools side effects should be enabled.
* @param {"yes"|"no"} openRandomImageOfDofleWhenDone - Indicates whether a random image of Dofle the cat should be opened when done.
* @returns {boolean} - The calculated boolean value 'false'.
*/
export default class falsejs {
/**
* Returns false from the given parameters.
*
* @param {"yes"|"no"} loggingEnabled - Indicates whether logging should be enabled.
* @param {"yes"|"no"} shouldDoSomethingAsync - A pointless option that indicates whether something should be done asynchronously that just waits 200ms before saying "Did something async"
* @param {"yes"|"no"} shouldDoSomethingAsyncWithIsTenThousand - Indicates whether something should be done asynchronously when checking the self equality of 10,000 using the isTenThousand module (credits to james-work-account)
* @param {"yes"|"no"} disableAprilFoolsSideEffects - Indicates whether April Fools side effects should be disabled.
* @param {"yes"|"no"} definitelyDisableAprilFoolsSideEffects - Indicates whether April Fools side effects should be definitely disabled.
* @param {"yes"|"no"} strictDisableAprilFoolsSideEffectsCheck - Indicates whether strict checking for disabling April Fools side effects should be enabled.
* @param {"yes"|"no"} openRandomImageOfDofleWhenDone - Indicates whether a random image of Dofle the cat should be opened when done.
* @returns {boolean} - The calculated boolean value 'false'.
*/
static False(
loggingEnabled?: "yes" | "no",
shouldDoSomethingAsync?: "yes" | "no",
shouldDoSomethingAsyncWithIsTenThousand?: "yes" | "no",
disableAprilFoolsSideEffects?: "yes" | "no",
definitelyDisableAprilFoolsSideEffects?: "yes" | "no",
strictDisableAprilFoolsSideEffectsCheck?: "yes" | "no",
openRandomImageOfDofleWhenDone?: "yes" | "no"
): boolean

export function False(loggingEnabled?: "yes" | "no", shouldDoSomethingAsync?: "yes" | "no", shouldDoSomethingAsyncWithIsTenThousand?: "yes" | "no", disableAprilFoolsSideEffects?: "yes" | "no", definitelyDisableAprilFoolsSideEffects?: "yes" | "no", strictDisableAprilFoolsSideEffectsCheck?: "yes" | "no", openRandomImageOfDofleWhenDone?: "yes" | "no"): boolean;
/**
* Checks if a given value is false.
*
* @param {any} value - The value to be checked.
* @returns {boolean} - True if the value is false, false otherwise.
*/

/**
* Checks if a given value is false.
*
* @param {any} value - The value to be checked.
* @returns {boolean} - True if the value is false, false otherwise.
*/
static isFalse(value: any, loggingEnabled?: "yes" | "no"): boolean

export function isFalse(value: any, loggingEnabled?: "yes" | "no"): boolean;

export function injectIntojQuery(): void;
export function expressMiddleware(req: any, res: any, next: any): void;
static injectIntojQuery(): void
static expressMiddleware(req: any, res: any, next: any): void
}
Loading

0 comments on commit 1bcb88e

Please sign in to comment.