Socket
Socket
Sign inDemoInstall

object-reshaper

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    object-reshaper

TypeScript-first schema-based object transformation


Version published
Weekly downloads
404
decreased by-14.04%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

0.1.0 (2023-04-25)

Features

  • Initial release! :rocket:

Readme

Source

Object Reshaper

CI Coverage Status Known Vulnerabilities

TypeScript-first schema-based object transformation.

Installation

Requirements

  • TypeScript 4.9+
$ npm install object-reshaper

Basic Usage

Renaming property names

import { reshaperBuilder, Schema } from "object-reshaper";

type Input = {
  id: number;
};
const schema = {
  new: "id",
} as const satisfies Schema<Input>;
const reshaper = reshaperBuilder<Input, typeof schema>(schema);
reshaper({ id: 1 }); // => { new: 1 } (Type: { new: number })

Extracting nested properties

import { reshaperBuilder, Schema } from "object-reshaper";

type Input = {
  user: {
    address: {
      street: string;
    };
  };
};
const schema = {
  street: "user.address.street",
} as const satisfies Schema<Input>;
const reshaper = reshaperBuilder<Input, typeof schema>(schema);
reshaper({ user: { address: { street: "home" } } }); // => { new: "home" } (Type: { new: string })

Keywords

FAQs

Last updated on 25 Apr 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc