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 🙏

© 2025 – Pkg Stats / Ryan Hefner

swiss-ssn

v1.0.6

Published

Small utility for validating and generating Swiss national identification number.

Readme

Swiss National Identification Number (AHV/AVS) or (SSN) validation and generation

npm version Downloads

A lightweight JavaScript library for validating and generating Swiss National Identification Numbers with:

  • Zero dependencies
  • Modern ES Module support
  • Full test coverage
  • TypeScript-friendly JSDoc annotations
  • Browser-ready UMD bundle

Installation

# NPM
npm install swiss-ssn

# Yarn
yarn add swiss-ssn

# pnpm
pnpm add swiss-ssn

Usage

ES Modules (Node.js)

import SwissSSN from 'swiss-ssn';

// Validate a SSN
const isValid = SwissSSN.validateSSN('756.9217.0769.85');
console.log(isValid); // true

// Generate a random valid SSN
const newSSN = SwissSSN.generateSSN();
console.log(newSSN); // e.g., '756.1234.5678.90'

Browser

<!-- Use the minified UMD bundle -->
<script src="https://unpkg.com/swiss-ssn/dist/swiss-ssn.min.js"></script>
<script>
  // The SwissSSN class is available globally
  const isValid = SwissSSN.validateSSN('756.9217.0769.85');
  console.log(isValid); // true

  // Generate a random SSN
  const newSSN = SwissSSN.generateSSN();
  console.log(newSSN);
</script>

Browser (ES Modules)

<!-- Use as ES Module in modern browsers -->
<script type="module">
  import SwissSSN from 'https://unpkg.com/swiss-ssn/dist/swiss-ssn.js';
  
  const isValid = SwissSSN.validateSSN('756.9217.0769.85');
  console.log(isValid);
</script>

API Reference

validateSSN(ssn: string): boolean

Validates a Swiss SSN number.

// Valid SSN examples
SwissSSN.validateSSN('756.9217.0769.85'); // true
SwissSSN.validateSSN('7569217076985');    // true (without dots)

// Invalid SSN examples
SwissSSN.validateSSN('756.9217.0769.84'); // false (wrong check digit)
SwissSSN.validateSSN('756.9217.076');     // false (incomplete)
SwissSSN.validateSSN('');                 // false

generateSSN(): string

Generates a random valid Swiss SSN.

const ssn = SwissSSN.generateSSN();
// Returns a formatted SSN like '756.9217.0769.85'

Development

# Install dependencies
npm install

# Run tests
npm test

# Run tests in watch mode
npm run test:watch

# Build distribution files
npm run dist

# Lint code
npm run lint

Test Online

check from my website

Changelog

1.0.6

  • Fixed npm package configuration to include dist files
  • Added explicit files field in package.json
  • Updated build process to ensure proper file inclusion
  • Fixed unpkg CDN availability

1.0.5

  • Fixed version number in package.json

1.0.3

  • Fixed jest configuration

1.0.3

  • Fixed browser compatibility issues with UMD bundle
  • Added proper global exports for browser environments
  • Improved documentation for browser usage
  • Added ES Module example for modern browsers
  • Updated build configuration for better browser support

1.0.2

  • Modernized codebase with ES Modules
  • Added Jest for testing
  • Improved test coverage
  • Added ESLint with modern config
  • Updated all dependencies
  • Added TypeScript-friendly JSDoc annotations

1.0.1

  • Dependencies upgraded for security fixes

1.0.0

  • Initial release

License

GPL License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.