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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@libs-ui/pipes-convert-signal-to-object

v0.2.356-24

Published

> Version: `0.2.355-15` > > Pipe chuyển đổi cấu trúc Signals lồng nhau thành plain object/value.

Readme

@libs-ui/pipes-convert-signal-to-object

Version: 0.2.355-15

Pipe chuyển đổi cấu trúc Signals lồng nhau thành plain object/value.

Giới thiệu

LibsUiPipesConvertSignalToObjectPipe là pipe ngược lại của convert-object-to-signal. Nó nhận vào một cấu trúc nested signals (object hoặc array chứa các signals) và unwrap toàn bộ chúng thành plain object/array. Điều này rất hữu ích khi bạn cần chuẩn bị dữ liệu để gửi đi (API call), lưu trữ (LocalStorage), hoặc sử dụng với các thư viện không hỗ trợ Signal.

Tính năng

  • ✅ Unwrap nested signals (multi-level)
  • ✅ Chuyển đổi Signal Object thành Plain Object
  • ✅ Chuyển đổi Signal Array thành Plain Array
  • ✅ Deep clone kết quả mặc định (an toàn)
  • ✅ Hỗ trợ primitive signals

Khi nào sử dụng

📤 Gửi data đến API

Các HTTP client thường yêu cầu plain object. Pipe này giúp bạn chuẩn bị payload dễ dàng:

// Nested signals state
const user = {
  name: signal('John'),
  settings: { theme: signal('dark') },
};

// Convert to plain object
const payload = user | LibsUiPipesConvertSignalToObjectPipe;
// => { name: 'John', settings: { theme: 'dark' } }

http.post('/api/user', payload);

💾 Serialize đến LocalStorage

Signal không thể được serialize trực tiếp bằng JSON.stringify. Hãy convert chúng trước:

const plainData = dataSignal | LibsUiPipesConvertSignalToObjectPipe;
localStorage.setItem('data', JSON.stringify(plainData));

🔌 Tích hợp External Libraries

Nhiều thư viện (charting, maps, etc.) chỉ chấp nhận plain JS objects/arrays:

const chartData = signalsData | LibsUiPipesConvertSignalToObjectPipe;
chart.update(chartData);

Cài đặt

npm install @libs-ui/pipes-convert-signal-to-object

Import

import { LibsUiPipesConvertSignalToObjectPipe } from '@libs-ui/pipes-convert-signal-to-object';

@Component({
  standalone: true,
  imports: [LibsUiPipesConvertSignalToObjectPipe],
  // ...
})
export class YourComponent {}

Ví dụ

1. Basic Object Unwrap

@let user = (userSignal | LibsUiPipesConvertSignalToObjectPipe);

<p>User: {{ user.name }}</p>

2. Array Unwrap

@let items = (itemsSignal | LibsUiPipesConvertSignalToObjectPipe);

<ul>
  @for (item of items; track $index) {
  <li>{{ item }}</li>
  }
</ul>

3. No Clone (Faster)

Nếu bạn chắc chắn không mutate kết quả hoặc cần performance tối đa:

@let rawData = (dataSignal | LibsUiPipesConvertSignalToObjectPipe : false);

API

LibsUiPipesConvertSignalToObjectPipe

data | LibsUiPipesConvertSignalToObjectPipe : isCloneDeep?

Parameters

| Property | Type | Default | Description | | ------------- | ---------------------- | ------- | --------------------------------------------------------- | | data | any | - | Nested signals cần chuyển đổi thành plain object. | | isCloneDeep | boolean \| undefined | true | true để deep clone (an toàn), false để giữ reference. |

Returns

Plain object, array, hoặc primitive value sau khi đã unwrap tất cả signals.

Hidden Logic

1. 🔄 Recursive Unwrap

Pipe sẽ đệ quy đi vào mọi property của object/array. Nếu gặp Signal, nó sẽ gọi () để lấy giá trị, sau đó tiếp tục đệ quy cho giá trị đó.

2. 🔀 Deep Clone

Mặc định, kết quả trả về là một bản sao deep clone của dữ liệu đã unwrap. Điều này đảm bảo rằng nếu bạn thay đổi property của object kết quả, nó KHÔNG ảnh hưởng ngược lại đến state trong Signal gốc.

Demo

Unit Tests

Xem file test-commands.md để biết cách chạy unit tests.

License

MIT