Comparing version 0.0.1 to 0.1.0
@@ -1,2 +0,2 @@ | ||
function n(n,t){void 0===t&&(t="");var r=new RegExp("[^"+t+"\\d]*","g");return n.trim().replace(r,"").slice(0,9)}function t(t,r,e){void 0===r&&(r="-"),void 0===e&&(e="*");var i=n(t,e);return[0,1,2,3,3,4,5,5,6,7,8,9,10].reduce(function(n,t,e){return n.concat(3===e||6===e?r:i[t]?i[t]:" ")},[]).join("").trim()}function r(t,r){return void 0===r&&(r="*"),n(t).split("").map(function(n,t,e){return t<5?t===e.length-1?n:r:n}).join("")}function e(n){return!!/^(?!666|000|9\d{2})\d{3}[\s-–]*(?!00)\d{2}[\s-–]*(?!0{4})\d{4}$/.test(n)&&parseInt(n.slice(0,3),10)<=733}export{n as clean,t as format,r as mask,e as validate}; | ||
function n(n,t){void 0===t&&(t="");var r=new RegExp("[^"+t+"\\d]*","g");return n.trim().replace(r,"").slice(0,9)}function t(t,r,e){void 0===r&&(r="-"),void 0===e&&(e="*");var i=n(t,e);return[0,1,2,3,3,4,5,5,6,7,8,9,10].reduce(function(n,t,e){return n.concat(3===e||6===e?r:i[t]?i[t]:" ")},[]).join("").trim()}function r(t,r){return void 0===r&&(r="*"),n(t).split("").map(function(n,t,e){return t<5?t===e.length-1?n:r:n}).join("")}function e(n){return/^(?!666|000|9\d{2})\d{3}(?!00)\d{2}(?!0{4})\d{4}$/.test(n)}export{n as clean,t as format,r as mask,e as validate}; | ||
//# sourceMappingURL=parse-ssn.es.js.map |
@@ -1,2 +0,2 @@ | ||
function t(t,n){void 0===n&&(n="");var r=new RegExp("[^"+n+"\\d]*","g");return t.trim().replace(r,"").slice(0,9)}exports.clean=t,exports.format=function(n,r,e){void 0===r&&(r="-"),void 0===e&&(e="*");var i=t(n,e);return[0,1,2,3,3,4,5,5,6,7,8,9,10].reduce(function(t,n,e){return t.concat(3===e||6===e?r:i[n]?i[n]:" ")},[]).join("").trim()},exports.mask=function(n,r){return void 0===r&&(r="*"),t(n).split("").map(function(t,n,e){return n<5?n===e.length-1?t:r:t}).join("")},exports.validate=function(t){return!!/^(?!666|000|9\d{2})\d{3}[\s-–]*(?!00)\d{2}[\s-–]*(?!0{4})\d{4}$/.test(t)&&parseInt(t.slice(0,3),10)<=733}; | ||
function t(t,n){void 0===n&&(n="");var r=new RegExp("[^"+n+"\\d]*","g");return t.trim().replace(r,"").slice(0,9)}exports.clean=t,exports.format=function(n,r,e){void 0===r&&(r="-"),void 0===e&&(e="*");var o=t(n,e);return[0,1,2,3,3,4,5,5,6,7,8,9,10].reduce(function(t,n,e){return t.concat(3===e||6===e?r:o[n]?o[n]:" ")},[]).join("").trim()},exports.mask=function(n,r){return void 0===r&&(r="*"),t(n).split("").map(function(t,n,e){return n<5?n===e.length-1?t:r:t}).join("")},exports.validate=function(t){return/^(?!666|000|9\d{2})\d{3}(?!00)\d{2}(?!0{4})\d{4}$/.test(t)}; | ||
//# sourceMappingURL=parse-ssn.js.map |
@@ -1,2 +0,2 @@ | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(n.parseSsn={})}(this,function(n){function e(n,e){void 0===e&&(e="");var t=new RegExp("[^"+e+"\\d]*","g");return n.trim().replace(t,"").slice(0,9)}n.clean=e,n.format=function(n,t,i){void 0===t&&(t="-"),void 0===i&&(i="*");var o=e(n,i);return[0,1,2,3,3,4,5,5,6,7,8,9,10].reduce(function(n,e,i){return n.concat(3===i||6===i?t:o[e]?o[e]:" ")},[]).join("").trim()},n.mask=function(n,t){return void 0===t&&(t="*"),e(n).split("").map(function(n,e,i){return e<5?e===i.length-1?n:t:n}).join("")},n.validate=function(n){return!!/^(?!666|000|9\d{2})\d{3}[\s-–]*(?!00)\d{2}[\s-–]*(?!0{4})\d{4}$/.test(n)&&parseInt(n.slice(0,3),10)<=733}}); | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(n.parseSsn={})}(this,function(n){function e(n,e){void 0===e&&(e="");var t=new RegExp("[^"+e+"\\d]*","g");return n.trim().replace(t,"").slice(0,9)}n.clean=e,n.format=function(n,t,i){void 0===t&&(t="-"),void 0===i&&(i="*");var o=e(n,i);return[0,1,2,3,3,4,5,5,6,7,8,9,10].reduce(function(n,e,i){return n.concat(3===i||6===i?t:o[e]?o[e]:" ")},[]).join("").trim()},n.mask=function(n,t){return void 0===t&&(t="*"),e(n).split("").map(function(n,e,i){return e<5?e===i.length-1?n:t:n}).join("")},n.validate=function(n){return/^(?!666|000|9\d{2})\d{3}(?!00)\d{2}(?!0{4})\d{4}$/.test(n)}}); | ||
//# sourceMappingURL=parse-ssn.umd.js.map |
{ | ||
"name": "parse-ssn", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Tiny utils to handle formatting, masking, and validating of US Social Security numbers.", | ||
@@ -5,0 +5,0 @@ "source": "index.ts", |
@@ -1,5 +0,4 @@ | ||
# parse-ssn | ||
# parse-ssn ![npm](https://img.shields.io/npm/v/parse-ssn) [![](https://badgen.net/bundlephobia/minzip/parse-ssn)](https://bundlephobia.com/result?p=parse-ssn) | ||
Tiny utils to handle formatting, masking, and validating of US Social Security | ||
numbers. **400 bytes gzipped.** | ||
Tiny toolkit to format, mask, and validate US Social Security numbers. | ||
@@ -12,11 +11,4 @@ ```bash | ||
`parse-ssn` includes four utilities: `mask`, `format`, `validate`, and `clean`. | ||
#### `mask(value: string[, placeholder = '*']): string` | ||
The library defaults to using `*` as a number placeholder, and `-` as a separator. To | ||
mask and format other variations, pass additional optional props. | ||
### `mask` | ||
Signature: `mask(value: string, placeholder = '*'): string` | ||
```javascript | ||
@@ -29,7 +21,4 @@ import { mask } from "parse-ssn"; | ||
### `format` | ||
#### `format(value: string[, separator = '-', existingPlaceholder = '*']): string` | ||
Signature: `format(value: string, separator = '-', existingPlaceholder = '*'): | ||
string` | ||
```javascript | ||
@@ -42,2 +31,4 @@ import { format } from "parse-ssn"; | ||
Compose methods for additional flexibility: | ||
```javascript | ||
@@ -59,6 +50,4 @@ import { format, mask } from "parse-ssn"; | ||
### `validate` | ||
#### `validate(value: string): boolean` | ||
Signature: `validate(value: string): boolean` | ||
Validation is based on information gathered from the [Social Security | ||
@@ -72,10 +61,6 @@ Administration's website](https://www.ssa.gov/employer/stateweb.htm). If an edge | ||
validate("123121234"); // => true | ||
validate("12312123"); // => false | ||
validate("1231212345"); // => false | ||
``` | ||
### `clean` | ||
#### `clean(value: string, exception = ''): string` | ||
Signature: `clean(value: string, exception = ''): string` | ||
By default, `clean` strips out all characters _except_ numbers, _and_ trims the | ||
@@ -92,3 +77,3 @@ string to nine characters. | ||
To clean a string that may be masked, pass exceptions. | ||
To clean a string that may be masked, pass an exception. | ||
@@ -103,2 +88,2 @@ ```javascript | ||
MIT License © [Eric Bailey](https://estrattonbailey.com) | ||
MIT License © [Truework](https://www.truework.com) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10756
83