Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paveldymkov/logical-not
https://github.com/paveldymkov/logical-not
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/paveldymkov/logical-not
- Owner: PavelDymkov
- License: mit
- Created: 2019-02-18T01:20:11.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-08-26T08:05:34.000Z (over 3 years ago)
- Last Synced: 2024-04-26T18:46:00.226Z (9 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Logical NOT Function
The **not** function is an alphabetic analogue of the unary operator **!**.
It is used to increase the readability of the code.Usage:
```js
import not from "logical-not";
// or import { not } from "logical-not";if (not("foo".includes("bar"))) {
console.log("baz");
}
```### Typescript support
```ts
function main(): void {
const div = document.querySelector("div");
const span = document.querySelector("span");
// now div is HTMLDivElement | null
// span is HTMLSpanElement | nullif (not(div)) return;
// now div is HTMLDivElement
div.textContent;
// need to use optional chaining
span?.textContent;
}
```## License
MIT License (see `LICENSE` file).