Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cc-expiry

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cc-expiry

An NPM package for formatting credit card expiry dates in MM/YY or MM/YYYY formats.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

cc-expiry

An NPM package for formatting credit card expiry dates in MM/YY or MM/YYYY formats.

Usage

Import the lib:

//With ES6-style imports
import {format} from "cc-expiry";

// With node-style requires:
var format = require("cc-expiry").format;
format(expiry: string, customSeparator?: string, fourDigitYear?: boolean)
console.log(format("12 / 3456")); // '12 / 34'
console.log(format("12 / 345"));  // '12 / 34'
console.log(format("12 / 34"));   // '12 / 34'
console.log(format("12/34"));     // '12 / 34'
console.log(format("1234"));      // '12 / 34'
console.log(format("123"));       // '12 / 3'
console.log(format("12"));        // '12'
console.log(format("1"));         // '1'

With a custom separator:

console.log(format("12 / 345", "🍎")); // '12🍎34'
console.log(format("12 / 34", "🍎"));  // '12🍎34'
console.log(format("12/34", "🍎"));    // '12🍎34'
console.log(format("1234", "🍎"));     // '12🍎34'
console.log(format("123", "🍎"));      // '12🍎3'
console.log(format("12", "🍎"));       // '12'
console.log(format("1", "🍎"));        // '1'

With a 4-digit year (MM / YYYY)

console.log(format("12 / 3456", "/", true)); // '12/3456'
console.log(format("12 / 345", "/", true));  // '12/345'
console.log(format("12 / 34", "/", true));   // '12/34'
console.log(format("12/34", "/", true));     // '12/34'
console.log(format("1234", "/", true));      // '12/34'
console.log(format("123", "/", true));       // '12/3'
console.log(format("12", "/", true));        // '12'
console.log(format("1", "/", true));         // '1'

Keywords

FAQs

Package last updated on 29 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc