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

@nrgyjs/core

v1.0.3

Published

The library for reactive programming with MVC/MVVM patterns

Readme

Пакет @nrgyjs/core

Назначение пакета

Пакет @nrgyjs/core содержит базовые реактивные примитивы, механизмы управления жизненным циклом и MVC/MVVM-абстракции, на которых строится экосистема Nrgy.js.

Общая информация

Пакет объединяет несколько уровней функциональности:

  1. Реактивный runtime на основе atom(), compute() и effect().
  2. Scope для владения ресурсами и централизованного уничтожения.
  3. Утилиты для композиции атомов и тестирования реактивных сценариев.
  4. API контроллеров, представлений и view-model для архитектур MVC/MVVM.

Большинство остальных пакетов Nrgy.js используют именно эти базовые контракты.

Установка пакета

npm install @nrgyjs/core
yarn add @nrgyjs/core
pnpm add @nrgyjs/core

Концептуальная архитектура

@nrgyjs/core разделен на несколько функциональных зон:

  1. common/*: общие типы и стратегии сравнения значений.
  2. reactivity/*: атомы, вычисления, эффекты и планировщики выполнения.
  3. scope/*: границы жизненного цикла и сбор ресурсов.
  4. utils/*: утилиты поверх атомов и эффектов.
  5. mvc/*: декларации контроллеров, связки с view и инструменты для view-model.

Документация по функционалу

  • defaultEquals: стратегия сравнения по умолчанию.
  • objectEquals: структурное сравнение плоских объектов.
  • common/types: общие типы, включая ValueEqualityFn.
  • reactivity: основной API атомов, вычислений и эффектов.
  • reactivity/types: публичные типы для атомов и эффектов.
  • createScope: управление жизненным циклом ресурсов.
  • ScopeDestructionError: ошибка агрегированного разрушения.
  • scope/types: общие контракты Scope.
  • createAtomSubject: атом с каналами значений и ошибок.
  • batch: пакетное выполнение обновлений.
  • mapAtom: преобразование атома в вычисляемый атом.
  • mergeAtoms: объединение нескольких атомов.
  • readonlyAtom: read-only представление атома.
  • runEffects: принудительный запуск очереди эффектов.
  • controller: декларации контроллеров и extensions.
  • view: контракты для связки контроллера и представления.
  • viewModel: декларации view-model.
  • viewProxy: реализация ViewBinding для тестов и адаптеров.
  • withView: extension для передачи view в контроллер.

Примеры использования

import { atom, compute, effect } from '@nrgyjs/core';

const count = atom(1);
const doubled = compute(() => count() * 2);

const subscription = effect(doubled, (value) => {
  console.log(value);
});

count.set(2);
subscription.destroy();
import { declareController } from '@nrgyjs/core';

const CounterController = declareController(({ scope }) => {
  const value = scope.atom(0);

  return {
    value,
    increase: () => value.update((prev) => prev + 1),
  };
});

const controller = new CounterController();
controller.increase();
controller.destroy();