Giter Club home page Giter Club logo

object-reduce-by-map's Introduction

object-reduce-by-map

Recursively reduce an object to match a given map.

Build Status | Dependencies | License

Table of Contents generated with DocToc

Features

  • Reduce a given object to match the structure and leaf data types of a given map
  • Delete non-matching input nodes
  • Optionally throw an error for non-matching nodes with throwErrorOnAlien
  • Provide options:
    • keepKeys: Retain mismatched keys as null opposed to deleting them
    • throwErrorOnAlien: Throw error on alien found
    • allowNullishKeys: Preserve null or undefined keys in the output

Breaking changes 1 -> 2

In version 1 a bug was discovered that permitted alien keys of null value into the output. This has now been resolved however may cause any tools using this helper tool to break, hence the major version bump.

Example use as an API output transformer

An example use case of this package can be found in the TypeScript openapi-nodegen templates as an output transformer: openapi-nodegen-typescript-server

Example usages

The most up to date examples can always be found in the tests

object-reduce-by-map's People

Contributors

acrontum-carmichael avatar j-d-carmichael avatar p-mcgowan avatar

Watchers

 avatar

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.