Socket
Socket
Sign inDemoInstall

object-scan

Package Overview
Dependencies
Maintainers
1
Versions
200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-scan - npm Package Compare versions

Comparing version 18.0.2 to 18.0.3

41

lib/core/compiler.js
/* compile needles to hierarchical map object */
import parser from './parser.js';
import iterator from '../generic/iterator.js';
import traverser from '../generic/traverser.js';
import { defineProperty } from '../generic/helper.js';
import { Wildcard } from './wildcard.js';
const COUNTER = Symbol('counter');
const LEAF = Symbol('leaf');

@@ -135,4 +132,5 @@ const markLeaf = (input, match, readonly) => defineProperty(input, LEAF, match, readonly);

cur[wc.value] = child;
ctx.stack.push(cur, child);
if (ctx.orderByNeedles) {
setOrder(child, ctx[COUNTER]);
setOrder(child, ctx.counter);
}

@@ -165,4 +163,4 @@ setWildcard(child, wc);

markLeaf(cur, !excluded, ctx.strict);
setIndex(cur, ctx[COUNTER], ctx.strict);
ctx[COUNTER] += 1;
setIndex(cur, ctx.counter, ctx.strict);
ctx.counter += 1;
}

@@ -173,19 +171,17 @@ });

const finalizeTower = (tower, ctx) => {
const matches = [];
let lastDepth = -1;
const { stack } = ctx;
traverser.traverse(tower, (type, obj, depth) => {
if (type === 'EXIT') {
const isUp = lastDepth === depth + 1;
if ((isUp && matches[lastDepth] === true) || isMatch(obj)) {
matches[depth] = true;
setHasMatches(obj);
}
if (isUp) {
matches[lastDepth] = false;
}
setValues(obj, Object.values(obj).reverse());
lastDepth = depth;
while (stack.length !== 0) {
const child = stack.pop();
const parent = stack.pop();
setValues(child, Object.values(child).reverse());
if (isMatch(child)) {
setHasMatches(child);
}
});
if (hasMatches(child) && !hasMatches(parent)) {
setHasMatches(parent);
}
}
setValues(tower, Object.values(tower).reverse());

@@ -204,3 +200,4 @@ if (ctx.useArraySelector === false) {

const tower = {};
ctx[COUNTER] = 0;
ctx.counter = 0;
ctx.stack = [];
for (let idx = 0; idx < needles.length; idx += 1) {

@@ -207,0 +204,0 @@ const needle = needles[idx];

{
"name": "object-scan",
"type": "module",
"version": "18.0.2",
"version": "18.0.3",
"description": "Traverse object hierarchies using matching and callbacks.",

@@ -6,0 +6,0 @@ "main": "lib/index.js",

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