Giter Site home page Giter Site logo

ivan114 / objectaccumulator Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 0.0 4.49 MB

A Javascript/Typescript object merging tool, focus on performance and easy-to-use. Good alternative to deepmerge and lodash _.merge in most cases.

Home Page: https://ivan114.github.io/ObjectAccumulator/

License: MIT License

JavaScript 63.88% TypeScript 36.12%
javascript merge deepmerge typescript lightweight performance browser nodejs accumulator object

objectaccumulator's People

Contributors

dependabot[bot] avatar ivan114 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

objectaccumulator's Issues

New properties are not added and array items are overwriten

import { Accumulator } from "object-accumulator";

let x = {
  name: "John",
  types: {
    age: 15,
    colors: ["green", "red"]
  },
  country: "Berkshire"
};

const a = Accumulator.from(x);

a.add({
  form: "cube",
  country: "Japan",
  types: { size: "big", colors: ["blue"] }
});

const mergedObject = a.merge();
console.log(`Merged Object`, mergedObject);

Merged Object {"name":"John","types":{"age":15,"colors":{"0":"blue","1":"red"}},"country":"Japan"}
'form, size' properties are not added, array item 'green' overwritten with 'blue'

Examples welcome, please help!

I would really like to use this library, but unfortunately there are no examples, how can I create and use KeyedAccumulator.
I would like to merge two objects in such way, that I remove from first object all elements (by key) which are not present in second object, then add to first object keys which are in second object, but not in first object, and lastly update values (by key) in first object from second object. Is this possible?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.