-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: optimized read-array & read-number-array helper & enhanced docs
- Loading branch information
Showing
3 changed files
with
42 additions
and
4 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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import { read } from './read'; | ||
|
||
export function readArray(key: string) : string[] | undefined { | ||
export function readArray(key: string) : string[] | undefined; | ||
export function readArray(key: string, alt: string[]) : string[]; | ||
export function readArray(key: string, alt?: string[]): any { | ||
const value = read(key); | ||
if (typeof value === 'undefined') { | ||
return undefined; | ||
return alt; | ||
} | ||
|
||
return value.split(','); | ||
return value.split(',').filter(Boolean); | ||
} |
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