0.0.5 • Published 2 years ago

oproxy v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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'}
0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago