Socket
Book a DemoInstallSign in
Socket

ffformat

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ffformat

![logo](./ffformat_logo.png)

latest
Source
npmnpm
Version
1.3.1
Version published
Maintainers
1
Created
Source

logo

ffformat

  • 数据格式化,数据源 + 类型 = 完全新的格式化后数据。
  • 暂只支持 stringnumberbooleanobjectarray

为啥子要用

  • 一般情况下用不到, 除非对后端有些怨言...

description

安装

yarn add ffformat 

使用

import { typeCreator as T, format } from 'ffformat';
// =============== basic usage =============
format('croatia', T.string());
// 'croatia'

format(21, T.string());
// '21'

format(null, T.string());
// ''

format(null, T.string('croatia'));
// 'croatia'


// ============== mixed usage =============
format(
  { name: 'croatia', age: '21', skillId: ['1', '2', '3', '4'] },
  T.object({ name: T.string(), age: T.number(), skillId: T.array(T.number()) })
);
// {
//    name: 'croatia',
//    age: 21,
//    skillId: [1, 2, 3, 4]
//  }
);

更多示例, 看 format/__tests__/format.test.ts

Keywords

data

FAQs

Package last updated on 08 Nov 2020

Did you know?

Socket

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