Skip to content

Rewrite the new object according to the schema. Delete the excess.

License

Notifications You must be signed in to change notification settings

productdevbookcom/schob

Repository files navigation

Schob

Schob

Installation

pnpm add schob

Usage

import { merge } from 'schob'

const schema = {
  isPro: false,
  darkMode: false,
  pages: {
    home: false,
    settings: false,
  },
}

const newData = {
  isPro: false,
  darkMode: true,
  pages: {
    home: false,
    settings: true,
    hello: false,
  },
  dd: 'dd',
  tt: {
    dd: 'dd',
  },
  cc: [{ dd: 'dd' }],
}

const res = merge({ schema, newData })

Output

{
    isPro: false,
    darkMode: true,
    pages: { home: false, settings: true },
 }

Sponsors

sponsors

License

MIT License © 2022-PRESENT productdevbook

About

Rewrite the new object according to the schema. Delete the excess.

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published