Socket
Socket
Sign inDemoInstall

prototypes

Package Overview
Dependencies
0
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.0 to 2.3.0

12

lib/object.js

@@ -44,2 +44,14 @@ 'use strict';

newObject.hasProperties = function()
{
for (var key in this)
{
if (this.hasOwnProperty(key))
{
return true;
}
}
return false;
}
/**

@@ -46,0 +58,0 @@ * Get a function to filter keys.

2

package.json
{
"name": "prototypes",
"version": "2.2.0",
"version": "2.3.0",
"description": "Some common prototypes for node.js: string.startsWith(), object.countProperties() and more. Facilities for functional programming with objects: object.forEach(), object.filter(). Functions are added safely using Object.defineProperty().",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/alexfernandez/prototypes",

@@ -281,2 +281,26 @@ [![Build Status](https://secure.travis-ci.org/alexfernandez/prototypes.png)](http://travis-ci.org/alexfernandez/prototypes)

### object.hasProperties()
Simply find out if the object has any properties at all.
Most of the time you just want to see if you have an empty object;
this function is for you!
Faster than counting all properties.
Does not count inherited properties: uses hasOwnProperty().
Example:
```js
{hello: 'a'}.hasProperties();
//=> true
{}.hasProperties();
//=> false
```
Common usage:
```js
var params = JSON.parse(string);
if (!params.hasProperties()) return;
```
### object.overwriteWith(overwriter)

@@ -283,0 +307,0 @@

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