0.0.1 • Published 6 years ago

deepformat v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

deepFormat

一个处理前后端数据规范的工具


Feature

  • 将后端返回的数据,格式化成前端已经定义好了的数据结构;解决当数据层级很多,后端却返回浅层级而导致前端需要在每层都check的问题

Install

$ npm i deepformat --save

Usage

import deepFormat from 'deepformat';

API

use: deepFormat(feObj, beObj); // feObj: 前端定义好了的数据格式;beObj:后端返回的数据
exp: deepFormat({ a : 1, b: { c: 1 } }, { a: 2, b: 2 })  =>   { a : 2, b: { c: 1 } }

TODO

  1. 还需要提供能直接深度比较前后端数据格式,如果不同则抛出警告的功能