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

@3dsource/utils

v1.0.22

Published

A set of utils for using in 3dsource projects

Downloads

223

Readme

@3dsource/utils

A comprehensive collection of utility functions and helpers for 3dsource projects. This library provides common functionality used across different 3dsource applications and libraries.

Overview

The utils library offers a wide range of utility functions organized by category:

  • Color manipulation and conversion
  • Mathematical operations for 3D applications
  • Geometry utilities
  • File and image processing
  • String manipulation
  • RxJS operators and utilities
  • Development helpers
  • And more

Installation

Prerequisites

  • Node.js 20+
  • TypeScript 5.8+

Peer Dependencies

This library requires the following peer dependencies:

{
  "rxjs": "^7.8.2",
  "ts-md5": "^1.3.1",
  "uuid": "^11.1.0"
}

Library Installation

  npm i @3dsource/utils

Usage

Import the specific utility functions you need:

import { hexToRgb } from '@3dsource/utils/color';
import { clamp } from '@3dsource/utils/math';
import { generateUUID } from '@3dsource/utils/helpers';

Available Utilities

Color Utilities

The color module provides functions for working with colors:

import { hexToRgb, rgbToHex, darken, lighten } from '@3dsource/utils/color';

// Convert hex color to RGB
const rgb = hexToRgb('#ff0000'); // { r: 255, g: 0, b: 0 }

// Convert RGB to hex
const hex = rgbToHex(255, 0, 0); // '#ff0000'

// Darken a color by 20%
const darkRed = darken('#ff0000', 0.2);

Math Utilities

The math module provides mathematical functions:

import { clamp, lerp, degToRad } from '@3dsource/utils/math';

// Clamp a value between min and max
const clampedValue = clamp(150, 0, 100); // 100

// Linear interpolation
const interpolated = lerp(0, 100, 0.5); // 50

// Convert degrees to radians
const radians = degToRad(180); // 3.14159...

Geometry Utilities

The geom module provides geometry-related functions:

import { calculateDistance, isPointInPolygon } from '@3dsource/utils/geom';

// Calculate distance between two points
const distance = calculateDistance({ x: 0, y: 0 }, { x: 3, y: 4 }); // 5

Complete List of Utility Categories

  • color - Color manipulation and conversion
  • constants - Common constants used across the project
  • csv - CSV parsing and generation
  • dev - Development utilities
  • filenaming - File naming utilities
  • geom - Geometry utilities
  • helpers - General helper functions
  • image - Image processing utilities
  • interfaces - Common TypeScript interfaces
  • math - Mathematical functions
  • mutex - Mutex implementation for async operations
  • predicates - Type guards and predicates
  • rxjs - RxJS operators and utilities
  • strings - String manipulation functions

Examples

Working with UUIDs

import { generateUUID, isValidUUID } from '@3dsource/utils/helpers';

// Generate a new UUID
const id = generateUUID();

// Check if a string is a valid UUID
const isValid = isValidUUID(id); // true

Using RxJS Utilities

import { retryWithBackoff } from '@3dsource/utils/rxjs';
import { of, throwError } from 'rxjs';
import { mergeMap } from 'rxjs/operators';

// Retry an operation with exponential backoff
function getData() {
  return of(Math.random()).pipe(
    mergeMap((val) => (val < 0.5 ? throwError(() => new Error('Failed')) : of(val))),
    retryWithBackoff({
      initialInterval: 100,
      maxRetries: 3,
    }),
  );
}