{"id":17419802,"url":"https://github.com/bendrucker/creditcards","last_synced_at":"2025-04-04T08:10:09.501Z","repository":{"id":18750291,"uuid":"21962405","full_name":"bendrucker/creditcards","owner":"bendrucker","description":"Parse, format, and validate credit cards in JS","archived":false,"fork":false,"pushed_at":"2024-05-14T22:46:46.000Z","size":134,"stargazers_count":186,"open_issues_count":0,"forks_count":19,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-28T07:09:37.027Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bendrucker.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-18T00:35:30.000Z","updated_at":"2025-02-13T20:34:44.000Z","dependencies_parsed_at":"2023-12-16T12:06:13.090Z","dependency_job_id":"c0b61d12-7c4c-4309-9801-c119f99c0923","html_url":"https://github.com/bendrucker/creditcards","commit_stats":{"total_commits":156,"total_committers":8,"mean_commits":19.5,"dds":"0.16666666666666663","last_synced_commit":"a66fbca63eee44c6e9b77d23efe86d43baa683ea"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fcreditcards","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fcreditcards/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fcreditcards/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bendrucker%2Fcreditcards/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bendrucker","download_url":"https://codeload.github.com/bendrucker/creditcards/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142074,"owners_count":20890653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-17T02:33:34.906Z","updated_at":"2025-04-04T08:10:09.485Z","avatar_url":"https://github.com/bendrucker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# creditcards [![tests](https://github.com/bendrucker/creditcards/workflows/tests/badge.svg)](https://github.com/bendrucker/creditcards/actions?query=workflow%3Atests)\n\n\u003e Parse, format, and validate credit card data.\n\n## Installing\n\n```sh\nnpm install --save creditcards\n``` \n\n## API\n\ncreditcards exports:\n\n* `card`\n* `cvc`\n* `expiration`\n* `withTypes` (constructs a new copy of the module with custom types)\n\nYou can also require modules individually. This is particularly useful if you wish to pass in custom types. `card` and `cvc` each export a function that accepts an array of card types [(see `creditcards-types`)](https://github.com/bendrucker/creditcards-types). `expiration` returns an object.\n\n```js\nconst Card = require('creditcards/card')\nconst card = Card([visa])\ncard.isValid('4242424242424242')\n// =\u003e true\n\nconst expiration = require('creditcards/expiration')\nexpiration.isPast(10, 2010)\n// =\u003e true\n```\n\n#### `withTypes(types)` -\u003e `object`\n\nReturns a new copy of the main module with custom types.\n\n##### types\n\n*Required*  \nType: `array`\n\nAn array of types from [creditcards-types](https://github.com/bendrucker/creditcards-types).\n\n---\n\n### `card`\n\n#### `card.parse(number)` -\u003e `string`\n\nRemove all non-numeric characters from a card number, including punctuation and spacing. \n\n##### number\n\n*Required*  \nType: `string`\n\n---\n\n#### `card.format(number, [separator])` -\u003e `string`\n\nFormats a card number as printed on the physical card\n\n##### number\n\n*Required*  \nType: `string`\n\n##### separator\n\nType: `string`\nDefault: `' '` (space)\n\n```js\ncard.format('4242424242424242') === '4242 4242 4242 4242' // Visa\ncard.format('378282246310005') === '3782 822463 10005' // American Express\n```\n\n---\n\n#### `card.type(number, [eager])` -\u003e `string`\n\nReturns the matched card type, or `undefined` if there was no match. For a full list of supported card types, see [`creditcards-types`](https://github.com/bendrucker/creditcards-types#card-types).\n\n##### number\n\n*Required*  \nType: `string`\n\nThe card number. Punctuation is not allowed. Sanitize input through `card.parse` first if needed.\n\n##### eager\n\nType: `boolean`  \nDefault: `false`\n\nWhen `true`, the card type will be eagerly matched using a more permissive pattern that can match partial card numbers.\n\n---\n\n#### `card.luhn(number)` -\u003e `Boolean`\n\nChecks the card number's validity using the [Luhn algorithm](http://en.wikipedia.org/wiki/Luhn_algorithm).\n\n##### number\n\n*Required*  \nType: `string`\n\n#### `card.isValid(number, [type])` -\u003e `boolean`\n\n##### number\n\n*Required*  \nType: `string`\n\n##### type\n\nType: `string`  \nDefault: `undefined`\n\nDetect if a card is a valid card of the specified type. If no type is provided, the card will be valid if any type is matched.\n\n### `cvc`\n\n#### `cvc.isValid(cvc, [type])` -\u003e `boolean`\n\n##### cvc\n\n*Required*  \nType: `string`\n\n##### type\n\nType: `string`  \nDefault: `undefined`\n\nDetect if a CVC is valid card for the specified type. \n\n### `expiration`\n\n#### `isPast(month, year)` -\u003e `boolean`\n\n##### month\n\n*Required*  \nType: `number`\n\n##### year\n\n*Required*  \nType: `number`\n\n---\n\n#### `expiration.month.parse(month)` -\u003e `number`\n\nCasts the provide value a number. All of the following will be `5` after parsing: \n* `5`\n* `'05'`\n* `'5'`\n\n##### month\n\n*Required*  \nType: `string` / `number`\n\n---\n\n#### `expiration.month.isValid(month)` -\u003e `Boolean`\n\n##### month\n\n*Required*  \nType: `number`\n\n---\n\n#### `expiration.year.parse(year, [expand])` -\u003e `number`\n\nAll of the following are equivalent: \n* `expiration.year.parse(2014)`\n* `expiration.year.parse('2014')`\n* `expiration.year.parse('14', true)`\n* `expiration.year.parse(14, true)`\n\n##### year\n\n*Required*  \nType: `string` / `number`\n\n##### expand\n\nType: `boolean`  \nDefault: `false`\n\nIf `true`, the year is assumed to be a 1 or 2 digit number and is expanded to its full value.\n\n---\n\n#### `expiration.year.format(year, [strip])` -\u003e `string`\n\n##### year\n\n*Required*  \nType: `number`\n\n##### strip\n\nType: `boolean`  \nDefault: `false`\n\nIf `true`, year is assumed to be a four digit number and will be converted to a two digit number. \n\n* `expiration.year.format(2014) === '2014'`\n* `expiration.year.format(2014, true) === '14'`\n\n---\n\n#### `expiration.year.isValid(year)` -\u003e `Boolean`\n\n##### year\n\n*Required*  \nType: `number`\n\n---\n\n#### `expiration.year.isPast(year)` -\u003e `boolean`\n\n##### year\n\n*Required*  \nType: `number`\n\n## License\n\nMIT © [Ben Drucker](http://bendrucker.me)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbendrucker%2Fcreditcards","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbendrucker%2Fcreditcards","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbendrucker%2Fcreditcards/lists"}