Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 67b3d6a
Showing
23 changed files
with
720 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
rules: { | ||
'type-enum': [ | ||
2, | ||
'always', | ||
['build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test', 'wip'], | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
patreon: # Replace with a single Patreon username | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: # Replace with a single Ko-fi username | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||
liberapay: # Replace with a single Liberapay username | ||
issuehunt: # Replace with a single IssueHunt username | ||
otechie: # Replace with a single Otechie username | ||
custom: ['https://paypal.me/hustcc', 'https://atool.vip'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: build | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: macOS-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [8.x, 10.x, 12.x, 14.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: ci | ||
run: | | ||
npm install | ||
npm run build | ||
npm run test | ||
- name: coverall | ||
if: success() | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Sys | ||
.DS_STORE | ||
.idea | ||
|
||
# Node | ||
node_modules/ | ||
|
||
# Build | ||
dist | ||
lib | ||
esm | ||
|
||
# Test | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"bracketSpacing": true, | ||
"printWidth": 120, | ||
"arrowParens": "always" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 hustcc | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# miz | ||
|
||
> (< 800b) Generate fake / mock structured variable in a modern, human-readable way. Just like a person. | ||
> | ||
> 用一个现代的、可读的方式来生成用于测试的假数据。 | ||
[![npm Version](https://img.shields.io/npm/v/miz.svg)](https://www.npmjs.com/package/miz) | ||
[![Build Status](https://github.com/hustcc/miz/workflows/build/badge.svg)](https://github.com/hustcc/miz/actions) | ||
[![Coverage Status](https://coveralls.io/repos/github/hustcc/miz/badge.svg?branch=master)](https://coveralls.io/github/hustcc/miz?branch=master) | ||
[![npm License](https://img.shields.io/npm/l/miz.svg)](https://www.npmjs.com/package/miz) | ||
|
||
|
||
## Features | ||
|
||
⚡️ Simple but highly perfection API | ||
🐣 Tiny footprint (< 800b) | ||
👓 Customize | ||
🎃 3 types of bundles exposed: ESM, CJS and UMD | ||
🔥 TypeScript Typings readily available | ||
🎸 Browser and NodeJs supported | ||
🎯 End-to-end testing with GitHub Action | ||
|
||
|
||
## Install | ||
|
||
```bash | ||
$ npm i --save miz | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
```ts | ||
import { M } from 'miz'; // ES6 | ||
|
||
const m = M.arrayOf(M.shape({ | ||
id: M.number(10000, 1000000), // id is between 10000 ~ 1000000. | ||
name: M.string(6), // 6 length random string. | ||
sex: M.bool(), // random true or false. | ||
city: 'hz', // constant value. | ||
work: M.oneOf(['QA', 'FED']) // random from array | ||
}), 2); // list length is 2. | ||
|
||
m.mock(); | ||
``` | ||
|
||
Then will get the mock variable like below: | ||
|
||
```ts | ||
[{ | ||
id: 757852, | ||
name: 'mU7RTB', | ||
sex: false, | ||
city: 'hz', | ||
work: 'FED' | ||
}, { | ||
id: 359987, | ||
name: 'jWuKxX', | ||
sex: true, | ||
city: 'hz', | ||
work: 'FED' | ||
}] | ||
``` | ||
|
||
|
||
## API & Mocker | ||
|
||
You can assemble the variable structure arbitrarily by **using the mockers** below: | ||
|
||
- **M.bool()** | ||
|
||
```ts | ||
M.bool().mock(); // true | ||
``` | ||
|
||
- **M.number(min[, max = min, fixed = 0])** | ||
|
||
```ts | ||
M.number(1, 9, 2).mock(); // 4.71 | ||
``` | ||
|
||
- **M.string([len = 8])** | ||
|
||
```ts | ||
M.string(6).mock(); // `Qv_teE` | ||
``` | ||
|
||
- **M.constant(value)** | ||
|
||
```ts | ||
M.constant('hello, hustcc.').mock(); // `hello, hustcc` | ||
M.constant(null).mock(); // got null | ||
``` | ||
|
||
- **M.oneOf(valueArray)** | ||
|
||
```ts | ||
M.oneOf(['hustcc', 'imcxl']).mock(); // hustcc | ||
``` | ||
|
||
- **M.arrayOf(mocker[, min = 20, max = min])** | ||
|
||
```ts | ||
// got an array which contains string, and array length 10 ~ 20. | ||
M.arrayOf(VT.string(4), 10, 20);.mock(); | ||
``` | ||
|
||
- **M.shape(mockerObject)** | ||
|
||
```ts | ||
// random value object. | ||
M.shape({ | ||
name: M.string(10), | ||
id: M.number(10000, 1000000), | ||
sex: M.bool(), | ||
city: 'hz', | ||
}).mock(); | ||
``` | ||
|
||
- **M.apply(Function)** | ||
|
||
```ts | ||
// will got number generate by fucntion Math.random() | ||
M.apply(() => Math.random()).mock(); | ||
``` | ||
|
||
> More `Mocker` needed, welcome to `send a pull request`, or put an issue to me. | ||
|
||
## License | ||
|
||
ISC@[hustcc](https://github.com/hustcc). |
Oops, something went wrong.