Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mpath

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mpath - npm Package Compare versions

Comparing version 0.5.2 to 0.6.0

4

History.md

@@ -0,1 +1,5 @@

0.6.0 / 2019-05-01
==================
* feat: support setting dotted paths within nested arrays
0.5.2 / 2019-04-25

@@ -2,0 +6,0 @@ ==================

32

lib/index.js

@@ -257,13 +257,3 @@ // These properties are special and can open client libraries to security

if (!copy && Array.isArray(val)) {
for (var item, j = 0; j < obj.length && j < val.length; ++j) {
item = obj[j];
if (item) {
if (lookup) {
lookup(item, part, map(val[j]));
} else {
if (item[special]) item = item[special];
item[part] = map(val[j]);
}
}
}
_setArray(obj, val, part, lookup, special, map);
} else {

@@ -294,2 +284,22 @@ for (var j = 0; j < obj.length; ++j) {

/*!
* Recursively set nested arrays
*/
function _setArray(obj, val, part, lookup, special, map) {
for (var item, j = 0; j < obj.length && j < val.length; ++j) {
item = obj[j];
if (Array.isArray(item) && Array.isArray(val[j])) {
_setArray(item, val[j], part, lookup, special, map);
} else if (item) {
if (lookup) {
lookup(item, part, map(val[j]));
} else {
if (item[special]) item = item[special];
item[part] = map(val[j]);
}
}
}
}
/*!
* Returns the value passed to it.

@@ -296,0 +306,0 @@ */

{
"name": "mpath",
"version": "0.5.2",
"version": "0.6.0",
"description": "{G,S}et object values using MongoDB-like path notation",

@@ -22,5 +22,5 @@ "main": "index.js",

"devDependencies": {
"mocha": "1.8.1",
"mocha": "5.x",
"benchmark": "~1.0.0"
}
}

@@ -0,1 +1,2 @@

'use strict';

@@ -1752,3 +1753,3 @@ /**

done();
})
});

@@ -1777,5 +1778,11 @@ it('array.prop', function(done){

done();
})
});
})
it('nested array', function(done) {
const obj = { arr: [[{ test: 41 }]] };
mpath.set('arr.test', [[42]], obj);
assert.deepEqual(obj.arr, [[{ test: 42 }]]);
done();
});
});

@@ -1789,4 +1796,4 @@ describe('multiple $ use', function(){

done();
})
})
});
});

@@ -1793,0 +1800,0 @@ it('has', function(done) {

Sorry, the diff of this file is not supported yet

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