-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from deanilvincent/releases/v2.0.3
Releases/v2.0.3
- Loading branch information
Showing
8 changed files
with
1,239 additions
and
27 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
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 @@ | ||
# Node.js | ||
# Build a general Node.js project with npm. | ||
# Add steps that analyze code, save build artifacts, deploy, and more: | ||
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript | ||
|
||
trigger: | ||
- master | ||
- releases/* | ||
|
||
pool: | ||
vmImage: 'ubuntu-latest' | ||
|
||
steps: | ||
- task: NodeTool@0 | ||
inputs: | ||
versionSpec: '10.x' | ||
displayName: 'Install Node.js' | ||
|
||
- script: | | ||
npm install | ||
npm test | ||
displayName: 'npm install and test' |
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,30 @@ | ||
export interface Option<V> { | ||
id: number; | ||
value: V; | ||
minDiversity: number; | ||
minLength: number; | ||
} | ||
|
||
export interface FirstOption<V> extends Option<V> { | ||
minDiversity: 0; | ||
minLength: 0; | ||
} | ||
|
||
export type Options<V> = [FirstOption<V>, ...Option<V>[]]; | ||
|
||
export const defaultOptions: Options<string>; | ||
|
||
export type DiversityType = "lowercase" | "uppercase" | "symbol" | "number"; | ||
|
||
export interface Result<V> { | ||
id: number; | ||
value: V; | ||
contains: DiversityType[]; | ||
length: number; | ||
} | ||
|
||
export function passwordStrength<V = string>( | ||
password: string, | ||
options?: Options<V>, | ||
allowedSymbols?: string, | ||
): Result<V>; |
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
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,68 @@ | ||
import { expectType } from "tsd"; | ||
import { DiversityType, passwordStrength } from "./index"; | ||
|
||
// Test result types | ||
expectType<string>(passwordStrength("asdfasdf").value); | ||
expectType<number>(passwordStrength("asdfasdf").id); | ||
expectType<number>(passwordStrength("asdfasdf").length); | ||
expectType<DiversityType[]>(passwordStrength("asdfasdf").contains); | ||
|
||
// Test options with custom value (string) | ||
expectType<string>( | ||
passwordStrength("asdfasdf", [ | ||
{ | ||
id: 0, | ||
value: "Too weak", | ||
minDiversity: 0, | ||
minLength: 0, | ||
}, | ||
{ | ||
id: 1, | ||
value: "Weak", | ||
minDiversity: 2, | ||
minLength: 6, | ||
}, | ||
{ | ||
id: 2, | ||
value: "Medium", | ||
minDiversity: 4, | ||
minLength: 8, | ||
}, | ||
{ | ||
id: 3, | ||
value: "Strong", | ||
minDiversity: 4, | ||
minLength: 10, | ||
}, | ||
]).value | ||
); | ||
|
||
// Test options with custom value (object) | ||
expectType<{ message: string, color: string }>( | ||
passwordStrength("asdfasdf", [ | ||
{ | ||
id: 0, | ||
value: {message: "Too weak", color: "red"}, | ||
minDiversity: 0, | ||
minLength: 0, | ||
}, | ||
{ | ||
id: 1, | ||
value: {message: "Weak", color: "orange"}, | ||
minDiversity: 2, | ||
minLength: 6, | ||
}, | ||
{ | ||
id: 2, | ||
value: {message: "Medium", color: "yellow"}, | ||
minDiversity: 4, | ||
minLength: 8, | ||
}, | ||
{ | ||
id: 3, | ||
value: {message: "Strong", color: "green"}, | ||
minDiversity: 4, | ||
minLength: 10, | ||
}, | ||
]).value | ||
); |
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
Oops, something went wrong.