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

@showroomprive/srp-gamma-lib-demo

v1.0.4

Published

A sample library nodejs

Readme

SRP Gamma Lib Demo - TypeScript Demo Library

TypeScript Node.js Jest npm

A demonstration TypeScript library showcasing best practices for Node.js library development within the Gamma platform ecosystem. This library serves as a template and reference implementation for creating robust, testable, and maintainable TypeScript libraries.

🚀 Features

  • TypeScript First: Full TypeScript support with strict type checking
  • Modern JavaScript: ES2020+ features with Node.js 18+ compatibility
  • Comprehensive Testing: Jest-based unit testing with coverage reports
  • Type Definitions: Exported TypeScript declarations for IntelliSense
  • NPM Package: Ready for publication and distribution
  • CI/CD Ready: Automated testing and deployment configurations
  • Documentation: JSDoc comments and comprehensive README
  • Best Practices: Follows industry standards for library development

📋 Prerequisites

  • Node.js 18.x or higher
  • npm 8.x or higher
  • TypeScript 5.0+ (for development)

🛠️ Installation

As a Package

npm install @showroomprive/srp-gamma-lib-demo

For Development

# Clone the repository
git clone <repository-url>
cd src/libs/srp-gamma-lib-demo

# Install dependencies
npm install

🏃‍♂️ Usage

Basic Usage

import { GammaDemoService } from '@showroomprive/srp-gamma-lib-demo';

// Initialize the service
const demoService = new GammaDemoService();

// Use service methods
const result = demoService.performDemoOperation('input-data');
console.log(result);

Advanced Usage

import { GammaDemoService } from '@showroomprive/srp-gamma-lib-demo';

// With configuration
const service = new GammaDemoService({
  enableLogging: true,
  timeout: 5000,
  retryAttempts: 3
});

// Async operations
async function example() {
  try {
    const result = await service.asyncOperation();
    return result;
  } catch (error) {
    console.error('Operation failed:', error);
  }
}

CommonJS Usage

const { GammaDemoService } = require('@showroomprive/srp-gamma-lib-demo');

const service = new GammaDemoService();
const result = service.performDemoOperation('data');

📁 Project Structure

src/libs/srp-gamma-lib-demo/
├── src/
│   └── services/
│       ├── gamma.demo.service.ts      # Main service implementation
│       └── gamma.demo.service.spec.ts # Unit tests
├── dist/                              # Compiled JavaScript output
├── jest.config.ts                     # Jest testing configuration
├── tsconfig.json                      # TypeScript base configuration
├── tsconfig.lib.json                  # Library-specific TypeScript config
├── package.json                       # Package configuration
└── README.md                          # This documentation

🧪 Development

Build the Library

# Compile TypeScript to JavaScript
npm run build

# Output will be in the dist/ directory

Run Tests

# Run all tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests in watch mode
npm run test:watch

Code Quality

# Lint code (if configured)
npm run lint

# Format code (if configured)
npm run format

# Type check
npx tsc --noEmit

🔧 API Reference

GammaDemoService

The main service class providing demonstration functionality.

Constructor

constructor(options?: GammaDemoOptions)

Parameters:

  • options (optional): Configuration options for the service

Methods

performDemoOperation(input: string): string

Performs a basic demonstration operation.

Parameters:

  • input: Input string to process

Returns:

  • Processed string result

Example:

const result = service.performDemoOperation('hello');
// Returns: "Processed: hello"
asyncOperation(): Promise<string>

Performs an asynchronous demonstration operation.

Returns:

  • Promise resolving to operation result

Example:

const result = await service.asyncOperation();
// Returns: "Async operation completed"
validateInput(input: unknown): boolean

Validates input data according to service rules.

Parameters:

  • input: Data to validate

Returns:

  • Boolean indicating validation success

Types

GammaDemoOptions

Configuration options for the demo service.

interface GammaDemoOptions {
  enableLogging?: boolean;
  timeout?: number;
  retryAttempts?: number;
  customConfig?: Record<string, any>;
}

📦 Building and Publishing

Build for Distribution

# Clean previous builds
rm -rf dist/

# Compile TypeScript
npm run build

# Verify build output
ls -la dist/

Package Verification

# Test the package locally
npm pack

