Socket
Socket
Sign inDemoInstall

get-prop

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-prop - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

bower.json
{
"name": "getprop",
"main": "getprop.js",
"version": "0.0.2",
"version": "0.0.3",
"homepage": "https://github.com/miguelmota/getprop",

@@ -6,0 +6,0 @@ "authors": [

@@ -7,3 +7,3 @@ (function(root) {

if (!(typeof s === 'string' || s instanceof String)) return;
var props = s.match(/(\[(.*?)\]|[0-9a-zA-Z]+)/gi).map(function(m) { return m.replace(/[\[\]]/gi,''); });
var props = s.match(/(\[(.*?)\]|[0-9a-zA-Z_]+)/gi).map(function(m) { return m.replace(/[\[\]]/gi,''); });

@@ -10,0 +10,0 @@ var last = props[props.length - 1],

{
"name": "get-prop",
"version": "0.0.2",
"version": "0.0.3",
"description": "Get a property from object",

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

@@ -21,7 +21,11 @@ # getprop

boop: 'yo',
peep: [55,'zonk']
peep: [55,'zonk', {
__data: 'pow'
}],
}
},
'key.with.dots': 'hello',
'"key.with.quotes"': 'hi'
'"key.with.quotes"': {
greet: 'hi'
}
};

@@ -35,3 +39,4 @@

getProp(obj, 'qux[key.with.dots]') // 'hello'
getProp(obj, 'qux["key.with.quotes"]') // 'hi'
getProp(obj, 'qux["key.with.quotes"].greet') // 'hi'
getProp(obj, 'qux.zee.peep.2.__data') // 'pow'
```

@@ -38,0 +43,0 @@

@@ -5,3 +5,3 @@ var test = require('tape');

test('getProp', function (t) {
t.plan(10);
t.plan(11);

@@ -13,6 +13,10 @@ var obj = {

boop: 'yo',
peep: [55,'zonk']
peep: [55,'zonk', {
__data: 'pow'
}],
},
'key.with.dots': 'hello',
'"key.with.quotes"': 'hi'
'"key.with.quotes"': {
greet: 'hi'
}
},

@@ -27,3 +31,4 @@ };

t.equal(getProp(obj, 'qux[key.with.dots]'), 'hello');
t.equal(getProp(obj, 'qux["key.with.quotes"]'), 'hi');
t.equal(getProp(obj, 'qux["key.with.quotes"].greet'), 'hi');
t.equal(getProp(obj, 'qux.zee.peep.2.__data'), 'pow');
t.equal(getProp(obj, ''), undefined);

@@ -30,0 +35,0 @@ t.equal(getProp(obj, {}), undefined);

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