@falsejs/falsejs 1.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -12
- package/biome.json +9 -5
- package/dist/index.d.ts +46 -0
- package/dist/index.js +1725 -0
- package/dist/index.js.map +1 -0
- package/package.json +24 -5
- package/packages-to-remove.txt +1 -0
- package/tsconfig.json +45 -0
- package/index.d.ts +0 -34
- package/index.js +0 -3104
package/README.md
CHANGED
|
@@ -55,15 +55,33 @@ The third argument, `shouldDoSomethingAsyncWithIsTenThousand`, is whether `is-te
|
|
|
55
55
|
|
|
56
56
|
The fourth and fifth arguments, `disableAprilFoolsSideEffects` and `definitelyDisableAprilFoolsSideEffects`, can be `"yes"` or `"no"`. Both of them have to be `"yes"` to bypass the side effects of it being April Fools? What side effects, you may ask? Well, let's just say, FalseJS does something different on April Fools. If these are enabled when it's not April Fools, then an error will be thrown, unless the sixth argument, `strictDisableAprilFoolsSideEffectsCheck`, is `"no"`.
|
|
57
57
|
|
|
58
|
+
And the last argument is the compatibility mode argument. This one has its own section about how it works which is after the example.
|
|
59
|
+
|
|
58
60
|
## Example
|
|
59
61
|
|
|
60
62
|
```javascript
|
|
61
63
|
const falsejs = require("@falsejs/falsejs").default
|
|
62
|
-
const falseValue = falsejs.False("yes", "
|
|
64
|
+
const falseValue = falsejs.False("yes", "yes", "yes", "yes", "yes", "no", falsejs.COMPATIBILITY_MODE.NONE) // outputs a bunch of logs
|
|
63
65
|
|
|
64
66
|
console.log(falseValue) // outputs false
|
|
65
67
|
```
|
|
66
68
|
|
|
69
|
+
## Legacy Compatibility Modes
|
|
70
|
+
To ensure the integrity of the returned boolean across every known runtime environment since the dawn of the internet, the `falsejs.False` function supports an optional `compatibilityMode` argument. The checks performed may seem CPU-intensive and unnecessary, but they guarantee that the runtime environment is free of historical browser quirks that could threaten the stable return value of false.
|
|
71
|
+
|
|
72
|
+
Here's an example:
|
|
73
|
+
```javascript
|
|
74
|
+
const myIE5CompatibleFalseValue = falsejs.False("yes", "yes", "yes", "yes", "yes", "no", falsejs.COMPATIBILITY_MODE.IE5) // Using IE5 compatibility mode
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
| Mode | Description | Possible Side Effects |
|
|
78
|
+
|----------|----------|----------|
|
|
79
|
+
| `falsejs.COMPATIBILITY_MODE.NONE` | Standard modern behavior | No side effects and extra checks for legacy compatibility. |
|
|
80
|
+
| `falsejs.COMPATIBILITY_MODE.IE5` | Activates JScript Engine Coercion Guard. Runs checks to ensure `false` is not improperly converted by an emulated 1999 environment. | May increase CPU usage to simulate JScript garbage collection. |
|
|
81
|
+
| `falsejs.COMPATIBILITY_MODE.NETSCAPE` | Activates the JavaScript 1.1 Type Coercion Audit. Runs extensive type-coercion validation and audits the DOM for the deprecated Netscape `<layer>` tag. | May cause computer overload due to repetitive type-coercion audits, and it may cause memory leaks due to not cleaning up JSDOM. |
|
|
82
|
+
| `falsejs.COMPATIBILITY_MODE.OPERA_PRESTO` | Simulates the single-threaded nature of the Presto engine and audits the global state for known Opera non-standard features. | May cause memory leaks, and block CPU during a ~0ms latency. |
|
|
83
|
+
|
|
84
|
+
|
|
67
85
|
## `isFalse` function
|
|
68
86
|
|
|
69
87
|
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.
|
|
@@ -74,7 +92,7 @@ Example:
|
|
|
74
92
|
|
|
75
93
|
```javascript
|
|
76
94
|
const falsejs = require("@falsejs/falsejs").default
|
|
77
|
-
const falseValue = falsejs.False("
|
|
95
|
+
const falseValue = falsejs.False("yes", "yes", "yes", "yes", "yes", "no", falsejs.COMPATIBILITY_MODE.NONE)
|
|
78
96
|
const trueValue = require("true-value")
|
|
79
97
|
|
|
80
98
|
console.log(falsejs.isFalse(falseValue)) // true
|
|
@@ -124,7 +142,7 @@ falsejs.injectIntojQuery()
|
|
|
124
142
|
|
|
125
143
|
const $ = jQuery
|
|
126
144
|
|
|
127
|
-
const myFalseValue = $.False("
|
|
145
|
+
const myFalseValue = $.False("yes", "yes", "yes", "yes", "yes", "no", falsejs.COMPATIBILITY_MODE.NONE)
|
|
128
146
|
console.log(myFalseValue) // false
|
|
129
147
|
console.log($.isFalse(myFalseValue)) // true
|
|
130
148
|
```
|
|
@@ -144,7 +162,7 @@ const PORT = Bro(process).doYouEven("env.PORT") ? process.env.PORT : 3000
|
|
|
144
162
|
app.use(falsejs.expressMiddleware)
|
|
145
163
|
|
|
146
164
|
app.get("/", (req, res) => {
|
|
147
|
-
res.send(req.isFalse(req.False())
|
|
165
|
+
res.send(req.isFalse(req.False("yes", "yes", "yes", "yes", "yes", "no", falsejs.COMPATIBILITY_MODE.NONE)) // sends true to the client
|
|
148
166
|
})
|
|
149
167
|
|
|
150
168
|
app.listen(PORT)
|
|
@@ -181,7 +199,8 @@ const falseValue = falsejs.False(
|
|
|
181
199
|
"no" /*the first three options you can choose, for examples we set them all to "no"*/,
|
|
182
200
|
disableAprilFoolsSideEffects,
|
|
183
201
|
disableAprilFoolsSideEffects,
|
|
184
|
-
disableChecking
|
|
202
|
+
disableChecking,
|
|
203
|
+
falsejs.COMPATIBILITY_MODE.NETSCAPE // for this example we'll use netscape compatibility mode
|
|
185
204
|
)
|
|
186
205
|
|
|
187
206
|
// or you can do this, but the above is better
|
|
@@ -192,7 +211,8 @@ const falseValue = falsejs.False(
|
|
|
192
211
|
"no" /*the first three options you can choose, for examples we set them all to "no"*/,
|
|
193
212
|
"yes",
|
|
194
213
|
"yes",
|
|
195
|
-
"no"
|
|
214
|
+
"no",
|
|
215
|
+
falsejs.COMPATIBILITY_MODE.NETSCAPE // for this example we'll use netscape compatibility mode
|
|
196
216
|
)
|
|
197
217
|
```
|
|
198
218
|
|
|
@@ -222,9 +242,4 @@ FalseJS uses the MIT license.
|
|
|
222
242
|
|
|
223
243
|
|
|
224
244
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
please help me i am going insane
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
245
|
+
Making this was very hard, but I was dedicated and now there's a 3000-line long library just to return false. Please help me. Please.
|
package/biome.json
CHANGED
|
@@ -6,10 +6,6 @@
|
|
|
6
6
|
"clientKind": "git",
|
|
7
7
|
"useIgnoreFile": true
|
|
8
8
|
},
|
|
9
|
-
|
|
10
|
-
"files": {
|
|
11
|
-
"ignoreUnknown": false
|
|
12
|
-
},
|
|
13
9
|
"formatter": {
|
|
14
10
|
"enabled": true,
|
|
15
11
|
"formatWithErrors": false,
|
|
@@ -53,5 +49,13 @@
|
|
|
53
49
|
"organizeImports": "off"
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
|
-
}
|
|
52
|
+
},
|
|
53
|
+
"files": {
|
|
54
|
+
"includes": [
|
|
55
|
+
"**",
|
|
56
|
+
"!dist/**",
|
|
57
|
+
"!node_modules/**"
|
|
58
|
+
],
|
|
59
|
+
"ignoreUnknown": false
|
|
60
|
+
}
|
|
57
61
|
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** biome-ignore-all lint/complexity/noStaticOnlyClass: BRO ITS A D.TS FILE */
|
|
2
|
+
type COMPATIBILITY_MODE_PARAM = "none" | "ie5" | "netscape" | "opera_presto";
|
|
3
|
+
|
|
4
|
+
export default class falsejs {
|
|
5
|
+
|
|
6
|
+
static COMPATIBILITY_MODE: {
|
|
7
|
+
readonly NONE: "none",
|
|
8
|
+
readonly IE5: "ie5",
|
|
9
|
+
readonly NETSCAPE: "netscape",
|
|
10
|
+
readonly OPERA_PRESTO: "opera_presto"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns false from the given parameters.
|
|
15
|
+
*
|
|
16
|
+
* @param {"yes"|"no"} loggingEnabled - Indicates whether logging should be enabled.
|
|
17
|
+
* @param {"yes"|"no"} shouldDoSomethingAsync - A pointless option that indicates whether something should be done asynchronously that just waits 200ms before saying "Did something async"
|
|
18
|
+
* @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)
|
|
19
|
+
* @param {"yes"|"no"} disableAprilFoolsSideEffects - Indicates whether April Fools side effects should be disabled.
|
|
20
|
+
* @param {"yes"|"no"} definitelyDisableAprilFoolsSideEffects - Indicates whether April Fools side effects should be definitely disabled.
|
|
21
|
+
* @param {"yes"|"no"} strictDisableAprilFoolsSideEffectsCheck - Indicates whether strict checking for disabling April Fools side effects should be enabled.
|
|
22
|
+
* @param {"none"|"ie5"|"netscape"|"opera_presto"} compatibilityMode - The compatibility mode for various legcay browser environments.
|
|
23
|
+
* @returns {boolean} - The calculated boolean value 'false'.
|
|
24
|
+
*/
|
|
25
|
+
static False(
|
|
26
|
+
loggingEnabled?: "yes" | "no",
|
|
27
|
+
shouldDoSomethingAsync?: "yes" | "no",
|
|
28
|
+
shouldDoSomethingAsyncWithIsTenThousand?: "yes" | "no",
|
|
29
|
+
disableAprilFoolsSideEffects?: "yes" | "no",
|
|
30
|
+
definitelyDisableAprilFoolsSideEffects?: "yes" | "no",
|
|
31
|
+
strictDisableAprilFoolsSideEffectsCheck?: "yes" | "no",
|
|
32
|
+
compatibilityMode?: COMPATIBILITY_MODE_PARAM
|
|
33
|
+
): boolean
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Checks if a given value is false.
|
|
37
|
+
*
|
|
38
|
+
* @param {any} value - The value to be checked.
|
|
39
|
+
* @returns {boolean} - True if the value is false, false otherwise.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
static isFalse(value: any, loggingEnabled?: "yes" | "no"): boolean
|
|
43
|
+
|
|
44
|
+
static injectIntojQuery(): void
|
|
45
|
+
static expressMiddleware(req: any, res: any, next: any): void
|
|
46
|
+
}
|