Skip to content

Commit 4cc166c

Browse files
committed
[add] 修复当只有一个选项时只输出一种类型的密码
1 parent fb1b167 commit 4cc166c

File tree

5 files changed

+48
-12
lines changed

5 files changed

+48
-12
lines changed

Diff for: .editorconfig

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
# Unix-style newlines with a newline ending every file
5+
[*]
6+
end_of_line = lf
7+
insert_final_newline = true
8+
9+
# Matches multiple files with brace expansion notation
10+
# Set default charset
11+
[*.{ts,tsx}]
12+
charset = utf-8
13+
indent_style = space
14+
indent_size = 2
15+
trim_trailing_whitespace = true
16+
17+
# Matches the exact files either package.json or .travis.yml
18+
[{package.json}]
19+
indent_style = space
20+
indent_size = 2

Diff for: package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
22
"name": "password-generation",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Password generation and complexity checking without headache",
55
"main": "lib/index.js",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/icepy/password-generation.git"
99
},
1010
"keywords": [
11-
"password"
11+
"password",
12+
"password generation",
13+
"generation"
1214
],
1315
"author": "icepy <[email protected]> (http://github.com/icepy)",
1416
"license": "MIT",

Diff for: src/index.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { charsLowerCase, charsUpperCase, random, special, shuffle, upperChar, lowerChar, anyChar } from "./utils";
1+
import {
2+
charsLowerCase,
3+
charsUpperCase,
4+
random,
5+
special,
6+
shuffle,
7+
upperChar,
8+
lowerChar,
9+
anyChar
10+
} from "./utils";
211

312
export interface IDefaultsConfig {
413
length: number[];
@@ -138,4 +147,4 @@ export default function generate(length: number | number[], options?: IDefaultsC
138147

139148
// Shuffle the array and make a string
140149
return shuffle(tmp).join('');
141-
}
150+
}

Diff for: src/utils.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ export const anyChar = (key: string) => {
3939
if (key === 'uppers') {
4040
return charFrom(charsUpperCase);
4141
}
42-
43-
// if (key === 'specials') {
44-
// return charFrom(specials);
45-
// }
46-
42+
if (key === 'specials') {
43+
return charFrom(specials);
44+
}
4745
return charFrom(charsNumber);
4846
}
4947

@@ -57,4 +55,4 @@ export const charFrom = (chars: string): string => {
5755

5856
export const random = (max: number, min = 0): number => {
5957
return Math.floor(Math.random() * (max - min + 1) + min);
60-
}
58+
}

Diff for: test/test.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const generate = require('./lib/index').default;
1+
const generate = require('../lib/index').default;
22

33
const a = generate();
44

@@ -48,6 +48,13 @@ const h = generate(10, {
4848

4949
console.log('长度是10并且无大小写字母和特殊字符', h);
5050

51+
const j = generate(10, {
52+
uppers: 0,
53+
lowers: 0,
54+
nums: 0
55+
});
56+
57+
console.log('长度是10并且无大小写字母和数字', j);
5158
// const i = generate(10, {
5259
// uppers: 0,
5360
// specials: 0,
@@ -70,4 +77,4 @@ console.log('长度是10并且无大小写字母和特殊字符', h);
7077
// nums: 0
7178
// });
7279

73-
// console.log('长度是10的全特殊字符',k);
80+
// console.log('长度是10的全特殊字符',k);

0 commit comments

Comments
 (0)