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

keypather

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keypather - npm Package Compare versions

Comparing version 1.8.0 to 1.8.1

23

index.js

@@ -28,14 +28,7 @@ var keypather = module.exports = function (opts) {

}
var match = keypath.match(/(.*)([.]|\[["'])([^.\[]+)$/);
if (match) {
var lastKey = match[2]+match[3];
lastKey = ~lastKey.indexOf('.') ?
lastKey.slice(1) :
lastKey.slice(2, -2);
var keypathWithoutLast = match[1];
this._get(obj, keypathWithoutLast)[lastKey] = value;
}
else {
obj[keypath] = value;
}
this.keypathSplit = this.splitKeypath(keypath);
var lastKey = this.getLastKey();
var val = this.getLastObj(arguments, true);
val[lastKey] = value;
return value;

@@ -258,3 +251,3 @@ };

};
Keypather.prototype.getLastObj = function (args) {
Keypather.prototype.getLastObj = function (args, setOperation) {
var val;

@@ -267,3 +260,5 @@ if (this.keypathSplit.length === 0) {

getArgs[1] = this.keypathSplit.join('.');
val = this.get.apply(this, getArgs);
val = setOperation ?
this._get.apply(this, getArgs):
this.get.apply(this, getArgs);
}

@@ -270,0 +265,0 @@ return val;

{
"name": "keypather",
"version": "1.8.0",
"version": "1.8.1",
"description": "Get or set a object values from a keypath string. Supports bracket notation, dot notation, and functions",

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

@@ -21,2 +21,6 @@ var keypather = require('../index')();

set("new.bar.foo.boom", 'value'));
describe("valueForKeyPath.set(obj, '[\"new.bar.foo.boom\"]', 'value')",
set('["new.bar.foo.boom"]', 'value'));
describe("valueForKeyPath.set(obj, '[\"new.bar\"].what[\"foo.boom\"]', 'value')",
set('[\"new.bar\"].what[\"foo.boom\"]', 'value'));
});

@@ -23,0 +27,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