oproxy
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

oproxy (🚧 Under Construction)

Oproxy is a schema-based data mapper. Just define your schema, then transform it into that shape. Oproxy's schema is simple, intuitive, flexible and readable.

import oproxy, { string, number } from 'oproxy';

const src = {
  firstName: 'foo',
  lastName: 'bar',
  city: 'Boston',
  age: '25',
  rating: {
    rate: 3.9,
  },
};

const schema = {
  username: string('{firstName} {lastName}').capitalize(),
  city: string('city').lowerCase(),
  age: number('age').defaultValue('NOT_SET'),
  rate: number('rating.rate'),
};

oproxy(src, schema);
// { username: 'fooBar', city: 'boston', age: 25, rate: 3.9 }

Installation

npm install oproxy --save
# or with yarn
yarn add oproxy

Table of Contents

API

oproxy(src: object, schema: Schema)

For mapping object based on schema, you can use oproxy function.

import oproxy, { string, number } from 'oproxy';

const src = {
  firstName: 'foo',
  lastName: 'bar',
};

const schema = {
  username: string('{firstName} {lastName}').capitalize(),
};

oproxy(src, schema);
// { username: 'fooBar'}

Readme

Keywords

none

Package Sidebar

Install

npm i oproxy

Weekly Downloads

1

Version

0.0.5

License

MIT

Unpacked Size

132 kB

Total Files

51

Last publish

Collaborators

  • jalalazimi