https://github.com/hugoalh-studio/is-primitive-js
A JavaScript module to determine whether the item is a primitive.
https://github.com/hugoalh-studio/is-primitive-js
is javascript js primitive
Last synced: 11 months ago
JSON representation
A JavaScript module to determine whether the item is a primitive.
- Host: GitHub
- URL: https://github.com/hugoalh-studio/is-primitive-js
- Owner: hugoalh-studio
- License: other
- Created: 2024-03-29T06:09:15.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-29T06:28:40.000Z (about 2 years ago)
- Last Synced: 2024-03-30T06:26:17.762Z (about 2 years ago)
- Topics: is, javascript, js, primitive
- Language: TypeScript
- Homepage:
- Size: 47.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Citation: CITATION.cff
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# Is Primitive (JavaScript)
[**âī¸** MIT](./LICENSE.md)
**đī¸**
[](https://github.com/hugoalh-studio/is-primitive-js)
[](https://www.npmjs.com/package/@hugoalh/is-primitive)
**đ**  ()
A JavaScript module to determine whether the item is a primitive.
## đ¯ Target
- Bun ^ v1.0.0
- Cloudflare Workers
- Deno >= v1.34.0
> **đĄī¸ Require Permission**
>
> *N/A*
- NodeJS >= v16.13.0
### đ Other Edition
- [TypeScript](https://github.com/hugoalh-studio/is-primitive-ts)
## đ° Usage
### Via Installation
> **đ¯ Supported Target**
>
> - Cloudflare Workers
> - NodeJS
1. Install via console/shell/terminal:
- Via NPM
```sh
npm install @hugoalh/is-primitive[@]
```
- Via PNPM
```sh
pnpm add @hugoalh/is-primitive[@]
```
- Via Yarn
```sh
yarn add @hugoalh/is-primitive[@]
```
2. Import at the script (`.js`):
```js
import ... from "@hugoalh/is-primitive";
```
> **âšī¸ Note**
>
> Although it is recommended to import the entire module, it is also able to import part of the module with sub path if available, please visit [file `package.json`](./package.json) property `exports` for available sub paths.
### Via NPM Specifier
> **đ¯ Supported Target**
>
> - Bun
> - Deno
1. Import at the script (`.js`):
```js
import ... from "npm:@hugoalh/is-primitive[@]";
```
> **âšī¸ Note**
>
> Although it is recommended to import the entire module, it is also able to import part of the module with sub path if available, please visit [file `package.json`](./package.json) property `exports` for available sub paths.
## đ§Š API
- ```ts
function isPrimitive(item: unknown): item is Primitive;
```
- ```ts
type Primitive = bigint | boolean | number | string | symbol | null | undefined;
```
## âī¸ Example
- ```js
isPrimitive({});
//=> false
```
- ```js
isPrimitive(new Headers());
//=> false
```
- ```js
isPrimitive(true);
//=> true
```
- ```js
isPrimitive(123n);
//=> true
```