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

js-select

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-select - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

LICENSE

16

index.js

@@ -15,3 +15,3 @@ var traverse = require("traverse"),

},
update: function(cb) {

@@ -21,4 +21,5 @@ this.forEach(function(node) {

});
return obj;
},
remove: function() {

@@ -28,8 +29,9 @@ this.forEach(function(node) {

})
return obj;
},
condense: function() {
traverse(obj).forEach(function(node) {
if (!this.parent) return;
if (this.parent.keep) {

@@ -58,4 +60,5 @@ this.keep = true;

});
return obj;
},
forEach: function(cb) {

@@ -68,5 +71,6 @@ traverse(obj).forEach(function(node) {

// inherit context from js-traverse
cb.call(this, node);
cb.call(this, node);
}
});
return obj;
}

@@ -73,0 +77,0 @@ };

{
"name": "js-select",
"description": "Traverse and modify objects with JSONSelect selectors",
"version": "0.5.1",
"version": "0.6.0",
"author": "Heather Arthur <fayearthur@gmail.com>",

@@ -6,0 +6,0 @@ "repository": {

@@ -35,3 +35,3 @@ var assert = require("assert"),

var people2;
var people2, obj;

@@ -63,3 +63,3 @@ assert.deepEqual(select(people, "*").nodes(), [{"george":{"age":35,"movies":[{"name":"Repo Man","stars":5}]},"mary":{"age":15,"movies":[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]},"chris":{"car":null,"male":true}},{"age":35,"movies":[{"name":"Repo Man","stars":5}]},35,[{"name":"Repo Man","stars":5}],{"name":"Repo Man","stars":5},"Repo Man",5,{"age":15,"movies":[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]},15,[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}],{"name":"Twilight","stars":3},"Twilight",3,{"name":"Trudy","stars":2},"Trudy",2,{"name":"The Fighter","stars":4},"The Fighter",4,{"car":null,"male":true},null,true]);

assert.deepEqual(select(people, ":only-child").nodes(), [{"name":"Repo Man","stars":5}]);
assert.deepEqual(select(people, ":root").nodes(),[{"george":{"age":35,"movies":[{"name":"Repo Man","stars":5}]},"mary":{"age":15,"movies":[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]},"chris":{"car":null,"male":true}}])
assert.deepEqual(select(people, ":root").nodes(),[{"george":{"age":35,"movies":[{"name":"Repo Man","stars":5}]},"mary":{"age":15,"movies":[{"name":"Twilight","stars":3},{"name":"Trudy","stars":2},{"name":"The Fighter","stars":4}]},"chris":{"car":null,"male":true}}])

@@ -97,4 +97,5 @@ assert.deepEqual(select(people, "string").nodes(),["Repo Man","Twilight","Trudy","The Fighter"]);

select(people2, ".age").update(3)
obj = select(people2, ".age").update(3)
assert.deepEqual(select(people2, ".age").nodes(), [3, 3]);
assert.deepEqual(obj, people2);

@@ -104,4 +105,5 @@ // remove()

select(people2, ".age").remove();
obj = select(people2, ".age").remove();
assert.deepEqual(select(people2, ".age").nodes(), []);
assert.deepEqual(obj, people2);

@@ -118,4 +120,5 @@ // condense()

people2 = traverse.clone(people);
select(people2, ".stars").condense();
obj = select(people2, ".stars").condense();
assert.deepEqual(people2, {"george": {movies: [{stars: 5}]}, "mary": {movies: [{stars: 3},{stars: 2},{stars: 4}]}});
assert.deepEqual(obj, people2);

@@ -125,6 +128,7 @@ // forEach()

select(people2, ".age").forEach(function(age) {
obj = select(people2, ".age").forEach(function(age) {
this.update(age - 5);
})
assert.deepEqual(select(people2, ".age").nodes(), [30, 10]);
assert.deepEqual(obj, people2);

@@ -131,0 +135,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