npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

playing-card-signature

v0.0.8

Published

Parse playing card signatures, to programatically determine their rank and suit

Downloads

4

Readme

playing-card-signature

Build Status codecov

Parse playing card signatures, to programatically determine their rank and suit

Ranks: A, 2, 3, 4, 5, 6, 7, 8, 9, 10 (or sometimes T), J, Q, K

Suits:clubs, ♦ diamonds, ♥ hearts, ♠ spades

When working with playing cards in software, the cards might be referred to using their signature. The signature is a shorthand notation of a card's rank and suit. For example, a card with a signature of 4s actually means the four of spades.

This library aims to provide a lightweight and reusable way to parse, validate, and process these card signatures, for the purpose of making it easier to work with them.

Note: This library supports the standard 52-card French deck only. Support for other decks is not planned.

Installation

yarn add playing-card-signature

Usage

const { parse } = require('playing-card-signature');

const options = {
  castTto10: false,
};

console.log(parse('4s', options)); // { rank: '4', suit: 's', signature: '4s', niceSignature: '♠4' }

API

parse(signature : string, options : object)

Accepts a card signature and an options object as parameter, and returns the parsed data from it:

  • rank
  • suit
  • the signature itself
  • nice signature (suit is displayed with respective unicode symbol)

Returns null if the signature could not be parsed.

Options

castTto10

Type: boolean Default: false

If true, the program casts any T rank it encounters to 10.

validate(signature : string)

Validates the given card signature, and returns a boolean, indicating the result.

Valid examples:

  • 8d
  • kh
  • as

Invalid examples:

  • s4
  • dd
  • 11c

License

MIT © Máté Farkas