-
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(filters): updated implementations, added test
- dividedBy, round, split, stripTags, urlize
- Loading branch information
Showing
7 changed files
with
75 additions
and
30 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export default function dividedBy(value: number, toDivideBy: number) { | ||
const isInteger = Number.isInteger(toDivideBy); | ||
const divided = value / toDivideBy; | ||
return isInteger ? Math.floor(divided) : divided; | ||
export default function dividedBy(value: number | string, toDivideBy: number | string) { | ||
const one = typeof value === 'string' ? parseFloat(value) : value; | ||
const two = typeof toDivideBy === 'string' ? parseFloat(toDivideBy) : toDivideBy; | ||
return one / two; | ||
} |
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,6 +1,4 @@ | ||
export default function round(n: number | string) { | ||
if (typeof n === 'string') { | ||
n = parseFloat(n); | ||
} | ||
n = typeof n === 'string' ? parseFloat(n) : n; | ||
return Math.round(n); | ||
} |
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,5 +1,5 @@ | ||
import { entries } from '../runtime'; | ||
|
||
export default function split(val: string | any[] | { [key: string]: any } | Map<any, any> | Set<any>) { | ||
return typeof val === 'string' ? val.split('') : [ ...entries(val) ]; | ||
export default function split(val: string) { | ||
return val.split(''); | ||
} |
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
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