node package manager



Playing card object.


You must use npm 2.7.0 or higher because of the scoped package name.

$ npm init
$ npm install @mitchallen/playing-card --save


A playing card contains a suit and a rank property. Use these two modules to create objects containing the suits and ranks for a standard 52 playing card deck:

var SUIT = require("@mitchallen/playing-card-suit");
var RANK = require("@mitchallen/playing-card-rank");

The module itself returns a factory that you can use to create playing cards.

var cardFactory = require("@mitchallen/playing-card");

const suit = SUIT.DIAMOND;
const rank = RANK.JACK;

var card = cardFactory({suit: suit, rank: rank});



You can find more info on the suit and rank modules here:

Invalid Values

  • If the card factory is passed invalid values for suit or rank a null object will be returned.


To test, go to the root folder and type (sans $):

$ npm test



In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Version History

Version 0.1.5

  • refreshed for latest version of suit and rank module dependencies

Version 0.1.4

  • added missing checkins and refreshed readme

Version 0.1.3

  • factory now uses spec object to create card

Version 0.1.2

  • checked in lint issue

Version 0.1.1

  • added validation checks for suit and rank

Version 0.1.0

  • initial release