@huz-com/merger

Merges or overrides two objects with deeply and type-concern

Usage no npm install needed!

<script type="module">
  import huzComMerger from 'https://cdn.skypack.dev/@huz-com/merger';
</script>

README

Huz.Com > Component > Merger

  • Merges or overrides two objects with deeply and type-concern
  • It supports multi-tenancy customization structure with $._merge.<tenant-code>
  • It supports environment customization structure with $._env.<environment>

Standards

  • Language: TS
  • Eslint: Yes
  • Static Code Analysis: Yes IntelliJ Code Inspections
  • DDD - Document Driven: Yes
  • EDD - Exception Driven: Yes
  • TDD - Test Driven: Yes go to test folder
  • Standards Complied: Huz Standards

Commands

  • npm run clear // clears "dist" folder
  • npm run lint // runs eslint for static code analysis
  • npm run test // runs test files in "test" folder
  • npm run build // builds JS files at "dist" folder
  • npm publish or npm run publix // publishes "dist" folder to npm

Install

npm i @huz-com/merger

Samples

const {merger} = require('@huz-com/merger');

// merges targetObject with sourceObject
const newObject = merger.applyNode(req, sourceObject, targetObject);

// merges tenant doc with given tenant identifiers and ignores some properties
const newDoc = merger.applyTenant(req, tenantDoc, tenantCode, tenantId, ['id', 'createdAt']);

// merges config data with given environment
const newConfig = merger.applyEnvironment(req, tenantDoc, 'prod');