New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@imhonglu/format

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@imhonglu/format

String formatting library based on RFC specifications

latest
Source
npmnpm
Version
1.0.9
Version published
Maintainers
1
Created
Source

@imhonglu/format

English | 한국어

Introduction

  • A strongly-typed string formatting library that complies with RFC standards
  • Provides an interface similar to the native JSON API
  • All Formatters consistently provide parse, stringify, and safeParse methods
  • Parsed objects are automatically serialized to strings when using JSON.stringify()

Table of Contents

Installation

npm install @imhonglu/format

Usage

For detailed examples, please refer to the API Reference.

import { FullTime } from '@imhonglu/format';
// Parse time string
const time = FullTime.parse('00:00:00.000Z');
// { hour: 0, minute: 0, second: 0, secfrac: '.000', offset: undefined }

// Using parsed results
console.log(time.hour); // 0
console.log(time.toString()); // '00:00:00.000Z'
console.log(JSON.stringify(time)); // '"00:00:00.000Z"'

// Safe parsing with validation
const result = FullTime.safeParse('invalid');
if (result.ok) {
  console.log(result.data);
  // result.data returns parsed FullTime instance
} else {
  console.error(result.error);
  // result.error returns InvalidFullTimeError with error information
}

API Reference

Date Time Formatter(RFC 3339)

IP Address Formatter(RFC 2673, RFC 4291, RFC 5954)

  • IPv4Address - IPv4 address based on RFC 2673, RFC 5954
  • IPv6Address - IPv6 address based on RFC 4291, RFC 5954

Hostname Formatter(RFC 1034, RFC 5890)

  • Hostname - Hostname based on RFC 1034
  • IdnHostname - Hostname(IDN) based on RFC 1034, RFC 5890

Email Formatter(RFC 5321, RFC 5322)

URI Formatter(RFC 3986, RFC 3987)

APIs that support IRI commonly provide the { isIri: boolean } option.

  • URI - URI / IRI based on RFC 3986, RFC 3987
  • URIReference - URI Reference / IRI Reference based on RFC 3986, RFC 3987
  • Authority - Authority / IRI Authority based on RFC 3986, RFC 3987
  • Path - Path / IRI Path based on RFC 3986, RFC 3987
  • Query - Query / IRI Query based on RFC 3986, RFC 3987
  • Fragment - Fragment / IRI Fragment based on RFC 3986, RFC 3987
  • Scheme - Scheme based on RFC 3986
  • IPvFuture - IPvFuture based on RFC 3986

URI Template Formatter(RFC 6570)

UUID Formatter(RFC 4122)

  • UUID - UUID based on RFC 4122

JSON Pointer Formatter(RFC 6901)

Keywords

format

FAQs

Package last updated on 10 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts