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

flat-tree

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flat-tree - npm Package Compare versions

Comparing version 1.11.0 to 1.12.0

39

index.js

@@ -51,2 +51,41 @@ exports.fullRoots = function (index, result) {

exports.patch = function (from, to) {
if (from === 0 || from >= to) return []
const roots = exports.fullRoots(from)
const target = exports.fullRoots(to)
// first find the first root that is different
let i = 0
for (; i < target.length; i++) {
if (i >= roots.length || roots[i] !== target[i]) break
}
// now we need to grow the newest root until it hits the diff one
let prev = roots.length - 1
const ite = exports.iterator(roots[prev--])
const patch = []
while (ite.index !== target[i]) {
ite.sibling()
if (prev >= 0 && ite.index === roots[prev]) {
prev--
} else {
patch.push(ite.index)
}
patch.push(ite.parent())
}
// include the rest
for (i++; i < target.length; i++) patch.push(target[i])
return patch
}
exports.depth = function (index) {

@@ -53,0 +92,0 @@ let depth = 0

2

package.json
{
"name": "flat-tree",
"version": "1.11.0",
"version": "1.12.0",
"description": "A series of functions to map a binary tree to a list",

@@ -5,0 +5,0 @@ "main": "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