0.0.6 • Published 6 years ago

@ballfish/shape_json v0.0.6

Weekly downloads
17
License
MIT
Repository
github
Last release
6 years ago

shape_json

NPM version

Introduction

A tool to help for shaping properties of json object to the type and name you want.

Install

$ yarn add shape_json
const ShapeJson = require('@ballfish/shape_json')

Usage

const origin = {
  campaignName: 'test',
  adsetName: 'owo',
  name: 'wow',
  clicks: '123'
}

const schema = {
  campaignName: {
    to: 'campaign'
  },
  adsetName: {},
  clicks: {
    to: 'cc',
    type: shape_json.type.number
  }
}

const option = {
  otherProperties: 'keep',
  error: 'ignore',
  notFoundProperties: 'give-default',
  keyDuplicate: 'keep-schema'
}

console.log(ShapeJson.shape(origin, schema, option))

/**
 * {
 *  name: 'wow',
 *  campaign: 'test',
 *  adsetName: 'owo',
 *  cc: 123
 * }
 */
0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago