npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

falsejs

v1.5.13

Published

False

Downloads

2,080

Readme

FalseJS

Better than the keyword itself.

Ever wondered what would happen if JavaScript changed the false keyword to something else, like no, nope, noway, or something else? Chaos. That is what FalseJS is for.

The 10 attempts to get the value of false ensure that if one fails, it will go on to the next, so if JavaScript breaks one, there will still be more attempts. This is an alternative to the library false by mde, which uses the hardcoded boolean value false (which I believe they are trying to resolve on the sister library true, which will probably be passed down to the false library), and is way too short. FalseJS is way better. It's even written in nocode, but the vanilla JS version is included as index.src.js if you want to read the source and can't read nocode. If you can read nocode, it's in the index.no file which includes the core logic.

Installation

Install FalseJS with your favorite package manager.

NPM: npm install falsejs

Yarn: yarn add falsejs

PNPM: pnpm add falsejs

Import it with require:

const f = require('falsejs')

Import it with import:

import f from 'falsejs'

Usage

f.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;

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.

The second argument, shouldDoSomethingAsync, is whether FalseJS should do an asyncronhous promise-based setTimeout and when it's done, if logging is enabled, output [falsejs] Did something async in green. This is just a pointless feature that is by default "no", because it can be "yes" or "no".

The third argument, shouldDoSomethingAsyncWithIsTenThousand, is whether is-ten-thousand, a package used by FalseJS, should have an asynchronous promise-based setTimeout before it checks if a value is 10,000. It can be "yes" or "no".

The third and fourth 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 fifth argument, strictDisableAprilFoolsSideEffectsCheck, is "no".

The sixth argument, openRandomImageOfDofleWhenDone, can be "yes" or "no". If it is "yes", then a random image of Sindre Sorhus's cat Dofle will be opened after false is calculated.

Example

const f = require('falsejs')
const False = f.False('yes', 'no', 'no', 'yes', 'yes', 'no', 'no') // outputs a bunch of logs

console.log(False) // 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.

Example:

const f = require('falsejs')
const False = f.False('yes', 'no', 'no')

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

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).

CLI

NPM:

npm install -g falsejs

Yarn:

yarn add -g falsejs

PNPM:

pnpm add -g falsejs

FalseJS provides a CLI.

$ npm install -g falsejs
$ false
false

jQuery plugin

A jQuery plugin is also provided for FalseJS. Here is an example:

const f = require('falsejs')
global.jQuery = require('jquery')
f.injectIntojQuery()

const $ = jQuery

const myFalseValue = $.False('no', 'no', 'no', 'yes', 'yes', 'no')
console.log(myFalseValue) // false
console.log($.isFalse(myFalseValue)) // true

Express middleware

Express middleware is also exported. Here is an example:

const express = require('express')
const f = require('falsejs')
const Bro = require('brototype')

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

app.use(f.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!
})

app.listen(PORT)

Related Projects