JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q32729F
  • License MIT

Shared package for npmjs.org with methods used in more projects.

Package Exports

  • @sunamo/suweb
  • @sunamo/suweb/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sunamo/suweb) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

suweb

CI/CD Tests Coverage

A TypeScript utility library for working with JSON, data, strings, time, and other common operations. Suitable for use in both Node.js and browser projects.

Key Features

  • Type-Safe: Fully written in TypeScript.
  • Modular: Import only what you need.
  • Universal: Works in Node.js and the browser.
  • Zero Dependencies: Has no production dependencies.
  • Tested: Covered by unit tests using Jest.

Installation

pnpm install

Running Tests

pnpm test

If you are using Jest, make sure you have the types installed:

pnpm add -D @types/jest

Usage Examples

Working with JSON

import { JsonGenerate } from "@/JsonGenerate";

// Generates a JSON object with random data based on a template
const template = {
  id: "{{Number}}",
  name: "{{String}}",
  active: "{{Boolean}}",
};
const result = JsonGenerate.generate(template);
console.log(result);
// { id: 123, name: "randomString", active: true }

Time Utilities

import { TimeUtils } from "@/nalch/su/utils/TimeUtils";

// Checks if a year is a leap year
console.log(TimeUtils.isLeapYear(2024)); // true

// Converts milliseconds to a readable time format
console.log(TimeUtils.msToTime(1234567)); // 00:20:34.567

Project Structure

  • src/ – Source TypeScript files
  • lib/ – Built JS files (if you use a build process)
  • test/ – Unit tests (Jest)

Main Utilities

  • JSON handling (JsonGenerate, JsonStringifySanitizers)
  • Date and time handling (RandomDate, TimeUtils)
  • Utilities for strings, arrays, objects
  • Helpers for testing and parsing

License

This project is licensed under the terms of the LICENSE file.

Contributing

Pull requests and issues are welcome!