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

typefix

v0.0.2

Published

Type Normalizer & Data Utility untuk JavaScript / Node.js

Downloads

172

Readme

typefix

Utilitas JavaScript ringan untuk normalisasi tipe dan pengelolaan data yang aman

factory, normalizer, dan utility lengkap untuk pengelolaan tipe dan nilai JavaScript — mulai dari tipe primitif, struktur kompleks, data biner, hingga utilitas lanjutan seperti deep clone, deep freeze, dan type detection.

Fitur

  • Semua tipe data primitif JavaScript
  • Struktur kompleks: Array, Object, Map, Set, WeakMap, WeakSet
  • Data biner: Buffer, ArrayBuffer, TypedArray
  • Deep clone (aman untuk circular reference)
  • Deep freeze (immutable object)
  • Normalisasi string → value JavaScript
  • Deteksi tipe data yang konsisten
  • Builder otomatis dari value

Instalasi

npm install typefix

Penggunaan

import typefix from 'typefix';

console.log(typefix.string(123)); // '123'
console.log(typefix.number('42')); // 42
console.log(typefix.boolean('')); // false
console.log(typefix.bigint('9000')); // 9000n

API

Tipe Primitif

typefix.string(value);
typefix.number(value);
typefix.boolean(value);
typefix.bigint(value);
typefix.symbol(description);
typefix.null();
typefix.undefined();

Fungsi & Promise

typefix.fn(() => {});
typefix.fn('return 1 + 1');

typefix.promise((resolve) => resolve(123));
typefix.promise(123); // Promise.resolve(123)

⚠️ fn(string) menggunakan new Functionhindari input tak terpercaya.

Struktur Data

Array & Object

typefix.array([1, 2, 3]);
typefix.object({ a: 1 });

Map & Set

typefix.map([[key, value]]);
typefix.set([1, 2, 3]);

WeakMap & WeakSet

typefix.weakMap([[obj, value]]);
typefix.weakSet([obj]);

Tanggal & Regex

typefix.date();
typefix.date('2025-12-23');

typefix.regex('abc', 'i');

Data Biner

Buffer (Node.js)

typefix.buffer('hello');

ArrayBuffer

typefix.arrayBuffer(8);
typefix.arrayBuffer(existingBuffer);

TypedArray

typefix.typedArray('Uint8Array', 8);
typefix.typedArray(Int16Array, [1, 2, 3]);

JSON Helper

typefix.json('{"a":1}');
typefix.json({ a: 1 }); // deep clone

typefix.jsonStringify(obj);

Utilitas

Deteksi Tipe

typefix.typeOf([]); // 'Array'
typefix.typeOf(new Date()); // 'Date'

Normalisasi Value

typefix.normalize('true'); // true
typefix.normalize('42'); // 42
typefix.normalize('{"a":1}'); // { a: 1 }

Builder Otomatis

typefix.from('123');
typefix.from([1, 2, 3]);
typefix.from(new Map());

Builder ini akan:

  • mengkloning struktur data
  • mempertahankan tipe aslinya
  • aman dari mutasi tidak sengaja

Deep Clone

typefix.deepClone(obj);

✔️ Aman untuk:

  • circular reference
  • Map / Set
  • Buffer
  • TypedArray

Deep Freeze

typefix.deepFreeze(config);

Membuat seluruh struktur objek menjadi immutable secara rekursif.

Filosofi Desain

  • Eksplisit lebih baik daripada implisit
  • Tidak mengubah data input
  • Mengikuti perilaku native JavaScript
  • Error lebih baik daripada silent failure

Keamanan

  • Tidak melakukan eval
  • new Function hanya digunakan secara opsional
  • Tidak memodifikasi prototype global