Socket
Socket
Sign inDemoInstall

libnested

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libnested - npm Package Compare versions

Comparing version 1.2.1 to 1.2.3

10

index.js

@@ -5,3 +5,8 @@ function isObject (o) {

function get (obj, path, dft) {
function isBasic (b) {
return 'string' === typeof b || 'number' === typeof b
}
function get (obj, path) {
if(isBasic(path)) return obj[path]
for(var i = 0; i < path.length; i++) {

@@ -15,2 +20,3 @@ if(null == (obj = obj[path[i]])) return dft

if(!obj) throw new Error('libnested.set: first arg must be an object')
if(isBasic(path)) return obj[path] = value
for(var i = 0; i < path.length; i++)

@@ -59,1 +65,3 @@ if(i === path.length - 1)

exports.paths = paths

4

package.json
{
"name": "libnested",
"description": "",
"version": "1.2.1",
"version": "1.2.3",
"homepage": "https://github.com/dominictarr/libnested",

@@ -15,3 +15,3 @@ "repository": {

"scripts": {
"test": "set -e; for t in test/*.js; do node $t; done"
"test": "node test.js"
},

@@ -18,0 +18,0 @@ "author": "'Dominic Tarr' <dominic.tarr@gmail.com> (dominictarr.com)",

@@ -8,2 +8,20 @@

t.deepEqual(
R.get({foo: true, bar: false}, 'foo'),
true
)
t.deepEqual(
R.get({foo: true, bar: false}, 'bar'),
false
)
t.deepEqual(
R.get({foo: true, bar: false}, ['foo']),
true
)
t.deepEqual(
R.get({foo: true, bar: false}, ['bar']),
false
)
t.deepEqual(
R.paths({foo: {bar: true}, baz: 2}),

@@ -56,2 +74,17 @@ [

var a = R.set(deep, 'zak', 53)
var a = R.set(deep, ['rom', 'pan', 2], 30)
t.deepEqual(
deep,
{
foo: {bar: true},
baz: 2,
blurg: {fop: {hif: []}},
rom: {pan: [1,2,30]},
zak: 53
}
)
t.end()

@@ -62,2 +95,1 @@

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