You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

visit-values

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

visit-values - npm Package Compare versions

Comparing version

to
2.0.0

20

index.js

@@ -0,1 +1,3 @@

'use strict'
/*

@@ -8,6 +10,7 @@ visit all the children of a javascript object

*/
var visit = module.exports = function (current, fn) {
let visit = module.exports = (current, fn) => {
for (var k in current) {
var value = current[k]
for (let i = 0, keys = Object.keys(current); i < keys.length; i++) {
let key = keys[i]
let value = current[key]

@@ -17,8 +20,15 @@ if (value === undefined || value === null) continue

if (typeof value === 'object' || typeof value === 'function') {
visit(current[k], fn)
visit(current[key], fn)
continue
}
fn(current[k], k, current)
let proceed = fn(current[key], key, current)
// returning false (and only false)
// from the visitor function will stop the
// visitations
if (proceed === false) {
break;
}
}
}
{
"name": "visit-values",
"version": "1.0.4",
"version": "2.0.0",
"description": "visit all the children of a javascript object",

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

@@ -1,7 +0,9 @@

var assert = require('assert')
var visitValues = require('./index.js')
'use strict'
const assert = require('assert')
const visitValues = require('./index.js')
describe('visit', function () {
it('visits', function() {
var tree = {
let tree = {
a: {

@@ -19,3 +21,3 @@ b: {

var results = []
let results = []

@@ -22,0 +24,0 @@ visitValues(tree, function(v, k, p) {