UNPKG
zippo
Version:
latest (1.0.1)
1.0.1
1.0.0
ZIP code validation and parsing
github.com/bendrucker/zippo
bendrucker/zippo
zippo
/
index.js
12 lines
(8 loc)
•
234 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
'use strict'
var
nonDigit =
/[^\d]/g
exports
.
parse
=
function
parseZip
(
zip
) {
return
zip.
replace
(nonDigit,
''
).
substring
(
0
,
5
) }
exports
.
validate
=
function
validateZip
(
zip
) {
return
zip.
length
===
5
&& !nonDigit.
test
(zip) }