Socket
Socket
Sign inDemoInstall

is-extendable

Package Overview
Dependencies
2
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-extendable

Returns true if a value is a plain object, array or function.


Version published
Maintainers
2
Weekly downloads
52,201,070
increased by2.32%
Install size
23.8 kB

Weekly downloads

Package description

What is is-extendable?

The is-extendable npm package is used to check if a value is extendable, meaning if it can have new properties added to it. This is typically used in the context of extending objects in JavaScript, where certain types of values, like null or undefined, cannot be extended.

What are is-extendable's main functionalities?

Checking if an object is extendable

This feature allows you to check if a given value is an object or function that can have new properties added to it. It returns true for plain objects and functions, and false for non-extendable values like null, undefined, and primitives.

const isExtendable = require('is-extendable');

// Returns true for plain objects
console.log(isExtendable({})); // true

// Returns true for functions
console.log(isExtendable(function() {})); // true

// Returns false for non-extendable values
console.log(isExtendable(null)); // false
console.log(isExtendable(undefined)); // false
console.log(isExtendable(123)); // false

Other packages similar to is-extendable

Readme

Source

is-extendable NPM version NPM monthly downloads NPM total downloads Linux Build Status

Returns true if a value is a plain object, array or function.

Install

Install with npm:

$ npm install --save is-extendable

Usage

var isExtendable = require('is-extendable');

Returns true if the value is any of the following:

  • array
  • plain object
  • function

Notes

All objects in JavaScript can have keys, but it's a pain to check for this, since we ether need to verify that the value is not null or undefined and:

  • the value is not a primitive, or
  • that the object is a plain object, function or array

Also note that an extendable object is not the same as an extensible object, which is one that (in es6) is not sealed, frozen, or marked as non-extensible using preventExtensions.

Release history

v1.0.0 - 2017/07/20

Breaking changes

  • No longer considers date, regex or error objects to be extendable

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on July 20, 2017.

Keywords

FAQs

Last updated on 11 Sep 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc