
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@egjs/children-differ
Advanced tools
A module that checks diff when child elements are added, removed, or changed
@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.
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' }] }
react-diff is a package that provides utilities for diffing React elements. It is similar to @egjs/children-differ in that it helps detect changes in a list of elements, but it is specifically designed for React components.
diff is a general-purpose text diffing library that can be used to compare strings, arrays, and objects. While it is not specifically designed for detecting changes in children elements, it provides similar functionality for comparing lists and detecting differences.
immutability-helper is a package that provides utilities for working with immutable data structures. It includes functions for updating lists and detecting changes, similar to @egjs/children-differ, but with a focus on immutability.
➕➖🔄 A module that checks diff when child elements are added, removed, or changed.
$ npm i @egjs/children-differ
<script src="//naver.github.io/egjs-children-differ/release/latest/dist/children-differ.pkgd.min.js"></script>
Package | Version | Description |
---|---|---|
@egjs/react-children-differ | ||
@egjs/ngx-children-differ | ||
@egjs/vue-children-differ |
Usage is similar to @egjs/list-differ.
<div id="container">
<div>0</div>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
<script>
import ChildrenDiffer from "@egjs/children-differ";
// Value is key
const differ = new ChildrenDiffer(conatiner.children);
container.removeChild(container.children[5]);
container.removeChild(container.children[2]);
const result = differ.update(container.children);
// [2, 5]
console.log(result.removed);
</script>
See CONTRIBUTING.md.
Please file an Issue.
@egjs/list-differ is released under the MIT license.
Copyright (c) 2019-present NAVER Corp.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
FAQs
A module that checks diff when child elements are added, removed, or changed
The npm package @egjs/children-differ receives a total of 211,808 weekly downloads. As such, @egjs/children-differ popularity was classified as popular.
We found that @egjs/children-differ demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.