Socket
Book a DemoInstallSign in
Socket

@egjs/children-differ

Package Overview
Dependencies
Maintainers
8
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@egjs/children-differ

A module that checks diff when child elements are added, removed, or changed

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
219K
5.41%
Maintainers
8
Weekly downloads
 
Created

What is @egjs/children-differ?

@egjs/children-differ is an npm package designed to efficiently detect changes in a list of children elements. It is particularly useful for applications where you need to track and respond to changes in a dynamic list of elements, such as in virtualized lists or complex UI components.

What are @egjs/children-differ's main functionalities?

Detecting Added and Removed Children

This feature allows you to detect which children have been added or removed between two states of a list. The code sample demonstrates how to use the `update` method to compare two lists and get the differences.

const ChildrenDiffer = require('@egjs/children-differ');

const differ = new ChildrenDiffer();
const prevList = ['a', 'b', 'c'];
const nextList = ['a', 'c', 'd'];

const result = differ.update(prevList, nextList);
console.log(result); // { added: [{ index: 2, value: 'd' }], removed: [{ index: 1, value: 'b' }], maintained: [{ index: 0, value: 'a' }, { index: 1, value: 'c' }] }

Detecting Moved Children

This feature allows you to detect which children have been moved between two states of a list. The code sample demonstrates how to use the `update` method to compare two lists and get the moved elements.

const ChildrenDiffer = require('@egjs/children-differ');

const differ = new ChildrenDiffer();
const prevList = ['a', 'b', 'c'];
const nextList = ['c', 'a', 'b'];

const result = differ.update(prevList, nextList);
console.log(result); // { added: [], removed: [], maintained: [{ index: 0, value: 'c' }, { index: 1, value: 'a' }, { index: 2, value: 'b' }], moved: [{ from: 2, to: 0, value: 'c' }, { from: 0, to: 1, value: 'a' }, { from: 1, to: 2, value: 'b' }] }

Other packages similar to @egjs/children-differ

Keywords

diff

FAQs

Package last updated on 12 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.