# Install locally for testing
npm install ./showroomprive-srp-gamma-lib-demo-1.0.3.tgz

Publishing

# Login to npm (if not already logged in)
npm login

# Publish to npm registry
npm publish

# Publish with specific tag
npm publish --tag beta

🧪 Testing Strategy

Unit Tests

Tests are written using Jest and cover:

  • Service functionality
  • Error handling
  • Edge cases
  • Type validation
  • Async operations

Test Structure

// Example test structure
describe('GammaDemoService', () => {
  let service: GammaDemoService;

  beforeEach(() => {
    service = new GammaDemoService();
  });

  describe('performDemoOperation', () => {
    it('should process input correctly', () => {
      const result = service.performDemoOperation('test');
      expect(result).toBe('Processed: test');
    });

    it('should handle empty input', () => {
      const result = service.performDemoOperation('');
      expect(result).toBe('Processed: ');
    });
  });
});

Coverage Targets

  • Statements: > 90%
  • Branches: > 85%
  • Functions: > 95%
  • Lines: > 90%

🔍 Configuration

TypeScript Configuration

// tsconfig.lib.json
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./dist",
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true,
    "removeComments": false,
    "emitDeclarationOnly": false
  },
  "include": ["src/**/*"],
  "exclude": ["**/*.spec.ts", "**/*.test.ts"]
}

Jest Configuration

// jest.config.ts
export default {
  preset: 'ts-jest',
  testEnvironment: 'node',
  roots: ['<rootDir>/src'],
  testMatch: ['**/__tests__/**/*.ts', '**/*.(test|spec).ts'],
  collectCoverageFrom: [
    'src/**/*.ts',
    '!src/**/*.d.ts',
    '!src/**/*.spec.ts'
  ],
  coverageThreshold: {
    global: {
      branches: 85,
      functions: 95,
      lines: 90,
      statements: 90
    }
  }
};

🚦 CI/CD Integration

Azure DevOps Pipeline

# azure-pipelines.yml
trigger:
  branches:
    include:
      - main
  paths:
    include:
      - src/libs/srp-gamma-lib-demo/*

jobs:
  - job: BuildAndTest
    pool:
      vmImage: 'ubuntu-latest'
    steps:
      - task: NodeTool@0
        inputs:
          versionSpec: '18.x'
      - script: npm ci
        displayName: 'Install dependencies'
      - script: npm run build
        displayName: 'Build library'
      - script: npm test
        displayName: 'Run tests'
      - task: PublishTestResults@2
        inputs:
          testResultsFormat: 'JUnit'
          testResultsFiles: 'junit.xml'

🔍 Troubleshooting

Common Issues

  1. Build Errors

    # Clear cache and rebuild
    rm -rf dist/ node_modules/
    npm install
    npm run build
  2. Type Errors

    # Check TypeScript configuration
    npx tsc --noEmit --listFiles
  3. Test Failures

    # Run tests in verbose mode
    npm test -- --verbose
  4. Import Issues

    # Verify package exports
    node -e "console.log(require('./package.json').main)"

📚 Documentation

🤝 Contributing

  1. Follow the Contributing Guidelines
  2. Maintain TypeScript strict mode compliance
  3. Write comprehensive unit tests
  4. Document public APIs with JSDoc comments
  5. Follow semantic versioning for releases
  6. Update README for API changes

Development Workflow

  1. Fork and Clone: Create your own fork and clone locally
  2. Branch: Create feature branch from main
  3. Develop: Write code following project standards
  4. Test: Ensure all tests pass with good coverage
  5. Document: Update documentation as needed
  6. PR: Submit pull request with clear description

📄 License

This project is part of the Gamma platform. See the main repository license for details.

🔗 Related Projects

📈 Version History

| Version | Date | Changes | |---------|------|---------| | 1.0.3 | Current | Latest stable release | | 1.0.2 | Previous | Bug fixes and improvements | | 1.0.1 | Previous | Initial bug fixes | | 1.0.0 | Initial | First stable release |

🎯 Roadmap

  • [ ] Add more demonstration patterns
  • [ ] ESM module support
  • [ ] Performance benchmarking
  • [ ] Advanced async patterns
  • [ ] Stream processing examples
  • [ ] Error handling best practices
  • [ ] Logging integration examples