Skip to content

hugoalh/is-primitive-es

Is Primitive (ES)

⚖️ MIT

GitHub: hugoalh/is-primitive-es JSR: @hugoalh/is-primitive NPM: @hugoalh/is-primitive

An ECMAScript module to determine whether the item is a primitive.

🎯 Targets

Runtime \ Source GitHub Raw JSR NPM
Bun >= v1.1.0 ✔️ ✔️
Deno >= v2.1.0 ✔️ ✔️ ✔️
NodeJS >= v20.9.0 ✔️ ✔️

🛡️ Runtime Permissions

This does not request any runtime permission.

#️⃣ Sources

  • GitHub Raw
    https://raw.githubusercontent.com/hugoalh/is-primitive-es/{Tag}/mod.ts
    
  • JSR
    jsr:@hugoalh/is-primitive[@{Tag}]
    
  • NPM
    npm:@hugoalh/is-primitive[@{Tag}]
    

Note

  • It is recommended to include tag for immutability.
  • These are not part of the public APIs hence should not be used:
    • Benchmark/Test file (e.g.: example.bench.ts, example.test.ts).
    • Entrypoint name or path include any underscore prefix (e.g.: _example.ts, foo/_example.ts).
    • Identifier/Namespace/Symbol include any underscore prefix (e.g.: _example, Foo._example).

⤵️ Entrypoints

Name Path Description
. ./mod.ts Default.

🧩 APIs

  • function isPrimitive(item: unknown): item is Primitive;
  • type Primitive = bigint | boolean | number | string | symbol | null | undefined;

Note

✍️ Examples

  • isPrimitive({});
    //=> false
  • isPrimitive(new Headers());
    //=> false
  • isPrimitive(true);
    //=> true
  • isPrimitive(123n);
    //=> true

About

An ECMAScript module to determine whether the item is a primitive.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •