Skip to content

Commit b3f6d6d

Browse files
committed
docs: ✏️ change readme
BREAKING CHANGE: 🧨 N ✅ Closes: N
1 parent fe0fca1 commit b3f6d6d

1 file changed

Lines changed: 74 additions & 4 deletions

File tree

README.md

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
</div>
88
<div align="center">
99

10-
[![npm version](https://badge.fury.io/js/suchjs.svg)](https://badge.fury.io/js/suchjs)&nbsp;&nbsp;[![Build Status](https://travis-ci.com/suchjs/such.svg?branch=master)](https://travis-ci.com/suchjs/such)&nbsp;&nbsp;[![Coverage Status](https://coveralls.io/repos/github/suchjs/such/badge.svg?branch=master)](https://coveralls.io/github/suchjs/such?branch=master)
10+
[![npm version](https://badge.fury.io/js/suchjs.svg)](https://badge.fury.io/js/suchjs)&nbsp;&nbsp;[![Build Status](https://travis-ci.com/suchjs/such.svg?branch=master)](https://travis-ci.com/suchjs/such)&nbsp;&nbsp;[![Coverage Status](https://coveralls.io/repos/github/suchjs/such/badge.svg)](https://coveralls.io/github/suchjs/such)
1111

1212
</div>
1313

14-
1514
An expandable and powerful library for generating fake data, both in nodejs & browser envirionment. You can use it to build a mock data server in nodejs, or just mocking data locally in the browser, normal built-in types can seen in [official site](https://www.suchjs.com/?locale=en-US), more extended types can seen in the [document](https://suchjs.github.io/vp-suchjs/en/extTypes.html), you can start it easily.
1615

1716
## Installation
@@ -20,16 +19,87 @@ An expandable and powerful library for generating fake data, both in nodejs & br
2019

2120
## Online demos
2221

22+
```javascript
23+
import globalSuch from 'suchjs';
24+
globalSuch.assign('city', {
25+
BeiJing: {
26+
BeiJing: ['ChaoYang', 'HaiDian', 'DongCheng'],
27+
},
28+
ShangHai: {
29+
ShangHai: ['JingAn', 'PuDong', 'PuTuo'],
30+
},
31+
GuangZhou: {
32+
GuangZhou: ['PanYu', 'YueXiu', 'BaiYun'],
33+
},
34+
});
35+
globalSuch.define(
36+
'mobile$china',
37+
'regexp',
38+
'/(\\\\+86\\\\-)?(?<service>1[3-8][0-9])\\\\d{8}/',
39+
);
40+
console.log(globalSuch.as({
41+
string: ":string:[65,121]:{10,20}:@concat('_suffix')",
42+
number: ':number:[100,200]:%.2f',
43+
date: ":date:['-1 week','+1 week']:%yyyy-mm-dd HH\\:MM\\:ss",
44+
regexp: ':regexp:/[a-z]{1,3}[0-9]{2,10}/',
45+
range: ':increment:{2,3}:#[start=2,step=3]',
46+
'menu{2}': {
47+
id: ':increment',
48+
title: ':uppercase:{5,10}',
49+
'childs{2}': {
50+
cid: ':increment',
51+
refPid: ':ref:&../id',
52+
title: ':lowercase:{5,10}',
53+
},
54+
},
55+
cascader: {
56+
province: ':cascader:#[root=true,data=city]',
57+
city: ':cascader:&./province',
58+
area: ':cascader:&./city',
59+
},
60+
'enum:{1}': ['one', 'two'],
61+
template:
62+
':::`:who` coming from `:ref:&./cascader/province`-`:ref:&./cascader/city`-`:ref:&./cascader/area`',
63+
diy: ':mobile$china',
64+
escape: '\\:number',
65+
extends: {
66+
bool: ':bool',
67+
int: ':int',
68+
percent: ':percent',
69+
uppercase: ':uppercase:{2,4}',
70+
lowercase: ':lowercase:{2,4}',
71+
alpha: ':alpha:{3,6}',
72+
alphaNumeric: ':alphaNumeric:{3,6}',
73+
alphaNumericDash: ':alphaNumericDash:{3,6}',
74+
tld: ':tld',
75+
domain: ':domain',
76+
protocol: ':protocol',
77+
url: ':url',
78+
email: ":email:#[domain='163.com']",
79+
ipv4: ':ipv4',
80+
ipv6: ':ipv6',
81+
color$hex: ':color$hex',
82+
color$rgb: ':color$rgb',
83+
color$rgba: ':color$rgba',
84+
color$hsl: ':color$hsl',
85+
color$hsla: ':color$hsla',
86+
},
87+
}));
88+
```
89+
2390
[Playground](https://suchjs.github.io/vp-suchjs/en/playground.html)
91+
2492
## Changelog
2593

2694
[Changelog](./CHANGELOG.md)
27-
## Expandable & Powerful
95+
96+
## Expandable & Powerful
2897

2998
Suchjs has powerful APIs for you to [design your own data](https://suchjs.github.io/vp-suchjs/en/api.html#such-define), you can use a template literal mixed normal string and all supported data types to generate a DIY string just like an article. A built-in recommend extend types can be seen in [such:recommend](./src/extends/recommend.ts)
99+
30100
## Questions & Bugs?
31101

32-
Welcome to report to us with [issue](https://github.com/suchjs/such/issues) if you meet any question or bug.
102+
Welcome to report to us with [issue](https://github.com/suchjs/such/issues) if you meet any question or bug.
33103

34104
## License
35105

0 commit comments

Comments
 (0)