Socket
Socket
Sign inDemoInstall

which-boxed-primitive

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

which-boxed-primitive

Which kind of boxed JS primitive is this?


Version published
Weekly downloads
24M
decreased by-15.09%
Maintainers
1
Weekly downloads
 
Created

What is which-boxed-primitive?

The `which-boxed-primitive` npm package is designed to help developers identify the type of boxed primitives (objects that encapsulate primitive values) in JavaScript. This can be particularly useful when working with code that needs to distinguish between different types of object wrappers around primitive values, such as `Number`, `String`, `Boolean`, `Symbol`, `BigInt`, etc.

What are which-boxed-primitive's main functionalities?

Identifying boxed primitives

This feature allows developers to pass an object to the `whichBoxedPrimitive` function and receive a string indicating the type of boxed primitive, or `undefined` if the object is not a boxed primitive. This can be useful for type checking and ensuring that certain operations are only performed on the expected types of objects.

"use strict";\nconst whichBoxedPrimitive = require('which-boxed-primitive');\n\nconsole.log(whichBoxedPrimitive(new String('hello'))); // 'String'\nconsole.log(whichBoxedPrimitive(new Number(123))); // 'Number'\nconsole.log(whichBoxedPrimitive(new Boolean(true))); // 'Boolean'\nconsole.log(whichBoxedPrimitive(Object(Symbol('sym')))); // 'Symbol'\nconsole.log(whichBoxedPrimitive(Object(BigInt(10)))); // 'BigInt'\nconsole.log(whichBoxedPrimitive([])); // undefined (not a boxed primitive)"

Other packages similar to which-boxed-primitive

Keywords

FAQs

Package last updated on 11 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc