Socket
Socket
Sign inDemoInstall

prototypes

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prototypes - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

26

lib/object.js

@@ -131,2 +131,28 @@ 'use strict';

/**
* For each property in the mapping object, if 'this' has a property of the same name, then the name of the property in 'this'
* is renamed to the value corresponding to the property from the mapping object.
* Example:
* var bla = {'yo': 'hi', 'bo': 'hi'};
* bla.renameProperties({'bo': 'do'});
* THEN
* bla.hasOwnProperty('do') === true
* bla.do === 'hi'
*/
newObject.renameProperties = function(mappingObject)
{
var self = this;
newObject.forEach.call(mappingObject, function(newPropertyName, oldPropertyName)
{
if (self.hasOwnProperty(oldPropertyName))
{
self[newPropertyName] = self[oldPropertyName];
delete self[oldPropertyName];
}
});
return self;
}
/**
* Get all values for a parameter object in an array.

@@ -133,0 +159,0 @@ * Note: operates on the global Object, not on the prototype.

2

package.json
{
"name": "prototypes",
"version": "1.3.1",
"version": "1.4.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",

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

### object.renameProperties(mappingObject)
Rename an object's properties based on another 'mapping' object's key/value pairs.
Example:
```js
{a: 1, b: 2}.renameProperties({a: 'z', b: 'y'});
//=> {z: 1, y: 2}
```
## Object Functions

@@ -327,0 +337,0 @@

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